UNPKG

36.5 kBJavaScriptView Raw
1/*
2 author:Guo Meishan
3 name:iTalent-header
4 verson:0.1.0
5*/
6
7define(["talent"], function(Talent) {
8 var jst = (function() {
9 this["JST"] = this["JST"] || {};
10
11 this["JST"]["header/company-info"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape;with (obj) {__p += '<div class="company-icon">\n\t<!-- <a href="' +((__t = ( href)) == null ? '' : __t) +'"><img class="cmpy-logo" src="' +((__t = (logo)) == null ? '' : __t) +'"></a> -->\n\t<a href="' +((__t = ( href)) == null ? '' : __t) +'"><img class="cmpy-logo" src="' +((__t = (logo)) == null ? '' : __t) +'" alt="logo"></a>\n\t<span class="company-name">' +((__t = ( name)) == null ? '' : __t) +'</span>\n</div>';}return __p};
12
13 this["JST"]["header/header"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape;with (obj) {__p += ' \n <div class="header-out-wrapper">\n <div class="header-left company-info-region clearfix"></div>\n <div class="header-right clearfix">\n <div class="lang-region"></div>\n <!--用户信息-->\n <div class="header-webim-region"></div>\n <div class="user-info-region"></div>\n <ul class=\'btns-group\'></ul>\n \n </div>\n </div>\n';}return __p};
14
15 this["JST"]["header/icon-view/appstore"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) {__p += '<a\n\tclass="common-link appstore-btn ' +((__t = (iconName)) == null ? '' : __t) +'"\n\ttarget="_blank"\n\thref="' +((__t = (href)) == null ? '' : __t) +'"\n\t';if(target){;__p += ' target=" ' +((__t = (target)) == null ? '' : __t) +'" ';};__p += ' \n\t>\n\t'; if(isShowNew){ ;__p += '\n\t<span class="new-icon"> </span>\n\t'; } ;__p += '\n\t<div class="btn-tips">\n\t\t<div class="entry-trangle-top"></div>\n\t\t' +((__t = (title)) == null ? '' : __t) +'\n\t</div>\n</a>\n<div class="list-wrapper"></div>\n';}return __p};
16
17 this["JST"]["header/icon-view/home-page"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) {__p += '\n<a class="common-link ' +((__t = (iconName)) == null ? '' : __t) +'" href="' +((__t = (href)) == null ? '' : __t) +'" ';if(target){;__p += 'target="' +((__t = (target)) == null ? '' : __t) +'"';};__p += '>\n\t'; if(reminds.remindCount){ ;__p += '\n \t\t<span class="new-message">' +((__t = ( (reminds.remindCount <= 99)?reminds.remindCount : "99+" )) == null ? '' : __t) +'</span>\n \t'; } ;__p += '\n \t<div class="btn-tips">\n\t\t<div class="entry-trangle-top"></div>\n\t\t' +((__t = (title)) == null ? '' : __t) +'\n\t</div>\n</a>\n<div class="list-wrapper"></div>\n';}return __p};
18
19 this["JST"]["header/icon-view/lang"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) {__p += '<a class=\'lang-region-box\'>\n <span class="i18n_item ' +((__t = ( I18NUserLang )) == null ? '' : __t) +' header-icon-lang_' +((__t = ( I18NUserLang )) == null ? '' : __t) +'">&nbsp;</span>\n <div class="btn-tips">\n <div class="entry-trangle-top"></div>\n ' +((__t = ( title )) == null ? '' : __t) +'\n </div>\n</a>\n<div class="dp-down-list ">\n\t\t<ul class="list-ul-box dp-list-front">\n '; Talent._.each(list,function(item,index){ ;__p += '\n <li class="dp-list-item"><a href="javascript:;"data-text="' +((__t = ( item.text )) == null ? '' : __t) +'" data-value="' +((__t = ( item.value )) == null ? '' : __t) +'" index="' +((__t = ( index )) == null ? '' : __t) +'">' +((__t = ( item.text )) == null ? '' : __t) +'</a></li>\n '; }) ;__p += '\n\t\t</ul>\n\t\t<ul class="list-ul-box dp-list-shadow">\n\t\t\t'; Talent._.each(list,function(item,index){ ;__p += '\n\t\t\t\t<li class="' +((__t = ( 'item-'+ index )) == null ? '' : __t) +'" item-index="' +((__t = ( index )) == null ? '' : __t) +'"><a href="">' +((__t = ( item.text )) == null ? '' : __t) +'</a></li>\n\t\t\t'; }) ;__p += '\n\t\t</ul>\n\t</div>\n\n';}return __p};
20
21 this["JST"]["header/icon-view/message"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) {__p += '<a\n\tclass="common-link ' +((__t = (iconName)) == null ? '' : __t) +'"\n\thref="' +((__t = ( (reminds.remindCount)?'javascript:void(0)':href )) == null ? '' : __t) +'"\n\t';if(!reminds.remindCount&&target){;__p += '\n\ttarget=" ' +((__t = (target)) == null ? '' : __t) +'" ';};__p += '> '; if(reminds.remindCount){ ;__p += '\n\t<span class="new-message">\n\t\t' +((__t = ( (reminds.remindCount <= 99)?reminds.remindCount : "99+" )) == null ? '' : __t) +'\n\t</span>\n\t'; } ;__p += '\n\t<div class="btn-tips">\n\t\t<div class="entry-trangle-top"></div>\n\t\t' +((__t = (title)) == null ? '' : __t) +'\n\t</div>\n</a>\n\n'; if(reminds.remindList.length){ ;__p += '\n<div class="list-wrapper">\n\t<div class="content-visible">\n\t\t<div class="title">\n\t\t\t' +((__t = ( (reminds.newNoticeText||"新通知")+"(" + reminds.remindCount + ")")) == null ? '' : __t) +'\n\t\t</div>\n\t\t<ul class="message-list">\n\t\t\t'; Talent._.each(reminds.remindList,function(item,index){ ;__p += '\n\t\t\t<li class="message-item">\n\t\t\t\t<a href="' +((__t = (item.href)) == null ? '' : __t) +'" target="_blank" class="message-item-a">\n\t\t\t\t\t<span class="icon-box ' +((__t = (item.className)) == null ? '' : __t) +'"></span>\n\t\t\t\t\t<span class="content">\n\t\t\t\t\t\t' +((__t = (item.content)) == null ? '' : __t) +'\n\t\t\t\t\t</span>\n\t\t\t\t\t<span class="num">\n\t\t\t\t\t\t' +((__t = (item.length)) == null ? '' : __t) +'\n\t\t\t\t\t</span>\n\t\t\t\t\t<span class="date">\n\t\t\t\t\t\t' +((__t = (item.date)) == null ? '' : __t) +'\n\t\t\t\t\t</span>\n\t\t\t\t</a>\n\t\t\t</li>\n\t\t\t'; }) ;__p += '\n\t\t</ul>\n\t\t<li class="view-all">\n\t\t\t<a href="' +((__t = (reminds.viewAllHref)) == null ? '' : __t) +'" target="_blank"\n\t\t\t\t>' +((__t = ( reminds.viewAllText||"查看全部")) == null ? '' : __t) +'</a\n\t\t\t>\n\t\t</li>\n\t</div>\n</div>\n'; } ;__p += '\n';}return __p};
22
23 this["JST"]["header/icon-view/search"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) {__p += '<a class="common-link ' +((__t = (iconName)) == null ? '' : __t) +'" href="' +((__t = (href)) == null ? '' : __t) +'" ';if(target){;__p += '\n\ttarget="' +((__t = (target)) == null ? '' : __t) +'"';};__p += '> '; if(reminds.remindCount){ ;__p += '\n\t<span class="new-message">' +((__t = ( reminds.remindCount )) == null ? '' : __t) +'</span> '; } ;__p += '\n\t<div class="btn-tips">\n\t\t<div class="entry-trangle-top"></div>\n\t\t' +__e(searchTip) +'\n\t</div>\n</a>\n<div class="list-wrapper">\n\t<div class="form-input form-input-active">\n\t\t<form action="" data-name="search-form">\n\t\t\t<input placeholder="' +((__t = ( title)) == null ? '' : __t) +'" />\n\t\t</form>\n\t</div>\n\t<div class="comfirm-btn"></div>\n</div>\n';}return __p};
24
25 this["JST"]["header/icon-view/settings"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) {__p += '\n<a class="common-link ' +((__t = (iconName)) == null ? '' : __t) +'" ';if(href){;__p += ' href="' +((__t = (href)) == null ? '' : __t) +'" ';};__p += ' ';if(target){;__p += ' target="' +((__t = (target)) == null ? '' : __t) +'"';};__p += '>\n\t'; if(reminds.remindCount){ ;__p += '\n \t\t<span class="new-message">' +((__t = ( (reminds.remindCount <= 99)?reminds.remindCount : "99+" )) == null ? '' : __t) +'</span>\n \t'; } ;__p += '\n \t<div class="btn-tips">\n\t\t<div class="entry-trangle-top"></div>\n\t\t' +((__t = (title)) == null ? '' : __t) +'\n\t</div>\n</a>\n';if(reminds.remindList && reminds.remindList.length){;__p += '\n\t<div class="list-wrapper">\n\t\t<div class="content-visible">\n\t\t\t<ul class="message-list">\n\t\t\t\t'; Talent._.each(reminds.remindList,function(item,index){ ;__p += '\n\t\t\t\t\t<li class="message-item">\n\t\t\t\t\t\t<a href="' +((__t = (item.href)) == null ? '' : __t) +'" ';if(item.target){;__p += ' target="' +((__t = (target)) == null ? '' : __t) +'"';};__p += ' class="message-item-a">\n\t\t\t\t\t\t\t<span class="settings-icon ' +((__t = (item.className)) == null ? '' : __t) +'"></span>\n\t\t\t\t\t\t\t<span class="content">' +((__t = (item.content)) == null ? '' : __t) +'</span>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</li>\n\t\t\t\t'; }) ;__p += '\n\t\t\t</ul>\n\t</div>\n\t</div>\n';};__p += '\n\n';}return __p};
26
27 this["JST"]["header/icon-view/skin"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) {__p += '\t<a class="common-link ' +((__t = (iconName)) == null ? '' : __t) +'" href="' +((__t = (href)) == null ? '' : __t) +'" ';if(target){;__p += ' target="' +((__t = (target)) == null ? '' : __t) +'"';};__p += '>\n\t\t'; if(reminds.remindCount){ ;__p += '\n \t\t<span class="new-message">' +((__t = ( (reminds.remindCount <= 99)?reminds.remindCount : "99+" )) == null ? '' : __t) +'</span>\n\t \t'; } ;__p += '\n\t \t<div class="btn-tips">\n\t\t\t<div class="entry-trangle-top"></div>\n\t\t\t' +((__t = (title)) == null ? '' : __t) +'\n\t\t</div>\n\t</a>\n\t<div class="list-wrapper">\n\t\t<div class="content-visible">\n\t\t\t<div class="color-title">拖动滑块选择颜色</div>\n\t\t\t<input type="range" class="color-range">\n\t\t\t<div class="selector-btn clearfix">\n\t\t\t\t<div class="check-default check-back">\n\t\t\t\t\t<div class="check-box ">\n\t\t\t\t\t\t<span class="un-check"></span>\n\t\t\t\t\t\t<span class="in-check"></span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<label class="text">恢复默认</label>\n\t\t\t\t</div>\n\n\t\t\t\t<span class="comfirm-btn-style comfirm-btn">确定</span>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</div>\n';}return __p};
28
29 this["JST"]["header/icon-view/todos-item/todos-item"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) {__p += '\n\t'; Talent._.each(reminds.remindList,function(item,index){ ;__p += '\n\t\t<li class="message-item">\n\t\t\t<a href="' +((__t = ( item.href )) == null ? '' : __t) +'" target="_blank" class="clearfix message-item-a">\n\t\t\t\t'; if(item.avatar.hasAvatar){ ;__p += '\n\t\t\t\t\t<div class="user-pic"><img src="' +((__t = ( item.avatar.medium)) == null ? '' : __t) +'"></div>\n\t\t\t\t'; }else{ ;__p += '\n\t\t\t\t\t<div class="user-pic" style="background-color: ' +((__t = ( item.avatar.color)) == null ? '' : __t) +'">' +((__t = ( item.userName.substr(0,1) || "Name")) == null ? '' : __t) +'</div>\n\t\t\t\t';};__p += '\n\t\t\t\t<div class="item-detail">\n\t\t\t\t\t<div class="detail-head clearfix">\n\t\t\t\t\t\t<span class="user-name">' +((__t = ( item.userName )) == null ? '' : __t) +'</span>\n\t\t\t\t\t\t<span class="user-opr">' +((__t = ( item.teskName )) == null ? '' : __t) +'</span>\n\t\t\t\t\t\t<span class="date">' +((__t = ( item.date )) == null ? '' : __t) +'</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="detail-content">' +((__t = ( item.taskContent )) == null ? '' : __t) +'</div>\n\t\t\t\t</div>\n\t\t\t</a>\n\t\t</li>\n\t'; }) ;__p += '\n';}return __p};
30
31 this["JST"]["header/icon-view/todos"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) {__p += '<a\n\tclass="common-link ' +((__t = (iconName)) == null ? '' : __t) +'"\n\thref="' +((__t = ( (reminds.remindCount)?'javascript:void(0)':href )) == null ? '' : __t) +'"\n\t';if(!reminds.remindCount&&target){;__p += '\n\ttarget="' +((__t = (target)) == null ? '' : __t) +'"';};__p += '> '; if(reminds.remindCount){ ;__p += '\n\t<span class="new-message"\n\t\t>' +((__t = ( (reminds.remindCount <= 99)?reminds.remindCount : "99+" )) == null ? '' : __t) +'</span\n\t>\n\t'; } ;__p += '\n\t<div class="btn-tips">\n\t\t<div class="entry-trangle-top"></div>\n\t\t' +((__t = (title)) == null ? '' : __t) +'\n\t</div>\n</a>\n\n'; if(reminds.remindCount){ ;__p += '\n<div class="list-wrapper">\n\t<div class="content-visible">\n\t\t<div class="title">\n\t\t\t' +((__t = ( (reminds.myTodoText||"我的待办")+"(" + reminds.remindCount + ")")) == null ? '' : __t) +'\n\t\t</div>\n\t\t<ul class="message-list">\n\t\t\t<div class="spinner">\n\t\t\t\t<div class="rect1"></div>\n\t\t\t\t<div class="rect2"></div>\n\t\t\t\t<div class="rect3"></div>\n\t\t\t\t<div class="rect4"></div>\n\t\t\t</div>\n\t\t\t<div class="text-loading">加载中...</div>\n\t\t</ul>\n\t\t<li class="view-all">\n\t\t\t<a href="' +((__t = ( reminds.viewAllHref)) == null ? '' : __t) +'" target="_blank"\n\t\t\t\t>' +((__t = ( reminds.viewAllText||"查看全部" )) == null ? '' : __t) +'</a\n\t\t\t>\n\t\t\t';if(showTodoIgnore){;__p += '\n\t\t\t<a\n\t\t\t\thref="javascript:void(0)"\n\t\t\t\tclass="view-ignore-all"\n\t\t\t\tdata-name="head-ignore-all"\n\t\t\t>\n\t\t\t\t<div class="btn-tips-child">\n\t\t\t\t\t' +((__t = ( reminds.ignoreAllTip||"点击后除审批外的待办全部转移到已处理中")) == null ? '' : __t) +'\n\t\t\t\t\t<div class="entry-trangle-top"></div>\n\t\t\t\t</div>\n\t\t\t\t<span>' +((__t = ( reminds.ignoreAllText||"忽略全部" )) == null ? '' : __t) +'</span>\n\t\t\t</a>\n\t\t\t';};__p += '\n\t\t</li>\n\t</div>\n</div>\n'; } ;__p += '\n';}return __p};
32
33 this["JST"]["header/icon-view/upgrade"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) {__p += '<a class="common-link ' +((__t = (iconName)) == null ? '' : __t) +'" target="_blank" href="' +((__t = (href)) == null ? '' : __t) +'" ';if(target){;__p += ' target="\n\t' +((__t = (target)) == null ? '' : __t) +'"\n\t\t';};__p += '>\n\t\t\t<!-- '; if(reminds.remindCount){ ;__p += ' -->\n\t\t\t<!-- TODO:new图标 -->\n\t\t\t<span class="new-icon">\n\n\t\t\t</span>\n\t\t\t<!-- '; } ;__p += ' -->\n\t\t\t<div class="btn-tips">\n\t\t\t\t<div class="entry-trangle-top"></div>\n\t\t\t\t' +((__t = (title)) == null ? '' : __t) +'\n\t\t\t</div>\n</a>\n<div class="list-wrapper">\n</div>\n\n<!-- <a class="common-link ' +((__t = (iconName)) == null ? '' : __t) +'" href="' +((__t = ( (reminds.remindCount)?'javascript:void(0)':href )) == null ? '' : __t) +'" ';if(target){;__p += ' target="\n\t' +((__t = (target)) == null ? '' : __t) +'"\n\t\t';};__p += '>\n\t\t\t'; if(reminds.remindCount){ ;__p += '\n\t\t\t\t<span class="new-message">\n\t\t\t\t\t' +((__t = ( (reminds.remindCount <= 99)?reminds.remindCount : "99+" )) == null ? '' : __t) +'\n\t\t\t\t</span>\n\t\t\t\t'; } ;__p += '\n\t\t\t\t\t<div class="btn-tips">\n\t\t\t\t\t\t<div class="entry-trangle-top"></div>\n\t\t\t\t\t\t' +((__t = (title)) == null ? '' : __t) +'\n\t\t\t\t\t</div>\n</a> -->';}return __p};
34
35 this["JST"]["header/user-info"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) {__p += '\n\t<div class="user-info">\n\t\t'; if(userInfo.avatar.hasAvatar){ ;__p += '\n\t\t\t<span class="user-photo"><img src="' +((__t = (userInfo.avatar.small)) == null ? '' : __t) +'"></span>\n\t\t'; }else{ ;__p += '\n\t\t\t<span class="name-pic" style="background-color: ' +((__t = (userInfo.avatar.color)) == null ? '' : __t) +'">' +((__t = ( userInfo.name.substr(0,1) || "Name")) == null ? '' : __t) +'</span>\n\t\t';};__p += '\n\t\t\t<span class="user-name">' +((__t = (userInfo.name)) == null ? '' : __t) +'</span>\n\t</div>\n\n\t<div class="dp-down-list">\n\t\t<ul class="list-ul-box dp-list-front">\n\t\t'; Talent._.each(userInfoDropDown,function(item,index){ ;__p += '\n\t\t\t<li class="dp-list-item"><a href="' +((__t = (item.href)) == null ? '' : __t) +'" target="' +((__t = ( item.target )) == null ? '' : __t) +'" data-name="' +((__t = ( item.type )) == null ? '' : __t) +'" index="' +((__t = ( index )) == null ? '' : __t) +'">' +((__t = ( item.title )) == null ? '' : __t) +'</a></li>\n\t\t'; }) ;__p += '\n\t\t\t<!-- <li class="item-high-light"></li> -->\n\t\t</ul>\n\n\t\t<ul class="list-ul-box dp-list-shadow">\n\t\t\t'; Talent._.each(userInfoDropDown,function(item,index){ ;__p += '\n\t\t\t\t<li class="' +((__t = ( 'item-'+ index )) == null ? '' : __t) +'" item-index="' +((__t = ( index )) == null ? '' : __t) +'"><a href="">' +((__t = ( item.title )) == null ? '' : __t) +'</a></li>\n\t\t\t'; }) ;__p += '\n\t\t</ul>\n\t</div>';}return __p};
36
37 this["JST"]["header/webim"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape;with (obj) {__p += '<span class="header-icon-titaim ico-webim disabled"></span>\n<b class="u-unread new-message hide">0<b>\n';}return __p};
38 return this["JST"]
39 })()
40
41 /** 功能按钮单独的view **/
42 //基类
43 var BaseView = Talent.Layout.extend({
44 initialize:function(options){
45 this.options = options;
46 this.model = new Talent.Model(options);
47 this.listenTo(this.model,"change",this.render);
48 }
49 //注册自动消失
50 ,autoHideRegister:function(){
51 // var self = this;
52 // clearTimeout(this.autoHide);
53 // this.autoHide = setTimeout(function(){
54 // self.ui.popList.removeClass("list-open").addClass("list-close");
55 // self.ui.iconBtn.removeClass("opr-btns-select")
56 // },3500);
57 }
58 //取消自动消失
59 ,autoHideCancle:function(){
60
61 }
62 //关闭下拉弹窗
63 ,listClose:function(){
64 this.ui.iconBtn.removeClass("opr-btns-select")
65 this.ui.popList.removeClass("list-open").addClass("list-close");
66 }
67 ,popListClick:function(evt){
68 var e = evt || window.event;
69 e.stopPropagation();
70 }
71 //显示列表
72 ,listShow:function(e){
73 var self = this;
74 this.ui.popList.addClass("list-open").removeClass("list-close");
75 this.ui.iconBtn.addClass("opr-btns-select")
76 Talent.$(document).off('mousedown.list-wrapper');
77 Talent.$(document).on('mousedown.list-wrapper', function(e) {
78 self.ui.popList.removeClass("list-open").addClass("list-close");
79 self.ui.iconBtn.removeClass("opr-btns-select")
80 Talent.$(document).off('mousedown.list-wrapper');
81 });
82 this.trigger("iconClickEvent",this.options);
83 }
84 });
85
86
87 var Search = BaseView.extend({
88 template: jst["header/icon-view/search"],
89 className: "search-icon-box",
90 ui: {
91 iconBtn: ".common-link",
92 popList: ".list-wrapper",
93 valueInput: ".form-input input",
94 searchForm: "[data-name=search-form]"
95 },
96 events: function() {
97 var events = {}
98 events["click " + this.ui.iconBtn] = "selfListShow"
99 events["mousedown " + this.ui.popList] = "popListClick"
100 events["mouseleave " + this.ui.popList] = "autoHideRegister"
101 events["mouseenter " + this.ui.popList] = "autoHideCancle"
102 events["submit " + this.ui.searchForm] = "formSubmit"
103 return events
104 },
105 templateHelpers: function() {
106 var searchTip = this.model.get("tip") || "搜索"
107 return {
108 searchTip: searchTip
109 }
110 },
111 //显示列表
112 selfListShow: function(e) {
113 // this.ui.valueInput.focus();
114 this.listShow()
115 this.ui.valueInput.focus()
116 },
117 //抛出搜索事件
118 formSubmit: function(e) {
119 var triggerData = {
120 target: this.options.type,
121 id: this.options.id,
122 exportData: {
123 searchValue: this.ui.valueInput.val()
124 }
125 }
126 this.trigger("iconOprEvents", triggerData)
127
128 this.ui.valueInput.val("")
129 //解决ie8下 当div隐藏时,焦点不能隐藏
130 this.ui.valueInput.blur()
131
132 this.listClose()
133 return false
134 },
135 messageRenew: function(newMsg) {
136 this.model.clear({ silent: true }).set(newMsg)
137 }
138 })
139
140
141 var HomePage = Talent.Layout.extend({
142 template: jst['header/icon-view/home-page']
143 ,className : ''
144 ,initialize:function(options){
145 this.options = options;
146 this.model = new Talent.Model(options);
147 this.listenTo(this.model,'change',this.render);
148 }
149 ,ui: {
150 iconBtn:".common-link"
151 }
152 ,events: function () {
153 var events = {};
154 events['click ' + this.ui.iconBtn] = 'iconBtnClick';
155 return events;
156 }
157 ,iconBtnClick:function(){
158 this.trigger("iconClickEvent",this.options);
159 }
160 ,messageRenew:function(){
161 this.model.set({"reminds":newMsg.reminds});
162 }
163 });
164
165 var Message = BaseView.extend({
166 template: jst['header/icon-view/message']
167 ,className : 'message-icon-box'
168 ,regions:{
169 popRegion:".list-wrapper"
170 }
171 ,ui: {
172 iconBtn:".common-link"
173 ,popList:".list-wrapper"
174 ,messageItem:".message-item"
175 ,viewAll:".view-all a"
176 }
177 ,events: function () {
178 var events = {};
179 events['click ' + this.ui.iconBtn] = 'listShow';
180 events['click ' + this.ui.messageItem] = 'listClose';
181 events['mousedown ' + this.ui.popList] = 'popListClick';
182 events['mouseleave ' + this.ui.popList] = 'autoHideRegister';
183 events['mouseenter ' + this.ui.popList] = 'autoHideCancle';
184 events['click ' + this.ui.viewAll] = 'listClose';
185 return events;
186 }
187 ,messageRenew:function(newMsg){
188 //这里需要更新所有数据,包括红点和列表内容.需要测试!
189 this.model.clear({silent:true}).set(newMsg);
190 }
191 });
192
193 var TodosItems = Talent.ItemView.extend({
194 template: jst["header/icon-view/todos-item/todos-item"],
195 initialize: function(options) {
196 this.model = new Talent.Model(options)
197 },
198 onRender: function() {},
199 onShow: function() {
200 this.$el.find(".message-item").each(function(index) {
201 //用于计算user-opr区域何时换行
202 var userOpr = $(this).find(".user-opr")
203 var userOprWidth = userOpr.width()
204 var dateWidth = $(this)
205 .find(".date")
206 .width()
207 var userNameWidth = $(this)
208 .find(".user-name")
209 .width()
210 if (userOprWidth + dateWidth + userNameWidth > 250) {
211 userOpr.css({ order: "1" })
212 }
213 })
214 }
215 })
216
217 var Todos = BaseView.extend({
218 template: jst["header/icon-view/todos"],
219 className: "todos-icon-box",
220 regions: {
221 listRegion: ".message-list"
222 },
223 ui: {
224 iconBtn: ".common-link",
225 popList: ".list-wrapper",
226 messageItem: ".message-item",
227 viewAll: ".view-all a",
228 headIgnoreAll: '[data-name="head-ignore-all"]'
229 },
230 events: function() {
231 var events = {}
232 events["click " + this.ui.iconBtn] = "selfListShow"
233 events["mousedown " + this.ui.popList] = "popListClick"
234 events["mouseleave " + this.ui.popList] = "autoHideRegister"
235 events["mouseenter " + this.ui.popList] = "autoHideCancle"
236 events["click " + this.ui.messageItem] = "listClose"
237 events["click " + this.ui.viewAll] = "listClose"
238 events["click " + this.ui.headIgnoreAll] = "_headIgnoreAll"
239
240 return events
241 },
242 selfListShow: function(e) {
243 //如果当前存在有红点提示,这显示loading,等待外部接口调用显示数据
244 if (this.model.get("reminds").remindCount) {
245 this.listShow(e)
246 }
247 },
248 //这里需要特殊处理//用于刷新列表。
249 messageRenew: function(newMsg) {
250 if (newMsg.reminds.remindList && newMsg.reminds.remindList.length) {
251 this.listRegion.show(new TodosItems(newMsg))
252 } else {
253 this.model.clear({ silent: true }).set(newMsg)
254 }
255 },
256 _headIgnoreAll: function() {
257 this.trigger("ignoreAllTodo")
258 }
259 })
260
261 var Skin = BaseView.extend({
262 template: jst['header/icon-view/skin']
263 ,className : 'skin-icon-box'
264 ,ui: {
265 iconBtn:".common-link"
266 ,popList:".list-wrapper"
267 ,comfirmBtn:".comfirm-btn"
268 ,inputRange:".color-range"
269 ,checkbox:".check-default"
270 }
271 ,events: function () {
272 var events = {};
273 events['click ' + this.ui.iconBtn] = 'listShow';
274 events['mousedown ' + this.ui.popList] = 'popListClick';
275 events['mouseleave ' + this.ui.popList] = 'autoHideRegister';
276 events['mouseenter ' + this.ui.popList] = 'autoHideCancle';
277 events['click ' + this.ui.comfirmBtn] = 'getRangeVal';
278 events['click ' + this.ui.checkbox] = 'setDefalutColor';
279 return events;
280 }
281 ,getRangeVal:function(){
282 var triggerData = {
283 target:this.options.type
284 ,id:this.options.id
285 ,exportData:{
286 rangeValue:this.ui.inputRange.val()
287 ,isDefaultColor : this.ui.checkbox.hasClass("check-go")
288 }
289 }
290 this.trigger("iconOprEvents",triggerData);
291 this.listClose();
292 }
293 ,setDefalutColor:function(){
294 this.ui.checkbox.toggleClass("check-back").toggleClass("check-go");
295 }
296 ,messageRenew:function(newMsg){
297 this.model.clear({silent:true}).set(newMsg);
298 }
299 });
300
301
302 var Settings = BaseView.extend({
303 template: jst['header/icon-view/settings']
304 ,className : 'settings-box'
305 ,initialize:function(options){
306 this.model = new Talent.Model(options);
307 this.listenTo(this.model,"change",this.render);
308 }
309 ,ui: {
310 iconBtn:".common-link"
311 ,popList:".list-wrapper"
312 ,messageItem:".message-item"
313 }
314 ,events: function () {
315 var events = {};
316 events['click ' + this.ui.iconBtn] = 'iconBtnClick';
317 events['click ' + this.ui.messageItem] = 'listClose';
318 events['mousedown ' + this.ui.popList] = 'popListClick';
319 return events;
320 }
321 ,iconBtnClick:function(){
322 var reminds = this.model.get('reminds');
323 var settingsList = reminds && reminds.remindList;
324 if(settingsList && settingsList.length){
325 this.listShow()
326 }
327 this.trigger("iconClickEvent",this.options);
328 }
329 ,messageRenew:function(newMsg){
330 this.model.clear({silent:true}).set(newMsg);
331 }
332 });
333
334 var Upgrade = BaseView.extend({
335 template: jst["header/icon-view/upgrade"],
336 className: "upgrade-icon-box",
337 ui: {
338 iconBtn: ".common-link",
339 // ,popList:".list-wrapper"
340 // ,valueInput:".form-input input"
341 // ,searchForm:"[data-name=upgrade-form]"
342 },
343 messageRenew: function(newMsg) {
344 this.model.clear({ silent: true }).set(newMsg)
345 },
346 })
347
348 var Appstore = BaseView.extend({
349 template: jst["header/icon-view/appstore"],
350 className: "appstore-icon-box",
351 ui: {
352 iconBtn: ".appstore-btn",
353
354 // ,popList:".list-wrapper"
355 // ,valueInput:".form-input input"
356 // ,searchForm:"[data-name=upgrade-form]"
357 }
358 ,events: function () {
359 var events = {};
360 events['click ' + this.ui.iconBtn] = 'iconBtnClick';
361 return events;
362 },
363 initialize:function(options){
364 this.options = options;
365 this.model = new Talent.Model(options);
366 this.listenTo(this.model,"change",this.render);
367 },
368 iconBtnClick:function(e){
369 e.stopPropagation()
370 this.trigger("iconClickEvent",this.options)
371 },
372 messageRenew: function(newMsg) {
373 this.model.set("isShowNew",false)
374 },
375 })
376
377 var Lang = BaseView.extend({
378 template: jst['header/icon-view/lang'],
379
380 ui: {
381 iconBtn: '.lang-region',
382 showList: '.lang-region-box',
383 popList: '.dp-down-list',
384 listWrap: '.dp-down-list',
385 listItem: '.dp-list-item a',
386 listFront: '.dp-list-front',
387 listShadow: '.dp-list-shadow'
388 },
389 initialize: function(options) {
390 this.options = options
391
392 // this.model.set(options.i18nInfo)
393 // this.model.set({
394 // show: true,
395 // list: []
396 // })
397 },
398 refresh: function(params) {
399 this.model.set(params)
400
401 this.render()
402 },
403 setData: function(data) {
404 this.model.set(data)
405 // this.model.set({
406 // show: this.model.get('show'),
407 // list: []
408 // })
409 },
410 events: function() {
411 var events = {}
412
413 events['click ' + this.ui.showList] = 'showList'
414 events['click ' + this.ui.listItem] = 'listItemScale'
415 return events
416 },
417 ui: {
418 iconBtn: '.lang-region',
419 showList: '.lang-region-box',
420 popList: '.dp-down-list',
421 listWrap: '.dp-down-list',
422 listItem: '.dp-list-item a',
423 listFront: '.dp-list-front',
424 listShadow: '.dp-list-shadow'
425 },
426 initialize: function(options) {
427 this.options = options
428 },
429 render: function() {
430 var meData = this.model.toJSON()
431 if (meData.show) {
432 this.$el.html(this.template(meData))
433 this.bindUIElements()
434 } else {
435 this.$el.html('')
436 this.bindUIElements()
437 }
438 return this
439 },
440 showList: function(e) {
441 var self = this
442 this.ui.listWrap.addClass('dp-down-active')
443 clearTimeout(self.timer)
444 Talent.$(document).off('mouseup.alertLang')
445 Talent.$(document).on('mouseup.alertLang', function(e) {
446 self.ui.listWrap.removeClass('dp-down-active')
447 Talent.$(document).off('mouseup.alertLang')
448 })
449 self.timer = setTimeout(function() {
450 self.ui.listWrap.removeClass('dp-down-active')
451 }, 6000)
452 },
453 listItemScale: function(e) {
454 var self = this
455 var itemIndex = Talent.$(e.target).attr('index')
456 var target = this.model.toJSON().list[itemIndex]
457 this.trigger('iconClickEvent', this.model.toJSON().list[itemIndex])
458 this.ui.listWrap.removeClass('dp-down-active')
459 !self.isIE() && this.ui.listShadow.show()
460
461 this.model.set({
462 I18NUserLang: target.value
463 })
464
465 this.ui.listShadow
466 .find('.item-' + itemIndex)
467 .addClass('li-scale')
468 .siblings()
469 .removeClass('li-scale')
470
471 setTimeout(function() {
472 self.ui.listShadow.hide()
473 self.render()
474 }, 350)
475 },
476 isIE: function() {
477 //ie?
478 if (!!window.ActiveXObject || 'ActiveXObject' in window) return true
479 else return false
480 }
481 })
482
483
484 /** webIm **/
485
486 /** 用户信息类 **/
487
488 var UserInfo = Talent.Layout.extend({
489 template: jst['header/user-info']
490 ,className : ''
491 ,initialize:function(options){
492 // this.model = new Talent.Model(options);
493 this.options = options;
494 this.model = new Talent.Model(options);
495 }
496 ,ui: {
497 'showList':".user-info"
498 ,listWrap:".dp-down-list"
499
500 ,listItem:".list-ul-box .dp-list-item a"
501
502 ,listFront:".dp-list-front"
503 ,listShadow:".dp-list-shadow"
504 }
505 ,events: function () {
506 var events = {};
507 events['click ' + this.ui.showList] = 'showList';
508 events['click ' + this.ui.listItem] = 'listItemScale';
509 return events;
510 }
511 ,showList:function(e){
512 var self = this;
513 this.ui.listWrap.addClass("dp-down-active");
514 Talent.$(document).off('mouseup.alertList');
515 Talent.$(document).on('mouseup.alertList', function(e) {
516 self.ui.listWrap.removeClass("dp-down-active");
517 Talent.$(document).off('mouseup.alertList');
518 });
519 setTimeout(function(){
520 self.ui.listWrap.removeClass("dp-down-active");
521 },6000)
522 }
523 ,listItemScale:function(e){
524 var self = this;
525 var itemIndex = Talent.$(e.target).attr("index");
526
527 this.ui.listWrap.removeClass("dp-down-active");
528 !this.isIE()&&this.ui.listShadow.show();
529
530 this.ui.listShadow.find(".item-" + itemIndex).addClass("li-scale").siblings().removeClass("li-scale");
531
532 setTimeout(function(){
533 self.ui.listShadow.hide();
534 },350);
535 }
536 ,isIE:function() { //ie?
537 if (!!window.ActiveXObject || "ActiveXObject" in window)
538 return true;
539 else
540 return false;
541 }
542 });
543
544
545 /** 用户信息类 **/
546
547 var CompanyInfo = Talent.Layout.extend({
548 template: jst['header/company-info']
549 ,className : ''
550 ,initialize:function(options){
551 //设置默认图标
552 if(!options.logo)options.logo = "http://st-web.tita.com/ux/tita-web-v4/release/app/images/components/tita-common/logo_v3.png";
553 this.model = new Talent.Model(options);
554 }
555 ,ui: {
556 companyLogo:".cmpy-logo"
557 }
558 ,onRender:function(){
559 /**backup**/
560 // var self = this;
561 // this.ui.companyLogo.attr("src", this.model.get("logo")).load(function() {
562 // imgWidth = this.width;
563 // imgHeight = this.height;
564 // var radio = imgWidth/imgHeight;
565 // if(this.height > 30){
566 // var h = 30;
567 // var w = radio*30;
568 // $(this).css({height:h,width:w,display:"block"})
569 // }else{
570 // var marginTop = (30-imgHeight) / 2;
571 // var h = radio*imgHeight;
572 // $(this).css({height:imgHeight,"margin-top":marginTop,width:h,display:"block"})
573 // }
574 // });
575 //分界线
576 // var self = this;
577 // var imgUrl = this.model.get("logo");
578 // if(!imgUrl)return;
579 // var img = new Image();
580 // img.onload= function(){
581 // var imgWidth = img.width;
582 // var imgHeight = img.height;
583
584 // var size = fixSize(imgWidth,imgHeight)
585
586 // self.ui.companyLogo.css({
587 // width:parseInt(size.w) || 1,
588 // height:parseInt(size.h) || 1,
589 // display:"block",
590 // marginTop:(30-size.h) / 2
591 // })
592
593 // self.ui.companyLogo.attr("src", imgUrl);
594 // function fixSize(imgWidth,imgHeight){
595 // var iWidth = 150,
596 // iHeight = 30;
597 // var newSize = {}
598
599 // var fix = imgWidth/imgHeight;
600
601 // if(imgWidth > 150 || imgHeight > 30 ){
602
603 // width = fix *30
604 // height = 150/fix;
605 // if(width > 150){
606 // width = 150
607 // }
608 // if(height > 30){
609 // height = 30
610 // }
611
612 // newSize = {
613 // w : width,
614 // h : height
615 // }
616
617 // }else{
618 // newSize = {
619 // w : imgWidth,
620 // h : imgHeight
621 // }
622 // }
623 // return newSize
624 // }
625 // };
626 // img.src = imgUrl;
627 }
628 });
629
630
631 /** 头部组件入口 **/
632 /** 头部组件入口 **/
633 var Header = Talent.Layout.extend({
634 template: jst["header/header"],
635 className: "iTalent-header",
636 initialize: function(options) {
637 this.options = options
638
639 this.viewMapping = {
640 Search: Search,
641 HomePage: HomePage,
642 Message: Message,
643 Skin: Skin,
644 Todos: Todos,
645 Settings: Settings,
646 Upgrade: Upgrade,
647 Appstore: Appstore,
648 Lang: Lang
649 }
650 },
651 ui: {
652 btnGroup: ".btns-group"
653 },
654 regions: {
655 userInfoRegion: ".user-info-region",
656 companyInfoRegion: ".company-info-region",
657 langRegion: ".lang-region"
658 },
659 onShow: function() {},
660 onRender: function() {
661 this.companyInfoShow()
662 this.userInfoShow()
663 this.oprBtnShow()
664 // this.renderLangView();
665 // if (this.options.langInfo.show) {
666 this.langShow()
667 // }
668 },
669 refreshI18nView: function(params) {
670 if (this.langView) {
671 this.langView.setData(params.i18nInfo)
672 this.langView.refresh({
673 list: params.datas,
674 show: params.isOpenInternational
675 })
676 this.langRegion.show(this.langView)
677 }
678 },
679 langShow: function() {
680 var self = this
681 // this.langView = new Lang({
682 // i18nInfo: this.options.i18nInfo,
683 // })
684 //if (this.options.i18nInfo) {
685 this.langView = new Lang()
686
687 this.listenTo(this.langView, "iconClickEvent", function(ret) {
688 self.trigger("iconClickEvent", {
689 type: "Lang",
690 value: ret
691 })
692 })
693
694 //}
695
696 if (this.options.i18nInfo) {
697 this.langView.setData(this.options.i18nInfo)
698 this.langRegion.show(this.langView)
699 }
700 },
701 //render userInfo
702 userInfoShow: function() {
703 this.userInfoRegion.show(
704 new UserInfo({
705 userInfo: this.options.userInfo,
706 userInfoDropDown: this.options.userInfoDropDown
707 })
708 )
709 },
710 //render companyInfo
711 companyInfoShow: function() {
712 this.companyInfoRegion.show(new CompanyInfo(this.options.companyInfo))
713 },
714 //render opr iconbtns view
715 oprBtnShow: function() {
716 var self = this
717
718 Talent._.each(this.options.oprBtn, function(item, index) {
719 var node = document.createElement("li")
720
721 var iconViewName = item.type
722
723 var regionName = iconViewName + "-region"
724
725 var className = "opr-btns " + regionName
726
727 $(node).addClass(className)
728
729 self.ui.btnGroup.prepend(node)
730
731 self.addRegion(regionName, "." + regionName)
732
733 //链接打开方式,如果传则默认a标签没有target属性
734 item.target = item.target || ""
735
736 self[iconViewName] = new self.viewMapping[iconViewName](item)
737
738 self[regionName].show(self[iconViewName])
739
740 //按钮下拉列表中抛出的事件(搜索、换肤)
741 self.listenTo(self[iconViewName], "iconOprEvents", function(resp) {
742 self.trigger("iconOprEvents", resp)
743 })
744 //所有按钮点击抛出的事件
745 self.listenTo(self[iconViewName], "iconClickEvent", function(resp) {
746 self.trigger("iconClickEvent", resp)
747 })
748 //按钮下拉列表中抛出的事件(搜索、换肤)
749 self.listenTo(self[iconViewName], "ignoreAllTodo", function(resp) {
750 self.trigger("ignoreAllTodo")
751 })
752 })
753 },
754 reloadMessage: function(newMsg) {
755 this[newMsg.type]["messageRenew"](newMsg)
756 },
757 _checkIEVersion: function() {
758 var ua = navigator.userAgent
759 var s = "MSIE"
760 var i = ua.indexOf(s)
761 if (i >= 0) {
762 //获取IE版本号
763 var ver = parseFloat(ua.substr(i + s.length))
764 }
765 return ver
766 }
767 })
768
769
770 return Header
771})