_FormValueWidget.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. define("dijit/form/_FormValueWidget", [
  2. "dojo/_base/declare", // declare
  3. "dojo/_base/sniff", // has("ie")
  4. "./_FormWidget",
  5. "./_FormValueMixin"
  6. ], function(declare, has, _FormWidget, _FormValueMixin){
  7. /*=====
  8. var _FormWidget = dijit.form._FormWidget;
  9. var _FormValueMixin = dijit.form._FormValueMixin;
  10. =====*/
  11. // module:
  12. // dijit/form/_FormValueWidget
  13. // summary:
  14. // FormValueWidget
  15. return declare("dijit.form._FormValueWidget", [_FormWidget, _FormValueMixin],
  16. {
  17. // summary:
  18. // Base class for widgets corresponding to native HTML elements such as <input> or <select> that have user changeable values.
  19. // description:
  20. // Each _FormValueWidget represents a single input value, and has a (possibly hidden) <input> element,
  21. // to which it serializes it's input value, so that form submission (either normal submission or via FormBind?)
  22. // works as expected.
  23. // Don't attempt to mixin the 'type', 'name' attributes here programatically -- they must be declared
  24. // directly in the template as read by the parser in order to function. IE is known to specifically
  25. // require the 'name' attribute at element creation time. See #8484, #8660.
  26. _layoutHackIE7: function(){
  27. // summary:
  28. // Work around table sizing bugs on IE7 by forcing redraw
  29. if(has("ie") == 7){ // fix IE7 layout bug when the widget is scrolled out of sight
  30. var domNode = this.domNode;
  31. var parent = domNode.parentNode;
  32. var pingNode = domNode.firstChild || domNode; // target node most unlikely to have a custom filter
  33. var origFilter = pingNode.style.filter; // save custom filter, most likely nothing
  34. var _this = this;
  35. while(parent && parent.clientHeight == 0){ // search for parents that haven't rendered yet
  36. (function ping(){
  37. var disconnectHandle = _this.connect(parent, "onscroll",
  38. function(){
  39. _this.disconnect(disconnectHandle); // only call once
  40. pingNode.style.filter = (new Date()).getMilliseconds(); // set to anything that's unique
  41. setTimeout(function(){ pingNode.style.filter = origFilter }, 0); // restore custom filter, if any
  42. }
  43. );
  44. })();
  45. parent = parent.parentNode;
  46. }
  47. }
  48. }
  49. });
  50. });