MSelector.js 26 KB

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