ComboBoxMixin.js.uncompressed.js 5.6 KB

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