ttrss/lib/dijit/form/_FormSelectWidget.js

2 lines
9.1 KiB
JavaScript
Raw Permalink Normal View History

2012-08-14 14:59:10 +00:00
//>>built
2023-04-09 08:14:46 +00:00
define("dijit/form/_FormSelectWidget",["dojo/_base/array","dojo/_base/Deferred","dojo/aspect","dojo/data/util/sorter","dojo/_base/declare","dojo/dom","dojo/dom-class","dojo/_base/kernel","dojo/_base/lang","dojo/query","dojo/when","dojo/store/util/QueryResults","./_FormValueWidget"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d){var _e=_5("dijit.form._FormSelectWidget",_d,{multiple:false,options:null,store:null,_setStoreAttr:function(_f){if(this._created){this._deprecatedSetStore(_f);}},query:null,_setQueryAttr:function(_10){if(this._created){this._deprecatedSetStore(this.store,this.selectedValue,{query:_10});}},queryOptions:null,_setQueryOptionsAttr:function(_11){if(this._created){this._deprecatedSetStore(this.store,this.selectedValue,{queryOptions:_11});}},labelAttr:"",onFetch:null,sortByLabel:true,loadChildrenOnOpen:false,onLoadDeferred:null,getOptions:function(_12){var _13=this.options||[];if(_12==null){return _13;}if(_9.isArrayLike(_12)){return _1.map(_12,function(_14){return this.getOptions(_14);},this);}if(_9.isString(_12)){_12={value:_12};}if(_9.isObject(_12)){if(!_1.some(_13,function(_15,idx){for(var a in _12){if(!(a in _15)||_15[a]!=_12[a]){return false;}}_12=idx;return true;})){_12=-1;}}if(_12>=0&&_12<_13.length){return _13[_12];}return null;},addOption:function(_16){_1.forEach(_9.isArrayLike(_16)?_16:[_16],function(i){if(i&&_9.isObject(i)){this.options.push(i);}},this);this._loadChildren();},removeOption:function(_17){var _18=this.getOptions(_9.isArrayLike(_17)?_17:[_17]);_1.forEach(_18,function(_19){if(_19){this.options=_1.filter(this.options,function(_1a){return (_1a.value!==_19.value||_1a.label!==_19.label);});this._removeOptionItem(_19);}},this);this._loadChildren();},updateOption:function(_1b){_1.forEach(_9.isArrayLike(_1b)?_1b:[_1b],function(i){var _1c=this.getOptions({value:i.value}),k;if(_1c){for(k in i){_1c[k]=i[k];}}},this);this._loadChildren();},setStore:function(_1d,_1e,_1f){_8.deprecated(this.declaredClass+"::setStore(store, selectedValue, fetchArgs) is deprecated. Use set('query', fetchArgs.query), set('queryOptions', fetchArgs.queryOptions), set('store', store), or set('value', selectedValue) instead.","","2.0");this._deprecatedSetStore(_1d,_1e,_1f);},_deprecatedSetStore:function(_20,_21,_22){var _23=this.store;_22=_22||{};if(_23!==_20){var h;while((h=this._notifyConnections.pop())){h.remove();}if(!_20.get){_9.mixin(_20,{_oldAPI:true,get:function(id){var _24=new _2();this.fetchItemByIdentity({identity:id,onItem:function(_25){_24.resolve(_25);},onError:function(_26){_24.reject(_26);}});return _24.promise;},query:function(_27,_28){var _29=new _2(function(){if(_2a.abort){_2a.abort();}});_29.total=new _2();var _2a=this.fetch(_9.mixin({query:_27,onBegin:function(_2b){_29.total.resolve(_2b);},onComplete:function(_2c){_29.resolve(_2c);},onError:function(_2d){_29.reject(_2d);}},_28));return new _c(_29);}});if(_20.getFeatures()["dojo.data.api.Notification"]){this._notifyConnections=[_3.after(_20,"onNew",_9.hitch(this,"_onNewItem"),true),_3.after(_20,"onDelete",_9.hitch(this,"_onDeleteItem"),true),_3.after(_20,"onSet",_9.hitch(this,"_onSetItem"),true)];}}this._set("store",_20);}if(this.options&&this.options.length){this.removeOption(this.options);}if(this._queryRes&&this._queryRes.close){this._queryRes.close();}if(this._observeHandle&&this._observeHandle.remove){this._observeHandle.remove();this._observeHandle=null;}if(_22.query){this._set("query",_22.query);}if(_22.queryOptions){this._set("queryOptions",_22.queryOptions);}if(_20&&_20.query){this._loadingStore=true;this.onLoadDeferred=new _2();this._queryRes=_20.query(this.query,this.queryOptions);_b(this._queryRes,_9.hitch(this,function(_2e){if(this.sortByLabel&&!_22.sort&&_2e.length){if(_20.getValue){_2e.sort(_4.createSortFunction([{attribute:_20.getLabelAttributes(_2e[0])[0]}],_20));}else{var _2f=this.labelAttr;_2e.sort(function(a,b){return a[_2f]>b[_2f]?1:b[_2f]>a[_2f]?-1:0;});}}if(_22.onFetch){_2e=_22.onFetch.call(this,_2e,_22);}_1.forEach(_2e,function(i){this._addOptionForItem(i);},this);if(this._queryRes.observe){this._observeHandle=this._queryR