]> git.wh0rd.org Git - tt-rss.git/blob - lib/dijit/form/ComboBoxMixin.js.uncompressed.js
upgrade dojo to 1.8.3 (refs #570)
[tt-rss.git] / lib / dijit / form / ComboBoxMixin.js.uncompressed.js
1 require({cache:{
2 'url:dijit/form/templates/DropDownBox.html':"<div class=\"dijit dijitReset dijitInline dijitLeft\"\n\tid=\"widget_${id}\"\n\trole=\"combobox\"\n\t><div class='dijitReset dijitRight dijitButtonNode dijitArrowButton dijitDownArrowButton dijitArrowButtonContainer'\n\t\tdata-dojo-attach-point=\"_buttonNode, _popupStateNode\" role=\"presentation\"\n\t\t><input class=\"dijitReset dijitInputField dijitArrowButtonInner\" value=\"&#9660; \" type=\"text\" tabIndex=\"-1\" readonly=\"readonly\" role=\"button presentation\" aria-hidden=\"true\"\n\t\t\t${_buttonInputDisabled}\n\t/></div\n\t><div class='dijitReset dijitValidationContainer'\n\t\t><input class=\"dijitReset dijitInputField dijitValidationIcon dijitValidationInner\" value=\"&#935; \" type=\"text\" tabIndex=\"-1\" readonly=\"readonly\" role=\"presentation\"\n\t/></div\n\t><div class=\"dijitReset dijitInputField dijitInputContainer\"\n\t\t><input class='dijitReset dijitInputInner' ${!nameAttrSetting} type=\"text\" autocomplete=\"off\"\n\t\t\tdata-dojo-attach-point=\"textbox,focusNode\" role=\"textbox\" aria-haspopup=\"true\"\n\t/></div\n></div>\n"}});
3 define("dijit/form/ComboBoxMixin", [
4         "dojo/_base/declare", // declare
5         "dojo/_base/Deferred",
6         "dojo/_base/kernel", // kernel.deprecated
7         "dojo/_base/lang", // lang.mixin
8         "dojo/store/util/QueryResults",
9         "./_AutoCompleterMixin",
10         "./_ComboBoxMenu",
11         "../_HasDropDown",
12         "dojo/text!./templates/DropDownBox.html"
13 ], function(declare, Deferred, kernel, lang, QueryResults, _AutoCompleterMixin, _ComboBoxMenu, _HasDropDown, template){
14
15
16         // module:
17         //              dijit/form/ComboBoxMixin
18
19         return declare("dijit.form.ComboBoxMixin", [_HasDropDown, _AutoCompleterMixin], {
20                 // summary:
21                 //              Provides main functionality of ComboBox widget
22
23                 // dropDownClass: [protected extension] Function String
24                 //              Dropdown widget class used to select a date/time.
25                 //              Subclasses should specify this.
26                 dropDownClass: _ComboBoxMenu,
27
28                 // hasDownArrow: Boolean
29                 //              Set this textbox to have a down arrow button, to display the drop down list.
30                 //              Defaults to true.
31                 hasDownArrow: true,
32
33                 templateString: template,
34
35                 baseClass: "dijitTextBox dijitComboBox",
36
37                 /*=====
38                 // store: [const] dojo/store/api/Store|dojo/data/api/Read
39                 //              Reference to data provider object used by this ComboBox.
40                 //
41                 //              Should be dojo/store/api/Store, but dojo/data/api/Read supported
42                 //              for backwards compatibility.
43                 store: null,
44                 =====*/
45
46                 // Set classes like dijitDownArrowButtonHover depending on
47                 // mouse action over button node
48                 cssStateNodes: {
49                         "_buttonNode": "dijitDownArrowButton"
50                 },
51
52                 _setHasDownArrowAttr: function(/*Boolean*/ val){
53                         this._set("hasDownArrow", val);
54                         this._buttonNode.style.display = val ? "" : "none";
55                 },
56
57                 _showResultList: function(){
58                         // hide the tooltip
59                         this.displayMessage("");
60                         this.inherited(arguments);
61                 },
62
63                 _setStoreAttr: function(store){
64                         // For backwards-compatibility, accept dojo.data store in addition to dojo/store/api/Store.  Remove in 2.0.
65                         if(!store.get){
66                                 lang.mixin(store, {
67                                         _oldAPI: true,
68                                         get: function(id){
69                                                 // summary:
70                                                 //              Retrieves an object by it's identity. This will trigger a fetchItemByIdentity.
71                                                 //              Like dojo/store/DataStore.get() except returns native item.
72                                                 var deferred = new Deferred();
73                                                 this.fetchItemByIdentity({
74                                                         identity: id,
75                                                         onItem: function(object){
76                                                                 deferred.resolve(object);
77                                                         },
78                                                         onError: function(error){
79                                                                 deferred.reject(error);
80                                                         }
81                                                 });
82                                                 return deferred.promise;
83                                         },
84                                         query: function(query, options){
85                                                 // summary:
86                                                 //              Queries the store for objects.   Like dojo/store/DataStore.query()
87                                                 //              except returned Deferred contains array of native items.
88                                                 var deferred = new Deferred(function(){ fetchHandle.abort && fetchHandle.abort(); });
89                                                 deferred.total = new Deferred();
90                                                 var fetchHandle = this.fetch(lang.mixin({
91                                                         query: query,
92                                                         onBegin: function(count){
93                                                                 deferred.total.resolve(count);
94                                                         },
95                                                         onComplete: function(results){
96                                                                 deferred.resolve(results);
97                                                         },
98                                                         onError: function(error){
99                                                                 deferred.reject(error);
100                                                         }
101                                                 }, options));
102                                                 return QueryResults(deferred);
103                                         }
104                                 });
105                         }
106                         this._set("store", store);
107                 },
108
109                 postMixInProperties: function(){
110                         // Since _setValueAttr() depends on this.store, _setStoreAttr() needs to execute first.
111                         // Unfortunately, without special code, it ends up executing second.
112                         var store = this.params.store || this.store;
113                         if(store){
114                                 this._setStoreAttr(store);
115                         }
116
117                         this.inherited(arguments);
118
119                         // User may try to access this.store.getValue() etc.  in a custom labelFunc() function.
120                         // It's not available with the new data store for handling inline <option> tags, so add it.
121                         if(!this.params.store && !this.store._oldAPI){
122                                 var clazz = this.declaredClass;
123                                 lang.mixin(this.store, {
124                                         getValue: function(item, attr){
125                                                 kernel.deprecated(clazz + ".store.getValue(item, attr) is deprecated for builtin store.  Use item.attr directly", "", "2.0");
126                                                 return item[attr];
127                                         },
128                                         getLabel: function(item){
129                                                 kernel.deprecated(clazz + ".store.getLabel(item) is deprecated for builtin store.  Use item.label directly", "", "2.0");
130                                                 return item.name;
131                                         },
132                                         fetch: function(args){
133                                                 kernel.deprecated(clazz + ".store.fetch() is deprecated for builtin store.", "Use store.query()", "2.0");
134                                                 var shim = ["dojo/data/ObjectStore"];   // indirection so it doesn't get rolled into a build
135                                                 require(shim, lang.hitch(this, function(ObjectStore){
136                                                         new ObjectStore({objectStore: this}).fetch(args);
137                                                 }));
138                                         }
139                                 });
140                         }
141                 }
142         });
143 });