summaryrefslogtreecommitdiff
path: root/includes/js/dijit/form/CheckBox.js
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
commite44a7e37b6c7b5961adaffc62b9042b8d442938e (patch)
tree95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dijit/form/CheckBox.js
parenta62b9742ee5e28bcec6872d88f50f25b820914f6 (diff)
downloadsemanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz
semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dijit/form/CheckBox.js')
-rw-r--r--includes/js/dijit/form/CheckBox.js133
1 files changed, 133 insertions, 0 deletions
diff --git a/includes/js/dijit/form/CheckBox.js b/includes/js/dijit/form/CheckBox.js
new file mode 100644
index 0000000..295a711
--- /dev/null
+++ b/includes/js/dijit/form/CheckBox.js
@@ -0,0 +1,133 @@
+if(!dojo._hasResource["dijit.form.CheckBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dijit.form.CheckBox"] = true;
+dojo.provide("dijit.form.CheckBox");
+
+dojo.require("dijit.form.Button");
+
+dojo.declare(
+ "dijit.form.CheckBox",
+ dijit.form.ToggleButton,
+ {
+ // summary:
+ // Same as an HTML checkbox, but with fancy styling.
+ //
+ // description:
+ // User interacts with real html inputs.
+ // On onclick (which occurs by mouse click, space-bar, or
+ // using the arrow keys to switch the selected radio button),
+ // we update the state of the checkbox/radio.
+ //
+ // There are two modes:
+ // 1. High contrast mode
+ // 2. Normal mode
+ // In case 1, the regular html inputs are shown and used by the user.
+ // In case 2, the regular html inputs are invisible but still used by
+ // the user. They are turned quasi-invisible and overlay the background-image.
+
+ templateString:"<div class=\"dijitReset dijitInline\" waiRole=\"presentation\"\n\t><input\n\t \ttype=\"${type}\" name=\"${name}\"\n\t\tclass=\"dijitReset dijitCheckBoxInput\"\n\t\tdojoAttachPoint=\"focusNode\"\n\t \tdojoAttachEvent=\"onmouseover:_onMouse,onmouseout:_onMouse,onclick:_onClick\"\n/></div>\n",
+
+ baseClass: "dijitCheckBox",
+
+ // Value of "type" attribute for <input>
+ type: "checkbox",
+
+ // value: Value
+ // equivalent to value field on normal checkbox (if checked, the value is passed as
+ // the value when form is submitted)
+ value: "on",
+
+ setValue: function(/*String or Boolean*/ newValue){
+ // summary:
+ // When passed a boolean, controls whether or not the CheckBox is checked.
+ // If passed a string, changes the value attribute of the CheckBox (the one
+ // specified as "value" when the CheckBox was constructed (ex: <input
+ // dojoType="dijit.CheckBox" value="chicken">)
+ if(typeof newValue == "string"){
+ this.setAttribute('value', newValue);
+ newValue = true;
+ }
+ this.setAttribute('checked', newValue);
+ },
+
+ _getValueDeprecated: false, // remove when _FormWidget:_getValueDeprecated is removed
+ getValue: function(){
+ // summary:
+ // If the CheckBox is checked, returns the value attribute.
+ // Otherwise returns false.
+ return (this.checked ? this.value : false);
+ },
+
+ reset: function(){
+ this.inherited(arguments);
+ this.setAttribute('value', this._resetValueAttr);
+ },
+
+ postCreate: function(){
+ this.inherited(arguments);
+ this._resetValueAttr = this.value;
+ }
+ }
+);
+
+dojo.declare(
+ "dijit.form.RadioButton",
+ dijit.form.CheckBox,
+ {
+ // summary:
+ // Same as an HTML radio, but with fancy styling.
+ //
+ // description:
+ // Implementation details
+ //
+ // Specialization:
+ // We keep track of dijit radio groups so that we can update the state
+ // of all the siblings (the "context") in a group based on input
+ // events. We don't rely on browser radio grouping.
+
+ type: "radio",
+ baseClass: "dijitRadio",
+
+ // This shared object keeps track of all widgets, grouped by name
+ _groups: {},
+
+ postCreate: function(){
+ // add this widget to _groups
+ (this._groups[this.name] = this._groups[this.name] || []).push(this);
+
+ this.inherited(arguments);
+ },
+
+ uninitialize: function(){
+ // remove this widget from _groups
+ dojo.forEach(this._groups[this.name], function(widget, i, arr){
+ if(widget === this){
+ arr.splice(i, 1);
+ return;
+ }
+ }, this);
+ },
+
+ setAttribute: function(/*String*/ attr, /*anything*/ value){
+ // If I am being checked then have to deselect currently checked radio button
+ this.inherited(arguments);
+ switch(attr){
+ case "checked":
+ if(this.checked){
+ dojo.forEach(this._groups[this.name], function(widget){
+ if(widget != this && widget.checked){
+ widget.setAttribute('checked', false);
+ }
+ }, this);
+ }
+ }
+ },
+
+ _clicked: function(/*Event*/ e){
+ if(!this.checked){
+ this.setAttribute('checked', true);
+ }
+ }
+ }
+);
+
+}