//>>built
require({cache:{
'url:dijit/form/templates/Button.html':"●\n"}});
define("dijit/form/Button", [
"require",
"dojo/_base/declare", // declare
"dojo/dom-class", // domClass.toggle
"dojo/_base/kernel", // kernel.deprecated
"dojo/_base/lang", // lang.trim
"dojo/ready",
"./_FormWidget",
"./_ButtonMixin",
"dojo/text!./templates/Button.html"
], function(require, declare, domClass, kernel, lang, ready, _FormWidget, _ButtonMixin, template){
/*=====
var _FormWidget = dijit.form._FormWidget;
var _ButtonMixin = dijit.form._ButtonMixin;
=====*/
// module:
// dijit/form/Button
// summary:
// Button widget
// Back compat w/1.6, remove for 2.0
if(!kernel.isAsync){
ready(0, function(){
var requires = ["dijit/form/DropDownButton", "dijit/form/ComboButton", "dijit/form/ToggleButton"];
require(requires); // use indirection so modules not rolled into a build
});
}
return declare("dijit.form.Button", [_FormWidget, _ButtonMixin], {
// summary:
// Basically the same thing as a normal HTML button, but with special styling.
// description:
// Buttons can display a label, an icon, or both.
// A label should always be specified (through innerHTML) or the label
// attribute. It can be hidden via showLabel=false.
// example:
// |
//
// example:
// | var button1 = new dijit.form.Button({label: "hello world", onClick: foo});
// | dojo.body().appendChild(button1.domNode);
// showLabel: Boolean
// Set this to true to hide the label text and display only the icon.
// (If showLabel=false then iconClass must be specified.)
// Especially useful for toolbars.
// If showLabel=true, the label will become the title (a.k.a. tooltip/hint) of the icon.
//
// The exception case is for computers in high-contrast mode, where the label
// will still be displayed, since the icon doesn't appear.
showLabel: true,
// iconClass: String
// Class to apply to DOMNode in button to make it display an icon
iconClass: "dijitNoIcon",
_setIconClassAttr: { node: "iconNode", type: "class" },
baseClass: "dijitButton",
templateString: template,
// Map widget attributes to DOMNode attributes.
_setValueAttr: "valueNode",
_onClick: function(/*Event*/ e){
// summary:
// Internal function to handle click actions
var ok = this.inherited(arguments);
if(ok){
if(this.valueNode){
this.valueNode.click();
e.preventDefault(); // cancel BUTTON click and continue with hidden INPUT click
// leave ok = true so that subclasses can do what they need to do
}
}
return ok;
},
_fillContent: function(/*DomNode*/ source){
// Overrides _Templated._fillContent().
// If button label is specified as srcNodeRef.innerHTML rather than
// this.params.label, handle it here.
// TODO: remove the method in 2.0, parser will do it all for me
if(source && (!this.params || !("label" in this.params))){
var sourceLabel = lang.trim(source.innerHTML);
if(sourceLabel){
this.label = sourceLabel; // _applyAttributes will be called after buildRendering completes to update the DOM
}
}
},
_setShowLabelAttr: function(val){
if(this.containerNode){
domClass.toggle(this.containerNode, "dijitDisplayNone", !val);
}
this._set("showLabel", val);
},
setLabel: function(/*String*/ content){
// summary:
// Deprecated. Use set('label', ...) instead.
kernel.deprecated("dijit.form.Button.setLabel() is deprecated. Use set('label', ...) instead.", "", "2.0");
this.set("label", content);
},
_setLabelAttr: function(/*String*/ content){
// summary:
// Hook for set('label', ...) to work.
// description:
// Set the label (text) of the button; takes an HTML string.
// If the label is hidden (showLabel=false) then and no title has
// been specified, then label is also set as title attribute of icon.
this.inherited(arguments);
if(!this.showLabel && !("title" in this.params)){
this.titleNode.title = lang.trim(this.containerNode.innerText || this.containerNode.textContent || '');
}
}
});
});