MSelector.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. //提供两种方式,一种是传入selectValue,selectText, 另外一种是 用onLoadData 或 loadData 加载数据,
  2. MWF.xDesktop.requireApp("Template", "MTooltips", null, false);
  3. var MSelector = new Class({
  4. Extends: MWF.widget.Common,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "width": "230px",
  9. "height": "30px",
  10. "defaultOptionLp" : "请选择",
  11. "trigger" : "delay", //immediately
  12. "isSetSelectedValue" : true,
  13. "isChangeOptionStyle" : true,
  14. "inputEnable" : false,
  15. "isCreateReadNode" : true, //适应给MDomitem的做法
  16. "emptyOptionEnable" : true,
  17. "containerIsTarget" : false,
  18. "tooltipWhenNoSelectValue" : false,
  19. "hasScrollBar" : true,
  20. "hideByClickBody" : false,
  21. "textField" : "",
  22. "valueField" : "",
  23. "value" : "",
  24. "text" : "",
  25. "defaultVaue" : "",
  26. "selectValue" : "",
  27. "selectText" : "",
  28. "isEdited" : true,
  29. "tooltipsOptions" : {
  30. axis: "y", //箭头在x轴还是y轴上展现
  31. position : { //node 固定的位置
  32. x : "center", //x轴上left center right, auto 系统自动计算
  33. y : "bottom" //y 轴上top middle bottom, auto 系统自动计算
  34. },
  35. event : "click", //事件类型,有target 时有效, mouseenter对应mouseleave,click 对应 container 的 click
  36. hiddenDelay : 200, //ms , 有target 且 事件类型为 mouseenter 时有效
  37. displayDelay : 0 //ms , 有target 且事件类型为 mouseenter 时有效
  38. }
  39. },
  40. initialize: function (container, options , app, css, dropdownContainer ) {
  41. this.setOptions(options);
  42. if( !this.options.isEdited && !this.options.isCreateReadNode ){
  43. }else{
  44. this.path = "../x_component_Template/$MSelector/";
  45. this.cssPath = "../x_component_Template/$MSelector/"+this.options.style+"/css.wcss";
  46. this._loadCss();
  47. if( css ){
  48. this.css = Object.merge( Object.clone(this.css), css )
  49. }
  50. }
  51. this.valSeparator = /,|;|\^\^|\|/; //如果是多值对象,作为用户选择的多个值的分隔符
  52. this.app = app;
  53. this.container = $(container);
  54. this.dropdownContainer = dropdownContainer || $(dropdownContainer);
  55. },
  56. load : function( callback ){
  57. if( this.options.isEdited ){
  58. this.loadEdit(callback)
  59. }else{
  60. this.loadRead(callback)
  61. }
  62. },
  63. initPara: function(){
  64. this.itemNodeList = [];
  65. this.itemNodeObject = {};
  66. this.value = this.options.value || this.options.text || this.options.defaultVaue;
  67. this.text = this.options.text || this.options.value || this.options.defaultVaue;
  68. this.textField = this.options.textField || this.options.valueField;
  69. this.valueField = this.options.valueField || this.options.textField;
  70. if( this.options.selectValue || this.options.selectText ){
  71. this.textField = "text";
  72. this.valueField = "value";
  73. var selectValue = this.options.selectValue;
  74. var selectText = this.options.selectText;
  75. this.selectValues = typeOf( selectValue ) == "array" ? selectValue : selectValue.split( this.valSeparator );
  76. this.selectTexts = typeOf( selectText ) == "array" ? selectText : selectText.split(this.valSeparator);
  77. this.data = [];
  78. if( this.options.emptyOptionEnable ){
  79. this.data.push({
  80. value : "",
  81. text : this.options.defaultOptionLp || ""
  82. })
  83. }
  84. this.selectValues.each( function( v,i ){
  85. this.data.push({
  86. value : v,
  87. text : this.selectTexts[i]
  88. })
  89. }.bind(this))
  90. }
  91. },
  92. loadRead: function(callback){
  93. this.initPara();
  94. var fun = function(){
  95. for( var i=0; i<this.data.length; i++ ){
  96. var d = this.data[i];
  97. if( this.options.text ){
  98. if( d[this.textField] == this.options.text ){
  99. this.value = d[this.valueField];
  100. this.text = this.options.text;
  101. this.currentItemData = d;
  102. break;
  103. }
  104. }else if( this.options.value ){
  105. if( d[this.valueField] == this.options.value ){
  106. this.value = this.options.value;
  107. this.text = d[this.textField];
  108. this.currentItemData = d;
  109. break;
  110. }
  111. }
  112. }
  113. this.loadReadNode( this.text );
  114. if( callback )callback();
  115. }.bind(this);
  116. if( this.data ){
  117. fun()
  118. }else{
  119. this._loadData( function( data ) {
  120. this.data = this.parseData(data);
  121. fun();
  122. }.bind(this))
  123. }
  124. },
  125. loadReadNode: function( text ){
  126. this.fireEvent( "loadReadNode", text );
  127. if( this.options.isCreateReadNode ){
  128. if( this.node )this.node.destroy();
  129. this.node = new Element("div", {
  130. styles : this.css.readNode,
  131. text : text
  132. }).inject( this.container );
  133. }
  134. },
  135. loadEdit:function( callback ){
  136. this.initPara();
  137. if( !this.node ){
  138. if( this.options.containerIsTarget ){
  139. this.node = this.container
  140. }else{
  141. this.node = new Element("div.selectNode", {
  142. styles : this.css.selectNode
  143. }).inject( this.container );
  144. this.node.setStyles({
  145. "width":this.options.width,
  146. "height":this.options.height
  147. });
  148. }
  149. }
  150. if( this.data ){
  151. this.createDefaultItem();
  152. this.loadContent( this.data );
  153. this.fireEvent("postLoad", [this]);
  154. }else{
  155. this._loadData( function( data ){
  156. this.data = this.parseData( data );
  157. this.createDefaultItem();
  158. this.loadContent( this.data );
  159. this.fireEvent("postLoad", [this]);
  160. }.bind(this))
  161. }
  162. //this.node.addEvent( "click" , function( ev ){
  163. // this.loadContent();
  164. // ev.stopPropagation();
  165. //}.bind(this));
  166. if(callback)callback();
  167. },
  168. resetOptions : function(){
  169. if( this.contentTooltip ){
  170. this.contentTooltip.destroy();
  171. this.contentTooltip = null;
  172. }
  173. if( this.node ){
  174. this.node.empty()
  175. }
  176. //if( this.node && this.options.containerIsTarget ){
  177. // var node = this.node;
  178. //
  179. // this.node = new Element("div.selectNode", {
  180. // styles : this.css.selectNode
  181. // }).inject( node, "after" );
  182. //
  183. // this.node.setStyles({
  184. // "width":this.options.width,
  185. // "height":this.options.height
  186. // });
  187. //
  188. // node.destroy();
  189. //}
  190. this.data = null;
  191. this.load();
  192. },
  193. addOption : function(text, value){
  194. var obj = {};
  195. obj[this.textField] = text;
  196. obj[this.valueField] = value;
  197. this.data.push( obj );
  198. if( this.contentTooltip ){
  199. this.contentTooltip.createItem(obj);
  200. }
  201. },
  202. deleteOption : function(value){
  203. for( var i=0; i<this.itemNodeList.length; i++ ){
  204. var listItemNode = this.itemNodeList[i];
  205. var data = listItemNode.retrieve("data");
  206. if( data[this.valueField] == value ){
  207. this.itemNodeList.erase(listItemNode);
  208. listItemNode.destroy();
  209. break;
  210. }
  211. }
  212. if(this.itemNodeObject[ value ])delete this.itemNodeObject[ value ];
  213. if(this.data){
  214. for( var i=0; i<this.data.length; i++ ) {
  215. var d = this.data[i];
  216. if( d[this.valueField] == value ){
  217. this.data.erase(d);
  218. }
  219. }
  220. }
  221. },
  222. loadContent : function( data ){
  223. if( !this.contentTooltip ){
  224. var width = parseInt(this.options.width)+"px";
  225. this.css.tooltipNode.width = width;
  226. this.css.tooltipNode["max-width"] = width;
  227. var options = Object.merge({
  228. hideByClickBody : this.options.hideByClickBody,
  229. nodeStyles : this.css.tooltipNode,
  230. onPostLoad : function(){
  231. if( this.selectArrowNode )this.selectArrowNode.setStyles( this.css.selectArrowNode_up );
  232. if( this.inputNode ){
  233. this.inputNode.focus();
  234. }
  235. var parent = this.node.getParent();
  236. var zIndex;
  237. while( parent ){
  238. zIndex = parent.getStyle("z-index");
  239. if( zIndex && parseFloat(zIndex).toString() !== "NaN" ){
  240. parent = null;
  241. }else{
  242. parent = parent.getParent();
  243. }
  244. }
  245. if( zIndex && parseFloat(zIndex).toString() !== "NaN" ){
  246. this.contentTooltip.node.setStyle("z-index", parseFloat( zIndex )+1)
  247. }else{
  248. this.contentTooltip.node.setStyle("z-index", "auto")
  249. }
  250. parent = this.node.getParent();
  251. while( parent ){
  252. var overflow = parent.getStyle("overflow");
  253. var overflowY = parent.getStyle("overflow-y");
  254. if( overflow === "auto" || overflow === "scroll" || overflowY === "auto" || overflowY === "scroll" ){
  255. this.scrollFun = function( e ){
  256. this.contentTooltip.setPosition();
  257. }.bind(this);
  258. this.scrollParentNode = parent;
  259. parent.addEvent( "scroll", this.scrollFun );
  260. parent = null;
  261. }else{
  262. parent = parent.getParent();
  263. }
  264. }
  265. }.bind(this),
  266. onPostInitialize : function(){
  267. if(this.options.trigger == "immediately" ){
  268. this.contentTooltip.load();
  269. }
  270. }.bind(this),
  271. onHide : function(){
  272. this.status = "hidden";
  273. if(this.selectArrowNode) this.selectArrowNode.setStyles( this.css.selectArrowNode );
  274. //this.node.setStyles(this.css.selectNode);
  275. if( this.scrollParentNode && this.scrollFun ){
  276. this.scrollParentNode.removeEvent("scroll", this.scrollFun);
  277. }
  278. }.bind(this)
  279. }, this.options.tooltipsOptions );
  280. this.contentTooltip = new MSelector.Tootips( this.dropdownContainer || this.app.content, this.node, this.app, data, options );
  281. this.contentTooltip.selector = this;
  282. }
  283. },
  284. setWidth : function( width ){
  285. this.options.width = width;
  286. if( this.contentTooltip ){
  287. this.contentTooltip.options.nodeStyles.width = width;
  288. this.contentTooltip.options.nodeStyles["max-width"] = width;
  289. if( this.contentTooltip.nodeStyles ){
  290. this.contentTooltip.nodeStyles.width = width;
  291. this.contentTooltip.nodeStyles["max-width"] = width;
  292. }
  293. if(this.contentTooltip.node){
  294. this.contentTooltip.node.setStyle("width",width);
  295. this.contentTooltip.node.setStyle("max-width",width);
  296. }
  297. }
  298. if( this.node ){
  299. this.node.setStyle("width",width);
  300. }
  301. this.selectValueNode.setStyle("width",parseInt(width)-25);
  302. },
  303. createDefaultItem:function(){
  304. if( this.options.containerIsTarget )return;
  305. this.selectValueNode = new Element("div.selectValueNode",{
  306. "styles":this.css.selectValueNode
  307. }).inject(this.node);
  308. this.selectValueNode.setStyles({
  309. "width":(parseInt(this.options.width)-parseInt(this.options.height)-10)+"px",
  310. "height":this.options.height,
  311. "line-height":this.options.height
  312. });
  313. var d = this._getData( this.options.value );
  314. var text = d ? d[ this.textField ] : this.options.value;
  315. if( this.options.inputEnable ){
  316. this.inputNode = new Element("input", {
  317. "value" : text || this.options.defaultOptionLp ,
  318. "styles" : this.css.inputNode
  319. }).inject( this.selectValueNode );
  320. this.inputNode.addEvents( {
  321. focus : function(){
  322. if( this.inputNode.get("value") == this.options.defaultOptionLp ){
  323. this.inputNode.set("value", "" );
  324. }
  325. }.bind(this),
  326. blur : function(){
  327. var flag = false;
  328. var val = this.inputNode.get("value");
  329. if( val == "" ){
  330. this.inputNode.set("value", this.options.defaultOptionLp);
  331. }else{
  332. for( var i=0; i<this.data.length; i++ ){
  333. var d = this.data[i];
  334. if( d[ this.textField ] == val ){
  335. var itemNode = this.itemNodeObject[ d[this.valueField] ];
  336. this.setCurrentItem( itemNode );
  337. flag = true;
  338. break;
  339. }
  340. }
  341. if( !flag ){
  342. this.cancelCurrentItem();
  343. }
  344. }
  345. }.bind(this)
  346. } )
  347. }else{
  348. this.selectValueNode.set("text", text || this.options.defaultOptionLp);
  349. }
  350. this.selectArrowNode = new Element("div.selectArrowNode",{
  351. "styles":this.css.selectArrowNode
  352. }).inject(this.node);
  353. this.selectArrowNode.setStyles({
  354. "width":this.options.height,
  355. "height":this.options.height
  356. });
  357. },
  358. setCurrentItem : function( itemNode ){
  359. var data = itemNode.retrieve( "data" );
  360. if( this.currentItemNode ){
  361. this.currentItemNode.setStyles( this.css.listItemNode );
  362. }
  363. this.currentItemNode = itemNode;
  364. this.currentItemData = data;
  365. this.currentItemText = itemNode.get("text");
  366. if( this.options.isChangeOptionStyle )itemNode.setStyles( this.css.listItemNode_current );
  367. if( this.options.isSetSelectedValue && this.selectValueNode ){
  368. if( this.options.inputEnable ){
  369. this.inputNode.set("value", data[ this.textField ] );
  370. }else{
  371. this.selectValueNode.set("text", data[ this.textField ] );
  372. }
  373. }
  374. },
  375. cancelCurrentItem: function(){
  376. if( this.currentItemNode ){
  377. this.currentItemNode.setStyles( this.css.listItemNode );
  378. }
  379. this.currentItemNode = null;
  380. this.currentItemData = null;
  381. this.currentItemText = null;
  382. },
  383. parseData: function( data ){
  384. if( typeOf( data[0] ) == "string" ){
  385. var arr = [];
  386. this.textField = "text";
  387. this.valueField = "value";
  388. if(this.options.emptyOptionEnable ){
  389. arr.push({
  390. value : "",
  391. text : this.options.defaultOptionLp || ""
  392. });
  393. }
  394. data.each( function(d){
  395. arr.push({
  396. value : d,
  397. text : d
  398. })
  399. }.bind(this));
  400. return arr;
  401. }else{
  402. if( this.options.emptyOptionEnable && this.textField ){
  403. var obj = {};
  404. obj[ this.textField ] = this.options.defaultOptionLp || "";
  405. if( this.valueField != this.textField )obj[ this.valueField ] = "";
  406. data.unshift( obj )
  407. }
  408. return data;
  409. }
  410. },
  411. destroy : function(){
  412. if( this.node )this.node.destroy();
  413. if( this.contentTooltip )this.contentTooltip.destroy();
  414. },
  415. showTooltip : function(){
  416. this.contentTooltip.load();
  417. },
  418. hide : function(){
  419. this.status = "hidden";
  420. if(this.selectArrowNode) this.selectArrowNode.setStyles( this.css.selectArrowNode );
  421. if( this.contentTooltip )this.contentTooltip.hide();
  422. },
  423. setValue : function( value ){
  424. if( this.options.isEdited ){
  425. var itemNode = this.itemNodeObject[ value ];
  426. if( itemNode ){
  427. this.setCurrentItem( itemNode );
  428. }else if( this.options.inputEnable ) {
  429. var d = this._getData( value );
  430. if( d ){
  431. this.inputNode.set("value", d[ this.textField ] );
  432. }else{
  433. this.inputNode.set("value", value );
  434. }
  435. }else{
  436. if( this.options.isSetSelectedValue && this.selectValueNode ){
  437. var d = this._getData( value );
  438. if( d ) {
  439. this.selectValueNode.set("text", d[this.textField]);
  440. }else{
  441. this.selectValueNode.set("text", value || "");
  442. }
  443. this.value = value;
  444. }
  445. }
  446. }else{
  447. var d = this._getData( value );
  448. if( d ){
  449. this.loadReadNode( d[this.textField] );
  450. }else{
  451. this.loadReadNode( value );
  452. }
  453. }
  454. },
  455. get : function(){
  456. return {
  457. "value" : this.getValue(),
  458. "text" : this.getText()
  459. }
  460. },
  461. getValue : function(){
  462. if( this.options.isEdited ){
  463. if( this.currentItemData && this.valueField ) {
  464. return this.currentItemData[this.valueField]
  465. }else if( this.inputNode ){
  466. return this.inputNode.get("value");
  467. }else{
  468. return this.value;
  469. }
  470. }else{
  471. return this.value;
  472. }
  473. },
  474. getText : function(){
  475. if( this.options.isEdited ){
  476. if( this.currentItemData && this.textField ) {
  477. return this.currentItemData[this.textField]
  478. }else if( this.inputNode ){
  479. var d = this._getData( this.inputNode.get("value"), "text" );
  480. if( d ){
  481. return d[ this.textField ];
  482. }else{
  483. return this.inputNode.get("value");
  484. }
  485. }else{
  486. return this.text;
  487. }
  488. }else{
  489. return this.text;
  490. }
  491. },
  492. getData : function(){
  493. if( this.currentItemData )return this.currentItemData;
  494. if( this.inputNode )return this.inputNode.get("value");
  495. if( !this.options.text || !this.options.value )return null;
  496. for( var i=0; i<this.data.length; i++ ){
  497. var d = this.data[i];
  498. if( this.options.text ){
  499. if( d[this.textField] == this.options.text ){
  500. return d;
  501. }
  502. }else if( this.options.value ){
  503. if( d[this.valueField] == this.options.value ){
  504. return d;
  505. }
  506. }
  507. }
  508. return null;
  509. },
  510. _getData : function( vort, type ){
  511. for( var i=0; i<this.data.length; i++ ){
  512. var d = this.data[i];
  513. if( type == "text" ){
  514. if( d[this.textField] == vort ){
  515. return d;
  516. }
  517. }else{
  518. if( d[this.valueField] == vort ){
  519. return d;
  520. }
  521. }
  522. }
  523. return null;
  524. },
  525. _selectItem : function( itemNode, itemData, ev ){
  526. // this.fireEvent("selectItem", [itemNode, itemData, ev] );
  527. },
  528. _loadData : function( callback ){
  529. //if(callback)callback();
  530. this.fireEvent("loadData",callback );
  531. },
  532. _postCreateItem: function(listItemNode, data){
  533. }
  534. });
  535. MSelector.Tootips = new Class({
  536. Extends: MTooltips,
  537. options : {
  538. axis: "y", //箭头在x轴还是y轴上展现
  539. position : { //node 固定的位置
  540. x : "center", //x轴上left center right, auto 系统自动计算
  541. y : "bottom" //y 轴上top middle bottom, auto 系统自动计算
  542. },
  543. event : "click", //事件类型,有target 时有效, mouseenter对应mouseleave,click 对应 container 的 click
  544. hiddenDelay : 200, //ms , 有target 且 事件类型为 mouseenter 时有效
  545. displayDelay : 0, //ms , 有target 且事件类型为 mouseenter 时有效
  546. hasArrow : false
  547. },
  548. _customNode : function( node, contentNode ){
  549. //var width = ( parseInt( this.selector.options.width ) )+ "px";
  550. //node.setStyles({
  551. // "width": width,
  552. // "max-width": width
  553. //});
  554. debugger;
  555. if( this.data && this.data.length > 0 ){
  556. this.createItemList( this.data, contentNode )
  557. }else if( this.selector.options.tooltipWhenNoSelectValue ){
  558. this.createNoSelectValueNode( contentNode );
  559. }
  560. },
  561. createNoSelectValueNode:function( node ){
  562. var _selector = this.selector;
  563. this.css = _selector.css;
  564. if(_selector.selectArrowNode)_selector.selectArrowNode.setStyles( this.css.selectArrowNode_up );
  565. _selector.listContentNode = new Element("div.listContentNode",{
  566. "styles":this.css.listContentNode
  567. }).inject( node );
  568. _selector.listNode = new Element("div.listNode",{
  569. "styles":this.css.listNode
  570. }).inject(_selector.listContentNode);
  571. var noTooltipNode = new Element("div.listItemNode",{
  572. "styles":this.css.listItemNode,
  573. "text" : _selector.options.tooltipWhenNoSelectValue
  574. }).inject(_selector.listNode);
  575. var height = parseFloat(_selector.options.height)+"px";
  576. noTooltipNode.setStyles({
  577. "height": height,
  578. "line-height":height
  579. });
  580. },
  581. createItemList:function(data, node){
  582. data = data || [];
  583. var _selector = this.selector;
  584. this.css = _selector.css;
  585. if(_selector.selectArrowNode)_selector.selectArrowNode.setStyles( this.css.selectArrowNode_up );
  586. _selector.listContentNode = new Element("div.listContentNode",{
  587. "styles":this.css.listContentNode
  588. }).inject( node );
  589. //_selector.listContentNode.setStyles({
  590. // "width": node.getSize().x+"px"
  591. //});
  592. _selector.listNode = new Element("div.listNode",{
  593. "styles":this.css.listNode
  594. }).inject(_selector.listContentNode);
  595. if( _selector.options.hasScrollBar )_selector.setScrollBar(_selector.listNode);
  596. data.each(function(d){
  597. this.createItem( d );
  598. }.bind(this));
  599. },
  600. createItem: function( data ){
  601. var _selector = this.selector;
  602. if( !_selector.listNode )return;
  603. var listItemNode = new Element("div.listItemNode",{
  604. "styles":this.css.listItemNode,
  605. "text": data[ _selector.textField ]
  606. }).inject(_selector.listNode);
  607. listItemNode.setStyles({
  608. "height":_selector.options.height,
  609. "line-height":_selector.options.height
  610. });
  611. if(data)listItemNode.store("data",data);
  612. listItemNode.addEvents({
  613. "mousedown" : function(ev){
  614. ev.stopPropagation();
  615. },
  616. "click":function(ev){
  617. var _self = this.obj;
  618. var data = this.itemNode.retrieve( "data" );
  619. _self.selector.setCurrentItem( this.itemNode );
  620. _self.selector._selectItem( this.itemNode, data, ev );
  621. _self.selector.fireEvent("selectItem", [ this.itemNode, data, ev ] );
  622. _self.hide();
  623. ev.stopPropagation();
  624. }.bind({ obj : this, itemNode : listItemNode }),
  625. "mouseover":function(){
  626. if( this.obj.selector.currentItemNode != this.itemNode || !this.obj.selector.options.isChangeOptionStyle ){
  627. this.itemNode.setStyles( this.obj.selector.css.listItemNode_over );
  628. if( this.obj.selector.options.mainColor_bg )this.itemNode.addClass(this.obj.selector.options.mainColor_bg)
  629. }
  630. }.bind( {obj : this, itemNode : listItemNode }),
  631. "mouseout":function(){
  632. if( this.obj.selector.currentItemNode != this.itemNode || !this.obj.selector.options.isChangeOptionStyle ){
  633. this.itemNode.setStyles( this.obj.selector.css.listItemNode );
  634. if( this.obj.selector.options.mainColor_bg )this.itemNode.removeClass(this.obj.selector.options.mainColor_bg)
  635. }
  636. }.bind( {obj : this, itemNode : listItemNode })
  637. });
  638. _selector.itemNodeList.push( listItemNode );
  639. _selector.itemNodeObject[ data[ _selector.valueField ] ] = listItemNode;
  640. var isCurrent = false;
  641. if( _selector.currentItemData ){
  642. isCurrent = data[ _selector.valueField ] == _selector.currentItemData[ _selector.valueField ];
  643. }else if( _selector.value ){
  644. isCurrent = data[ _selector.valueField ] == _selector.value;
  645. }else if( _selector.text ){
  646. isCurrent = data[ _selector.textField ] == _selector.text;
  647. }
  648. if( isCurrent )_selector.setCurrentItem( listItemNode );
  649. _selector.fireEvent("postCreateItem", [ listItemNode, data ] );
  650. _selector._postCreateItem(listItemNode, data)
  651. }
  652. });
  653. MWF.xApplication.Template = MWF.xApplication.Template || {};
  654. MWF.xApplication.Template.MSelector = MSelector;