Person.js 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824
  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. "level1Indent" : 10,
  20. "indent" : 10,
  21. "hasLetter" : true, //字母
  22. "hasTop" : false, //可选、已选的标题
  23. "hasShuttle" : false, //穿梭按钮
  24. "searchbarInTopNode" : true, //搜索框在标题上还是另起一行
  25. "hasSelectedSearchbar" : false
  26. },
  27. initialize: function(container, options){
  28. this.setOptions(options);
  29. this.path = "/x_component_Selector/$Selector/";
  30. this.cssPath = "/x_component_Selector/$Selector/"+this.options.style+"/css.wcss";
  31. this._loadCss(true);
  32. this.container = $(container);
  33. this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  34. this.processAction = MWF.Actions.get("x_processplatform_assemble_surface");
  35. this.designerAction = MWF.Actions.get("x_processplatform_assemble_designer");
  36. this.portalAction = MWF.Actions.get("x_portal_assemble_surface");
  37. this.portalDesignerAction = MWF.Actions.get("x_portal_assemble_designer");
  38. this.cmsAction = MWF.Actions.get("x_cms_assemble_control");
  39. this.queryAction = MWF.Actions.get("x_query_assemble_designer");
  40. //this.action = new MWF.xApplication.Selector.Actions.RestActions();
  41. this.lastPeople = "";
  42. this.pageCount = "13";
  43. this.selectedItems = []; //所有已选项
  44. this.items = []; //所有选择项
  45. this.subCategorys = []; //直接的分类
  46. this.subItems = []; //直接的选择项
  47. },
  48. load: function(){
  49. this.fireEvent("queryLoad",[this]);
  50. if (layout.mobile){
  51. this.loadMobile();
  52. }else{
  53. this.loadPc();
  54. }
  55. this.fireEvent("load");
  56. },
  57. loadMobile: function(){
  58. this.maskRelativeNode = $(document.body);
  59. this.maskRelativeNode.mask({
  60. "destroyOnHide": true,
  61. "style": this.css.maskNode
  62. });
  63. this.node = new Element("div", {"styles": this.css.containerNodeMobile});
  64. this.node.setStyle("z-index", this.options.zIndex.toInt()+1);
  65. this.node.setStyle("height", ( document.body.getSize().y ) + "px");
  66. this.titleNode = new Element("div", {
  67. "styles": this.css.titleNodeMobile
  68. }).inject(this.node);
  69. this.titleCancelActionNode = new Element("div", {
  70. "styles": this.css.titleCancelActionNodeMobile,
  71. "text": MWF.SelectorLP.back
  72. }).inject(this.titleNode);
  73. this.titleOkActionNode = new Element("div", {
  74. "styles": this.css.titleOkActionNodeMobile,
  75. "text": MWF.SelectorLP.ok
  76. }).inject(this.titleNode);
  77. this.titleTextNode = new Element("div", {
  78. "styles": this.css.titleTextNodeMobile,
  79. "text": this.options.title
  80. }).inject(this.titleNode);
  81. this.contentNode = new Element("div", {
  82. "styles": this.css.contentNode
  83. }).inject(this.node);
  84. var size = document.body.getSize();
  85. var height = size.y-40;
  86. //var height = size.y;
  87. this.contentNode.setStyle("height", ""+height+"px");
  88. this.loadContent();
  89. this.node.inject(document.body);
  90. this.node.setStyles({
  91. "top": "0px",
  92. "left": "0px"
  93. });
  94. this.setEvent();
  95. },
  96. setMaskResize: function(){
  97. var size = this.container.getSize();
  98. this.mask.resize();
  99. this.maskInterval = window.setInterval(function(){
  100. var resize = this.container.getSize();
  101. if ((size.x!==resize.x) || (size.y!==resize.y)){
  102. this.mask.position();
  103. this.mask.resize();
  104. size.x = resize.x;
  105. size.y = resize.y;
  106. }
  107. }.bind(this), 66);
  108. },
  109. loadPc: function(){
  110. if( this.options.embedded ){
  111. this.node = new Element("div", {
  112. "styles": this.css.containerNode_embedded, //(this.options.count.toInt()===1) ? this.css.containerNodeSingle_embedded : this.css.containerNode_embedded,
  113. "events": {
  114. "click": function(e){e.stopPropagation();},
  115. "mousedown": function(e){e.stopPropagation();},
  116. "mouseover": function(e){e.stopPropagation();},
  117. "mouseout": function(e){e.stopPropagation();},
  118. "keydown": function(e){e.stopPropagation();}
  119. }
  120. });
  121. this.contentNode = new Element("div", {
  122. "styles": this.css.contentNode_embedded ? this.css.contentNode_embedded : this.css.contentNode
  123. }).inject(this.node);
  124. this.loadContent();
  125. if( this.options.width || this.options.height ){
  126. this.setSize()
  127. }
  128. this.node.inject(this.container);
  129. } else {
  130. this.css.maskNode["z-index"] = this.options.zIndex;
  131. var position = this.container.getPosition(this.container.getOffsetParent());
  132. this.mask = new Mask(this.container, {
  133. "destroyOnHide": true,
  134. "style": this.css.maskNode,
  135. "useIframeShim": true,
  136. "iframeShimOptions": {"browsers": true},
  137. "onShow": function () {
  138. this.shim.shim.setStyles({
  139. "opacity": 0,
  140. "top": "" + position.y + "px",
  141. "left": "" + position.x + "px"
  142. });
  143. }
  144. //
  145. // "destroyOnHide": true,
  146. // "style": this.css.maskNode,
  147. // "useIframeShim": true,
  148. // "iframeShimOptions": {"browsers": true},
  149. // "onShow": function(){
  150. // this.shim.shim.setStyles({
  151. // "opacity": 0,
  152. // "top": ""+position.y+"px",
  153. // "left": ""+position.x+"px"
  154. // });
  155. // }
  156. });
  157. this.mask.show();
  158. this.setMaskResize();
  159. // this.container.setStyle("z-index", this.options.zIndex);
  160. this.node = new Element("div", {
  161. "styles": this.css.containerNode, //(this.options.count.toInt()===1) ? this.css.containerNodeSingle : this.css.containerNode,
  162. "events": {
  163. "click": function(e){e.stopPropagation();},
  164. "mousedown": function(e){e.stopPropagation();},
  165. "mouseover": function(e){e.stopPropagation();},
  166. "mouseout": function(e){e.stopPropagation();},
  167. "keydown": function(e){e.stopPropagation();}
  168. }
  169. });
  170. this.node.setStyle("z-index", this.options.zIndex.toInt()+1);
  171. this.titleNode = new Element("div.titleNode", {
  172. "styles": this.css.titleNode
  173. }).inject(this.node);
  174. this.titleActionNode = new Element("div", {
  175. "styles": this.css.titleActionNode
  176. }).inject(this.titleNode);
  177. this.titleTextNode = new Element("div", {
  178. "styles": this.css.titleTextNode,
  179. "text": this.options.title
  180. }).inject(this.titleNode);
  181. this.contentNode = new Element("div", {
  182. "styles": this.css.contentNode
  183. }).inject(this.node);
  184. this.loadContent();
  185. this.actionNode = new Element("div", {
  186. "styles": this.css.actionNode
  187. }).inject(this.node);
  188. //if (this.options.count.toInt() === 1) this.actionNode.setStyle("text-align", "center");
  189. this.loadAction();
  190. this.node.inject(this.container);
  191. this.node.position({
  192. relativeTo: this.container,
  193. position: "center",
  194. edge: "center"
  195. });
  196. var size = this.container.getSize();
  197. var nodeSize = this.node.getSize();
  198. this.node.makeDraggable({
  199. "handle": this.titleNode,
  200. "limit": {
  201. "x": [0, size.x - nodeSize.x],
  202. "y": [0, size.y - nodeSize.y]
  203. }
  204. });
  205. if( this.options.width || this.options.height ){
  206. this.setSize()
  207. }
  208. this.setEvent();
  209. }
  210. },
  211. setEvent: function(){
  212. if (this.titleActionNode){
  213. this.titleActionNode.addEvent("click", function(){
  214. this.fireEvent("cancel");
  215. this.close();
  216. }.bind(this));
  217. }
  218. if (this.titleCancelActionNode){
  219. this.titleCancelActionNode.addEvent("click", function(){
  220. this.fireEvent("cancel");
  221. this.close();
  222. }.bind(this));
  223. }
  224. if (this.titleOkActionNode){
  225. this.titleOkActionNode.addEvent("click", function(){
  226. this.fireEvent("complete", [this.selectedItems]);
  227. this.close();
  228. }.bind(this));
  229. }
  230. },
  231. close: function(){
  232. this.fireEvent("close");
  233. this.node.destroy();
  234. //if (this.mask) this.mask.hide();
  235. if( !this.options.embedded ){
  236. (this.maskRelativeNode || this.container).unmask();
  237. }
  238. if (this.maskInterval){
  239. window.clearInterval(this.maskInterval);
  240. this.maskInterval = null;
  241. }
  242. MWF.release(this);
  243. delete this;
  244. },
  245. loadAction: function(){
  246. this.okActionNode = new Element("button", {
  247. "styles": this.css.okActionNode,
  248. "text": MWF.SelectorLP.ok
  249. }).inject(this.actionNode);
  250. this.cancelActionNode = new Element("button", {
  251. "styles": this.css.cancelActionNode,
  252. "text": MWF.SelectorLP.cancel
  253. }).inject(this.actionNode);
  254. this.okActionNode.addEvent("click", function(){
  255. this.fireEvent("complete", [this.selectedItems]);
  256. this.close();
  257. }.bind(this));
  258. this.cancelActionNode.addEvent("click", function(){this.fireEvent("cancel"); this.close();}.bind(this));
  259. },
  260. loadContent: function( contentNode ){
  261. if( contentNode )this.contentNode = contentNode;
  262. if (layout.mobile){
  263. if (this.options.count.toInt()!==1) this.loadSelectedNodeMobile();
  264. this.loadSelectNodeMobile();
  265. }else{
  266. this.loadSelectNode();
  267. if( this.options.hasShuttle ){
  268. this.loadShuttleNode();
  269. }
  270. //if (this.options.count.toInt()!==1) this.loadSelectedNode();
  271. this.loadSelectedNode();
  272. }
  273. },
  274. loadSelectNodeMobile: function(){
  275. this.selectNode = new Element("div", {
  276. "styles": this.css.selectNodeMobile
  277. }).inject(this.contentNode);
  278. var containerSize = this.container.getSize();
  279. var bodySize = $(document.body).getSize();
  280. var size = {
  281. "x" : Math.min( containerSize.x, bodySize.x ),
  282. "y" : Math.min( containerSize.y, bodySize.y )
  283. };
  284. var isFormWithAction = window.location.href.toLowerCase().indexOf("workmobilewithaction.html") > -1;
  285. var height;
  286. if( isFormWithAction ){
  287. height = size.y-40-20-6-20;
  288. }else{
  289. height = size.y;
  290. }
  291. this.selectNode.setStyle("height", ""+height+"px");
  292. this.searchInputDiv = new Element("div", {
  293. "styles": this.css.searchInputDiv
  294. }).inject(this.selectNode);
  295. this.searchInput = new Element("input", {
  296. "styles": (this.options.count.toInt()===1) ? this.css.searchInputSingle : this.css.searchInput,
  297. "type": "text"
  298. }).inject(this.searchInputDiv);
  299. var width = size.x-20-18;
  300. this.searchInput.setStyle("width", ""+width+"px");
  301. this.searchInput.setStyle("height", "20px");
  302. this.initSearchInput();
  303. this.letterAreaNode = new Element("div", {
  304. "styles": this.css.letterAreaMobileNode
  305. }).inject(this.selectNode);
  306. width = size.x-18;
  307. this.letterAreaNode.setStyle("width", ""+width+"px");
  308. this.loadLetters();
  309. this.itemAreaScrollNode = new Element("div.itemAreaScrollNode", {
  310. "styles": this.css.itemAreaScrollNode
  311. }).inject(this.selectNode);
  312. if( isFormWithAction ){
  313. height = size.y-40-20-78-20;
  314. }else{
  315. height = size.y-42-31-40;
  316. }
  317. this.itemAreaScrollNode.setStyle("height", ""+height+"px");
  318. this.itemAreaScrollNode.setStyle("overflow", "auto");
  319. this.itemAreaNode = new Element("div", {
  320. "styles": this.css.itemAreaNode
  321. }).inject(this.itemAreaScrollNode);
  322. this.itemSearchAreaNode = new Element("div", {
  323. "styles": this.css.itemAreaNode
  324. }).inject(this.itemAreaScrollNode);
  325. this.itemSearchAreaNode.setStyle("display", "none");
  326. //MWF.require("MWF.widget.ScrollBar", function(){
  327. // var _self = this;
  328. // new MWF.widget.ScrollBar(this.itemAreaScrollNode, {
  329. // "style":"xApp_Organization_Explorer",
  330. // "where": "before",
  331. // "distance": 30,
  332. // "friction": 4,
  333. // "axis": {"x": false, "y": true},
  334. // "onScroll": function(y){
  335. // _self._scrollEvent(y);
  336. // }
  337. // });
  338. //}.bind(this));
  339. this.initLoadSelectItems();
  340. this.checkLoadSelectItems();
  341. },
  342. checkLoadSelectItems: function(){
  343. if (!this.options.groups.length && !this.options.roles.length){
  344. this.loadSelectItems();
  345. }else{
  346. this.loadSelectItemsByCondition();
  347. }
  348. },
  349. loadShuttleNode : function(){
  350. this.shuttleNode = new Element("div.shuttleNode", {
  351. "styles": this.css.shuttleNode
  352. }).inject(this.contentNode);
  353. this.shuttleInnerNode = new Element("div.shuttleInnerNode", {
  354. "styles": this.css.shuttleInnerNode
  355. }).inject(this.shuttleNode);
  356. this.goRightNode = new Element("div.goRightNode", {
  357. "styles": this.css.goRightNode
  358. }).inject(this.shuttleInnerNode);
  359. this.goLeftNode = new Element("div.goLeftNode", {
  360. "styles": this.css.goLeftNode
  361. }).inject(this.shuttleInnerNode);
  362. },
  363. loadSelectNode: function(){
  364. this.selectNode = new Element("div.selectNode", {
  365. "styles": this.css.selectNode //(this.options.count.toInt()===1) ? this.css.selectNodeSingle : this.css.selectNode
  366. }).inject(this.contentNode);
  367. if( this.options.hasTop ){ //if( this.options.embedded && this.options.count.toInt()!==1 ){
  368. this.selectTopNode = new Element("div.selectTopNode",{
  369. "styles" : this.css.selectTopNode
  370. }).inject( this.selectNode );
  371. this.selectTopTextNode = new Element("div",{
  372. "text" : MWF.SelectorLP.waitingSelect,
  373. "styles" : this.css.selectTopTextNode
  374. }).inject( this.selectTopNode );
  375. }
  376. if( this.options.searchbarInTopNode ){
  377. this.searchInputDiv = new Element("div", {
  378. "styles": this.css.searchInputDiv
  379. }).inject( this.selectTopNode || this.selectNode);
  380. }else{
  381. this.searchInputDiv = new Element("div.searchInputDiv", {
  382. "styles": this.css.searchInputDiv
  383. }).inject( this.selectNode);
  384. }
  385. this.searchInput = new Element("input", {
  386. "styles": this.css.searchInput, //(this.options.count.toInt()===1) ? this.css.searchInputSingle : this.css.searchInput,
  387. "placeholder" : MWF.SelectorLP.searchDescription,
  388. "type": "text"
  389. }).inject(this.searchInputDiv);
  390. this.initSearchInput();
  391. if( this.options.hasLetter ){
  392. this.letterAreaNode = new Element("div", {
  393. "styles": this.css.letterAreaNode
  394. }).inject(this.selectNode);
  395. this.loadLetters();
  396. }
  397. this.itemAreaScrollNode = new Element("div", {
  398. "styles": this.css.itemAreaScrollNode
  399. }).inject(this.selectNode);
  400. this.itemAreaNode = new Element("div", {
  401. "styles": this.css.itemAreaNode
  402. }).inject(this.itemAreaScrollNode);
  403. this.itemSearchAreaNode = new Element("div", {
  404. "styles": this.css.itemAreaNode
  405. }).inject(this.itemAreaScrollNode);
  406. this.itemSearchAreaNode.setStyle("display", "none");
  407. this.loadSelectNodeScroll();
  408. this.initLoadSelectItems();
  409. this.checkLoadSelectItems();
  410. },
  411. loadSelectNodeScroll: function(){
  412. var overflowY = this.itemAreaScrollNode.getStyle("overflow-y");
  413. if( typeOf(overflowY)==="string" && (overflowY.toLowerCase() === "auto" || overflowY.toLowerCase() === "scroll") )return;
  414. MWF.require("MWF.widget.ScrollBar", function(){
  415. var _self = this;
  416. new MWF.widget.ScrollBar(this.itemAreaScrollNode, {
  417. "style":"xApp_Organization_Explorer",
  418. "where": "before",
  419. "distance": 30,
  420. "friction": 4,
  421. "axis": {"x": false, "y": true},
  422. "onScroll": function(y){
  423. _self._scrollEvent(y);
  424. }
  425. });
  426. }.bind(this));
  427. },
  428. initSearchInput: function(){
  429. this.searchInput.addEvents({
  430. "keydown": function(e){
  431. var iTimerID = this.searchInput.retrieve("searchTimer", null);
  432. if (iTimerID){
  433. window.clearTimeout(iTimerID);
  434. this.searchInput.eliminate("searchTimer");
  435. }
  436. iTimerID = window.setTimeout(function(){
  437. this.search();
  438. }.bind(this), 800);
  439. this.searchInput.store("searchTimer", iTimerID);
  440. }.bind(this),
  441. "change": function(e){
  442. var key = this.searchInput.get("value");
  443. if (!key) this.initSearchArea(false);
  444. }.bind(this),
  445. "blur": function(){
  446. var key = this.searchInput.get("value");
  447. if (!key) this.initSearchArea(false);
  448. }.bind(this)
  449. });
  450. },
  451. initSearchArea: function(flag){
  452. if (flag){
  453. this.itemSearchAreaNode.empty();
  454. this.itemAreaNode.setStyle("display", "none");
  455. this.itemSearchAreaNode.setStyle("display", "block");
  456. }else{
  457. this.itemAreaNode.setStyle("display", "block");
  458. this.itemSearchAreaNode.setStyle("display", "none");
  459. }
  460. },
  461. search: function(){
  462. if (!this.options.groups.length && !this.options.roles.length){
  463. var key = this.searchInput.get("value");
  464. if (key){
  465. this._listItemByKey(function(json){
  466. this.initSearchArea(true);
  467. json.data.each(function(data){
  468. this._newItemSearch(data, this, this.itemSearchAreaNode);
  469. //this._newItem(data, this, this.itemSearchAreaNode);
  470. }.bind(this));
  471. }.bind(this), null, key);
  472. }else{
  473. this.initSearchArea(false);
  474. }
  475. }else{
  476. var key = this.searchInput.get("value");
  477. if (key){
  478. this.initSearchArea(true);
  479. this.searchInItems(key);
  480. }else{
  481. this.initSearchArea(false);
  482. }
  483. }
  484. },
  485. searchInItems: function(key){
  486. var createdId = [];
  487. this.createItemsSearchData(function(){
  488. var word = key.toLowerCase();
  489. this.itemsSearchData.each(function(obj){
  490. var text = obj.text+"#"+obj.pinyin+"#"+obj.firstPY;
  491. if (text.indexOf(word)!==-1){
  492. if (createdId.indexOf(obj.data.distinguishedName)===-1){
  493. this._newItem(obj.data, this, this.itemSearchAreaNode);
  494. createdId.push(obj.data.distinguishedName);
  495. }
  496. }
  497. }.bind(this));
  498. //delete createdId;
  499. }.bind(this));
  500. return createdId;
  501. },
  502. createItemsSearchData: function(callback){
  503. if (!this.itemsSearchData){
  504. this.itemsSearchData = [];
  505. MWF.require("MWF.widget.PinYin", function(){
  506. var initIds = [];
  507. this.items.each(function(item){
  508. if (initIds.indexOf(item.data.distinguishedName)==-1){
  509. var text = item._getShowName().toLowerCase();
  510. var pinyin = text.toPY().toLowerCase();
  511. var firstPY = text.toPYFirst().toLowerCase();
  512. this.itemsSearchData.push({
  513. "text": text,
  514. "pinyin": pinyin,
  515. "firstPY": firstPY,
  516. "data": item.data
  517. });
  518. initIds.push(item.data.distinguishedName);
  519. }
  520. }.bind(this));
  521. delete initIds;
  522. if (callback) callback();
  523. }.bind(this));
  524. }else{
  525. if (callback) callback();
  526. }
  527. },
  528. initSelectedSearchInput: function(){
  529. this.selectedSearchInput.addEvents({
  530. "keydown": function(e){
  531. var iTimerID = this.selectedSearchInput.retrieve("searchTimer", null);
  532. if (iTimerID){
  533. window.clearTimeout(iTimerID);
  534. this.selectedSearchInput.eliminate("searchTimer");
  535. }
  536. iTimerID = window.setTimeout(function(){
  537. this.selectedSearch();
  538. }.bind(this), 800);
  539. this.selectedSearchInput.store("searchTimer", iTimerID);
  540. }.bind(this),
  541. "change": function(e){
  542. var key = this.selectedSearchInput.get("value");
  543. if (!key) this.selectedSearch();
  544. }.bind(this),
  545. "blur": function(){
  546. var key = this.selectedSearchInput.get("value");
  547. if (!key) this.selectedSearch();
  548. }.bind(this)
  549. });
  550. },
  551. selectedSearch: function(){
  552. var key = this.selectedSearchInput.get("value");
  553. if (key){
  554. this.selectedSearchInItems(key);
  555. }else{
  556. this.showAllSelectedItem()
  557. }
  558. },
  559. selectedSearchInItems: function(key){
  560. var word = key.toLowerCase();
  561. MWF.require("MWF.widget.PinYin", function() {
  562. this.selectedItems.each(function (item) {
  563. if (!item.searchedText) {
  564. var text = item._getShowName().toLowerCase();
  565. var pinyin = text.toPY().toLowerCase();
  566. var firstPY = text.toPYFirst().toLowerCase();
  567. item.searchedText = text + "#" + pinyin + "#" + firstPY
  568. }
  569. if (item.searchedText.indexOf(word) !== -1) {
  570. item.node.show()
  571. } else {
  572. item.node.hide()
  573. }
  574. }.bind(this));
  575. }.bind(this), null, false);
  576. },
  577. showAllSelectedItem: function(){
  578. this.selectedItems.each(function(item){
  579. item.node.show()
  580. })
  581. },
  582. loadSelectedNode: function(){
  583. this.selectedContainerNode = new Element("div", {
  584. "styles": this.css.selectedContainerNode
  585. }).inject(this.contentNode);
  586. //if( this.options.embedded && this.options.count.toInt()!==1 ){
  587. if( this.options.hasTop ){
  588. this.selectedTopNode = new Element("div",{
  589. "styles" : this.css.selectedTopNode
  590. }).inject( this.selectedContainerNode );
  591. this.selectedTopTextNode = new Element("div",{
  592. "text" : MWF.SelectorLP.selected,
  593. "styles" : this.css.selectedTopTextNode
  594. }).inject( this.selectedTopNode );
  595. this.emptySelectedNode = new Element("div",{
  596. "text" : MWF.SelectorLP.empty,
  597. "styles" : this.css.selectedTopActionNode,
  598. "events" : {
  599. "click" : function(){
  600. this.emptySelectedItems()
  601. }.bind(this)
  602. }
  603. }).inject( this.selectedTopNode );
  604. }
  605. if( this.options.hasSelectedSearchbar ){
  606. if( this.options.searchbarInTopNode ){
  607. this.selectedSearchInputDiv = new Element("div", {
  608. "styles": this.css.searchInputDiv
  609. }).inject( this.selectedTopNode || this.selectedContainerNode);
  610. }else{
  611. this.selectedSearchInputDiv = new Element("div.selectedSearchInputDiv", {
  612. "styles": this.css.searchInputDiv
  613. }).inject( this.selectedContainerNode);
  614. }
  615. this.selectedSearchInput = new Element("input", {
  616. "styles": this.css.searchInput, //(this.options.count.toInt()===1) ? this.css.searchInputSingle : this.css.searchInput,
  617. "placeholder" : MWF.SelectorLP.searchDescription,
  618. "type": "text"
  619. }).inject(this.selectedSearchInputDiv);
  620. this.initSelectedSearchInput();
  621. }
  622. this.selectedScrollNode = new Element("div.selectedScrollNode", {
  623. "styles": this.css.selectedScrollNode
  624. }).inject(this.selectedContainerNode);
  625. this.selectedNode = new Element("div.selectedNode", {
  626. "styles": this.css.selectedNode
  627. }).inject(this.selectedScrollNode);
  628. if( this.options.hasSelectedSearchbar ){
  629. this.selectedItemSearchAreaNode = new Element("div", {
  630. "styles": this.css.itemAreaNode
  631. }).inject(this.selectedScrollNode);
  632. this.selectedItemSearchAreaNode.setStyle("display", "none");
  633. }
  634. this.setSelectedItem();
  635. this.loadSelectedNodeScroll();
  636. },
  637. emptySelectedItems : function(){
  638. while (this.selectedItems.length){
  639. this.selectedItems[0].clickItem();
  640. }
  641. },
  642. loadSelectedNodeScroll: function(){
  643. var overflowY = this.selectedScrollNode.getStyle("overflow-y");
  644. if( typeOf(overflowY)==="string" && (overflowY.toLowerCase() === "auto" || overflowY.toLowerCase() === "scroll") )return;
  645. MWF.require("MWF.widget.ScrollBar", function(){
  646. var _self = this;
  647. new MWF.widget.ScrollBar(this.selectedScrollNode, {
  648. "style":"xApp_Organization_Explorer", "where": "before", "distance": 100, "friction": 4,"axis": {"x": false, "y": true}
  649. });
  650. }.bind(this));
  651. },
  652. loadSelectedNodeMobile: function(){
  653. this.selectedScrollNode = new Element("div", {
  654. "styles": this.css.selectedScrollNode
  655. }).inject(this.contentNode);
  656. this.selectedNode = new Element("div", {
  657. "styles": this.css.selectedNode
  658. }).inject(this.selectedScrollNode);
  659. this.setSelectedItem();
  660. MWF.require("MWF.widget.ScrollBar", function(){
  661. var _self = this;
  662. new MWF.widget.ScrollBar(this.selectedScrollNode, {
  663. "style":"xApp_Organization_Explorer", "where": "before", "distance": 100, "friction": 4,"axis": {"x": false, "y": true}
  664. });
  665. }.bind(this));
  666. this.selectedScrollNode.setStyle("display", "none");
  667. },
  668. setSelectedItem: function(){
  669. if (this.options.values.length){
  670. this.options.values.each(function(v, i){
  671. if (typeOf(v)==="object"){
  672. this.selectedItems.push(this._newItemSelected(v, this, null));
  673. }else{
  674. this._getItem(function(json){
  675. this.options.values[i] = json.data;
  676. this.selectedItems.push(this._newItemSelected(json.data, this, null));
  677. }.bind(this), null, v, false);
  678. }
  679. // this._getItem(function(json){
  680. // this.selectedItems.push(this._newItemSelected(json.data, this, null));
  681. // }.bind(this), null, v, false);
  682. }.bind(this));
  683. }
  684. },
  685. loadLetters: function(){
  686. var _self = this;
  687. 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"];
  688. if (layout.mobile){
  689. var size = this.container.getSize();
  690. var w = (layout.mobile) ? (size.x-18)/13 : (size.x-20-4-18)/13;
  691. //letterNode.setStyle("width", ""+w+"px");
  692. this.css.letterNode.width = ""+w+"px";
  693. this.css.letterNode_over.width = ""+w+"px";
  694. }
  695. letters.each(function(l){
  696. var letterNode = new Element("div", {
  697. "styles": this.css.letterNode,
  698. "text": l
  699. }).inject(this.letterAreaNode);
  700. if (layout.mobile){
  701. letterNode.addEvents({
  702. "click": function(){
  703. _self.listPersonByPinyin(this);
  704. }
  705. });
  706. }else{
  707. letterNode.addEvents({
  708. "mouseover": function(e){
  709. e.target.setStyles(this.css.letterNode_over);
  710. var showNode = new Element("div", {
  711. "styles": this.css.letterShowNode,
  712. "text": e.target.get("text")
  713. }).inject(this.selectNode);
  714. showNode.position({
  715. relativeTo: this.itemAreaScrollNode,
  716. position: "center",
  717. edge: "center"
  718. });
  719. e.target.store("showNode", showNode);
  720. }.bind(this),
  721. "mouseout": function(e){
  722. var showNode = e.target.retrieve("showNode");
  723. showNode.destroy();
  724. e.target.setStyles(this.css.letterNode);
  725. }.bind(this),
  726. "click": function(){
  727. _self.listPersonByPinyin(this);
  728. }
  729. });
  730. }
  731. }.bind(this));
  732. },
  733. listPersonByPinyin: function(node){
  734. this.searchInput.focus();
  735. var pinyin = this.searchInput.get("value");
  736. pinyin = pinyin+node.get("text");
  737. this.searchInput.set("value", pinyin);
  738. if (!this.options.groups.length && !this.options.roles.length){
  739. if (pinyin){
  740. this._listItemByPinyin(function(json){
  741. this.initSearchArea(true);
  742. json.data.each(function(data){
  743. // var flag = true;
  744. // if (this.options.departments){
  745. // if (this.options.departments.length){
  746. // if (this.options.departments.indexOf(data.departmentName)==-1) flag = false;
  747. // }
  748. // }
  749. // if (this.options.companys){
  750. // if (this.options.companys.length){
  751. // if (this.options.companys.indexOf(data.company)==-1) flag = false;
  752. // }
  753. // }
  754. if( !this.isExcluded( data ) ) {
  755. this._newItemSearch(data, this, this.itemSearchAreaNode);
  756. }
  757. //this._newItem(data, this, this.itemSearchAreaNode);
  758. //this._newItem(data, this, this.itemSearchAreaNode);
  759. }.bind(this));
  760. }.bind(this), null, pinyin.toLowerCase());
  761. }
  762. }else{
  763. if (pinyin){
  764. this.initSearchArea(true);
  765. this.searchInItems(pinyin);
  766. }else{
  767. this.initSearchArea(false);
  768. }
  769. }
  770. },
  771. initLoadSelectItems: function(){
  772. this.loaddingItems = false;
  773. this.isItemLoaded = false;
  774. this.loadItemsQueue = 0;
  775. this.initSearchArea(false);
  776. },
  777. //loadSelectItems: function(addToNext){
  778. // if (!this.isItemLoaded){
  779. // if (!this.loaddingItems){
  780. // this.loaddingItems = true;
  781. // var count = 20;
  782. // this._listItemNext(this.getLastLoadedItemId(), count, function(json){
  783. // if (json.data.length){
  784. // json.data.each(function(data){
  785. // var item = this._newItem(data, this, this.itemAreaNode);
  786. // this.items.push(item);
  787. // }.bind(this));
  788. // this.loaddingItems = false;
  789. //
  790. // if (json.data.length<count){
  791. // this.isItemLoaded = true;
  792. // }else{
  793. // if (this.loadItemsQueue>0){
  794. // this.loadItemsQueue--;
  795. // this.loadSelectItems();
  796. // }
  797. // }
  798. // }else{
  799. // this.isItemLoaded = true;
  800. // this.loaddingItems = false;
  801. // }
  802. // }.bind(this));
  803. // }else{
  804. // if (addToNext) this.loadItemsQueue++;
  805. // }
  806. // }
  807. //},
  808. loadSelectItems: function(addToNext, lastExcludeCount ){
  809. //lastExcludeCount 参数:表示本次加载是为了补足上次load的时候被排除的数量
  810. if (!this.isItemLoaded){
  811. if (!this.loaddingItems){
  812. this.loaddingItems = true;
  813. var count = 20;
  814. this._listItemNext(this.getLastLoadedItemId(), count, function(json){
  815. if (json.data.length){
  816. var excludedCount = 0;
  817. json.data.each(function(data, i){
  818. if( this.isExcluded( data ) ){
  819. excludedCount++;
  820. if( i+1 === count )this.tailExcludeItemId = data.distinguishedName
  821. }else{
  822. var item = this._newItem(data, this, this.itemAreaNode);
  823. this.items.push(item);
  824. if( i+1 === count )this.tailExcludeItemId = null;
  825. }
  826. }.bind(this));
  827. this.loaddingItems = false;
  828. if( lastExcludeCount ){ //如果是因为上次load的时候被排除而加载的
  829. if( count - lastExcludeCount - excludedCount < 0 ){ //如果本次load的数量还不够补足排除的数量,需要再次load
  830. excludedCount = lastExcludeCount + excludedCount - count; //把不足的数量作为再次load的参数
  831. this.loadItemsQueue++
  832. }
  833. }else if( excludedCount > 0 ){ //把排除的数量作为再次load的参数
  834. this.loadItemsQueue++
  835. }
  836. if (json.data.length<count){
  837. this.isItemLoaded = true;
  838. }else{
  839. if (this.loadItemsQueue>0){
  840. this.loadItemsQueue--;
  841. this.loadSelectItems( addToNext, excludedCount );
  842. }
  843. }
  844. }else{
  845. this.isItemLoaded = true;
  846. this.loaddingItems = false;
  847. }
  848. }.bind(this));
  849. }else{
  850. if (addToNext) this.loadItemsQueue++;
  851. }
  852. }
  853. },
  854. getLastLoadedItemId: function(){
  855. if( this.tailExcludeItemId )return this.tailExcludeItemId;
  856. return (this.items.length) ? this.items[this.items.length-1].data.distinguishedName : "(0)";
  857. },
  858. //loadSelectItemsByCondition: function(){
  859. // this.options.groups.each(function(group){
  860. //
  861. // this.orgAction.listGroupByKey(function(json){
  862. // if (json.data.length){
  863. // var groupData = json.data[0];
  864. // var category = this._newItemCategory("ItemGroupCategory", groupData, this, this.itemAreaNode);
  865. // this._getChildrenItemIds(groupData).each(function(id){
  866. // this._getItem(function(json){
  867. // var item = this._newItem(json.data, this, category.children);
  868. // this.items.push(item);
  869. // }.bind(this), null, id);
  870. // }.bind(this));
  871. // }
  872. // }.bind(this), null, group);
  873. // }.bind(this));
  874. //
  875. // this.options.roles.each(function(role){
  876. // this.orgAction.listRoleByKey(function(json){
  877. // if (json.data.length){
  878. // var roleData = json.data[0];
  879. // var category = this._newItemCategory("ItemRoleCategory", roleData, this, this.itemAreaNode);
  880. // this._getChildrenItemIds(roleData).each(function(id){
  881. // this._getItem(function(json){
  882. // var item = this._newItem(json.data, this, category.children);
  883. // this.items.push(item);
  884. // }.bind(this), null, id)
  885. // }.bind(this));
  886. // }
  887. // }.bind(this), null, role);
  888. // }.bind(this));
  889. //},
  890. loadSelectItemsByCondition: function(){
  891. this.options.groups.each(function(group){
  892. this.orgAction.listGroupByKey(function(json){
  893. if (json.data.length){
  894. var groupData = json.data[0];
  895. var category = this._newItemCategory("ItemGroupCategory", groupData, this, this.itemAreaNode);
  896. this.subCategorys.push(category);
  897. this._getChildrenItemIds(groupData).each(function(id){
  898. this._getItem(function(json){
  899. if( !this.isExcluded( json.data ) ) {
  900. var item = this._newItem(json.data, this, category.children);
  901. this.items.push(item);
  902. }
  903. }.bind(this), null, id);
  904. }.bind(this));
  905. }
  906. }.bind(this), null, group);
  907. }.bind(this));
  908. this.options.roles.each(function(role){
  909. this.orgAction.listRoleByKey(function(json){
  910. if (json.data.length){
  911. var roleData = json.data[0];
  912. var category = this._newItemCategory("ItemRoleCategory", roleData, this, this.itemAreaNode);
  913. this.subCategorys.push(category);
  914. this._getChildrenItemIds(roleData).each(function(id){
  915. this._getItem(function(json){
  916. if( !this.isExcluded( json.data ) ) {
  917. var item = this._newItem(json.data, this, category.children);
  918. this.items.push(item);
  919. }
  920. }.bind(this), null, id)
  921. }.bind(this));
  922. }
  923. }.bind(this), null, role);
  924. }.bind(this));
  925. },
  926. isExcluded : function( d ){
  927. if( this.options.exclude.length === 0 )return false;
  928. if( !this.excludeFlagMap ){
  929. this.excludeFlagMap = {};
  930. this.options.exclude.each( function( e ){
  931. if( !e )return;
  932. this.excludeFlagMap[ typeOf( e ) === "string" ? e : ( e.distinguishedName || e.id || e.unique || e.employee || e.levelName) ] = true;
  933. }.bind(this));
  934. }
  935. var map = this.excludeFlagMap;
  936. return ( d.distinguishedName && map[ d.distinguishedName ] ) ||
  937. ( d.id && map[ d.id ] ) ||
  938. ( d.unique && map[ d.unique ] ) ||
  939. ( d.employee && map[ d.employee ] ) ||
  940. ( d.levelName && map[ d.levelName ] );
  941. },
  942. _getChildrenItemIds: function(data){
  943. return data.personList;
  944. },
  945. _newItemCategory: function(type, data, selector, item){
  946. return new MWF.xApplication.Selector.Person[type](data, selector, item)
  947. },
  948. _listItemByKey: function(callback, failure, key){
  949. this.orgAction.listPersonByKey(function(json){
  950. if (callback) callback.apply(this, [json]);
  951. }.bind(this), failure, key);
  952. },
  953. _getItem: function(callback, failure, id, async){
  954. this.orgAction.getPerson(function(json){
  955. if (callback) callback.apply(this, [json]);
  956. }.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async);
  957. },
  958. _newItemSelected: function(data, selector, item){
  959. return new MWF.xApplication.Selector.Person.ItemSelected(data, selector, item)
  960. },
  961. _listItemByPinyin: function(callback, failure, key){
  962. this.orgAction.listPersonByPinyin(function(json){
  963. if (callback) callback.apply(this, [json]);
  964. }.bind(this), failure, key);
  965. },
  966. _newItem: function(data, selector, container){
  967. return new MWF.xApplication.Selector.Person.Item(data, selector, container);
  968. },
  969. _newItemSearch: function(data, selector, container){
  970. return this._newItem(data, selector, container);
  971. },
  972. _listItemNext: function(last, count, callback){
  973. this.orgAction.listPersonNext(last, count, function(json){
  974. if (callback) callback.apply(this, [json]);
  975. }.bind(this));
  976. },
  977. _scrollEvent: function(y){
  978. if (!this.options.groups.length && !this.options.roles.length){
  979. var scrollSize = this.itemAreaScrollNode.getScrollSize();
  980. var clientSize = this.itemAreaScrollNode.getSize();
  981. var scrollHeight = scrollSize.y-clientSize.y;
  982. if (y+30>scrollHeight) {
  983. if (!this.isItemLoaded) this.loadSelectItems();
  984. }
  985. }
  986. },
  987. setSize : function(){
  988. if( !this.options.width && !this.options.height )return;
  989. var getOffsetX = function(node){
  990. return (node.getStyle("margin-left").toInt() || 0 )+
  991. (node.getStyle("margin-right").toInt() || 0 ) +
  992. (node.getStyle("padding-left").toInt() || 0 ) +
  993. (node.getStyle("padding-right").toInt() || 0 ) +
  994. (node.getStyle("border-left-width").toInt() || 0 ) +
  995. (node.getStyle("border-right-width").toInt() || 0 );
  996. };
  997. var getOffsetY = function(node){
  998. return (node.getStyle("margin-top").toInt() || 0 ) +
  999. (node.getStyle("margin-bottom").toInt() || 0 ) +
  1000. (node.getStyle("padding-top").toInt() || 0 ) +
  1001. (node.getStyle("padding-bottom").toInt() || 0 )+
  1002. (node.getStyle("border-top-width").toInt() || 0 ) +
  1003. (node.getStyle("border-bottom-width").toInt() || 0 );
  1004. };
  1005. if( this.options.width && this.options.width === "auto" ){
  1006. //if (this.options.count.toInt() !== 1){
  1007. if( this.node )this.node.setStyle("width", "auto");
  1008. this.selectNode.setStyles({
  1009. "width": "50%",
  1010. "float" : "left"
  1011. });
  1012. //this.searchInput.setStyle("width", "99%");
  1013. if(this.letterAreaNode ){
  1014. this.letterAreaNode.setStyle("width", "auto");
  1015. }
  1016. this.selectedContainerNode.setStyle("width", "auto");
  1017. var overflowY = this.selectedScrollNode.getStyle("overflow-y");
  1018. if( typeOf(overflowY)==="string" && (overflowY.toLowerCase() === "auto" || overflowY.toLowerCase() === "scroll") ){
  1019. this.selectedScrollNode.setStyle("width", "auto");
  1020. }else{
  1021. this.selectedScrollNode.setStyle("margin-right", "8px");
  1022. }
  1023. //}else{
  1024. // this.node.setStyle("width", "auto");
  1025. // this.selectNode.setStyle("width", "auto");
  1026. //}
  1027. }else if( this.options.width && typeOf( this.options.width.toInt() ) === "number" ){
  1028. var nodeWidth;
  1029. if( this.node ){
  1030. nodeWidth = this.options.width.toInt() - getOffsetX(this.node);
  1031. this.node.setStyle("width", nodeWidth);
  1032. }else{
  1033. nodeWidth = this.options.width.toInt();
  1034. }
  1035. nodeWidth = nodeWidth - getOffsetX( this.contentNode );
  1036. if( this.shuttleNode ){
  1037. nodeWidth = nodeWidth - getOffsetX(this.shuttleNode) - this.shuttleNode.getStyle("width").toInt();
  1038. }
  1039. //if (this.options.count.toInt() !== 1){
  1040. var width = nodeWidth - getOffsetX(this.selectNode) - getOffsetX(this.selectedContainerNode);
  1041. var halfWidth = Math.floor(width / 2);
  1042. this.selectNode.setStyle("width", halfWidth);
  1043. //this.searchInput.setStyle("width", halfWidth - 6);
  1044. if(this.letterAreaNode ){
  1045. this.letterAreaNode.setStyle("width", halfWidth - 19);
  1046. }
  1047. this.selectedContainerNode.setStyle("width", halfWidth);
  1048. var overflowY = this.selectedScrollNode.getStyle("overflow-y");
  1049. if( typeOf(overflowY)==="string" && (overflowY.toLowerCase() === "auto" || overflowY.toLowerCase() === "scroll") ){
  1050. this.selectedScrollNode.setStyle("width", halfWidth);
  1051. }else{
  1052. this.selectedScrollNode.setStyle("width", halfWidth - 8);
  1053. }
  1054. //}else{
  1055. // var width = nodeWidth - getOffsetX(this.selectNode);
  1056. // this.selectNode.setStyle("width", width);
  1057. //}
  1058. }
  1059. if( this.options.height && typeOf( this.options.height.toInt() ) === "number" ){
  1060. var nodeHeight;
  1061. if( this.node ){
  1062. nodeHeight = this.options.height.toInt() - getOffsetY(this.node);
  1063. this.node.setStyle("height", nodeHeight);
  1064. }else{
  1065. nodeHeight = this.options.height.toInt();
  1066. }
  1067. nodeHeight = nodeHeight - getOffsetY( this.contentNode );
  1068. if( this.titleNode ){
  1069. nodeHeight = nodeHeight - getOffsetY( this.titleNode ) - this.titleNode.getStyle("height").toInt();
  1070. }
  1071. if( this.actionNode ){
  1072. nodeHeight = nodeHeight - getOffsetY( this.actionNode ) - this.actionNode.getStyle("height").toInt();
  1073. }
  1074. var selectNodeHeight = nodeHeight - getOffsetY(this.selectNode);
  1075. this.selectNode.setStyle("height", selectNodeHeight);
  1076. if( this.shuttleNode ){
  1077. this.shuttleNode.setStyle("height", selectNodeHeight);
  1078. var shuttleInnerHieght = getOffsetY( this.shuttleInnerNode ) + this.shuttleInnerNode.getStyle("height").toInt();
  1079. this.shuttleInnerNode.setStyle("margin-top", (selectNodeHeight-shuttleInnerHieght)/2 +"px" )
  1080. }
  1081. var itemAreaScrollNodeHeight = selectNodeHeight - getOffsetY( this.searchInputDiv ) - this.searchInputDiv.getStyle("height").toInt();
  1082. if( !this.options.searchbarInTopNode && this.selectTopNode ){
  1083. itemAreaScrollNodeHeight = itemAreaScrollNodeHeight - getOffsetY( this.selectTopNode ) - this.selectTopNode.getStyle("height").toInt();
  1084. }
  1085. if(this.letterAreaNode ){
  1086. itemAreaScrollNodeHeight = itemAreaScrollNodeHeight - getOffsetY( this.letterAreaNode ) - this.letterAreaNode.getStyle("height").toInt();
  1087. }
  1088. itemAreaScrollNodeHeight = itemAreaScrollNodeHeight - getOffsetY( this.itemAreaScrollNode );
  1089. this.itemAreaScrollNode.setStyle("height", itemAreaScrollNodeHeight);
  1090. var selectedContainerNodeHeight = nodeHeight - getOffsetY(this.selectedContainerNode);
  1091. this.selectedContainerNode.setStyle("height", selectedContainerNodeHeight);
  1092. var selectedScrollNodeHeight = selectedContainerNodeHeight;
  1093. if( this.selectedTopNode ) {
  1094. selectedScrollNodeHeight = selectedScrollNodeHeight - getOffsetY(this.selectedTopNode) - this.selectedTopNode.getStyle("height").toInt();
  1095. }
  1096. if( !this.options.searchbarInTopNode && this.selectedSearchInputDiv ){
  1097. selectedScrollNodeHeight = selectedScrollNodeHeight - getOffsetY( this.selectedSearchInputDiv ) - this.selectedSearchInputDiv.getStyle("height").toInt();
  1098. }
  1099. this.selectedScrollNode.setStyle("height", selectedScrollNodeHeight);
  1100. }
  1101. this.fireEvent("setSize",[this])
  1102. }
  1103. });
  1104. MWF.xApplication.Selector.Person.Item = new Class({
  1105. initialize: function(data, selector, container, level, category){
  1106. this.data = data;
  1107. this.selector = selector;
  1108. this.container = container;
  1109. this.isSelected = false;
  1110. this.level = (level) ? level.toInt() : 1;
  1111. this.category = category;
  1112. this.subItems = [];
  1113. this.subCategorys = [];
  1114. this.load();
  1115. },
  1116. _getShowName: function(){
  1117. return this.data.name+"("+this.data.employee+")";
  1118. },
  1119. _getTtiteText: function(){
  1120. return this.data.name+"("+this.data.employee+")";
  1121. },
  1122. _setIcon: function(){
  1123. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/personicon.png)");
  1124. },
  1125. load: function(){
  1126. this.selector.fireEvent("queryLoadItem",[this]);
  1127. this.node = new Element("div", {
  1128. "styles": this.selector.css.selectorItem
  1129. }).inject(this.container);
  1130. this.levelNode = new Element("div", {
  1131. "styles": this.selector.css.selectorItemLevelNode
  1132. }).inject(this.node);
  1133. var indent = this.selector.options.level1Indent + (this.level-1)*this.selector.options.indent;
  1134. this.levelNode.setStyle("width", ""+indent+"px");
  1135. this.iconNode = new Element("div", {
  1136. "styles": this.selector.css.selectorItemIconNode
  1137. }).inject(this.node);
  1138. this._setIcon();
  1139. this.actionNode = new Element("div", {
  1140. "styles": this.selector.css.selectorItemActionNode
  1141. }).inject(this.node);
  1142. this.textNode = new Element("div", {
  1143. "styles": this.selector.css.selectorItemTextNode,
  1144. "text": this._getShowName(),
  1145. "title": this._getTtiteText()
  1146. }).inject(this.node);
  1147. var m = this.textNode.getStyle("margin-left").toFloat()+indent;
  1148. this.textNode.setStyle("margin-left", ""+m+"px");
  1149. if(this.postLoad)this.postLoad();
  1150. this.loadSubItem();
  1151. this.setEvent();
  1152. this.check();
  1153. this.selector.fireEvent("postLoadItem",[this]);
  1154. },
  1155. loadSubItem: function(){},
  1156. check: function(){
  1157. //if (this.selector.options.count.toInt()===1){
  1158. // this.checkSelectedSingle();
  1159. //}else{
  1160. this.checkSelected();
  1161. //}
  1162. },
  1163. checkSelectedSingle: function(){
  1164. var selectedItem = this.selector.options.values.filter(function(item, index){
  1165. if (typeOf(item)==="object") return this.data.distinguishedName === item.distinguishedName;
  1166. if (typeOf(item)==="string") return this.data.distinguishedName === item;
  1167. return false;
  1168. }.bind(this));
  1169. if (selectedItem.length){
  1170. this.selectedSingle();
  1171. }
  1172. },
  1173. checkSelected: function(){
  1174. var selectedItem = this.selector.selectedItems.filter(function(item, index){
  1175. return item.data.distinguishedName === this.data.distinguishedName;
  1176. }.bind(this));
  1177. if (selectedItem.length){
  1178. //selectedItem[0].item = this;
  1179. selectedItem[0].addItem(this);
  1180. this.selectedItem = selectedItem[0];
  1181. this.setSelected();
  1182. }
  1183. },
  1184. setSelected: function(){
  1185. this.isSelected = true;
  1186. this.node.setStyles(this.selector.css.selectorItem_selected);
  1187. this.textNode.setStyles(this.selector.css.selectorItemTextNode_selected);
  1188. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
  1189. },
  1190. setEvent: function(){
  1191. this.node.addEvents({
  1192. "mouseover": function(){
  1193. this.overItem();
  1194. }.bind(this),
  1195. "mouseout": function(){
  1196. this.outItem();
  1197. }.bind(this),
  1198. "click": function(){
  1199. this.clickItem();
  1200. }.bind(this)
  1201. });
  1202. },
  1203. clickItem: function(){
  1204. //if (this.selector.options.count.toInt()===1){
  1205. // this.selectedSingle();
  1206. //}else{
  1207. if (this.isSelected){
  1208. this.unSelected();
  1209. this.selector.fireEvent("unselectItem",[this])
  1210. }else{
  1211. this.selected();
  1212. this.selector.fireEvent("selectItem",[this])
  1213. }
  1214. //}
  1215. },
  1216. overItem: function(){
  1217. if (!this.isSelected ){
  1218. this.node.setStyles(this.selector.css.selectorItem_over);
  1219. }else if( this.selector.css.selectorItem_over_force ){
  1220. this.node.setStyles(this.selector.css.selectorItem_over_force);
  1221. }
  1222. if (!this.isSelected){
  1223. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_over);
  1224. }else if( this.selector.css.selectorItemActionNode_over_force ){
  1225. this.node.setStyles(this.selector.css.selectorItemActionNode_over_force);
  1226. }
  1227. },
  1228. outItem: function(){
  1229. if (!this.isSelected){
  1230. this.node.setStyles(this.selector.css.selectorItem);
  1231. }else if( this.selector.css.selectorItem_over_force ){
  1232. this.node.setStyles(this.selector.css.selectorItem_selected);
  1233. }
  1234. if (!this.isSelected){
  1235. this.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  1236. }else if( this.selector.css.selectorItemActionNode_over_force ){
  1237. this.node.setStyles(this.selector.css.selectorItemActionNode_selected);
  1238. }
  1239. },
  1240. selectedSingle: function(){
  1241. if (!this.isSelected){
  1242. if (this.selector.currentItem) this.selector.currentItem.unSelectedSingle();
  1243. this.getData(function(){
  1244. this.selector.currentItem = this;
  1245. this.isSelected = true;
  1246. this.selector.selectedItems.push(this);
  1247. this.node.setStyles(this.selector.css.selectorItem_selected);
  1248. this.textNode.setStyles(this.selector.css.selectorItemTextNode_selected);
  1249. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
  1250. }.bind(this));
  1251. }else {
  1252. this.unSelectedSingle();
  1253. }
  1254. },
  1255. getData: function(callback){
  1256. if (callback) callback();
  1257. },
  1258. unSelectedSingle: function(){
  1259. this.selector.currentItem = null;
  1260. this.isSelected = false;
  1261. this.selector.selectedItems.erase(this);
  1262. this.node.setStyles(this.selector.css.selectorItem);
  1263. this.textNode.setStyles(this.selector.css.selectorItemTextNode);
  1264. this.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  1265. },
  1266. selected: function(){
  1267. var count = this.selector.options.maxCount || this.selector.options.count;
  1268. if (!count) count = 0;
  1269. if ((count.toInt()===0) || (this.selector.selectedItems.length+1)<=count){
  1270. debugger;
  1271. this.isSelected = true;
  1272. this.node.setStyles(this.selector.css.selectorItem_selected);
  1273. this.textNode.setStyles(this.selector.css.selectorItemTextNode_selected);
  1274. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
  1275. this.selectedItem = this.selector._newItemSelected(this.data, this.selector, this);
  1276. this.selectedItem.check();
  1277. this.selector.selectedItems.push(this.selectedItem);
  1278. }else{
  1279. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "最多可选择"+count+"个选项", this.node);
  1280. }
  1281. },
  1282. unSelected: function(){
  1283. this.isSelected = false;
  1284. this.node.setStyles(this.selector.css.selectorItem);
  1285. this.textNode.setStyles(this.selector.css.selectorItemTextNode);
  1286. this.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  1287. if (this.selectedItem){
  1288. this.selector.selectedItems.erase(this.selectedItem);
  1289. this.selectedItem.items.each(function(item){
  1290. if (item != this){
  1291. item.isSelected = false;
  1292. item.node.setStyles(this.selector.css.selectorItem);
  1293. item.textNode.setStyles(this.selector.css.selectorItemTextNode);
  1294. item.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  1295. }
  1296. }.bind(this));
  1297. this.selectedItem.destroy();
  1298. this.selectedItem = null;
  1299. }
  1300. },
  1301. postLoad : function(){},
  1302. getParentCategoryByLevel : function( level ){
  1303. var category = this.category;
  1304. do{
  1305. if( category.level === level ){
  1306. return category;
  1307. }else{
  1308. category = category.category;
  1309. }
  1310. }while( category )
  1311. }
  1312. });
  1313. MWF.xApplication.Selector.Person.ItemSelected = new Class({
  1314. Extends: MWF.xApplication.Selector.Person.Item,
  1315. initialize: function(data, selector, item){
  1316. this.data = data;
  1317. this.selector = selector;
  1318. this.container = this.selector.selectedNode;
  1319. this.isSelected = false;
  1320. this.items = [];
  1321. if (item) this.items.push(item);
  1322. this.level = 0;
  1323. this.getData(function(){
  1324. this.load();
  1325. }.bind(this));
  1326. },
  1327. postLoad : function(){
  1328. if( this.selector.css.selectorSelectedItemActionNode ){
  1329. this.actionNode.setStyles( this.selector.css.selectorSelectedItemActionNode );
  1330. }
  1331. if( this.selector.css.selectorSelectedItemTextNode ){
  1332. this.textNode.setStyles(this.selector.css.selectorSelectedItemTextNode);
  1333. }
  1334. },
  1335. getData: function(callback){
  1336. if (callback) callback();
  1337. },
  1338. clickItem: function(){
  1339. if (this.items.length){
  1340. this.items.each(function(item){
  1341. item.unSelected();
  1342. });
  1343. }else{
  1344. //this.item.selectedItem = null;
  1345. //this.item.isSelected = false;
  1346. this.destroy();
  1347. this.selector.selectedItems.erase(this);
  1348. }
  1349. },
  1350. //overItem: function(){
  1351. // if (!this.isSelected){
  1352. // this.node.setStyles(this.selector.css.selectorItem_over);
  1353. // this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected_over);
  1354. // }
  1355. //},
  1356. overItem: function(){
  1357. if (!this.isSelected ){
  1358. if( this.selector.css.selectorItem_selected_over ){
  1359. this.node.setStyles(this.selector.css.selectorItem_selected_over);
  1360. }else{
  1361. this.node.setStyles(this.selector.css.selectorItem_over);
  1362. }
  1363. this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected_over);
  1364. }
  1365. },
  1366. outItem: function(){
  1367. if (!this.isSelected){
  1368. var styles = this.selector.css.selectorSelectedItem || this.selector.css.selectorItem;
  1369. this.node.setStyles(styles);
  1370. }else if( this.selector.css.selectorItem_over_force ){
  1371. this.node.setStyles(this.selector.css.selectorItem_selected);
  1372. }
  1373. if (!this.isSelected){
  1374. var styles = this.selector.css.selectorSelectedItemActionNode || this.selector.css.selectorItemActionNode;
  1375. this.actionNode.setStyles(styles);
  1376. }else if( this.selector.css.selectorItemActionNode_over_force ){
  1377. this.node.setStyles(this.selector.css.selectorItemActionNode_selected);
  1378. }
  1379. },
  1380. addItem: function(item){
  1381. if (this.items.indexOf(item)===-1) this.items.push(item);
  1382. },
  1383. check: function(){
  1384. if (this.selector.items.length){
  1385. var items = this.selector.items.filter(function(item, index){
  1386. return item.data.distinguishedName === this.data.distinguishedName;
  1387. }.bind(this));
  1388. this.items = items;
  1389. if (items.length){
  1390. items.each(function(item){
  1391. item.selectedItem = this;
  1392. item.setSelected();
  1393. }.bind(this));
  1394. }
  1395. }
  1396. },
  1397. destroy: function(){
  1398. if(this.node)this.node.destroy();
  1399. delete this;
  1400. }
  1401. });
  1402. MWF.xApplication.Selector.Person.ItemCategory = new Class({
  1403. Extends: MWF.xApplication.Selector.Person.Item,
  1404. initialize: function(data, selector, container, level, parentCategory){
  1405. this.data = data;
  1406. this.selector = selector;
  1407. this.container = container;
  1408. this.isSelected = false;
  1409. this.level = (level) ? level.toInt() : 1;
  1410. this.category = parentCategory;
  1411. this.subItems = [];
  1412. this.subCategorys = [];
  1413. this.load();
  1414. },
  1415. createNode: function(){
  1416. this.node = new Element("div", {
  1417. "styles": this.selector.css.selectorItemCategory
  1418. }).inject(this.container);
  1419. },
  1420. load: function(){
  1421. this.selector.fireEvent("queryLoadCategory",[this]);
  1422. this.createNode();
  1423. this.levelNode = new Element("div", {
  1424. "styles": this.selector.css.selectorItemLevelNode
  1425. }).inject(this.node);
  1426. var indent = this.selector.options.level1Indent + (this.level-1)*this.selector.options.indent;
  1427. this.levelNode.setStyle("width", ""+indent+"px");
  1428. this.iconNode = new Element("div", {
  1429. "styles": this.selector.css.selectorItemIconNode
  1430. }).inject(this.node);
  1431. this._setIcon();
  1432. this.actionNode = new Element("div", {
  1433. "styles": (this.selector.options.expand) ? this.selector.css.selectorItemCategoryActionNode_expand : this.selector.css.selectorItemCategoryActionNode_collapse
  1434. }).inject(this.node);
  1435. if( this.selector.options.selectAllEnable && this.selector.options.count.toInt()!==1 ){
  1436. this.selectAllNode = new Element("div", {
  1437. "styles": this.selector.css.selectorItemCategoryActionNode_selectAll,
  1438. "title" : "全选下级"
  1439. }).inject(this.node);
  1440. this.selectAllNode.addEvent( "click", function(ev){
  1441. if( this.isSelectedAll ){
  1442. this.unselectAll(ev);
  1443. this.selector.fireEvent("unselectCatgory",[this])
  1444. }else{
  1445. this.selectAll(ev);
  1446. this.selector.fireEvent("selectCatgory",[this])
  1447. }
  1448. ev.stopPropagation();
  1449. }.bind(this));
  1450. if( this.selector.css.selectorItemCategoryActionNode_selectAll_over ){
  1451. this.selectAllNode.addEvents( {
  1452. "mouseover" : function(ev){
  1453. if( !this.isSelectedAll )this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_over );
  1454. //ev.stopPropagation();
  1455. }.bind(this),
  1456. "mouseout" : function(ev){
  1457. if( !this.isSelectedAll )this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll );
  1458. //ev.stopPropagation();
  1459. }.bind(this)
  1460. })
  1461. }
  1462. }
  1463. this.textNode = new Element("div", {
  1464. "styles": this.selector.css.selectorItemCategoryTextNode,
  1465. "text": this._getShowName()
  1466. }).inject(this.node);
  1467. var m = this.textNode.getStyle("margin-left").toFloat()+indent;
  1468. this.textNode.setStyle("margin-left", ""+m+"px");
  1469. this.children = new Element("div", {
  1470. "styles": this.selector.css.selectorItemCategoryChildrenNode
  1471. }).inject(this.node, "after");
  1472. if (!this.selector.options.expand) this.children.setStyle("display", "none");
  1473. var subIdList = this.selector._getChildrenItemIds(this.data);
  1474. if (subIdList){
  1475. var count = subIdList.length;
  1476. this.childrenHeight = count*29;
  1477. this.children.setStyle("height", ""+this.childrenHeight+"px");
  1478. }
  1479. if (!this._hasChild()){
  1480. this.actionNode.setStyle("background", "transparent");
  1481. this.textNode.setStyle("color", "#777");
  1482. }
  1483. if( this.selectAllNode && !this._hasChildItem() ){
  1484. this.selectAllNode.setStyle("display", "none");
  1485. }
  1486. this.setEvent();
  1487. this.check();
  1488. this.afterLoad();
  1489. this.selector.fireEvent("postLoadCategory",[this]);
  1490. },
  1491. unselectAll : function(ev, exclude){
  1492. var excludeList = exclude || [];
  1493. if( exclude && typeOf(exclude) !== "array" )excludeList = [exclude];
  1494. ( this.subItems || [] ).each( function(item){
  1495. if(item.isSelected && !excludeList.contains(item) ){
  1496. item.unSelected();
  1497. }
  1498. }.bind(this));
  1499. if( this.selectAllNode && this.selector.css.selectorItemCategoryActionNode_selectAll ){
  1500. this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll );
  1501. }
  1502. this.isSelectedAll = false;
  1503. },
  1504. unselectAllNested : function( ev, exclude ){
  1505. this.unselectAll(ev, exclude );
  1506. if( this.subCategorys && this.subCategorys.length ){
  1507. this.subCategorys.each( function( category ){
  1508. category.unselectAllNested( ev, exclude )
  1509. })
  1510. }
  1511. },
  1512. selectAllNested : function(){
  1513. this.selectAll();
  1514. if( this.subCategorys && this.subCategorys.length ){
  1515. this.subCategorys.each( function( category ){
  1516. category.selectAllNested()
  1517. })
  1518. }
  1519. },
  1520. selectAll: function(ev){
  1521. if( this.loaded ){
  1522. this._selectAll( ev );
  1523. }else{
  1524. this.clickItem( function(){
  1525. this._selectAll( ev );
  1526. //this.children.setStyles({
  1527. // "display": "none",
  1528. // "height": "0px"
  1529. //});
  1530. //this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_collapse);
  1531. }.bind(this));
  1532. }
  1533. },
  1534. _selectAll : function( ev ){
  1535. if( !this.subItems || !this.subItems.length )return;
  1536. var count = this.selector.options.maxCount || this.selector.options.count;
  1537. if (!count) count = 0;
  1538. var selectedSubItemCount = 0;
  1539. this.subItems.each( function(item){
  1540. if(item.isSelected)selectedSubItemCount++
  1541. }.bind(this));
  1542. if ((count.toInt()===0) || (this.selector.selectedItems.length+(this.subItems.length-selectedSubItemCount))<=count){
  1543. this.subItems.each( function(item){
  1544. if(!item.isSelected)item.selected();
  1545. }.bind(this))
  1546. if( this.selectAllNode && this.selector.css.selectorItemCategoryActionNode_selectAll_selected ){
  1547. this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_selected );
  1548. }
  1549. this.isSelectedAll = true;
  1550. }else{
  1551. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "最多可选择"+count+"个选项", this.node);
  1552. }
  1553. },
  1554. afterLoad: function(){
  1555. if (this.level===1) this.clickItem();
  1556. },
  1557. clickItem: function( callback ){
  1558. if (this._hasChild()){
  1559. if (!this.fx){
  1560. this.fx = new Fx.Tween(this.children, {
  1561. "duration": 200
  1562. // "transition": Fx.Transitions.Cubic.easeIn
  1563. });
  1564. };
  1565. if (!this.fx.isRunning()){
  1566. var display = this.children.getStyle("display");
  1567. if (display === "none"){
  1568. this.children.setStyles({
  1569. "display": "block",
  1570. "height": "0px"
  1571. });
  1572. this.fx.start("height", "0px", ""+this.childrenHeight+"px");
  1573. this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_expand);
  1574. }else{
  1575. if (!this.childrenHeight) this.childrenHeight = this.children.getStyle("height").toFloat();
  1576. this.fx.start("height", ""+this.childrenHeight+"px", "0px").chain(function(){
  1577. this.children.setStyles({
  1578. "display": "none",
  1579. "height": "0px"
  1580. });
  1581. }.bind(this));
  1582. this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_collapse);
  1583. }
  1584. }
  1585. if(callback)callback()
  1586. }
  1587. },
  1588. overItem: function(){
  1589. //if (!this.isSelected){
  1590. // this.node.setStyles(this.selector.css.selectorItem_over);
  1591. // this.actionNode.setStyles(this.selector.css.selectorItemActionNode_over);
  1592. //}
  1593. if( this.selector.css.selectorItemCategory_over ){
  1594. this.node.setStyles(this.selector.css.selectorItemCategory_over);
  1595. }
  1596. var display = this.children.getStyle("display");
  1597. if( display === "none" ){
  1598. if( this._hasChild() && this.selector.css.selectorItemCategoryActionNode_collapse_over ){
  1599. this.actionNode.setStyles( this.selector.css.selectorItemCategoryActionNode_collapse_over )
  1600. }
  1601. }else{
  1602. if( this._hasChild() && this.selector.css.selectorItemCategoryActionNode_expand_over ){
  1603. this.actionNode.setStyles( this.selector.css.selectorItemCategoryActionNode_expand_over )
  1604. }
  1605. }
  1606. },
  1607. outItem: function(){
  1608. //if (!this.isSelected){
  1609. // this.node.setStyles(this.selector.css.selectorItem);
  1610. // this.actionNode.setStyles(this.selector.css.selectorItemActionNode);
  1611. //}
  1612. if( this.selector.css.selectorItemCategory_over ){
  1613. this.node.setStyles(this.selector.css.selectorItemCategory);
  1614. }
  1615. var display = this.children.getStyle("display");
  1616. if( display === "none" ){
  1617. if( this._hasChild() && this.selector.css.selectorItemCategoryActionNode_collapse_over ){
  1618. this.actionNode.setStyles( this.selector.css.selectorItemCategoryActionNode_collapse )
  1619. }
  1620. }else{
  1621. if( this._hasChild() && this.selector.css.selectorItemCategoryActionNode_expand_over ){
  1622. this.actionNode.setStyles( this.selector.css.selectorItemCategoryActionNode_expand )
  1623. }
  1624. }
  1625. },
  1626. _hasChild: function(){
  1627. var subIdList = this.selector._getChildrenItemIds(this.data);
  1628. if (subIdList) if (subIdList.length) return true;
  1629. return false;
  1630. },
  1631. _hasChildItem: function(){
  1632. return this._hasChild();
  1633. }
  1634. });
  1635. MWF.xApplication.Selector.Person.ItemGroupCategory = new Class({
  1636. Extends: MWF.xApplication.Selector.Person.ItemCategory,
  1637. _getShowName: function(){
  1638. return this.data.name;
  1639. },
  1640. _setIcon: function(){
  1641. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/groupicon.png)");
  1642. }
  1643. });
  1644. MWF.xApplication.Selector.Person.ItemRoleCategory = new Class({
  1645. Extends: MWF.xApplication.Selector.Person.ItemCategory,
  1646. _getShowName: function(){
  1647. return this.data.name;
  1648. },
  1649. _setIcon: function(){
  1650. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/roleicon.png)");
  1651. }
  1652. });
  1653. MWF.xApplication.Selector.Person.Filter = new Class({
  1654. Implements: [Options, Events],
  1655. options: {
  1656. "style": "default",
  1657. "groups": [],
  1658. "roles": []
  1659. },
  1660. initialize: function(value, options){
  1661. this.setOptions(options);
  1662. this.value = value;
  1663. this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  1664. },
  1665. filter: function(value, callback){
  1666. this.value = value;
  1667. var key = this.value;
  1668. if (this.options.groups.length || this.options.roles.length) key = {"key": key, "groupList": this.options.groupList, "roleList": this.options.roleList};
  1669. this.orgAction.listPersonByKey(function(json){
  1670. data = json.data;
  1671. if (callback) callback(data)
  1672. }.bind(this), null, key);
  1673. }
  1674. });