Person.js 116 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763
  1. MWF.xApplication.Selector = MWF.xApplication.Selector || {};
  2. MWF.xDesktop.requireApp("Selector", "lp."+MWF.language, null, false);
  3. //MWF.xDesktop.requireApp("Selector", "Actions.RestActions", null, false);
  4. MWF.xApplication.Selector.Person = new Class({
  5. Extends: MWF.widget.Common,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "count": 0,
  10. "title": MWF.xApplication.Selector.LP.selectPerson,
  11. "groups": [],
  12. "roles": [],
  13. "values": [],
  14. "exclude" : [],
  15. "zIndex": 1000,
  16. "expand": true,
  17. "embedded" : false, //是否嵌入在其他容器中
  18. "selectAllEnable" : false, //是否允许全选
  19. "selectAllRange" : "direct", //全选直属人员 还是 所有下级人员
  20. "level1Indent" : 10, //第一级的缩进
  21. "indent" : 10, //后续的缩进
  22. "hasLetter" : true, //字母
  23. "hasTop" : false, //可选、已选的标题
  24. "hasShuttle" : false, //穿梭按钮
  25. "searchbarInTopNode" : true, //搜索框在标题上还是另起一行
  26. "hasSelectedSearchbar" : false, //已选是不是有搜索框
  27. "noSelectedContainer" : false, //是否隐藏右侧已选区域
  28. "contentUrl" : "", //和默认的页面布局不一样的话,可以传入页面布局HTML URL
  29. "injectToBody" : false, //当传入HTML URL的时候是否插入到document.body, false的时候插入到this.container
  30. "selectSingleItem" : false, //当只有一个候选项的时候,是否默认选中
  31. "flatCategory" : false, //扁平化展现分类,
  32. "selectType" : "person",
  33. "itemHeight" : 29,
  34. "identityItemWidth" : 0, //选项宽度,如果不为0,设置为float:left,
  35. "showEmptyText" : true
  36. },
  37. initialize: function(container, options){
  38. this.active = true;
  39. this.setOptions(options);
  40. this.path = "../x_component_Selector/$Selector/";
  41. this.cssPath = "../x_component_Selector/$Selector/"+this.options.style+"/css.wcss";
  42. this._loadCss(true);
  43. this.container = $(container);
  44. Object.defineProperties(this, {
  45. "orgAction": {"get": function(){return o2.Actions.get("x_organization_assemble_control");}},
  46. "processAction": {"get": function(){return o2.Actions.get("x_processplatform_assemble_surface");}},
  47. "designerAction": {"get": function(){return o2.Actions.get("x_processplatform_assemble_designer");}},
  48. "portalAction": {"get": function(){return o2.Actions.get("x_portal_assemble_surface");}},
  49. "portalDesignerAction": {"get": function(){return o2.Actions.get("x_portal_assemble_designer");}},
  50. "cmsAction": {"get": function(){return o2.Actions.get("x_cms_assemble_control");}},
  51. "queryAction": {"get": function(){return o2.Actions.get("x_query_assemble_designer");}}
  52. });
  53. // this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  54. // //this.org2Action = MWF.Actions.get("x_organization_assemble_express");
  55. // this.processAction = MWF.Actions.get("x_processplatform_assemble_surface");
  56. // this.designerAction = MWF.Actions.get("x_processplatform_assemble_designer");
  57. // this.portalAction = MWF.Actions.get("x_portal_assemble_surface");
  58. // this.portalDesignerAction = MWF.Actions.get("x_portal_assemble_designer");
  59. // this.cmsAction = MWF.Actions.get("x_cms_assemble_control");
  60. // this.queryAction = MWF.Actions.get("x_query_assemble_designer");
  61. //this.action = new MWF.xApplication.Selector.Actions.RestActions();
  62. this.lastPeople = "";
  63. this.pageCount = "13";
  64. this.selectedItems = []; //所有已选项
  65. this.items = []; //所有选择项
  66. this.subCategorys = []; //直接的分类
  67. this.subItems = []; //直接的选择项
  68. },
  69. load: function(){
  70. this.fireEvent("queryLoad",[this]);
  71. if( this.options.contentUrl ){
  72. this.loadWithUrl()
  73. }else{
  74. if (layout.mobile){
  75. this.loadMobile();
  76. }else{
  77. this.loadPc();
  78. }
  79. this.fireEvent("load");
  80. }
  81. },
  82. loadMobile: function(){
  83. this.maskRelativeNode = $(document.body);
  84. this.maskRelativeNode.mask({
  85. "destroyOnHide": true,
  86. "style": this.css.maskNode
  87. });
  88. this.node = new Element("div", {"styles": this.css.containerNodeMobile});
  89. this.node.setStyle("z-index", this.options.zIndex.toInt()+1);
  90. this.node.setStyle("height", ( $(document.body).getSize().y ) + "px");
  91. this.titleNode = new Element("div", {
  92. "styles": this.css.titleNodeMobile
  93. }).inject(this.node);
  94. this.titleCancelActionNode = new Element("div", {
  95. "styles": this.css.titleCancelActionNodeMobile,
  96. "text": MWF.SelectorLP.back
  97. }).inject(this.titleNode);
  98. this.titleOkActionNode = new Element("div", {
  99. "styles": this.css.titleOkActionNodeMobile,
  100. "text": MWF.SelectorLP.ok
  101. }).inject(this.titleNode);
  102. this.titleTextNode = new Element("div", {
  103. "styles": this.css.titleTextNodeMobile,
  104. "text": this.options.title
  105. }).inject(this.titleNode);
  106. this.contentNode = new Element("div", {
  107. "styles": this.css.contentNode
  108. }).inject(this.node);
  109. var size = $(document.body).getSize();
  110. var height = size.y-40;
  111. //var height = size.y;
  112. this.contentNode.setStyle("height", ""+height+"px");
  113. this.loadContent();
  114. this.node.inject($(document.body));
  115. this.node.setStyles({
  116. "top": "0px",
  117. "left": "0px"
  118. });
  119. this.setEvent();
  120. },
  121. setMaskResize: function(){
  122. var size = this.container.getSize();
  123. this.mask.resize();
  124. this.maskInterval = window.setInterval(function(){
  125. var resize = this.container.getSize();
  126. if ((size.x!==resize.x) || (size.y!==resize.y)){
  127. this.mask.position();
  128. this.mask.resize();
  129. size.x = resize.x;
  130. size.y = resize.y;
  131. }
  132. }.bind(this), 66);
  133. },
  134. loadPc: function(){
  135. if( this.options.embedded ){
  136. this.node = new Element("div", {
  137. "styles": this.css.containerNode_embedded, //(this.options.count.toInt()===1) ? this.css.containerNodeSingle_embedded : this.css.containerNode_embedded,
  138. "events": {
  139. "click": function(e){e.stopPropagation();},
  140. "mousedown": function(e){e.stopPropagation();},
  141. "mouseover": function(e){e.stopPropagation();},
  142. "mouseout": function(e){e.stopPropagation();},
  143. "keydown": function(e){e.stopPropagation();}
  144. }
  145. });
  146. this.contentNode = new Element("div", {
  147. "styles": this.css.contentNode_embedded ? this.css.contentNode_embedded : this.css.contentNode
  148. }).inject(this.node);
  149. this.loadContent();
  150. if( this.options.width || this.options.height ){
  151. this.setSize()
  152. }
  153. this.node.inject(this.container);
  154. } else {
  155. this.css.maskNode["z-index"] = this.options.zIndex;
  156. var position = this.container.getPosition(this.container.getOffsetParent());
  157. this.mask = new Mask(this.container, {
  158. "destroyOnHide": true,
  159. "style": this.css.maskNode,
  160. "useIframeShim": true,
  161. "iframeShimOptions": {"browsers": true},
  162. "onShow": function () {
  163. this.shim.shim.setStyles({
  164. "opacity": 0,
  165. "top": "" + position.y + "px",
  166. "left": "" + position.x + "px"
  167. });
  168. }
  169. //
  170. // "destroyOnHide": true,
  171. // "style": this.css.maskNode,
  172. // "useIframeShim": true,
  173. // "iframeShimOptions": {"browsers": true},
  174. // "onShow": function(){
  175. // this.shim.shim.setStyles({
  176. // "opacity": 0,
  177. // "top": ""+position.y+"px",
  178. // "left": ""+position.x+"px"
  179. // });
  180. // }
  181. });
  182. this.mask.show();
  183. this.setMaskResize();
  184. // this.container.setStyle("z-index", this.options.zIndex);
  185. this.node = new Element("div", {
  186. "styles": this.options.noSelectedContainer ? this.css.containerNodeSingle : this.css.containerNode, //(this.options.count.toInt()===1)
  187. "events": {
  188. "click": function(e){e.stopPropagation();},
  189. "mousedown": function(e){e.stopPropagation();},
  190. "mouseover": function(e){e.stopPropagation();},
  191. "mouseout": function(e){e.stopPropagation();},
  192. "keydown": function(e){e.stopPropagation();}
  193. }
  194. });
  195. this.node.setStyle("z-index", this.options.zIndex.toInt()+1);
  196. this.titleNode = new Element("div.titleNode", {
  197. "styles": this.css.titleNode
  198. }).inject(this.node);
  199. this.titleActionNode = new Element("div", {
  200. "styles": this.css.titleActionNode
  201. }).inject(this.titleNode);
  202. this.titleTextNode = new Element("div", {
  203. "styles": this.css.titleTextNode,
  204. "text": this.options.title
  205. }).inject(this.titleNode);
  206. this.contentNode = new Element("div", {
  207. "styles": this.css.contentNode
  208. }).inject(this.node);
  209. this.loadContent();
  210. this.actionNode = new Element("div", {
  211. "styles": this.css.actionNode
  212. }).inject(this.node);
  213. //if (this.options.count.toInt() === 1) this.actionNode.setStyle("text-align", "center");
  214. this.loadAction();
  215. this.node.inject(this.container);
  216. this.node.position({
  217. relativeTo: this.container,
  218. position: "center",
  219. edge: "center"
  220. });
  221. var size = this.container.getSize();
  222. var nodeSize = this.node.getSize();
  223. this.node.makeDraggable({
  224. "handle": this.titleNode,
  225. "limit": {
  226. "x": [0, size.x - nodeSize.x],
  227. "y": [0, size.y - nodeSize.y]
  228. }
  229. });
  230. if( this.options.width || this.options.height ){
  231. this.setSize()
  232. }
  233. this.setEvent();
  234. }
  235. },
  236. loadWithUrl : function(){
  237. var request = new Request.HTML({
  238. url: this.options.contentUrl,
  239. method: "GET",
  240. async: false,
  241. onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
  242. this.node = responseTree[0];
  243. this.loadContentWithHTML();
  244. this.fireEvent("load");
  245. }.bind(this),
  246. onFailure: function(xhr){
  247. alert(xhr);
  248. }
  249. });
  250. request.send();
  251. },
  252. loadContentWithHTML : function(){
  253. var container = this.options.injectToBody ? $(document.body) : this.container;
  254. if( !this.options.embedded ){
  255. this.maskRelativeNode = container;
  256. this.css.maskNode["z-index"] = this.options.zIndex;
  257. this.maskRelativeNode.mask({
  258. "destroyOnHide": true,
  259. "style": this.css.maskNode
  260. });
  261. }
  262. if( !this.options.embedded ) {
  263. this.node.setStyles(this.css.containerNodeMobile);
  264. this.node.setStyle("z-index", this.options.zIndex.toInt() + 1);
  265. }
  266. this.node.setStyle("height", ( container.getSize().y ) + "px");
  267. this.titleNode = this.node.getElement(".MWF_selector_titleNode");
  268. this.titleTextNode = this.node.getElement(".MWF_selector_titleTextNode");
  269. this.titleCancelActionNode = this.node.getElement(".MWF_selector_titleCancelActionNode");
  270. this.titleOkActionNode = this.node.getElement(".MWF_selector_titleOkActionNode");
  271. this.contentNode = this.node.getElement(".MWF_selector_contentNode");
  272. this.selectNode = this.node.getElement(".MWF_selector_selectNode");
  273. this.searchInputDiv = this.node.getElement(".MWF_selector_searchInputDiv");
  274. this.searchInput = this.node.getElement(".MWF_selector_searchInput");
  275. this.flatCategoryScrollNode = this.node.getElement(".MWF_selector_flatCategoryScrollNode");
  276. this.flatCategoryNode = this.node.getElement(".MWF_selector_flatCategoryNode");
  277. if( this.options.flatCategory && this.flatCategoryScrollNode ){
  278. this.isFlatCategory = true;
  279. this.flatSubCategoryNodeList = [];
  280. }
  281. this.letterAreaNode = this.node.getElement(".MWF_selector_letterAreaNode");
  282. this.itemAreaScrollNode = this.node.getElement(".MWF_selector_itemAreaScrollNode");
  283. this.itemAreaNode = this.node.getElement(".MWF_selector_itemAreaNode");
  284. this.itemSearchAreaScrollNode = this.node.getElement(".MWF_selector_itemSearchAreaScrollNode");
  285. this.itemSearchAreaNode = this.node.getElement(".MWF_selector_itemSearchAreaNode");
  286. this.selectedScrollNode = this.node.getElement(".MWF_selector_selectedScrollNode");
  287. this.selectedNode = this.node.getElement(".MWF_selector_selectedNode");
  288. this.selectedItemSearchAreaNode = this.node.getElement(".MWF_selector_selectedItemSearchAreaNode");
  289. this.actionNode = this.node.getElement(".MWF_selector_actionNode");
  290. this.okActionNode = this.node.getElement(".MWF_selector_okActionNode");
  291. this.cancelActionNode = this.node.getElement(".MWF_selector_cancelActionNode");
  292. if (this.titleNode) this.titleNode.setStyles(this.css.titleNodeMobile);
  293. if (this.titleTextNode){
  294. this.titleTextNode.setStyles(this.css.titleTextNodeMobile);
  295. if(this.options.title)this.titleTextNode.set("text", this.options.title);
  296. }
  297. if (this.titleCancelActionNode) this.titleCancelActionNode.setStyles(this.css.titleCancelActionNodeMobile);
  298. if (this.titleOkActionNode) this.titleOkActionNode.setStyles(this.css.titleOkActionNodeMobile);
  299. if (this.contentNode) this.contentNode.setStyles(this.css.contentNode);
  300. if (this.selectNode) this.selectNode.setStyles(this.css.selectNodeMobile);
  301. if (this.searchInputDiv) this.searchInputDiv.setStyles(this.css.searchInputDiv);
  302. if (this.searchInput) this.searchInput.setStyles( (this.options.count.toInt()===1 || this.options.noSelectedContainer) ? this.css.searchInputSingle : this.css.searchInput );
  303. if (this.letterAreaNode) this.letterAreaNode.setStyles(this.css.letterAreaNode);
  304. if (this.itemAreaScrollNode) this.itemAreaScrollNode.setStyles(this.css.itemAreaScrollNode);
  305. if (this.itemAreaNode) this.itemAreaNode.setStyles(this.css.itemAreaNode);
  306. if (this.itemSearchAreaScrollNode) this.itemSearchAreaScrollNode.setStyles(this.css.itemSearchAreaScrollNode);
  307. if (this.itemSearchAreaNode) this.itemSearchAreaNode.setStyles(this.css.itemAreaNode);
  308. if (this.selectedScrollNode) this.selectedScrollNode.setStyles(this.css.selectedScrollNode);
  309. if (this.selectedNode) this.selectedNode.setStyles(this.css.selectedNode);
  310. if (this.selectedItemSearchAreaNode) this.selectedItemSearchAreaNode.setStyles(this.css.itemAreaNode);
  311. if (this.actionNode) this.actionNode.setStyles(this.css.actionNode);
  312. if (this.okActionNode) {
  313. this.okActionNode.setStyles(this.css.okActionNode);
  314. this.okActionNode.set("text", MWF.SelectorLP.ok);
  315. }
  316. if (this.cancelActionNode) {
  317. this.cancelActionNode.setStyles(this.css.cancelActionNode);
  318. this.cancelActionNode.set("text", MWF.SelectorLP.cancel);
  319. }
  320. this.loadContent();
  321. if( this.actionNode ){
  322. this.loadAction();
  323. }
  324. this.node.inject( container );
  325. if( !this.options.embedded ){
  326. this.node.setStyles({
  327. "top": "0px",
  328. "left": "0px"
  329. });
  330. }
  331. this.setEvent();
  332. },
  333. setEvent: function(){
  334. if (this.titleActionNode){
  335. this.titleActionNode.addEvent("click", function(){
  336. this.fireEvent("cancel");
  337. this.close();
  338. }.bind(this));
  339. }
  340. if (this.titleCancelActionNode){
  341. this.titleCancelActionNode.addEvent("click", function(){
  342. this.fireEvent("cancel");
  343. this.close();
  344. }.bind(this));
  345. }
  346. if (this.titleOkActionNode){
  347. this.titleOkActionNode.addEvent("click", function(){
  348. this.fireEvent("complete", [this.selectedItems]);
  349. if( this.options.closeOnclickOk !== false )this.close();
  350. }.bind(this));
  351. }
  352. },
  353. close: function(){
  354. this.fireEvent("close");
  355. this.node.destroy();
  356. //if (this.mask) this.mask.hide();
  357. if( !this.options.embedded ){
  358. (this.maskRelativeNode || this.container).unmask();
  359. }
  360. if (this.maskInterval){
  361. window.clearInterval(this.maskInterval);
  362. this.maskInterval = null;
  363. }
  364. this.active = false;
  365. MWF.release(this);
  366. delete this;
  367. },
  368. loadAction: function(){
  369. if( !this.okActionNode ){
  370. this.okActionNode = new Element("button", {
  371. "styles": this.css.okActionNode,
  372. "text": MWF.SelectorLP.ok
  373. }).inject(this.actionNode);
  374. }
  375. if( !this.cancelActionNode ){
  376. this.cancelActionNode = new Element("button", {
  377. "styles": this.css.cancelActionNode,
  378. "text": MWF.SelectorLP.cancel
  379. }).inject(this.actionNode);
  380. }
  381. this.okActionNode.addEvent("click", function(){
  382. this.fireEvent("complete", [this.selectedItems]);
  383. if( this.options.closeOnclickOk !== false )this.close();
  384. }.bind(this));
  385. this.cancelActionNode.addEvent("click", function(){this.fireEvent("cancel"); this.close();}.bind(this));
  386. },
  387. loadContent: function( contentNode, isHTML ){
  388. this.fireEvent("queryLoadContent",[this]);
  389. if( contentNode )this.contentNode = contentNode;
  390. if( this.options.contentUrl || isHTML ){
  391. // if (this.options.count.toInt()!==1){
  392. // this.loadSelectedNodeHTML();
  393. // this.loadSelectNodeHTML(contentNode);
  394. // }else{
  395. // this.setSelectedItem();
  396. // this.loadSelectNodeHTML(contentNode);
  397. // }
  398. this.loadSelectedNodeHTML();
  399. this.loadSelectNodeHTML(contentNode);
  400. }else{
  401. if (layout.mobile){
  402. // if (this.options.count.toInt()!==1) this.loadSelectedNodeMobile();
  403. this.loadSelectedNodeMobile();
  404. this.loadSelectNodeMobile();
  405. }else{
  406. this.loadSelectNode();
  407. if( this.options.hasShuttle ){
  408. this.loadShuttleNode();
  409. }
  410. //if (this.options.count.toInt()!==1) this.loadSelectedNode();
  411. this.loadSelectedNode();
  412. }
  413. }
  414. this.fireEvent("postLoadContent", [this]);
  415. },
  416. getOffsetX : function(node){
  417. return (node.getStyle("margin-left").toInt() || 0 )+
  418. (node.getStyle("margin-right").toInt() || 0 ) +
  419. (node.getStyle("padding-left").toInt() || 0 ) +
  420. (node.getStyle("padding-right").toInt() || 0 ) +
  421. (node.getStyle("border-left-width").toInt() || 0 ) +
  422. (node.getStyle("border-right-width").toInt() || 0 );
  423. },
  424. getOffsetY : function(node){
  425. return (node.getStyle("margin-top").toInt() || 0 ) +
  426. (node.getStyle("margin-bottom").toInt() || 0 ) +
  427. (node.getStyle("padding-top").toInt() || 0 ) +
  428. (node.getStyle("padding-bottom").toInt() || 0 )+
  429. (node.getStyle("border-top-width").toInt() || 0 ) +
  430. (node.getStyle("border-bottom-width").toInt() || 0 );
  431. },
  432. loadSelectNodeHTML: function(contentNode){
  433. var size;
  434. var height;
  435. if( contentNode ){
  436. size = contentNode.getSize();
  437. height = size.y;
  438. if( height === 0 ){
  439. height = contentNode.getStyle("height").toInt();
  440. }
  441. }else{
  442. var container = this.options.injectToBody ? $(document.body) : this.container;
  443. //var containerSize = this.container.getSize();
  444. //var bodySize = $(document.body).getSize();
  445. size = container.getSize();
  446. if(size.y === 0){
  447. size.y = $(document.body).getSize().y
  448. }
  449. //size = {
  450. // "x" : Math.min( containerSize.x, bodySize.x ),
  451. // "y" : Math.min( containerSize.y, bodySize.y )
  452. //};
  453. if(this.node){
  454. var zoom = this.node.getStyle("zoom").toInt() || 0;
  455. if( zoom ){
  456. size.x = size.x * 100 / zoom;
  457. size.y = size.y * 100 / zoom;
  458. }
  459. this.node.setStyles({
  460. "width" : size.x+"px",
  461. "height" : size.y+"px"
  462. })
  463. }
  464. height = size.y-this.getOffsetY( this.contentNode );
  465. if( this.titleNode ){
  466. height = height - this.getOffsetY( this.titleNode ) - ( this.titleNode.getStyle("height").toInt() || 0 )
  467. }
  468. if( this.actionNode ){
  469. height = height - this.getOffsetY( this.actionNode ) - ( this.actionNode.getStyle("height").toInt() || 0 )
  470. }
  471. this.contentNode.setStyle("height", ""+height+"px");
  472. }
  473. var isFormWithAction = window.location.href.toLowerCase().indexOf("workmobilewithaction.html") > -1;
  474. this.selectNode.setStyle("height", ""+height+"px");
  475. if( this.searchInput ){
  476. this.initSearchInput();
  477. height = height - this.getOffsetY( this.searchInputDiv ) - ( this.searchInputDiv.getStyle("height").toInt() || 0 )
  478. }
  479. if( this.options.hasLetter && this.letterAreaNode ){
  480. width = size.x - 18;
  481. this.letterAreaNode.setStyle("width", "" + width + "px");
  482. this.loadLetters();
  483. height = height - this.getOffsetY( this.letterAreaNode ) - ( this.letterAreaNode.getStyle("height").toInt() || 0 )
  484. }
  485. this.itemAreaScrollNode.setStyle("height", ""+height+"px");
  486. this.itemAreaScrollNode.setStyle("overflow", "auto");
  487. if(this.itemSearchAreaScrollNode){
  488. this.itemSearchAreaScrollNode.setStyles({
  489. "display": "none",
  490. "height": ""+height+"px",
  491. "overflow" : "hidden"
  492. });
  493. }
  494. this.itemSearchAreaNode.setStyle("display", "none");
  495. this.initLoadSelectItems();
  496. this.checkLoadSelectItems();
  497. },
  498. loadSelectNodeMobile: function(){
  499. this.selectNode = new Element("div.selectNode", {
  500. "styles": this.css.selectNodeMobile
  501. }).inject(this.contentNode);
  502. var containerSize = this.container.getSize();
  503. var bodySize = $(document.body).getSize();
  504. var size = {
  505. "x" : Math.min( containerSize.x, bodySize.x ),
  506. "y" : Math.min( containerSize.y, bodySize.y )
  507. };
  508. var isFormWithAction = window.location.href.toLowerCase().indexOf("workmobilewithaction.html") > -1;
  509. var height;
  510. if( isFormWithAction ){
  511. height = size.y-40-20-6-20;
  512. }else{
  513. height = size.y;
  514. }
  515. this.selectNode.setStyle("height", ""+height+"px");
  516. this.searchInputDiv = new Element("div.searchInputDiv", {
  517. "styles": this.css.searchInputDiv
  518. }).inject(this.selectNode);
  519. this.searchInput = new Element("input.searchInput", {
  520. "styles": (this.options.count.toInt()===1 || this.options.noSelectedContainer) ? this.css.searchInputSingle : this.css.searchInput,
  521. "type": "text"
  522. }).inject(this.searchInputDiv);
  523. var width = size.x-20-18;
  524. this.searchInput.setStyle("width", ""+width+"px");
  525. this.searchInput.setStyle("height", "20px");
  526. this.initSearchInput();
  527. if( this.options.hasLetter ) {
  528. this.letterAreaNode = new Element("div", {
  529. "styles": this.css.letterAreaMobileNode
  530. }).inject(this.selectNode);
  531. width = size.x - 18;
  532. this.letterAreaNode.setStyle("width", "" + width + "px");
  533. this.loadLetters();
  534. }
  535. this.itemAreaScrollNode = new Element("div.itemAreaScrollNode", {
  536. "styles": this.css.itemAreaScrollNode
  537. }).inject(this.selectNode);
  538. if( isFormWithAction ){
  539. height = size.y-40-20-78-20;
  540. }else{
  541. height = size.y-42-31-40;
  542. }
  543. this.itemAreaScrollNode.setStyle("height", ""+height+"px");
  544. this.itemAreaScrollNode.setStyle("overflow", "auto");
  545. this.itemAreaNode = new Element("div.itemAreaNode", {
  546. "styles": this.css.itemAreaNode
  547. }).inject(this.itemAreaScrollNode);
  548. this.itemSearchAreaNode = new Element("div.itemSearchAreaNode", {
  549. "styles": this.css.itemAreaNode
  550. }).inject(this.itemAreaScrollNode);
  551. this.itemSearchAreaNode.setStyle("display", "none");
  552. //MWF.require("MWF.widget.ScrollBar", function(){
  553. // var _self = this;
  554. // new MWF.widget.ScrollBar(this.itemAreaScrollNode, {
  555. // "style":"xApp_Organization_Explorer",
  556. // "where": "before",
  557. // "distance": 30,
  558. // "friction": 4,
  559. // "axis": {"x": false, "y": true},
  560. // "onScroll": function(y){
  561. // _self._scrollEvent(y);
  562. // }
  563. // });
  564. //}.bind(this));
  565. this.initLoadSelectItems();
  566. this.checkLoadSelectItems();
  567. },
  568. loadSelectedNodeHTML: function(){
  569. this.setSelectedItem();
  570. //MWF.require("MWF.widget.ScrollBar", function(){
  571. // var _self = this;
  572. // new MWF.widget.ScrollBar(this.selectedScrollNode, {
  573. // "style":"xApp_Organization_Explorer", "where": "before", "distance": 100, "friction": 4,"axis": {"x": false, "y": true}
  574. // });
  575. //}.bind(this));
  576. if(this.selectedScrollNode)this.selectedScrollNode.setStyle("display", "none");
  577. },
  578. checkLoadSelectItems: function(){
  579. if (!this.options.groups.length && !this.options.roles.length){
  580. this.loadSelectItems();
  581. }else{
  582. this.loadSelectItemsByCondition();
  583. }
  584. },
  585. loadShuttleNode : function(){
  586. if(this.shuttleNode)return;
  587. this.shuttleNode = new Element("div.shuttleNode", {
  588. "styles": this.css.shuttleNode
  589. }).inject(this.contentNode);
  590. this.shuttleInnerNode = new Element("div.shuttleInnerNode", {
  591. "styles": this.css.shuttleInnerNode
  592. }).inject(this.shuttleNode);
  593. this.goRightNode = new Element("div.goRightNode", {
  594. "styles": this.css.goRightNode
  595. }).inject(this.shuttleInnerNode);
  596. this.goLeftNode = new Element("div.goLeftNode", {
  597. "styles": this.css.goLeftNode
  598. }).inject(this.shuttleInnerNode);
  599. },
  600. loadSelectNode: function(){
  601. this.selectNode = new Element("div.selectNode", {
  602. "styles": this.css.selectNode //(this.options.count.toInt()===1) ? this.css.selectNodeSingle : this.css.selectNode
  603. }).inject(this.contentNode);
  604. if( this.options.hasTop ){ //if( this.options.embedded && this.options.count.toInt()!==1 ){
  605. this.selectTopNode = new Element("div.selectTopNode",{
  606. "styles" : this.css.selectTopNode
  607. }).inject( this.selectNode );
  608. this.selectTopTextNode = new Element("div",{
  609. "text" : MWF.SelectorLP.waitingSelect,
  610. "styles" : this.css.selectTopTextNode
  611. }).inject( this.selectTopNode );
  612. }
  613. if( this.options.searchbarInTopNode ){
  614. this.searchInputDiv = new Element("div", {
  615. "styles": this.css.searchInputDiv
  616. }).inject( this.selectTopNode || this.selectNode);
  617. }else{
  618. this.searchInputDiv = new Element("div.searchInputDiv", {
  619. "styles": this.css.searchInputDiv
  620. }).inject( this.selectNode);
  621. }
  622. this.searchInput = new Element("input", {
  623. "styles": this.css.searchInput, //(this.options.count.toInt()===1) ? this.css.searchInputSingle : this.css.searchInput,
  624. "placeholder" : MWF.SelectorLP.searchDescription,
  625. "type": "text"
  626. }).inject(this.searchInputDiv);
  627. this.initSearchInput();
  628. if( this.options.hasLetter ){
  629. this.letterAreaNode = new Element("div", {
  630. "styles": this.css.letterAreaNode
  631. }).inject(this.selectNode);
  632. this.loadLetters();
  633. }
  634. this.itemAreaScrollNode = new Element("div", {
  635. "styles": this.css.itemAreaScrollNode
  636. }).inject(this.selectNode);
  637. this.itemAreaNode = new Element("div", {
  638. "styles": this.css.itemAreaNode
  639. }).inject(this.itemAreaScrollNode);
  640. this.itemSearchAreaNode = new Element("div", {
  641. "styles": this.css.itemAreaNode
  642. }).inject(this.itemAreaScrollNode);
  643. this.itemSearchAreaNode.setStyle("display", "none");
  644. this.loadSelectNodeScroll();
  645. this.initLoadSelectItems();
  646. this.checkLoadSelectItems();
  647. },
  648. loadSelectNodeScroll: function(){
  649. var overflowY = this.itemAreaScrollNode.getStyle("overflow-y");
  650. if( typeOf(overflowY)==="string" && (overflowY.toLowerCase() === "auto" || overflowY.toLowerCase() === "scroll") )return;
  651. MWF.require("MWF.widget.ScrollBar", function(){
  652. var _self = this;
  653. new MWF.widget.ScrollBar(this.itemAreaScrollNode, {
  654. "style":"xApp_Organization_Explorer",
  655. "where": "before",
  656. "distance": 30,
  657. "friction": 4,
  658. "axis": {"x": false, "y": true},
  659. "onScroll": function(y){
  660. _self._scrollEvent(y);
  661. }
  662. });
  663. }.bind(this));
  664. },
  665. initSearchInput: function(){
  666. this.searchInput.addEvents({
  667. "keydown": function(e){
  668. var iTimerID = this.searchInput.retrieve("searchTimer", null);
  669. if (iTimerID){
  670. window.clearTimeout(iTimerID);
  671. this.searchInput.eliminate("searchTimer");
  672. }
  673. iTimerID = window.setTimeout(function(){
  674. this.search();
  675. }.bind(this), 800);
  676. this.searchInput.store("searchTimer", iTimerID);
  677. }.bind(this),
  678. "change": function(e){
  679. var key = this.searchInput.get("value");
  680. if (!key) this.initSearchArea(false);
  681. }.bind(this),
  682. "blur": function(){
  683. var key = this.searchInput.get("value");
  684. if (!key) this.initSearchArea(false);
  685. }.bind(this)
  686. });
  687. },
  688. initSearchArea: function(flag){
  689. this.searchItems = [];
  690. if (flag){
  691. this.itemSearchAreaNode.empty();
  692. this.itemAreaNode.setStyle("display", "none");
  693. if( this.itemSearchAreaNode.getParent() !== this.itemAreaScrollNode ){
  694. this.itemAreaScrollNode.setStyle("display", "none");
  695. }
  696. if(this.flatCategoryScrollNode){
  697. this.flatCategoryScrollNode.setStyle("display", "none");
  698. }
  699. if( this.itemSearchAreaScrollNode )this.itemSearchAreaScrollNode.setStyle("display", "block");
  700. this.itemSearchAreaNode.setStyle("display", "block");
  701. }else{
  702. this.itemAreaScrollNode.setStyle("display", "block");
  703. this.itemAreaNode.setStyle("display", "block");
  704. if(this.flatCategoryScrollNode && this.flatSubCategoryNodeList && this.flatSubCategoryNodeList.length > 1 ){
  705. this.flatCategoryScrollNode.setStyle("display", "block");
  706. }
  707. if( this.itemSearchAreaScrollNode )this.itemSearchAreaScrollNode.setStyle("display", "none");
  708. this.itemSearchAreaNode.setStyle("display", "none");
  709. }
  710. },
  711. search: function(){
  712. if (!this.options.groups.length && !this.options.roles.length && !this.options.forceSearchInItem ){
  713. var key = this.searchInput.get("value");
  714. if (key){
  715. this._listItemByKey(function(json){
  716. this.initSearchArea(true);
  717. json.data.each(function(data){
  718. if( !this.isExcluded( data ) ) {
  719. var itemSearch = this._newItemSearch(data, this, this.itemSearchAreaNode);
  720. this.searchItems.push( itemSearch );
  721. }
  722. //this._newItem(data, this, this.itemSearchAreaNode);
  723. }.bind(this));
  724. }.bind(this), null, key);
  725. }else{
  726. this.initSearchArea(false);
  727. }
  728. }else{
  729. var key = this.searchInput.get("value");
  730. if (key){
  731. this.initSearchArea(true);
  732. this.searchInItems(key);
  733. }else{
  734. this.initSearchArea(false);
  735. }
  736. }
  737. },
  738. searchInItems: function(key){
  739. var createdId = [];
  740. this.createItemsSearchData(function(){
  741. var word = key.toLowerCase();
  742. this.itemsSearchData.each(function(obj){
  743. var text = obj.text+"#"+obj.pinyin+"#"+obj.firstPY;
  744. var id = obj.data.distinguishedName || obj.data.id || obj.data.name || obj.data.text;
  745. if (text.indexOf(word)!==-1){
  746. if (createdId.indexOf( id )===-1){
  747. this._newItem(obj.data, this, this.itemSearchAreaNode);
  748. createdId.push( id );
  749. }
  750. }
  751. }.bind(this));
  752. //delete createdId;
  753. }.bind(this));
  754. return createdId;
  755. },
  756. createItemsSearchData: function(callback){
  757. if (!this.itemsSearchData){
  758. this.itemsSearchData = [];
  759. MWF.require("MWF.widget.PinYin", function(){
  760. var initIds = [];
  761. this.items.each(function(item){
  762. var id = item.data.distinguishedName || item.data.id || item.data.name || item.data.text;
  763. if (initIds.indexOf( id )==-1){
  764. var text = item._getShowName().toLowerCase();
  765. var pinyin = text.toPY().toLowerCase();
  766. var firstPY = text.toPYFirst().toLowerCase();
  767. this.itemsSearchData.push({
  768. "text": text,
  769. "pinyin": pinyin,
  770. "firstPY": firstPY,
  771. "data": item.data
  772. });
  773. initIds.push( id );
  774. }
  775. }.bind(this));
  776. delete initIds;
  777. if (callback) callback();
  778. }.bind(this));
  779. }else{
  780. if (callback) callback();
  781. }
  782. },
  783. initSelectedSearchInput: function(){
  784. this.selectedSearchInput.addEvents({
  785. "keydown": function(e){
  786. var iTimerID = this.selectedSearchInput.retrieve("searchTimer", null);
  787. if (iTimerID){
  788. window.clearTimeout(iTimerID);
  789. this.selectedSearchInput.eliminate("searchTimer");
  790. }
  791. iTimerID = window.setTimeout(function(){
  792. this.selectedSearch();
  793. }.bind(this), 800);
  794. this.selectedSearchInput.store("searchTimer", iTimerID);
  795. }.bind(this),
  796. "change": function(e){
  797. var key = this.selectedSearchInput.get("value");
  798. if (!key) this.selectedSearch();
  799. }.bind(this),
  800. "blur": function(){
  801. var key = this.selectedSearchInput.get("value");
  802. if (!key) this.selectedSearch();
  803. }.bind(this)
  804. });
  805. },
  806. selectedSearch: function(){
  807. var key = this.selectedSearchInput.get("value");
  808. if (key){
  809. this.selectedSearchInItems(key);
  810. }else{
  811. this.showAllSelectedItem()
  812. }
  813. },
  814. selectedSearchInItems: function(key){
  815. var word = key.toLowerCase();
  816. MWF.require("MWF.widget.PinYin", function() {
  817. this.selectedItems.each(function (item) {
  818. if (!item.searchedText) {
  819. var text = item._getShowName().toLowerCase();
  820. var pinyin = text.toPY().toLowerCase();
  821. var firstPY = text.toPYFirst().toLowerCase();
  822. item.searchedText = text + "#" + pinyin + "#" + firstPY
  823. }
  824. if (item.searchedText.indexOf(word) !== -1) {
  825. item.node.show()
  826. } else {
  827. item.node.hide()
  828. }
  829. }.bind(this));
  830. }.bind(this), null, false);
  831. },
  832. showAllSelectedItem: function(){
  833. this.selectedItems.each(function(item){
  834. item.node.show()
  835. })
  836. },
  837. loadSelectedNode: function( callback ){
  838. if( this.selectedContainerNode )return;
  839. this.selectedContainerNode = new Element("div", {
  840. "styles": this.css.selectedContainerNode
  841. }).inject(this.contentNode);
  842. if( this.options.noSelectedContainer ){
  843. this.selectedContainerNode.hide();
  844. }
  845. //if( this.options.embedded && this.options.count.toInt()!==1 ){
  846. if( this.options.hasTop ){
  847. this.selectedTopNode = new Element("div",{
  848. "styles" : this.css.selectedTopNode
  849. }).inject( this.selectedContainerNode );
  850. this.selectedTopTextNode = new Element("div",{
  851. "text" : MWF.SelectorLP.selected,
  852. "styles" : this.css.selectedTopTextNode
  853. }).inject( this.selectedTopNode );
  854. this.emptySelectedNode = new Element("div",{
  855. "text" : MWF.SelectorLP.empty,
  856. "styles" : this.css.selectedTopActionNode,
  857. "events" : {
  858. "click" : function(){
  859. this.emptySelectedItems()
  860. }.bind(this)
  861. }
  862. }).inject( this.selectedTopNode );
  863. }
  864. if( this.options.hasSelectedSearchbar ){
  865. if( this.options.searchbarInTopNode ){
  866. this.selectedSearchInputDiv = new Element("div", {
  867. "styles": this.css.searchInputDiv
  868. }).inject( this.selectedTopNode || this.selectedContainerNode);
  869. }else{
  870. this.selectedSearchInputDiv = new Element("div.selectedSearchInputDiv", {
  871. "styles": this.css.searchInputDiv
  872. }).inject( this.selectedContainerNode);
  873. }
  874. this.selectedSearchInput = new Element("input", {
  875. "styles": this.css.searchInput, //(this.options.count.toInt()===1) ? this.css.searchInputSingle : this.css.searchInput,
  876. "placeholder" : MWF.SelectorLP.searchDescription,
  877. "type": "text"
  878. }).inject(this.selectedSearchInputDiv);
  879. this.initSelectedSearchInput();
  880. }
  881. this.selectedScrollNode = new Element("div.selectedScrollNode", {
  882. "styles": this.css.selectedScrollNode
  883. }).inject(this.selectedContainerNode);
  884. this.selectedNode = new Element("div.selectedNode", {
  885. "styles": this.css.selectedNode
  886. }).inject(this.selectedScrollNode);
  887. if( this.options.hasSelectedSearchbar ){
  888. this.selectedItemSearchAreaNode = new Element("div.selectedItemSearchAreaNode", {
  889. "styles": this.css.itemAreaNode
  890. }).inject(this.selectedScrollNode);
  891. this.selectedItemSearchAreaNode.setStyle("display", "none");
  892. }
  893. this.setSelectedItem();
  894. this.loadSelectedNodeScroll();
  895. if(callback)callback();
  896. },
  897. emptySelectedItems : function(){
  898. while (this.selectedItems.length){
  899. this.selectedItems[0].clickItem();
  900. }
  901. },
  902. loadSelectedNodeScroll: function(){
  903. var overflowY = this.selectedScrollNode.getStyle("overflow-y");
  904. if( typeOf(overflowY)==="string" && (overflowY.toLowerCase() === "auto" || overflowY.toLowerCase() === "scroll") )return;
  905. MWF.require("MWF.widget.ScrollBar", function(){
  906. var _self = this;
  907. new MWF.widget.ScrollBar(this.selectedScrollNode, {
  908. "style":"xApp_Organization_Explorer", "where": "before", "distance": 100, "friction": 4,"axis": {"x": false, "y": true}
  909. });
  910. }.bind(this));
  911. },
  912. loadSelectedNodeMobile: function(){
  913. this.selectedScrollNode = new Element("div.selectedScrollNode", {
  914. "styles": this.css.selectedScrollNode
  915. }).inject(this.contentNode);
  916. this.selectedNode = new Element("div.selectedNode", {
  917. "styles": this.css.selectedNode
  918. }).inject(this.selectedScrollNode);
  919. this.setSelectedItem();
  920. // MWF.require("MWF.widget.ScrollBar", function(){
  921. // var _self = this;
  922. // new MWF.widget.ScrollBar(this.selectedScrollNode, {
  923. // "style":"xApp_Organization_Explorer", "where": "before", "distance": 100, "friction": 4,"axis": {"x": false, "y": true}
  924. // });
  925. // }.bind(this));
  926. this.selectedScrollNode.setStyle("display", "none");
  927. },
  928. setSelectedItem: function(){
  929. if (this.options.values.length){
  930. this.options.values.each(function(v, i){
  931. if (typeOf(v)==="object"){
  932. this.selectedItems.push(this._newItemSelected(v, this, null));
  933. }else{
  934. this._getItem(function(json){
  935. this.options.values[i] = json.data;
  936. this.selectedItems.push(this._newItemSelected(json.data, this, null));
  937. }.bind(this), null, v, false);
  938. }
  939. // this._getItem(function(json){
  940. // this.selectedItems.push(this._newItemSelected(json.data, this, null));
  941. // }.bind(this), null, v, false);
  942. }.bind(this));
  943. }
  944. },
  945. loadLetters: function(){
  946. var _self = this;
  947. letters = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
  948. var letterNodeCss = this.css.letterNode;
  949. var letterNodeCss_over = this.css.letterNode_over;
  950. if (layout.mobile){
  951. letterNodeCss = this.css.letterNode_mobile || letterNodeCss;
  952. letterNodeCss_over = this.css.letterNode_mobile_over || letterNodeCss_over;
  953. var size = this.container.getSize();
  954. var w = (layout.mobile) ? (size.x-18)/13 : (size.x-20-4-18)/13;
  955. //letterNode.setStyle("width", ""+w+"px");
  956. letterNodeCss.width = ""+w+"px";
  957. letterNodeCss_over.width = ""+w+"px";
  958. }
  959. letters.each(function(l){
  960. var letterNode = new Element("div", {
  961. "styles": letterNodeCss,
  962. "text": l
  963. }).inject(this.letterAreaNode);
  964. if (layout.mobile){
  965. letterNode.addEvents({
  966. "click": function(){
  967. _self.listPersonByPinyin(this);
  968. }
  969. });
  970. }else{
  971. letterNode.addEvents({
  972. "mouseover": function(e){
  973. e.target.setStyles(letterNodeCss_over);
  974. var showNode = new Element("div", {
  975. "styles": this.css.letterShowNode,
  976. "text": e.target.get("text")
  977. }).inject(this.selectNode);
  978. showNode.position({
  979. relativeTo: this.itemAreaScrollNode,
  980. position: "center",
  981. edge: "center"
  982. });
  983. e.target.store("showNode", showNode);
  984. }.bind(this),
  985. "mouseout": function(e){
  986. var showNode = e.target.retrieve("showNode");
  987. showNode.destroy();
  988. e.target.setStyles(letterNodeCss);
  989. }.bind(this),
  990. "click": function(){
  991. _self.listPersonByPinyin(this);
  992. }
  993. });
  994. }
  995. }.bind(this));
  996. },
  997. listPersonByPinyin: function(node){
  998. this.searchInput.focus();
  999. var pinyin = this.searchInput.get("value");
  1000. pinyin = pinyin+node.get("text");
  1001. this.searchInput.set("value", pinyin);
  1002. if (!this.options.groups.length && !this.options.roles.length){
  1003. if (pinyin){
  1004. this._listItemByPinyin(function(json){
  1005. this.initSearchArea(true);
  1006. json.data.each(function(data){
  1007. // var flag = true;
  1008. // if (this.options.departments){
  1009. // if (this.options.departments.length){
  1010. // if (this.options.departments.indexOf(data.departmentName)==-1) flag = false;
  1011. // }
  1012. // }
  1013. // if (this.options.companys){
  1014. // if (this.options.companys.length){
  1015. // if (this.options.companys.indexOf(data.company)==-1) flag = false;
  1016. // }
  1017. // }
  1018. if( !this.isExcluded( data ) ) {
  1019. this._newItemSearch(data, this, this.itemSearchAreaNode);
  1020. }
  1021. //this._newItem(data, this, this.itemSearchAreaNode);
  1022. //this._newItem(data, this, this.itemSearchAreaNode);
  1023. }.bind(this));
  1024. }.bind(this), null, pinyin.toLowerCase());
  1025. }
  1026. }else{
  1027. if (pinyin){
  1028. this.initSearchArea(true);
  1029. this.searchInItems(pinyin);
  1030. }else{
  1031. this.initSearchArea(false);
  1032. }
  1033. }
  1034. },
  1035. initLoadSelectItems: function(){
  1036. this.loaddingItems = false;
  1037. this.isItemLoaded = false;
  1038. this.loadItemsQueue = 0;
  1039. this.initSearchArea(false);
  1040. },
  1041. //loadSelectItems: function(addToNext){
  1042. // if (!this.isItemLoaded){
  1043. // if (!this.loaddingItems){
  1044. // this.loaddingItems = true;
  1045. // var count = 20;
  1046. // this._listItemNext(this.getLastLoadedItemId(), count, function(json){
  1047. // if (json.data.length){
  1048. // json.data.each(function(data){
  1049. // var item = this._newItem(data, this, this.itemAreaNode);
  1050. // this.items.push(item);
  1051. // }.bind(this));
  1052. // this.loaddingItems = false;
  1053. //
  1054. // if (json.data.length<count){
  1055. // this.isItemLoaded = true;
  1056. // }else{
  1057. // if (this.loadItemsQueue>0){
  1058. // this.loadItemsQueue--;
  1059. // this.loadSelectItems();
  1060. // }
  1061. // }
  1062. // }else{
  1063. // this.isItemLoaded = true;
  1064. // this.loaddingItems = false;
  1065. // }
  1066. // }.bind(this));
  1067. // }else{
  1068. // if (addToNext) this.loadItemsQueue++;
  1069. // }
  1070. // }
  1071. //},
  1072. loadSelectItems: function(addToNext, lastExcludeCount ){
  1073. //lastExcludeCount 参数:表示本次加载是为了补足上次load的时候被排除的数量
  1074. if (!this.isItemLoaded){
  1075. if (!this.loaddingItems){
  1076. this.loaddingItems = true;
  1077. var count = 20;
  1078. this._listItemNext(this.getLastLoadedItemId(), count, function(json){
  1079. if (json.data.length){
  1080. var excludedCount = 0;
  1081. json.data.each(function(data, i){
  1082. if( this.isExcluded( data ) ){
  1083. excludedCount++;
  1084. if( i+1 === count )this.tailExcludeItemId = data.distinguishedName
  1085. }else{
  1086. var item = this._newItem(data, this, this.itemAreaNode);
  1087. this.items.push(item);
  1088. if( i+1 === count )this.tailExcludeItemId = null;
  1089. }
  1090. }.bind(this));
  1091. this.loaddingItems = false;
  1092. if( lastExcludeCount ){ //如果是因为上次load的时候被排除而加载的
  1093. if( count - lastExcludeCount - excludedCount < 0 ){ //如果本次load的数量还不够补足排除的数量,需要再次load
  1094. excludedCount = lastExcludeCount + excludedCount - count; //把不足的数量作为再次load的参数
  1095. this.loadItemsQueue++
  1096. }
  1097. }else if( excludedCount > 0 ){ //把排除的数量作为再次load的参数
  1098. this.loadItemsQueue++
  1099. }
  1100. if (json.data.length<count){
  1101. this.isItemLoaded = true;
  1102. }else{
  1103. if (this.loadItemsQueue>0){
  1104. this.loadItemsQueue--;
  1105. this.loadSelectItems( addToNext, excludedCount );
  1106. }
  1107. }
  1108. }else{
  1109. this.isItemLoaded = true;
  1110. this.loaddingItems = false;
  1111. }
  1112. if( this.afterLoadSelectItem )this.afterLoadSelectItem();
  1113. }.bind(this));
  1114. }else{
  1115. if (addToNext) this.loadItemsQueue++;
  1116. }
  1117. }
  1118. },
  1119. getLastLoadedItemId: function(){
  1120. if( this.tailExcludeItemId )return this.tailExcludeItemId;
  1121. return (this.items.length) ? this.items[this.items.length-1].data.distinguishedName : "(0)";
  1122. },
  1123. //loadSelectItemsByCondition: function(){
  1124. // this.options.groups.each(function(group){
  1125. //
  1126. // this.orgAction.listGroupByKey(function(json){
  1127. // if (json.data.length){
  1128. // var groupData = json.data[0];
  1129. // var category = this._newItemCategory("ItemGroupCategory", groupData, this, this.itemAreaNode);
  1130. // this._getChildrenItemIds(groupData).each(function(id){
  1131. // this._getItem(function(json){
  1132. // var item = this._newItem(json.data, this, category.children);
  1133. // this.items.push(item);
  1134. // }.bind(this), null, id);
  1135. // }.bind(this));
  1136. // }
  1137. // }.bind(this), null, group);
  1138. // }.bind(this));
  1139. //
  1140. // this.options.roles.each(function(role){
  1141. // this.orgAction.listRoleByKey(function(json){
  1142. // if (json.data.length){
  1143. // var roleData = json.data[0];
  1144. // var category = this._newItemCategory("ItemRoleCategory", roleData, this, this.itemAreaNode);
  1145. // this._getChildrenItemIds(roleData).each(function(id){
  1146. // this._getItem(function(json){
  1147. // var item = this._newItem(json.data, this, category.children);
  1148. // this.items.push(item);
  1149. // }.bind(this), null, id)
  1150. // }.bind(this));
  1151. // }
  1152. // }.bind(this), null, role);
  1153. // }.bind(this));
  1154. //},
  1155. loadSelectItemsByCondition: function(){
  1156. this.options.groups.each(function(group){
  1157. this.orgAction.listGroupByKey(function(json){
  1158. if (json.data.length){
  1159. var groupData = json.data[0];
  1160. var category = this._newItemCategory("ItemGroupCategory", groupData, this, this.itemAreaNode);
  1161. this.subCategorys.push(category);
  1162. this._getChildrenItemIds(groupData).each(function(id){
  1163. this._getItem(function(json){
  1164. if( !this.isExcluded( json.data ) ) {
  1165. var item = this._newItem(json.data, this, category.children);
  1166. this.items.push(item);
  1167. }
  1168. }.bind(this), null, id);
  1169. }.bind(this));
  1170. }
  1171. }.bind(this), null, group);
  1172. }.bind(this));
  1173. this.options.roles.each(function(role){
  1174. this.orgAction.listRoleByKey(function(json){
  1175. if (json.data.length){
  1176. var roleData = json.data[0];
  1177. var category = this._newItemCategory("ItemRoleCategory", roleData, this, this.itemAreaNode);
  1178. this.subCategorys.push(category);
  1179. this._getChildrenItemIds(roleData).each(function(id){
  1180. this._getItem(function(json){
  1181. if( !this.isExcluded( json.data ) ) {
  1182. var item = this._newItem(json.data, this, category.children);
  1183. this.items.push(item);
  1184. }
  1185. }.bind(this), null, id)
  1186. }.bind(this));
  1187. }
  1188. }.bind(this), null, role);
  1189. }.bind(this));
  1190. },
  1191. isExcluded : function( d ){
  1192. if( this.options.exclude.length === 0 )return false;
  1193. if( !this.excludeFlagMap ){
  1194. this.excludeFlagMap = {};
  1195. this.options.exclude.each( function( e ){
  1196. if( !e )return;
  1197. this.excludeFlagMap[ typeOf( e ) === "string" ? e : ( e.distinguishedName || e.id || e.unique || e.employee || e.levelName) ] = true;
  1198. }.bind(this));
  1199. }
  1200. var map = this.excludeFlagMap;
  1201. return ( d.distinguishedName && map[ d.distinguishedName ] ) ||
  1202. ( d.id && map[ d.id ] ) ||
  1203. ( d.unique && map[ d.unique ] ) ||
  1204. ( d.employee && map[ d.employee ] ) ||
  1205. ( d.levelName && map[ d.levelName ] );
  1206. },
  1207. _getChildrenItemIds: function(data){
  1208. return data.personList;
  1209. },
  1210. _newItemCategory: function(type, data, selector, item){
  1211. return new MWF.xApplication.Selector.Person[type](data, selector, item)
  1212. },
  1213. _listItemByKey: function(callback, failure, key){
  1214. this.orgAction.listPersonByKey(function(json){
  1215. if (callback) callback.apply(this, [json]);
  1216. }.bind(this), failure, key);
  1217. },
  1218. _getItem: function(callback, failure, id, async){
  1219. this.orgAction.getPerson(function(json){
  1220. if (callback) callback.apply(this, [json]);
  1221. }.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async);
  1222. },
  1223. _newItemSelected: function(data, selector, item, selectedNode){
  1224. return new MWF.xApplication.Selector.Person.ItemSelected(data, selector, item, selectedNode)
  1225. },
  1226. _listItemByPinyin: function(callback, failure, key){
  1227. this.orgAction.listPersonByPinyin(function(json){
  1228. if (callback) callback.apply(this, [json]);
  1229. }.bind(this), failure, key);
  1230. },
  1231. _newItem: function(data, selector, container){
  1232. return new MWF.xApplication.Selector.Person.Item(data, selector, container);
  1233. },
  1234. _newItemSearch: function(data, selector, container){
  1235. return this._newItem(data, selector, container);
  1236. },
  1237. _listItemNext: function(last, count, callback){
  1238. this.orgAction.listPersonNext(last, count, function(json){
  1239. if (callback) callback.apply(this, [json]);
  1240. }.bind(this));
  1241. },
  1242. _scrollEvent: function(y){
  1243. if (!this.options.groups.length && !this.options.roles.length){
  1244. var scrollSize = this.itemAreaScrollNode.getScrollSize();
  1245. var clientSize = this.itemAreaScrollNode.getSize();
  1246. var scrollHeight = scrollSize.y-clientSize.y;
  1247. if (y+30>scrollHeight) {
  1248. if (!this.isItemLoaded) this.loadSelectItems();
  1249. }
  1250. }
  1251. },
  1252. afterLoadSelectItem : function(){
  1253. if( this.items.length === 0 && this.subItems.length === 0 && this.subCategorys.length === 0 ){
  1254. this.noSelectableItemTextDiv = new Element("div", {
  1255. text : MWF.SelectorLP.noSelectableItemText,
  1256. styles : this.css.noSelectableItemText
  1257. }).inject( this.itemAreaNode );
  1258. }
  1259. if( this.options.selectSingleItem ){
  1260. this.selectSingleItem()
  1261. }
  1262. this.fireEvent("afterLoadSelectItem", [this]);
  1263. },
  1264. selectSingleItem: function(){
  1265. if( !this.options.contentUrl && !layout.mobile){
  1266. if( this.options.hasShuttle && !this.shuttleNode ){
  1267. this.loadShuttleNode();
  1268. }
  1269. if( !this.selectedContainerNode ) {
  1270. this.loadSelectedNode(function () {
  1271. this._selectSingleItem();
  1272. }.bind(this));
  1273. }else{
  1274. this._selectSingleItem();
  1275. }
  1276. }else{
  1277. this._selectSingleItem();
  1278. }
  1279. },
  1280. _selectSingleItem : function(){
  1281. var checkItem = function () {
  1282. if(this.items.length === 1 || this.subItems.length === 1 ){
  1283. if( this.items.length === 1 && this.subItems.length === 0 ){
  1284. if( !this.items[0].isSelected )this.items[0].clickItem();
  1285. }else if( this.items.length === 0 && this.subItems.length === 1 ){
  1286. if( !this.items[0].isSelected )this.subItems[0].clickItem();
  1287. }else if( this.items.length === 1 && this.subItems.length === 1 ){
  1288. if( this.items[0] === this.subItems[0] ){
  1289. if( !this.items[0].isSelected )this.items[0].clickItem();
  1290. }
  1291. }
  1292. }
  1293. }.bind(this);
  1294. var checkCategoryItem = function (category) {
  1295. if( !category.subCategorys || category.subCategorys.length === 0 ){
  1296. if( category.subItems && category.subItems.length === 1 ){
  1297. if( !category.subItems[0].isSelected )category.subItems[0].clickItem();
  1298. }
  1299. }else if(category.subCategorys.length === 1){
  1300. if( !category.subCategorys[0]._hasChild || !category.subCategorys[0]._hasChild() ){ //category.subCategorys[0].isItem &&
  1301. if( !category.subItems[0].isSelected )category.subItems[0].clickItem();
  1302. }else{
  1303. checkCategory( category.subCategorys[0] )
  1304. }
  1305. }else{
  1306. var list = [];
  1307. for( var i=0; i<category.subCategorys.length; i++ ){
  1308. if( category.subCategorys[i]._hasChild && category.subCategorys[i]._hasChild() ){
  1309. list.push( category.subCategorys[i] );
  1310. }
  1311. }
  1312. if( list.length === 1 ){
  1313. if( !category.subItems || category.subItems.length === 0 ){
  1314. checkCategory( list[0] );
  1315. }
  1316. }
  1317. if( list.length === 0 ){
  1318. if( category.subItems && category.subItems.length === 1 ){
  1319. if( !category.subItems[0].isSelected )category.subItems[0].clickItem();
  1320. }
  1321. }
  1322. }
  1323. };
  1324. var checkCategory = function ( category ) {
  1325. if( category.loaded ){
  1326. checkCategoryItem( category )
  1327. }else if( category.loading ){
  1328. window.setTimeout( function () {
  1329. checkCategory( category )
  1330. }, 100 )
  1331. }
  1332. };
  1333. if( this.subCategorys.length === 1 ) {
  1334. checkCategory( this.subCategorys[0] );
  1335. }else if( this.subCategorys.length === 0 ){
  1336. checkItem();
  1337. }
  1338. },
  1339. setSize : function(){
  1340. if( !this.options.width && !this.options.height )return;
  1341. var getOffsetX = function(node){
  1342. return (node.getStyle("margin-left").toInt() || 0 )+
  1343. (node.getStyle("margin-right").toInt() || 0 ) +
  1344. (node.getStyle("padding-left").toInt() || 0 ) +
  1345. (node.getStyle("padding-right").toInt() || 0 ) +
  1346. (node.getStyle("border-left-width").toInt() || 0 ) +
  1347. (node.getStyle("border-right-width").toInt() || 0 );
  1348. };
  1349. var getOffsetY = function(node){
  1350. return (node.getStyle("margin-top").toInt() || 0 ) +
  1351. (node.getStyle("margin-bottom").toInt() || 0 ) +
  1352. (node.getStyle("padding-top").toInt() || 0 ) +
  1353. (node.getStyle("padding-bottom").toInt() || 0 )+
  1354. (node.getStyle("border-top-width").toInt() || 0 ) +
  1355. (node.getStyle("border-bottom-width").toInt() || 0 );
  1356. };
  1357. if( this.options.width && this.options.width === "auto" ){
  1358. //if (this.options.count.toInt() !== 1){
  1359. if( this.node )this.node.setStyle("width", "auto");
  1360. this.selectNode.setStyles({
  1361. "width": "50%",
  1362. "float" : "left"
  1363. });
  1364. //this.searchInput.setStyle("width", "99%");
  1365. if(this.letterAreaNode ){
  1366. this.letterAreaNode.setStyle("width", "auto");
  1367. }
  1368. this.selectedContainerNode.setStyle("width", "auto");
  1369. var overflowY = this.selectedScrollNode.getStyle("overflow-y");
  1370. if( typeOf(overflowY)==="string" && (overflowY.toLowerCase() === "auto" || overflowY.toLowerCase() === "scroll") ){
  1371. this.selectedScrollNode.setStyle("width", "auto");
  1372. }else{
  1373. this.selectedScrollNode.setStyle("margin-right", "8px");
  1374. }
  1375. //}else{
  1376. // this.node.setStyle("width", "auto");
  1377. // this.selectNode.setStyle("width", "auto");
  1378. //}
  1379. }else if( this.options.width && typeOf( this.options.width.toInt() ) === "number" ){
  1380. var nodeWidth;
  1381. if( this.node ){
  1382. nodeWidth = this.options.width.toInt() - getOffsetX(this.node);
  1383. this.node.setStyle("width", nodeWidth);
  1384. }else{
  1385. nodeWidth = this.options.width.toInt();
  1386. }
  1387. nodeWidth = nodeWidth - getOffsetX( this.contentNode );
  1388. if( this.shuttleNode ){
  1389. nodeWidth = nodeWidth - getOffsetX(this.shuttleNode) - this.shuttleNode.getStyle("width").toInt();
  1390. }
  1391. //if (this.options.count.toInt() !== 1){
  1392. var width = nodeWidth - getOffsetX(this.selectNode) - getOffsetX(this.selectedContainerNode);
  1393. var halfWidth = this.options.noSelectedContainer ? width : Math.floor(width / 2);
  1394. this.selectNode.setStyle("width", halfWidth);
  1395. //this.searchInput.setStyle("width", halfWidth - 6);
  1396. if(this.letterAreaNode ){
  1397. this.letterAreaNode.setStyle("width", halfWidth - 19);
  1398. }
  1399. this.selectedContainerNode.setStyle("width", halfWidth);
  1400. var overflowY = this.selectedScrollNode.getStyle("overflow-y");
  1401. if( typeOf(overflowY)==="string" && (overflowY.toLowerCase() === "auto" || overflowY.toLowerCase() === "scroll") ){
  1402. this.selectedScrollNode.setStyle("width", halfWidth);
  1403. }else{
  1404. this.selectedScrollNode.setStyle("width", halfWidth - 8);
  1405. }
  1406. //}else{
  1407. // var width = nodeWidth - getOffsetX(this.selectNode);
  1408. // this.selectNode.setStyle("width", width);
  1409. //}
  1410. }
  1411. if( this.options.height && typeOf( this.options.height.toInt() ) === "number" ){
  1412. var nodeHeight;
  1413. if( this.node ){
  1414. nodeHeight = this.options.height.toInt() - getOffsetY(this.node);
  1415. this.node.setStyle("height", nodeHeight);
  1416. }else{
  1417. nodeHeight = this.options.height.toInt();
  1418. }
  1419. nodeHeight = nodeHeight - getOffsetY( this.contentNode );
  1420. if( this.titleNode ){
  1421. nodeHeight = nodeHeight - getOffsetY( this.titleNode ) - this.titleNode.getStyle("height").toInt();
  1422. }
  1423. if( this.actionNode ){
  1424. nodeHeight = nodeHeight - getOffsetY( this.actionNode ) - this.actionNode.getStyle("height").toInt();
  1425. }
  1426. var selectNodeHeight = nodeHeight - getOffsetY(this.selectNode);
  1427. this.selectNode.setStyle("height", selectNodeHeight);
  1428. if( this.shuttleNode ){
  1429. this.shuttleNode.setStyle("height", selectNodeHeight);
  1430. var shuttleInnerHieght = getOffsetY( this.shuttleInnerNode ) + this.shuttleInnerNode.getStyle("height").toInt();
  1431. this.shuttleInnerNode.setStyle("margin-top", (selectNodeHeight-shuttleInnerHieght)/2 +"px" )
  1432. }
  1433. var itemAreaScrollNodeHeight = selectNodeHeight - getOffsetY( this.searchInputDiv ) - this.searchInputDiv.getStyle("height").toInt();
  1434. if( !this.options.searchbarInTopNode && this.selectTopNode ){
  1435. itemAreaScrollNodeHeight = itemAreaScrollNodeHeight - getOffsetY( this.selectTopNode ) - this.selectTopNode.getStyle("height").toInt();
  1436. }
  1437. if(this.letterAreaNode ){
  1438. itemAreaScrollNodeHeight = itemAreaScrollNodeHeight - getOffsetY( this.letterAreaNode ) - this.letterAreaNode.getStyle("height").toInt();
  1439. }
  1440. itemAreaScrollNodeHeight = itemAreaScrollNodeHeight - getOffsetY( this.itemAreaScrollNode );
  1441. this.itemAreaScrollNode.setStyle("height", itemAreaScrollNodeHeight);
  1442. var selectedContainerNodeHeight = nodeHeight - getOffsetY(this.selectedContainerNode);
  1443. this.selectedContainerNode.setStyle("height", selectedContainerNodeHeight);
  1444. var selectedScrollNodeHeight = selectedContainerNodeHeight;
  1445. if( this.selectedTopNode ) {
  1446. selectedScrollNodeHeight = selectedScrollNodeHeight - getOffsetY(this.selectedTopNode) - this.selectedTopNode.getStyle("height").toInt();
  1447. }
  1448. if( !this.options.searchbarInTopNode && this.selectedSearchInputDiv ){
  1449. selectedScrollNodeHeight = selectedScrollNodeHeight - getOffsetY( this.selectedSearchInputDiv ) - this.selectedSearchInputDiv.getStyle("height").toInt();
  1450. }
  1451. this.selectedScrollNode.setStyle("height", selectedScrollNodeHeight);
  1452. }
  1453. this.fireEvent("setSize",[this])
  1454. },
  1455. addFlatCategoryItem : function( categoryItemNode, hasChildrenItem, itemNodeContainer, isCreateSubCategoryListNode ){
  1456. if(!this.flatSubCategoryNodeList)this.flatSubCategoryNodeList = [];
  1457. if( hasChildrenItem )this.flatSubCategoryNodeList.push( categoryItemNode );
  1458. if( !this.isFlatCategoryLoaded && this.flatSubCategoryNodeList.length > 1 ){
  1459. this.flatCategoryScrollNode.show();
  1460. this.flatCategoryScrollNode.setStyles( this.css.flatCategoryScrollNode );
  1461. var height = this.itemAreaScrollNode.getStyle("height").toInt();
  1462. this.flatCategoryScrollNode.setStyle("height", ""+height+"px");
  1463. this.flatCategoryNode.setStyles( this.css.flatCategoryNode );
  1464. this.isFlatCategoryLoaded = true;
  1465. this.itemAreaScrollNode.setStyles( this.css.itemAreaScrollNode_flatCategory );
  1466. //alert(this.flatSubCategoryNodeList[0].outerHTML)
  1467. }
  1468. if( hasChildrenItem )categoryItemNode.inject( itemNodeContainer || this.flatCategoryNode );
  1469. var subCategoryListNode;
  1470. if( isCreateSubCategoryListNode ){
  1471. subCategoryListNode = new Element("div.subCategoryListNode").inject( itemNodeContainer || this.flatCategoryNode );
  1472. }
  1473. //this.setFlatCategorySequence(categoryItemNode, itemNodeContainer, subCategoryListNode);
  1474. if( hasChildrenItem ){
  1475. //if( this.checkClickFlatCategoryItem(categoryItemNode, itemNodeContainer) ){
  1476. // categoryItemNode.click();
  1477. //}
  1478. if( !this.currentCategoryItemNode ){
  1479. categoryItemNode.click();
  1480. this.currentCategoryItemNode = categoryItemNode
  1481. }else{
  1482. //var date = new Date();
  1483. var first = this.flatCategoryNode.getElement(".flatCategoryItemNode");
  1484. //if(first)console.log(first.get("title"));
  1485. //console.log(new Date() - date );
  1486. //console.log(" " );
  1487. if( first ){
  1488. var dn1 = first.retrieve("dn");
  1489. var dn2 = this.currentCategoryItemNode.retrieve("dn");
  1490. if( dn1 && dn2 ){
  1491. if( dn1 != dn2 ){
  1492. categoryItemNode.click();
  1493. this.currentCategoryItemNode = categoryItemNode
  1494. }
  1495. }else{
  1496. var title1 = first.get("title");
  1497. var title2 = this.currentCategoryItemNode.get("title");
  1498. if( title1 && title1 ){
  1499. if( title1 != title2 ){
  1500. categoryItemNode.click();
  1501. this.currentCategoryItemNode = categoryItemNode
  1502. }
  1503. }else{
  1504. var text1 = first.get("text");
  1505. var text2 = this.currentCategoryItemNode.get("text");
  1506. if( text1 != text2 ){
  1507. categoryItemNode.click();
  1508. this.currentCategoryItemNode = categoryItemNode
  1509. }
  1510. }
  1511. }
  1512. }
  1513. }
  1514. }
  1515. return subCategoryListNode;
  1516. }
  1517. //checkClickFlatCategoryItem : function(categoryItemNode, itemNodeContainer){
  1518. // if( !this.flatCategorySeqObj_current ){
  1519. // this.flatCategorySeqObj_current = categoryItemNode.retrieve("seq");
  1520. // //console.log(this.flatCategorySeqObj_current)
  1521. // return true;
  1522. // }
  1523. // var seq_cur = this.flatCategorySeqObj_current;
  1524. // var seq = categoryItemNode ? categoryItemNode.retrieve("seq") : [];
  1525. // for( var i=0; i<seq.length; i++ ){
  1526. // if( seq_cur[i] && seq[i] < seq_cur[i] ){
  1527. // //console.log(seq)
  1528. // this.flatCategorySeqObj_current = seq;
  1529. // return true;
  1530. // }else if( !seq_cur[i] || seq[i] > seq_cur[i] ){
  1531. // return false;
  1532. // }
  1533. // }
  1534. // return false;
  1535. //},
  1536. //setFlatCategorySequence: function(categoryItemNode, itemNodeContainer, subCategoryListNode){
  1537. // if( !this.flatCategorySeqObj )this.flatCategorySeqObj = {};
  1538. // var parentSeq = itemNodeContainer ? itemNodeContainer.retrieve("seq") : [];
  1539. // var seq = Array.clone( parentSeq );
  1540. // if( this.flatCategorySeqObj[ parentSeq.length ] ){
  1541. // seq.push( this.flatCategorySeqObj[ parentSeq.length ] + 1 );
  1542. // this.flatCategorySeqObj[parentSeq.length] = this.flatCategorySeqObj[parentSeq.length]+1;
  1543. //
  1544. // categoryItemNode.store( "seq", seq );
  1545. // categoryItemNode.set( "seq", seq );
  1546. //
  1547. // if(subCategoryListNode){
  1548. // seq = Array.clone( seq );
  1549. // seq[ seq.length - 1 ] = seq[ seq.length - 1 ]+1;
  1550. // this.flatCategorySeqObj[parentSeq.length] = this.flatCategorySeqObj[parentSeq.length]+1;
  1551. // subCategoryListNode.store("seq", seq );
  1552. // subCategoryListNode.set( "seq", seq );
  1553. // }
  1554. // }else{
  1555. // seq.push( 1 );
  1556. // this.flatCategorySeqObj[ parentSeq.length ] = 1;
  1557. // categoryItemNode.store( "seq", seq );
  1558. // categoryItemNode.set( "seq", seq );
  1559. //
  1560. // if(subCategoryListNode) {
  1561. // seq = Array.clone(seq);
  1562. // seq[seq.length - 1] = seq[seq.length - 1]+1;
  1563. // this.flatCategorySeqObj[parentSeq.length] = this.flatCategorySeqObj[parentSeq.length]+1;
  1564. // subCategoryListNode.store("seq", seq);
  1565. // subCategoryListNode.set("seq", seq);
  1566. // }
  1567. // }
  1568. //}
  1569. });
  1570. MWF.xApplication.Selector.Person.Item = new Class({
  1571. initialize: function(data, selector, container, level, category, delay){
  1572. this.clazz = "Item";
  1573. this.data = data;
  1574. this.selector = selector;
  1575. this.container = container;
  1576. this.isSelected = false;
  1577. this.level = (level) ? level.toInt() : 1;
  1578. this.category = category;
  1579. this.subItems = [];
  1580. this.subCategorys = [];
  1581. if(!delay)this.load();
  1582. },
  1583. _getShowName: function(){
  1584. return this.data.name + ( this.data.employee ? ("("+this.data.employee+")") : "" );
  1585. },
  1586. _getTtiteText: function(){
  1587. return this.data.name + ( this.data.employee ? ("("+this.data.employee+")") : "" );
  1588. },
  1589. _setIcon: function(){
  1590. var style = this.selector.options.style;
  1591. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/personicon.png)");
  1592. },
  1593. load: function(){
  1594. if( this.clazz === "Item" ){
  1595. this.selector.fireEvent("queryLoadItem",[this]);
  1596. }
  1597. if( !this.node )this.node = new Element("div", {
  1598. "styles": this.selector.css.selectorItem
  1599. }).inject(this.container);
  1600. this.levelNode = new Element("div", {
  1601. "styles": this.selector.css.selectorItemLevelNode
  1602. }).inject(this.node);
  1603. if( this.selector.options.selectType !== "identity" || this.selector.options.identityItemWidth === 0 ) {
  1604. var indent = this.selector.options.level1Indent + (this.level - 1) * this.selector.options.indent;
  1605. this.levelNode.setStyle("width", "" + indent + "px");
  1606. }
  1607. this.iconNode = new Element("div", {
  1608. "styles": this.selector.css.selectorItemIconNode
  1609. }).inject(this.node);
  1610. this._setIcon();
  1611. this.actionNode = new Element("div", {
  1612. "styles": this.selector.css.selectorItemActionNode
  1613. }).inject(this.node);
  1614. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single ){
  1615. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
  1616. }
  1617. this.textNode = new Element("div", {
  1618. "styles": this.selector.css.selectorItemTextNode,
  1619. "text": this._getShowName(),
  1620. "title": this._getTtiteText()
  1621. }).inject(this.node);
  1622. this.textNode.store("indent", indent);
  1623. var m = this.textNode.getStyle("margin-left").toFloat()+indent;
  1624. this.textNode.setStyle("margin-left", ""+m+"px");
  1625. if( this.selector.options.identityItemWidth && this.selector.options.selectType === "identity"){
  1626. this.node.setStyles({
  1627. "float" : "left",
  1628. "min-width" : this.selector.options.identityItemWidth + "px"
  1629. })
  1630. }
  1631. if(this.postLoad)this.postLoad();
  1632. this.loadSubItem();
  1633. this.setEvent();
  1634. this.check();
  1635. if( this.clazz === "Item" ) {
  1636. this.selector.fireEvent("postLoadItem", [this]);
  1637. }
  1638. },
  1639. loadSubItem: function(){},
  1640. disable : function(){
  1641. this.node.hide();
  1642. this.disabled = true;
  1643. },
  1644. enable : function(){
  1645. this.node.show();
  1646. this.disabled = false;
  1647. },
  1648. check: function(){
  1649. //if (this.selector.options.count.toInt()===1){
  1650. // this.checkSelectedSingle();
  1651. //}else{
  1652. this.checkSelected();
  1653. //}
  1654. },
  1655. checkSelectedSingle: function(){
  1656. var selectedItem = this.selector.options.values.filter(function(item, index){
  1657. if (typeOf(item)==="object") return this.data.distinguishedName === item.distinguishedName;
  1658. if (typeOf(item)==="string") return this.data.distinguishedName === item;
  1659. return false;
  1660. }.bind(this));
  1661. if (selectedItem.length){
  1662. this.selectedSingle();
  1663. }
  1664. },
  1665. checkSelected: function(){
  1666. var selectedItem = this.selector.selectedItems.filter(function(item, index){
  1667. return item.data.distinguishedName === this.data.distinguishedName;
  1668. }.bind(this));
  1669. if (selectedItem.length){
  1670. //selectedItem[0].item = this;
  1671. selectedItem[0].addItem(this);
  1672. this.selectedItem = selectedItem[0];
  1673. this.setSelected();
  1674. }
  1675. },
  1676. checkTextNodeIndent : function( textNode, styles ){
  1677. var indent = textNode.retrieve("indent");
  1678. if( indent && styles && styles["margin-left"] ){
  1679. var m = styles["margin-left"].toFloat()+indent;
  1680. textNode.setStyle("margin-left", ""+m+"px");
  1681. }
  1682. },
  1683. setSelected: function(){
  1684. this.isSelected = true;
  1685. this.node.setStyles(this.selector.css.selectorItem_selected);
  1686. this.textNode.setStyles(this.selector.css.selectorItemTextNode_selected);
  1687. this.checkTextNodeIndent( this.textNode, this.selector.css.selectorItemTextNode_selected );
  1688. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
  1689. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected ){
  1690. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
  1691. }
  1692. // if( this.category ){
  1693. // this.category.checkSelectAll();
  1694. // }
  1695. },
  1696. setEvent: function(){
  1697. this.node.addEvents({
  1698. "mouseover": function(){
  1699. this.overItem();
  1700. }.bind(this),
  1701. "mouseout": function(){
  1702. this.outItem();
  1703. }.bind(this),
  1704. "click": function(){
  1705. this.clickItem( null, true );
  1706. }.bind(this)
  1707. });
  1708. },
  1709. clickItem: function( callback, checkValid ){
  1710. if ( layout.mobile && this.selector.options.count.toInt()===1){
  1711. this.selectedSingle( checkValid );
  1712. }else{
  1713. if (this.isSelected){
  1714. this.unSelected( checkValid );
  1715. }else{
  1716. this.selected( checkValid );
  1717. }
  1718. }
  1719. },
  1720. overItem: function(){
  1721. if (!this.isSelected ){
  1722. this.node.setStyles(this.selector.css.selectorItem_over);
  1723. }else if( this.selector.css.selectorItem_over_force ){
  1724. this.node.setStyles(this.selector.css.selectorItem_over_force);
  1725. }
  1726. if (!this.isSelected){
  1727. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_over);
  1728. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_over ){
  1729. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_over );
  1730. }
  1731. }else if( this.selector.css.selectorItemActionNode_over_force ){
  1732. this.node.setStyles(this.selector.css.selectorItemActionNode_over_force);
  1733. }
  1734. },
  1735. outItem: function(){
  1736. if (!this.isSelected){
  1737. this.node.setStyles(this.selector.css.selectorItem);
  1738. }else if( this.selector.css.selectorItem_over_force ){
  1739. this.node.setStyles(this.selector.css.selectorItem_selected);
  1740. }
  1741. if (!this.isSelected){
  1742. this.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  1743. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single ){
  1744. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
  1745. }
  1746. }else if( this.selector.css.selectorItemActionNode_over_force ){
  1747. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
  1748. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected ){
  1749. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
  1750. }
  1751. }
  1752. },
  1753. selectedSingle: function( checkValid ){
  1754. if (!this.isSelected){
  1755. if (this.selector.currentItem) this.selector.currentItem.unSelectedSingle();
  1756. this.getData(function(){
  1757. this.selector.currentItem = this;
  1758. this.isSelected = true;
  1759. this.selector.selectedItems.push(this);
  1760. this.node.setStyles(this.selector.css.selectorItem_selected);
  1761. this.textNode.setStyles(this.selector.css.selectorItemTextNode_selected);
  1762. this.checkTextNodeIndent( this.textNode, this.selector.css.selectorItemTextNode_selected );
  1763. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
  1764. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected ){
  1765. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
  1766. }
  1767. this.selector.fireEvent("selectItem",[this]);
  1768. if( checkValid )this.selector.fireEvent("valid", [this.selector, this]);
  1769. }.bind(this));
  1770. }else {
  1771. this.unSelectedSingle( checkValid );
  1772. }
  1773. },
  1774. getData: function(callback){
  1775. if (callback) callback();
  1776. },
  1777. unSelectedSingle: function(checkValid){
  1778. this.selector.currentItem = null;
  1779. this.isSelected = false;
  1780. this.selector.selectedItems.erase(this);
  1781. this.node.setStyles(this.selector.css.selectorItem);
  1782. this.textNode.setStyles(this.selector.css.selectorItemTextNode);
  1783. this.checkTextNodeIndent( this.textNode, this.selector.css.selectorItemTextNode );
  1784. this.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  1785. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single ){
  1786. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
  1787. }
  1788. this.selector.fireEvent("unselectItem",[this]);
  1789. if( checkValid )this.selector.fireEvent("valid", [this.selector, this]);
  1790. },
  1791. selected: function( checkValid, callback, selectedNode ){
  1792. var count = this.selector.options.maxCount || this.selector.options.count;
  1793. count = count.toInt();
  1794. if (!count) count = 0;
  1795. if( count == 1 && this.selector.emptySelectedItems){
  1796. this.selector.emptySelectedItems();
  1797. }
  1798. if ((count===0) || (this.selector.selectedItems.length+1)<=count) {
  1799. this.isSelected = true;
  1800. if( this.node ){
  1801. this.node.setStyles(this.selector.css.selectorItem_selected);
  1802. this.textNode.setStyles(this.selector.css.selectorItemTextNode_selected);
  1803. this.checkTextNodeIndent( this.textNode, this.selector.css.selectorItemTextNode_selected );
  1804. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
  1805. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected ){
  1806. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
  1807. }
  1808. }
  1809. this.selectedItem = this.selector._newItemSelected(this.data, this.selector, this, selectedNode);
  1810. this.selectedItem.check();
  1811. this.selector.selectedItems.push(this.selectedItem);
  1812. // if( this.category ){
  1813. // this.category.checkSelectAll();
  1814. // }
  1815. this.selector.fireEvent("selectItem",[this]);
  1816. if( checkValid )this.selector.fireEvent("valid", [this.selector, this]);
  1817. if(callback)callback();
  1818. }else{
  1819. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "最多可选择"+count+"个选项", this.node);
  1820. }
  1821. },
  1822. unSelected: function( checkValid, callback ){
  1823. this.isSelected = false;
  1824. if( this.node ){
  1825. this.node.setStyles(this.selector.css.selectorItem);
  1826. this.textNode.setStyles(this.selector.css.selectorItemTextNode);
  1827. this.checkTextNodeIndent( this.textNode, this.selector.css.selectorItemTextNode );
  1828. this.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  1829. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single ){
  1830. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
  1831. }
  1832. }
  1833. if( this.category ){
  1834. this.category.checkUnselectAll();
  1835. }
  1836. if( this.selector.searchItems && this.selector.searchItems.length ){
  1837. this.selector.searchItems.each( function(itemSearch){
  1838. var sd = itemSearch.data;
  1839. var d = this.data;
  1840. if(
  1841. ( sd.distinguishedName && (sd.distinguishedName === d.distinguishedName) ) ||
  1842. ( sd.id && (sd.id === d.id) ) ||
  1843. ( sd.unique && (sd.unique === d.unique) ) ||
  1844. ( sd.employee && (sd.employee === d.employee) ) ||
  1845. ( sd.levelName && (sd.levelName === d.levelName) )
  1846. ){
  1847. itemSearch.isSelected = false;
  1848. itemSearch.node.setStyles(this.selector.css.selectorItem);
  1849. itemSearch.textNode.setStyles(this.selector.css.selectorItemTextNode);
  1850. this.checkTextNodeIndent( itemSearch.textNode, this.selector.css.selectorItemTextNode );
  1851. itemSearch.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  1852. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single ){
  1853. itemSearch.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
  1854. }
  1855. }
  1856. }.bind(this))
  1857. }
  1858. if (this.selectedItem){
  1859. this.selector.selectedItems.erase(this.selectedItem);
  1860. this.selectedItem.items.each(function(item){
  1861. if (item != this){
  1862. item.isSelected = false;
  1863. item.node.setStyles(this.selector.css.selectorItem);
  1864. item.textNode.setStyles(this.selector.css.selectorItemTextNode);
  1865. this.checkTextNodeIndent( item.textNode, this.selector.css.selectorItemTextNode );
  1866. item.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  1867. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single ){
  1868. item.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
  1869. }
  1870. }
  1871. }.bind(this));
  1872. this.selectedItem.destroy();
  1873. this.selectedItem = null;
  1874. }
  1875. this.selector.fireEvent("unselectItem",[this]);
  1876. if( checkValid )this.selector.fireEvent("valid", [this.selector, this]);
  1877. if(callback)callback();
  1878. },
  1879. postLoad : function(){},
  1880. getParentCategoryByLevel : function( level ){
  1881. var category = this.category;
  1882. do{
  1883. if( category.level === level ){
  1884. return category;
  1885. }else{
  1886. category = category.category;
  1887. }
  1888. }while( category )
  1889. }
  1890. });
  1891. MWF.xApplication.Selector.Person.ItemSelected = new Class({
  1892. Extends: MWF.xApplication.Selector.Person.Item,
  1893. initialize: function(data, selector, item, selectedNode){
  1894. this.data = data;
  1895. this.selector = selector;
  1896. this.container = selectedNode || this.selector.selectedNode;
  1897. this.isSelected = false;
  1898. this.clazz = "ItemSelected";
  1899. this.items = [];
  1900. if (item) this.items.push(item);
  1901. this.level = 0;
  1902. this.node = new Element("div", {
  1903. "styles": this.selector.css.selectorItem
  1904. }).inject(this.container);
  1905. this.node.setStyle("display","none");
  1906. this.getData(function(){
  1907. this.node.setStyle("display","");
  1908. this.load();
  1909. }.bind(this));
  1910. },
  1911. postLoad : function(){
  1912. if( this.selector.css.selectorSelectedItemActionNode ){
  1913. this.actionNode.setStyles( this.selector.css.selectorSelectedItemActionNode );
  1914. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorSelectedItemActionNode_single ){
  1915. this.actionNode.setStyles( this.selector.css.selectorSelectedItemActionNode_single );
  1916. }
  1917. }
  1918. if( this.selector.css.selectorSelectedItemTextNode ){
  1919. this.textNode.setStyles(this.selector.css.selectorSelectedItemTextNode);
  1920. }
  1921. },
  1922. getData: function(callback){
  1923. if (callback) callback();
  1924. },
  1925. clickItem: function( callback, checkValid ){
  1926. if (this.items.length){
  1927. this.items.each(function(item){
  1928. item.unSelected( checkValid );
  1929. });
  1930. if( checkValid )this.selector.fireEvent("valid", [this.selector, this])
  1931. }else{
  1932. //this.item.selectedItem = null;
  1933. //this.item.isSelected = false;
  1934. this.destroy();
  1935. this.selector.selectedItems.erase(this);
  1936. if( checkValid )this.selector.fireEvent("valid", [this.selector, this])
  1937. }
  1938. },
  1939. //overItem: function(){
  1940. // if (!this.isSelected){
  1941. // this.node.setStyles(this.selector.css.selectorItem_over);
  1942. // this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected_over);
  1943. // }
  1944. //},
  1945. overItem: function(){
  1946. if (!this.isSelected ){
  1947. if( this.selector.css.selectorItem_selected_over ){
  1948. this.node.setStyles(this.selector.css.selectorItem_selected_over);
  1949. }else{
  1950. this.node.setStyles(this.selector.css.selectorItem_over);
  1951. }
  1952. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected_over);
  1953. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected_over ){
  1954. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected_over );
  1955. }
  1956. }
  1957. },
  1958. outItem: function(){
  1959. if (!this.isSelected){
  1960. var styles = this.selector.css.selectorSelectedItem || this.selector.css.selectorItem;
  1961. this.node.setStyles(styles);
  1962. }else if( this.selector.css.selectorItem_over_force ){
  1963. this.node.setStyles(this.selector.css.selectorItem_selected);
  1964. }
  1965. if (!this.isSelected){
  1966. var styles = this.selector.css.selectorSelectedItemActionNode || this.selector.css.selectorItemActionNode;
  1967. this.actionNode.setStyles(styles);
  1968. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) &&
  1969. ( this.selector.css.selectorSelectedItemActionNode_single || this.selector.css.selectorItemActionNode_single ) ){
  1970. this.actionNode.setStyles( this.selector.css.selectorSelectedItemActionNode_single || this.selector.css.selectorItemActionNode_single );
  1971. }
  1972. }else if( this.selector.css.selectorItemActionNode_over_force ){
  1973. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
  1974. if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected ){
  1975. this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
  1976. }
  1977. }
  1978. },
  1979. addItem: function(item){
  1980. if (this.items.indexOf(item)===-1) this.items.push(item);
  1981. },
  1982. check: function(){
  1983. if (this.selector.items.length){
  1984. var items = this.selector.items.filter(function(item, index){
  1985. return item.data.distinguishedName === this.data.distinguishedName;
  1986. }.bind(this));
  1987. this.items = items;
  1988. if (items.length){
  1989. items.each(function(item){
  1990. item.selectedItem = this;
  1991. item.setSelected();
  1992. }.bind(this));
  1993. }
  1994. }
  1995. },
  1996. destroy: function(){
  1997. if(this.node){
  1998. // var parent = this.node.getParent(".categorySelectedNode");
  1999. // if( parent && !this.node.getPrevious() && !this.node.getNext() ){ //parent.getChildren().length <= 1
  2000. // parent.destroy();
  2001. // }else{
  2002. this.node.destroy();
  2003. // }
  2004. }
  2005. delete this;
  2006. }
  2007. });
  2008. MWF.xApplication.Selector.Person.ItemCategory = new Class({
  2009. Extends: MWF.xApplication.Selector.Person.Item,
  2010. initialize: function(data, selector, container, level, parentCategory, delay){
  2011. this.data = data;
  2012. this.selector = selector;
  2013. this.container = container;
  2014. this.isSelected = false;
  2015. this.level = (level) ? level.toInt() : 1;
  2016. this.category = parentCategory;
  2017. this.subItems = [];
  2018. this.subCategorys = [];
  2019. if(!delay)this.load();
  2020. },
  2021. load : function(){
  2022. if( this.selector.isFlatCategory ){
  2023. this.loadForFlat();
  2024. }else{
  2025. this.loadForNormal();
  2026. }
  2027. },
  2028. loadForFlat : function(){
  2029. this.selector.fireEvent("queryLoadCategory",[this]);
  2030. //this.createNode();
  2031. this.node = new Element("div.flatCategoryItemNode", {
  2032. "styles": this.selector.css.flatCategoryItemNode,
  2033. "title" : this._getTtiteText()
  2034. });
  2035. this.node.store( "category", this );
  2036. this.node.store( "dn", this.data.distinguishedName );
  2037. this.textNode = new Element("div", {
  2038. "styles": this.selector.css.flatCategoryItemTextNode,
  2039. "text": this._getShowName()
  2040. }).inject(this.node);
  2041. //var level = this.level;
  2042. //var category = this;
  2043. //while( category.category ){
  2044. // level = category.category + "_" + level;
  2045. // category = category.category;
  2046. //}
  2047. this.children = new Element("div", {
  2048. "styles": this.selector.css.selectorItemCategoryChildrenNode
  2049. }).inject(this.selector.itemAreaNode); //this.container
  2050. //if (!this.selector.options.expand)
  2051. this.children.setStyle("display", "none");
  2052. if( this.selector.options.selectAllEnable && this.selector.options.count.toInt()!==1 ){
  2053. var selectAllWrap = new Element("div",{
  2054. styles : this.selector.css.flatCategory_selectAllWrap
  2055. }).inject(this.children);
  2056. this.selectAllNode = new Element("div", {
  2057. "styles": this.selector.css.flatCategory_selectAll,
  2058. "text" : "全选"
  2059. }).inject(selectAllWrap);
  2060. this.selectAllNode.addEvent( "click", function(ev){
  2061. if( this.isSelectedAll ){
  2062. this.selector.options.selectAllRange === "all" ? this.unselectAllNested(ev, null, true ) : this.unselectAll(ev, null, true);
  2063. this.selector.fireEvent("unselectCatgory",[this])
  2064. }else{
  2065. this.selector.options.selectAllRange === "all" ? this.selectAllNested(ev, true) : this.selectAll(ev, true);
  2066. this.selector.fireEvent("selectCatgory",[this])
  2067. }
  2068. ev.stopPropagation();
  2069. }.bind(this));
  2070. }
  2071. // var subIdList = this.selector._getChildrenItemIds(this.data);
  2072. // if (subIdList){
  2073. // var count = subIdList.length;
  2074. // this.childrenHeight = count*this.selector.options.itemHeight;
  2075. // this.children.setStyle("height", ""+this.childrenHeight+"px");
  2076. // }
  2077. //if (!this._hasChild()){
  2078. // this.textNode.setStyle("color", "#333");
  2079. //}
  2080. if( this.selectAllNode ){
  2081. if( this.selector.options.selectAllRange === "direct" && !this._hasChildItem() ){
  2082. this.selectAllNode.setStyle("display", "none");
  2083. }
  2084. }
  2085. this.node.addEvents({
  2086. //"mouseover": function(){
  2087. // if (!this.isSelected )this.node.setStyles(this.selector.css.flatCategoryItemNode_over );
  2088. //}.bind(this),
  2089. //"mouseout": function(){
  2090. // if (!this.isSelected )this.node.setStyles(this.selector.css.flatCategoryItemNode );
  2091. //}.bind(this),
  2092. "click": function(){
  2093. if( this.selector.currentFlatCategory === this )return;
  2094. if( this.selector.currentFlatCategory ){
  2095. this.selector.currentFlatCategory.clickFlatCategoryItem(null, true); //取消原来选择的
  2096. }
  2097. this.selector.currentFlatCategory = this;
  2098. this.clickFlatCategoryItem();
  2099. }.bind(this)
  2100. });
  2101. //this.setEvent();
  2102. var isCreateSubCategoryListNode = this._hasChildCategory ? this._hasChildCategory() : true;
  2103. var nodeContainer;
  2104. if( this.nodeContainer ){
  2105. nodeContainer = this.nodeContainer;
  2106. }else{
  2107. nodeContainer = (this.category && this.category.subCategoryListNode) ? this.category.subCategoryListNode : null;
  2108. }
  2109. this.subCategoryListNode = this.selector.addFlatCategoryItem( this.node, this._hasChildItem(), nodeContainer, isCreateSubCategoryListNode );
  2110. this.check();
  2111. if( this.loadCategoryChildren )this.loadCategoryChildren();
  2112. //this.afterLoad();
  2113. this.selector.fireEvent("postLoadCategory",[this]);
  2114. },
  2115. loadForNormal : function(){
  2116. this.selector.fireEvent("queryLoadCategory",[this]);
  2117. this.createNode();
  2118. this.levelNode = new Element("div", {
  2119. "styles": this.selector.css.selectorItemLevelNode
  2120. }).inject(this.node);
  2121. if(this.selector.options.selectType !== "identity" || this.selector.options.identityItemWidth === 0 ){
  2122. var indent = this.selector.options.level1Indent + (this.level - 1) * this.selector.options.indent;
  2123. this.levelNode.setStyle("width", "" + indent + "px");
  2124. }else{
  2125. this.node.setStyle("clear","both");
  2126. }
  2127. this.iconNode = new Element("div", {
  2128. "styles": this.selector.css.selectorItemCategoryIconNode || this.selector.css.selectorItemIconNode
  2129. }).inject(this.node);
  2130. this._setIcon();
  2131. this.actionNode = new Element("div", {
  2132. "styles": (this.selector.options.expand) ? this.selector.css.selectorItemCategoryActionNode_expand : this.selector.css.selectorItemCategoryActionNode_collapse
  2133. }).inject(this.node);
  2134. if( this.selector.options.selectAllEnable && this.selector.options.count.toInt()!==1 ){
  2135. this.selectAllNode = new Element("div", {
  2136. "styles": this.selector.css.selectorItemCategoryActionNode_selectAll,
  2137. "title" : "全选下级"
  2138. }).inject(this.node);
  2139. this.selectAllNode.addEvent( "click", function(ev){
  2140. if( this.isSelectedAll ){
  2141. // this.unselectAll(ev);
  2142. this.selector.options.selectAllRange === "all" ? this.unselectAllNested(ev, null, true ) : this.unselectAll(ev, null, true);
  2143. this.selector.fireEvent("unselectCatgory",[this]);
  2144. }else{
  2145. // this.selectAll(ev);
  2146. if( this.selector.options.selectAllRange === "all" ){
  2147. var node = new Element("div.categorySelectedNode").inject( this.selector.selectedNode );
  2148. this.selectAllNested(ev, true, node );
  2149. }else{
  2150. this.selectAll(ev, true)
  2151. }
  2152. this.selector.fireEvent("selectCatgory",[this]);
  2153. }
  2154. ev.stopPropagation();
  2155. }.bind(this));
  2156. if( this.selector.css.selectorItemCategoryActionNode_selectAll_over ){
  2157. this.selectAllNode.addEvents( {
  2158. "mouseover" : function(ev){
  2159. if( !this.isSelectedAll )this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_over );
  2160. //ev.stopPropagation();
  2161. }.bind(this),
  2162. "mouseout" : function(ev){
  2163. if( !this.isSelectedAll )this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll );
  2164. //ev.stopPropagation();
  2165. }.bind(this)
  2166. })
  2167. }
  2168. }
  2169. this.textNode = new Element("div", {
  2170. "styles": this.selector.css.selectorItemCategoryTextNode,
  2171. "text": this._getShowName()
  2172. }).inject(this.node);
  2173. var m = this.textNode.getStyle("margin-left").toFloat()+indent;
  2174. this.textNode.setStyle("margin-left", ""+m+"px");
  2175. this.children = new Element("div.children", {
  2176. "styles": this.selector.css.selectorItemCategoryChildrenNode
  2177. }).inject(this.node, "after");
  2178. if (!this.selector.options.expand) this.children.setStyle("display", "none");
  2179. if( this.selector.options.expandEmptyCategory && !this._hasChildItem() ){ //点击允许展开空分类
  2180. this.children.hide();
  2181. this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_collapse);
  2182. this.isExpand = false;
  2183. }else{
  2184. var subIdList = this.selector._getChildrenItemIds(this.data);
  2185. if (subIdList){
  2186. var count = subIdList.length;
  2187. this.childrenHeight = count*this.selector.options.itemHeight;
  2188. this.children.setStyle("height", ""+this.childrenHeight+"px");
  2189. }
  2190. if(this.selector.options.identityItemWidth && this.selector.options.selectType === "identity"){
  2191. var indent = this.level === 0 ? this.selector.options.level1Indent : this.selector.options.indent;
  2192. this.children.setStyles({
  2193. "padding-left": "" + indent + "px",
  2194. "overflow" : "hidden"
  2195. });
  2196. }
  2197. if ( !this._hasChild()){
  2198. this.actionNode.setStyle("background", "transparent");
  2199. this.textNode.setStyle("color", "#777");
  2200. }
  2201. if( this.selectAllNode ){
  2202. if( this.selector.options.selectAllRange === "direct" && !this._hasChildItem() ){
  2203. this.selectAllNode.setStyle("display", "none");
  2204. }
  2205. }
  2206. }
  2207. this.setEvent();
  2208. this.check();
  2209. this.afterLoad();
  2210. this.selector.fireEvent("postLoadCategory",[this]);
  2211. },
  2212. createNode: function(){
  2213. this.node = new Element("div", {
  2214. "styles": this.selector.css.selectorItemCategory,
  2215. "title" : this._getTtiteText()
  2216. }).inject(this.container);
  2217. },
  2218. isSelectAllEnable : function(){
  2219. },
  2220. unselectAll : function(ev, exclude, checkValid ){
  2221. var excludeList = exclude || [];
  2222. if( exclude && typeOf(exclude) !== "array" )excludeList = [exclude];
  2223. ( this.subItems || [] ).each( function(item){
  2224. if(item.isSelected && !excludeList.contains(item) ){
  2225. item.unSelected( checkValid );
  2226. }
  2227. }.bind(this));
  2228. if( this.selectAllNode ){
  2229. if( this.selector.isFlatCategory ){
  2230. this.selectAllNode.setStyles( this.selector.css.flatCategory_selectAll );
  2231. }else if(this.selector.css.selectorItemCategoryActionNode_selectAll){
  2232. this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll );
  2233. }
  2234. }
  2235. this.isSelectedAll = false;
  2236. },
  2237. unselectAllNested : function( ev, exclude, checkValid ){
  2238. this.unselectAll(ev, exclude, checkValid);
  2239. if( this.subCategorys && this.subCategorys.length ){
  2240. this.subCategorys.each( function( category ){
  2241. category.unselectAllNested( ev, exclude, checkValid )
  2242. })
  2243. }
  2244. },
  2245. selectAllNested : function( ev, checkValid, selectedNode ){
  2246. var node;
  2247. if(selectedNode)node = new Element("div.categorySelectedNode").inject( selectedNode );
  2248. this.selectAll(ev, checkValid, node);
  2249. if( this.subCategorys && this.subCategorys.length ){
  2250. this.subCategorys.each( function( category ){
  2251. if(selectedNode)var node = new Element("div.categorySelectedNode").inject( selectedNode );
  2252. category.selectAllNested(ev, checkValid, node)
  2253. })
  2254. }
  2255. },
  2256. selectAll: function(ev, checkValid, selectedNode){
  2257. if( this.loaded || this.selector.isFlatCategory ){
  2258. this._selectAll( ev, checkValid, selectedNode );
  2259. }else{
  2260. this.clickItem( function(){
  2261. this._selectAll( ev, checkValid, selectedNode );
  2262. //this.children.setStyles({
  2263. // "display": "none",
  2264. // "height": "0px"
  2265. //});
  2266. //this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_collapse);
  2267. }.bind(this));
  2268. }
  2269. },
  2270. _selectAll : function( ev, checkValid, selectedNode ){
  2271. if( this.selector.options.selectAllRange === "direct" && ( !this.subItems || !this.subItems.length ) )return;
  2272. var count = this.selector.options.maxCount || this.selector.options.count;
  2273. if (!count) count = 0;
  2274. var selectedSubItemCount = 0;
  2275. this.subItems.each( function(item){
  2276. if(item.isSelected)selectedSubItemCount++
  2277. }.bind(this));
  2278. if ((count.toInt()===0) || (this.selector.selectedItems.length+(this.subItems.length-selectedSubItemCount))<=count){
  2279. var checkedCount = 0;
  2280. var doSelectAll = function () {
  2281. this.subItems.each( function(item){
  2282. if(!item.isSelected && !item.disabled )item.selected( false, function () {
  2283. checkedCount++;
  2284. if( this.subItems.length === checkedCount ){
  2285. if( checkValid )this.selector.fireEvent("valid", [this.selector, this]);
  2286. }
  2287. }.bind(this), selectedNode);
  2288. }.bind(this));
  2289. if( this.selectAllNode ){
  2290. if( this.selector.isFlatCategory ){
  2291. this.selectAllNode.setStyles( this.selector.css.flatCategory_selectAll_selected );
  2292. }else if(this.selector.css.selectorItemCategoryActionNode_selectAll_selected){
  2293. this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_selected );
  2294. }
  2295. }
  2296. this.isSelectedAll = true;
  2297. }.bind(this);
  2298. if( this._beforeSelectAll ){
  2299. this._beforeSelectAll( doSelectAll );
  2300. }else{
  2301. doSelectAll();
  2302. }
  2303. }else{
  2304. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "最多可选择"+count+"个选项", this.node);
  2305. }
  2306. },
  2307. checkSelectAll : function(){
  2308. if( this.isSelectedAll )return;
  2309. if( !this.selectAllNode )return;
  2310. if( !this.subItems )return;
  2311. var isAllItemSelected = true;
  2312. for( var i=0; i< this.subItems.length; i++ ){
  2313. if( !this.subItems[i].isSelected ){
  2314. isAllItemSelected = false;
  2315. break;
  2316. }
  2317. }
  2318. if( isAllItemSelected ){
  2319. if( this.selector.isFlatCategory ){
  2320. this.selectAllNode.setStyles( this.selector.css.flatCategory_selectAll_selected );
  2321. }else if( this.selector.css.selectorItemCategoryActionNode_selectAll_selected ){
  2322. this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_selected );
  2323. }
  2324. this.isSelectedAll = true;
  2325. }
  2326. },
  2327. checkUnselectAll : function(){
  2328. if( !this.isSelectedAll )return;
  2329. if( !this.selectAllNode )return;
  2330. if( !this.subItems )return;
  2331. var hasSelectedItem = false;
  2332. for( var i=0; i< this.subItems.length; i++ ){
  2333. if( this.subItems[i].isSelected ){
  2334. hasSelectedItem = true;
  2335. break;
  2336. }
  2337. }
  2338. if( !hasSelectedItem ){
  2339. if( this.selector.isFlatCategory ){
  2340. this.selectAllNode.setStyles( this.selector.css.flatCategory_selectAll );
  2341. }else if( this.selector.css.selectorItemCategoryActionNode_selectAll ){
  2342. this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll );
  2343. }
  2344. this.isSelectedAll = false;
  2345. }
  2346. },
  2347. afterLoad: function(){
  2348. if (this.level===1) this.clickItem();
  2349. },
  2350. clickFlatCategoryItem : function( callback, hidden ){
  2351. if (this._hasChildItem()){
  2352. var display = this.children.getStyle("display");
  2353. if( hidden ){
  2354. this.children.setStyles({ "display": "none" });
  2355. this.node.setStyles( this.selector.css.flatCategoryItemNode );
  2356. this.isExpand = false;
  2357. }else if (display === "none"){
  2358. this.children.setStyles({
  2359. "display": "block",
  2360. "height": "auto"
  2361. });
  2362. this.node.setStyles( this.selector.css.flatCategoryItemNode_selected );
  2363. this.isExpand = true;
  2364. }else{
  2365. this.children.setStyles({
  2366. "display": "none"
  2367. });
  2368. this.node.setStyles( this.selector.css.flatCategoryItemNode );
  2369. this.isExpand = false;
  2370. }
  2371. if(callback)callback()
  2372. }
  2373. },
  2374. clickItem: function( callback ){
  2375. if (this._hasChild() || this.selector.options.expandEmptyCategory ){
  2376. if (!this.fx){
  2377. this.fx = new Fx.Tween(this.children, {
  2378. "duration": 200
  2379. // "transition": Fx.Transitions.Cubic.easeIn
  2380. });
  2381. }
  2382. if (!this.fx.isRunning()){
  2383. var display = this.children.getStyle("display");
  2384. if (display === "none"){
  2385. this.selector.fireEvent("expand", [this] );
  2386. this.children.setStyles({
  2387. "display": "block",
  2388. "height": "0px"
  2389. });
  2390. this.fx.start("height", "0px", ""+this.childrenHeight+"px");
  2391. this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_expand);
  2392. this.isExpand = true;
  2393. }else{
  2394. this.selector.fireEvent("collapse", [this] );
  2395. if (!this.childrenHeight) this.childrenHeight = this.children.getStyle("height").toFloat();
  2396. this.fx.start("height", ""+this.childrenHeight+"px", "0px").chain(function(){
  2397. this.children.setStyles({
  2398. "display": "none",
  2399. "height": "0px"
  2400. });
  2401. }.bind(this));
  2402. this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_collapse);
  2403. this.isExpand = false;
  2404. }
  2405. }
  2406. if(callback)callback()
  2407. }
  2408. },
  2409. overItem: function(){
  2410. //if (!this.isSelected){
  2411. // this.node.setStyles(this.selector.css.selectorItem_over);
  2412. // this.actionNode.setStyles(this.selector.css.selectorItemActionNode_over);
  2413. //}
  2414. if( this.selector.css.selectorItemCategory_over ){
  2415. this.node.setStyles(this.selector.css.selectorItemCategory_over);
  2416. }
  2417. var display = this.children.getStyle("display");
  2418. if( display === "none" ){
  2419. if( this._hasChild() && this.selector.css.selectorItemCategoryActionNode_collapse_over ){
  2420. this.actionNode.setStyles( this.selector.css.selectorItemCategoryActionNode_collapse_over )
  2421. }
  2422. }else{
  2423. if( this._hasChild() && this.selector.css.selectorItemCategoryActionNode_expand_over ){
  2424. this.actionNode.setStyles( this.selector.css.selectorItemCategoryActionNode_expand_over )
  2425. }
  2426. }
  2427. },
  2428. outItem: function(){
  2429. //if (!this.isSelected){
  2430. // this.node.setStyles(this.selector.css.selectorItem);
  2431. // this.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  2432. //}
  2433. if( this.selector.css.selectorItemCategory_over ){
  2434. this.node.setStyles(this.selector.css.selectorItemCategory);
  2435. }
  2436. var display = this.children.getStyle("display");
  2437. if( display === "none" ){
  2438. if( this._hasChild() && this.selector.css.selectorItemCategoryActionNode_collapse_over ){
  2439. this.actionNode.setStyles( this.selector.css.selectorItemCategoryActionNode_collapse )
  2440. }
  2441. }else{
  2442. if( this._hasChild() && this.selector.css.selectorItemCategoryActionNode_expand_over ){
  2443. this.actionNode.setStyles( this.selector.css.selectorItemCategoryActionNode_expand )
  2444. }
  2445. }
  2446. },
  2447. _hasChild: function(){
  2448. var subIdList = this.selector._getChildrenItemIds(this.data);
  2449. if (subIdList) if (subIdList.length) return true;
  2450. return false;
  2451. },
  2452. _hasChildCategory: function(){
  2453. return null;
  2454. },
  2455. _hasChildItem: function(){
  2456. return this._hasChild();
  2457. },
  2458. _getTtiteText: function(){
  2459. if( this.data.levelName ){
  2460. return this.data.name+"("+ this.data.levelName +")";
  2461. }else{
  2462. return this.data.name;
  2463. }
  2464. }
  2465. });
  2466. MWF.xApplication.Selector.Person.ItemGroupCategory = new Class({
  2467. Extends: MWF.xApplication.Selector.Person.ItemCategory,
  2468. _getShowName: function(){
  2469. return this.data.name;
  2470. },
  2471. _setIcon: function(){
  2472. var style = this.selector.options.style;
  2473. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/groupicon.png)");
  2474. }
  2475. });
  2476. MWF.xApplication.Selector.Person.ItemRoleCategory = new Class({
  2477. Extends: MWF.xApplication.Selector.Person.ItemCategory,
  2478. _getShowName: function(){
  2479. return this.data.name;
  2480. },
  2481. _setIcon: function(){
  2482. var style = this.selector.options.style;
  2483. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/roleicon.png)");
  2484. }
  2485. });
  2486. MWF.xApplication.Selector.Person.Filter = new Class({
  2487. Implements: [Options, Events],
  2488. options: {
  2489. "style": "default",
  2490. "groups": [],
  2491. "roles": []
  2492. },
  2493. initialize: function(value, options){
  2494. this.setOptions(options);
  2495. this.value = value;
  2496. this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  2497. },
  2498. filter: function(value, callback){
  2499. this.value = value;
  2500. var key = this.value;
  2501. if (this.options.groups.length || this.options.roles.length) key = {"key": key, "groupList": this.options.groupList, "roleList": this.options.roleList};
  2502. this.orgAction.listPersonByKey(function(json){
  2503. data = json.data;
  2504. if (callback) callback(data)
  2505. }.bind(this), null, key);
  2506. }
  2507. });