From 1354d17270961fff662d40f90521223f8fd0d73b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 14 Aug 2012 18:59:10 +0400 Subject: update dojo to 1.7.3 --- .../form/_RadioButtonMixin.js.uncompressed.js | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 lib/dijit/form/_RadioButtonMixin.js.uncompressed.js (limited to 'lib/dijit/form/_RadioButtonMixin.js.uncompressed.js') diff --git a/lib/dijit/form/_RadioButtonMixin.js.uncompressed.js b/lib/dijit/form/_RadioButtonMixin.js.uncompressed.js new file mode 100644 index 000000000..3ab34f226 --- /dev/null +++ b/lib/dijit/form/_RadioButtonMixin.js.uncompressed.js @@ -0,0 +1,70 @@ +define("dijit/form/_RadioButtonMixin", [ + "dojo/_base/array", // array.forEach + "dojo/_base/declare", // declare + "dojo/dom-attr", // domAttr.set + "dojo/_base/event", // event.stop + "dojo/_base/lang", // lang.hitch + "dojo/query", // query + "dojo/_base/window", // win.doc + "../registry" // registry.getEnclosingWidget +], function(array, declare, domAttr, event, lang, query, win, registry){ + + // module: + // dijit/form/_RadioButtonMixin + // summary: + // Mixin to provide widget functionality for an HTML radio button + + return declare("dijit.form._RadioButtonMixin", null, { + // summary: + // Mixin to provide widget functionality for an HTML radio button + + // type: [private] String + // type attribute on node. + // Users should not change this value. + type: "radio", + + _getRelatedWidgets: function(){ + // Private function needed to help iterate over all radio buttons in a group. + var ary = []; + query("input[type=radio]", this.focusNode.form || win.doc).forEach( // can't use name= since query doesn't support [] in the name + lang.hitch(this, function(inputNode){ + if(inputNode.name == this.name && inputNode.form == this.focusNode.form){ + var widget = registry.getEnclosingWidget(inputNode); + if(widget){ + ary.push(widget); + } + } + }) + ); + return ary; + }, + + _setCheckedAttr: function(/*Boolean*/ value){ + // If I am being checked then have to deselect currently checked radio button + this.inherited(arguments); + if(!this._created){ return; } + if(value){ + array.forEach(this._getRelatedWidgets(), lang.hitch(this, function(widget){ + if(widget != this && widget.checked){ + widget.set('checked', false); + } + })); + } + }, + + _onClick: function(/*Event*/ e){ + if(this.checked || this.disabled){ // nothing to do + event.stop(e); + return false; + } + if(this.readOnly){ // ignored by some browsers so we have to resync the DOM elements with widget values + event.stop(e); + array.forEach(this._getRelatedWidgets(), lang.hitch(this, function(widget){ + domAttr.set(this.focusNode || this.domNode, 'checked', widget.checked); + })); + return false; + } + return this.inherited(arguments); + } + }); +}); -- cgit v1.2.3