PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/tatami-1.1/j2ee/lib/tatami/com/objetdirect/tatami/public/dijit/form/CheckBox.js

http://tatami.googlecode.com/
JavaScript | 119 lines | 68 code | 18 blank | 33 comment | 12 complexity | 81d2cf0f92d513607e74a256286f69bc MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, LGPL-2.0, MIT
  1. if(!dojo._hasResource["dijit.form.CheckBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  2. dojo._hasResource["dijit.form.CheckBox"] = true;
  3. dojo.provide("dijit.form.CheckBox");
  4. dojo.require("dijit.form.Button");
  5. dojo.declare(
  6. "dijit.form.CheckBox",
  7. dijit.form.ToggleButton,
  8. {
  9. // summary:
  10. // Same as an HTML checkbox, but with fancy styling.
  11. //
  12. // description:
  13. // User interacts with real html inputs.
  14. // On onclick (which occurs by mouse click, space-bar, or
  15. // using the arrow keys to switch the selected radio button),
  16. // we update the state of the checkbox/radio.
  17. //
  18. // There are two modes:
  19. // 1. High contrast mode
  20. // 2. Normal mode
  21. // In case 1, the regular html inputs are shown and used by the user.
  22. // In case 2, the regular html inputs are invisible but still used by
  23. // the user. They are turned quasi-invisible and overlay the background-image.
  24. templateString:"<fieldset class=\"dijitReset dijitInline\" waiRole=\"presentation\"\n\t><input\n\t \ttype=\"${type}\" name=\"${name}\"\n\t\tclass=\"dijitReset dijitCheckBoxInput\"\n\t\tdojoAttachPoint=\"inputNode,focusNode\"\n\t \tdojoAttachEvent=\"onmouseover:_onMouse,onmouseout:_onMouse,onclick:_onClick\"\n/></fieldset>\n",
  25. baseClass: "dijitCheckBox",
  26. // Value of "type" attribute for <input>
  27. type: "checkbox",
  28. // value: Value
  29. // equivalent to value field on normal checkbox (if checked, the value is passed as
  30. // the value when form is submitted)
  31. value: "on",
  32. postCreate: function(){
  33. dojo.setSelectable(this.inputNode, false);
  34. this.setChecked(this.checked);
  35. this.inherited(arguments);
  36. },
  37. setChecked: function(/*Boolean*/ checked){
  38. if(dojo.isIE){
  39. if(checked){ this.inputNode.setAttribute('checked', 'checked'); }
  40. else{ this.inputNode.removeAttribute('checked'); }
  41. }else{ this.inputNode.checked = checked; }
  42. this.inherited(arguments);
  43. },
  44. setValue: function(/*String*/ value){
  45. if(value == null){ value = ""; }
  46. this.inputNode.value = value;
  47. dijit.form.CheckBox.superclass.setValue.call(this,value);
  48. }
  49. }
  50. );
  51. dojo.declare(
  52. "dijit.form.RadioButton",
  53. dijit.form.CheckBox,
  54. {
  55. // summary:
  56. // Same as an HTML radio, but with fancy styling.
  57. //
  58. // description:
  59. // Implementation details
  60. //
  61. // Specialization:
  62. // We keep track of dijit radio groups so that we can update the state
  63. // of all the siblings (the "context") in a group based on input
  64. // events. We don't rely on browser radio grouping.
  65. type: "radio",
  66. baseClass: "dijitRadio",
  67. // This shared object keeps track of all widgets, grouped by name
  68. _groups: {},
  69. postCreate: function(){
  70. // add this widget to _groups
  71. (this._groups[this.name] = this._groups[this.name] || []).push(this);
  72. this.inherited(arguments);
  73. },
  74. uninitialize: function(){
  75. // remove this widget from _groups
  76. dojo.forEach(this._groups[this.name], function(widget, i, arr){
  77. if(widget === this){
  78. arr.splice(i, 1);
  79. return;
  80. }
  81. }, this);
  82. },
  83. setChecked: function(/*Boolean*/ checked){
  84. // If I am being checked then have to deselect currently checked radio button
  85. if(checked){
  86. dojo.forEach(this._groups[this.name], function(widget){
  87. if(widget != this && widget.checked){
  88. widget.setChecked(false);
  89. }
  90. }, this);
  91. }
  92. this.inherited(arguments);
  93. },
  94. _clicked: function(/*Event*/ e){
  95. if(!this.checked){
  96. this.setChecked(true);
  97. }
  98. }
  99. }
  100. );
  101. }