Person.js 119 KB

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