You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
4.9 KiB
JavaScript
122 lines
4.9 KiB
JavaScript
require({cache:{
|
|
'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\">●</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"}});
|
|
define("dijit/form/Button", [
|
|
"require",
|
|
"dojo/_base/declare", // declare
|
|
"dojo/dom-class", // domClass.toggle
|
|
"dojo/has", // has("dijit-legacy-requires")
|
|
"dojo/_base/kernel", // kernel.deprecated
|
|
"dojo/_base/lang", // lang.trim
|
|
"dojo/ready",
|
|
"./_FormWidget",
|
|
"./_ButtonMixin",
|
|
"dojo/text!./templates/Button.html"
|
|
], function(require, declare, domClass, has, kernel, lang, ready, _FormWidget, _ButtonMixin, template){
|
|
|
|
// module:
|
|
// dijit/form/Button
|
|
|
|
// Back compat w/1.6, remove for 2.0
|
|
if(has("dijit-legacy-requires")){
|
|
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:
|
|
// | <button data-dojo-type="dijit/form/Button" onClick="...">Hello world</button>
|
|
//
|
|
// example:
|
|
// | var button1 = new 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
|
|
e.stopPropagation(); // avoid two events bubbling from Button widget
|
|
// 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 || '');
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
});
|
|
|