]>
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 // A mixin to provide functionality to allow a button that can be in two states (checked or not).
11 return declare("dijit.form._ToggleButtonMixin", null, {
13 // A mixin to provide functionality to allow a button that can be in two states (checked or not).
16 // Corresponds to the native HTML <input> element's attribute.
17 // In markup, specified as "checked='checked'" or just "checked".
18 // True if the button is depressed, or the checkbox is checked,
19 // or the radio button is selected, etc.
22 // aria-pressed for toggle buttons, and aria-checked for checkboxes
23 _aria_attr
: "aria-pressed",
25 _onClick: function(/*Event*/ evt
){
26 var original
= this.checked
;
27 this._set('checked', !original
); // partially set the toggled value, assuming the toggle will work, so it can be overridden in the onclick handler
28 var ret
= this.inherited(arguments
); // the user could reset the value here
29 this.set('checked', ret
? this.checked
: original
); // officially set the toggled or user value, or reset it back
33 _setCheckedAttr: function(/*Boolean*/ value
, /*Boolean?*/ priorityChange
){
34 this._set("checked", value
);
35 domAttr
.set(this.focusNode
|| this.domNode
, "checked", value
);
36 (this.focusNode
|| this.domNode
).setAttribute(this._aria_attr
, value
? "true" : "false"); // aria values should be strings
37 this._handleOnChange(value
, priorityChange
);
42 // Reset the widget's value to what it was at initialization time
44 this._hasBeenBlurred
= false;
46 // set checked state to original setting
47 this.set('checked', this.params
.checked
|| false);