Textarea.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. define("dijit/form/Textarea", [
  2. "dojo/_base/declare", // declare
  3. "dojo/dom-style", // domStyle.set
  4. "./_ExpandingTextAreaMixin",
  5. "./SimpleTextarea"
  6. ], function(declare, domStyle, _ExpandingTextAreaMixin, SimpleTextarea){
  7. /*=====
  8. var _ExpandingTextAreaMixin = dijit.form._ExpandingTextAreaMixin;
  9. var SimpleTextarea = dijit.form.SimpleTextarea;
  10. =====*/
  11. // module:
  12. // dijit/form/Textarea
  13. // summary:
  14. // A textarea widget that adjusts it's height according to the amount of data.
  15. return declare("dijit.form.Textarea", [SimpleTextarea, _ExpandingTextAreaMixin], {
  16. // summary:
  17. // A textarea widget that adjusts it's height according to the amount of data.
  18. //
  19. // description:
  20. // A textarea that dynamically expands/contracts (changing it's height) as
  21. // the user types, to display all the text without requiring a scroll bar.
  22. //
  23. // Takes nearly all the parameters (name, value, etc.) that a vanilla textarea takes.
  24. // Rows is not supported since this widget adjusts the height.
  25. //
  26. // example:
  27. // | <textarea data-dojo-type="dijit.form.TextArea">...</textarea>
  28. // TODO: for 2.0, rename this to ExpandingTextArea, and rename SimpleTextarea to TextArea
  29. baseClass: "dijitTextBox dijitTextArea dijitExpandingTextArea",
  30. // Override SimpleTextArea.cols to default to width:100%, for backward compatibility
  31. cols: "",
  32. buildRendering: function(){
  33. this.inherited(arguments);
  34. // tweak textarea style to reduce browser differences
  35. domStyle.set(this.textbox, { overflowY: 'hidden', overflowX: 'auto', boxSizing: 'border-box', MsBoxSizing: 'border-box', WebkitBoxSizing: 'border-box', MozBoxSizing: 'border-box' });
  36. }
  37. });
  38. });