]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/_ToggleButtonMixin.js.uncompressed.js
1 define("dijit/form/_ToggleButtonMixin", [
2 "dojo/_base/declare", // declare
3 "dojo/dom-attr" // domAttr.set
4 ], function(declare
, domAttr
){
7 // dijit/form/_ToggleButtonMixin
9 return declare("dijit.form._ToggleButtonMixin", null, {
11 // A mixin to provide functionality to allow a button that can be in two states (checked or not).
14 // Corresponds to the native HTML `<input>` element's attribute.
15 // In markup, specified as "checked='checked'" or just "checked".
16 // True if the button is depressed, or the checkbox is checked,
17 // or the radio button is selected, etc.
20 // aria-pressed for toggle buttons, and aria-checked for checkboxes
21 _aria_attr
: "aria-pressed",
23 _onClick: function(/*Event*/ evt
){
24 var original
= this.checked
;
25 this._set('checked', !original
); // partially set the toggled value, assuming the toggle will work, so it can be overridden in the onclick handler
26 var ret
= this.inherited(arguments
); // the user could reset the value here
27 this.set('checked', ret
? this.checked
: original
); // officially set the toggled or user value, or reset it back
31 _setCheckedAttr: function(/*Boolean*/ value
, /*Boolean?*/ priorityChange
){
32 this._set("checked", value
);
33 var node
= this.focusNode
|| this.domNode
;
34 domAttr
.set(node
, "checked", !!value
); // "mixed" -> true
36 node
.setAttribute("checked", "");
38 node
.removeAttribute("checked");
40 node
.setAttribute(this._aria_attr
, String(value
)); // aria values should be strings
41 this._handleOnChange(value
, priorityChange
);
46 // Reset the widget's value to what it was at initialization time
48 this._hasBeenBlurred
= false;
50 // set checked state to original setting
51 this.set('checked', this.params
.checked
|| false);