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