_FormWidget.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. define("dijit/form/_FormWidget", [
  2. "dojo/_base/declare", // declare
  3. "dojo/_base/kernel", // kernel.deprecated
  4. "dojo/ready",
  5. "../_Widget",
  6. "../_CssStateMixin",
  7. "../_TemplatedMixin",
  8. "./_FormWidgetMixin"
  9. ], function(declare, kernel, ready, _Widget, _CssStateMixin, _TemplatedMixin, _FormWidgetMixin){
  10. /*=====
  11. var _Widget = dijit._Widget;
  12. var _TemplatedMixin = dijit._TemplatedMixin;
  13. var _CssStateMixin = dijit._CssStateMixin;
  14. var _FormWidgetMixin = dijit.form._FormWidgetMixin;
  15. =====*/
  16. // module:
  17. // dijit/form/_FormWidget
  18. // summary:
  19. // FormWidget
  20. // Back compat w/1.6, remove for 2.0
  21. if(!kernel.isAsync){
  22. ready(0, function(){
  23. var requires = ["dijit/form/_FormValueWidget"];
  24. require(requires); // use indirection so modules not rolled into a build
  25. });
  26. }
  27. return declare("dijit.form._FormWidget", [_Widget, _TemplatedMixin, _CssStateMixin, _FormWidgetMixin], {
  28. // summary:
  29. // Base class for widgets corresponding to native HTML elements such as <checkbox> or <button>,
  30. // which can be children of a <form> node or a `dijit.form.Form` widget.
  31. //
  32. // description:
  33. // Represents a single HTML element.
  34. // All these widgets should have these attributes just like native HTML input elements.
  35. // You can set them during widget construction or afterwards, via `dijit._Widget.attr`.
  36. //
  37. // They also share some common methods.
  38. setDisabled: function(/*Boolean*/ disabled){
  39. // summary:
  40. // Deprecated. Use set('disabled', ...) instead.
  41. kernel.deprecated("setDisabled("+disabled+") is deprecated. Use set('disabled',"+disabled+") instead.", "", "2.0");
  42. this.set('disabled', disabled);
  43. },
  44. setValue: function(/*String*/ value){
  45. // summary:
  46. // Deprecated. Use set('value', ...) instead.
  47. kernel.deprecated("dijit.form._FormWidget:setValue("+value+") is deprecated. Use set('value',"+value+") instead.", "", "2.0");
  48. this.set('value', value);
  49. },
  50. getValue: function(){
  51. // summary:
  52. // Deprecated. Use get('value') instead.
  53. kernel.deprecated(this.declaredClass+"::getValue() is deprecated. Use get('value') instead.", "", "2.0");
  54. return this.get('value');
  55. },
  56. postMixInProperties: function(){
  57. // Setup name=foo string to be referenced from the template (but only if a name has been specified)
  58. // Unfortunately we can't use _setNameAttr to set the name due to IE limitations, see #8484, #8660.
  59. // Regarding escaping, see heading "Attribute values" in
  60. // http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.3.2
  61. this.nameAttrSetting = this.name ? ('name="' + this.name.replace(/'/g, "&quot;") + '"') : '';
  62. this.inherited(arguments);
  63. },
  64. // Override automatic assigning type --> focusNode, it causes exception on IE.
  65. // Instead, type must be specified as ${type} in the template, as part of the original DOM
  66. _setTypeAttr: null
  67. });
  68. });