]> git.wh0rd.org - tt-rss.git/blame - lib/dijit/form/Button.js.uncompressed.js
make precache_headlines_idle() start slower
[tt-rss.git] / lib / dijit / form / Button.js.uncompressed.js
CommitLineData
1354d172
AD
1require({cache:{
2'url:dijit/form/templates/Button.html':"<span class=\"dijit dijitReset dijitInline\" role=\"presentation\"\n\t><span class=\"dijitReset dijitInline dijitButtonNode\"\n\t\tdata-dojo-attach-event=\"ondijitclick:_onClick\" role=\"presentation\"\n\t\t><span class=\"dijitReset dijitStretch dijitButtonContents\"\n\t\t\tdata-dojo-attach-point=\"titleNode,focusNode\"\n\t\t\trole=\"button\" aria-labelledby=\"${id}_label\"\n\t\t\t><span class=\"dijitReset dijitInline dijitIcon\" data-dojo-attach-point=\"iconNode\"></span\n\t\t\t><span class=\"dijitReset dijitToggleButtonIconChar\">&#x25CF;</span\n\t\t\t><span class=\"dijitReset dijitInline dijitButtonText\"\n\t\t\t\tid=\"${id}_label\"\n\t\t\t\tdata-dojo-attach-point=\"containerNode\"\n\t\t\t></span\n\t\t></span\n\t></span\n\t><input ${!nameAttrSetting} type=\"${type}\" value=\"${value}\" class=\"dijitOffScreen\"\n\t\ttabIndex=\"-1\" role=\"presentation\" data-dojo-attach-point=\"valueNode\"\n/></span>\n"}});
3define("dijit/form/Button", [
4 "require",
5 "dojo/_base/declare", // declare
6 "dojo/dom-class", // domClass.toggle
7 "dojo/_base/kernel", // kernel.deprecated
8 "dojo/_base/lang", // lang.trim
9 "dojo/ready",
10 "./_FormWidget",
11 "./_ButtonMixin",
12 "dojo/text!./templates/Button.html"
13], function(require, declare, domClass, kernel, lang, ready, _FormWidget, _ButtonMixin, template){
14
15/*=====
16 var _FormWidget = dijit.form._FormWidget;
17 var _ButtonMixin = dijit.form._ButtonMixin;
18=====*/
19
20// module:
21// dijit/form/Button
22// summary:
23// Button widget
24
25// Back compat w/1.6, remove for 2.0
26if(!kernel.isAsync){
27 ready(0, function(){
28 var requires = ["dijit/form/DropDownButton", "dijit/form/ComboButton", "dijit/form/ToggleButton"];
29 require(requires); // use indirection so modules not rolled into a build
30 });
31}
32
33return declare("dijit.form.Button", [_FormWidget, _ButtonMixin], {
34 // summary:
35 // Basically the same thing as a normal HTML button, but with special styling.
36 // description:
37 // Buttons can display a label, an icon, or both.
38 // A label should always be specified (through innerHTML) or the label
39 // attribute. It can be hidden via showLabel=false.
40 // example:
41 // | <button data-dojo-type="dijit.form.Button" onClick="...">Hello world</button>
42 //
43 // example:
44 // | var button1 = new dijit.form.Button({label: "hello world", onClick: foo});
45 // | dojo.body().appendChild(button1.domNode);
46
47 // showLabel: Boolean
48 // Set this to true to hide the label text and display only the icon.
49 // (If showLabel=false then iconClass must be specified.)
50 // Especially useful for toolbars.
51 // If showLabel=true, the label will become the title (a.k.a. tooltip/hint) of the icon.
52 //
53 // The exception case is for computers in high-contrast mode, where the label
54 // will still be displayed, since the icon doesn't appear.
55 showLabel: true,
56
57 // iconClass: String
58 // Class to apply to DOMNode in button to make it display an icon
59 iconClass: "dijitNoIcon",
60 _setIconClassAttr: { node: "iconNode", type: "class" },
61
62 baseClass: "dijitButton",
63
64 templateString: template,
65
66 // Map widget attributes to DOMNode attributes.
67 _setValueAttr: "valueNode",
68
69 _onClick: function(/*Event*/ e){
70 // summary:
71 // Internal function to handle click actions
72 var ok = this.inherited(arguments);
73 if(ok){
74 if(this.valueNode){
75 this.valueNode.click();
76 e.preventDefault(); // cancel BUTTON click and continue with hidden INPUT click
77 // leave ok = true so that subclasses can do what they need to do
78 }
79 }
80 return ok;
81 },
82
83 _fillContent: function(/*DomNode*/ source){
84 // Overrides _Templated._fillContent().
85 // If button label is specified as srcNodeRef.innerHTML rather than
86 // this.params.label, handle it here.
87 // TODO: remove the method in 2.0, parser will do it all for me
88 if(source && (!this.params || !("label" in this.params))){
89 var sourceLabel = lang.trim(source.innerHTML);
90 if(sourceLabel){
91 this.label = sourceLabel; // _applyAttributes will be called after buildRendering completes to update the DOM
92 }
93 }
94 },
95
96 _setShowLabelAttr: function(val){
97 if(this.containerNode){
98 domClass.toggle(this.containerNode, "dijitDisplayNone", !val);
99 }
100 this._set("showLabel", val);
101 },
102
103 setLabel: function(/*String*/ content){
104 // summary:
105 // Deprecated. Use set('label', ...) instead.
106 kernel.deprecated("dijit.form.Button.setLabel() is deprecated. Use set('label', ...) instead.", "", "2.0");
107 this.set("label", content);
108 },
109
110 _setLabelAttr: function(/*String*/ content){
111 // summary:
112 // Hook for set('label', ...) to work.
113 // description:
114 // Set the label (text) of the button; takes an HTML string.
115 // If the label is hidden (showLabel=false) then and no title has
116 // been specified, then label is also set as title attribute of icon.
117 this.inherited(arguments);
118 if(!this.showLabel && !("title" in this.params)){
119 this.titleNode.title = lang.trim(this.containerNode.innerText || this.containerNode.textContent || '');
120 }
121 }
122});
123
124
125});
126