diff options
author | Andrew Dolgov <[email protected]> | 2012-08-14 18:59:10 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-08-14 18:59:18 +0400 |
commit | 1354d17270961fff662d40f90521223f8fd0d73b (patch) | |
tree | e9266be71587e47c800303446e968a6d3565e2cf /lib/dijit/form/_ButtonMixin.js.uncompressed.js | |
parent | d04f8c826f5283765f52cf6b98b42a1ed8f2d6bc (diff) |
update dojo to 1.7.3
Diffstat (limited to 'lib/dijit/form/_ButtonMixin.js.uncompressed.js')
-rw-r--r-- | lib/dijit/form/_ButtonMixin.js.uncompressed.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/lib/dijit/form/_ButtonMixin.js.uncompressed.js b/lib/dijit/form/_ButtonMixin.js.uncompressed.js new file mode 100644 index 000000000..f00ebdb07 --- /dev/null +++ b/lib/dijit/form/_ButtonMixin.js.uncompressed.js @@ -0,0 +1,85 @@ +define("dijit/form/_ButtonMixin", [ + "dojo/_base/declare", // declare + "dojo/dom", // dom.setSelectable + "dojo/_base/event", // event.stop + "../registry" // registry.byNode +], function(declare, dom, event, registry){ + +// module: +// dijit/form/_ButtonMixin +// summary: +// A mixin to add a thin standard API wrapper to a normal HTML button + +return declare("dijit.form._ButtonMixin", null, { + // summary: + // A mixin to add a thin standard API wrapper to a normal HTML button + // description: + // A label should always be specified (through innerHTML) or the label attribute. + // Attach points: + // focusNode (required): this node receives focus + // valueNode (optional): this node's value gets submitted with FORM elements + // containerNode (optional): this node gets the innerHTML assignment for label + // example: + // | <button data-dojo-type="dijit.form.Button" onClick="...">Hello world</button> + // + // example: + // | var button1 = new dijit.form.Button({label: "hello world", onClick: foo}); + // | dojo.body().appendChild(button1.domNode); + + // label: HTML String + // Content to display in button. + label: "", + + // type: [const] String + // Type of button (submit, reset, button, checkbox, radio) + type: "button", + + _onClick: function(/*Event*/ e){ + // summary: + // Internal function to handle click actions + if(this.disabled){ + event.stop(e); + return false; + } + var preventDefault = this.onClick(e) === false; // user click actions + if(!preventDefault && this.type == "submit" && !(this.valueNode||this.focusNode).form){ // see if a non-form widget needs to be signalled + for(var node=this.domNode; node.parentNode; node=node.parentNode){ + var widget=registry.byNode(node); + if(widget && typeof widget._onSubmit == "function"){ + widget._onSubmit(e); + preventDefault = true; + break; + } + } + } + if(preventDefault){ + e.preventDefault(); + } + return !preventDefault; + }, + + postCreate: function(){ + this.inherited(arguments); + dom.setSelectable(this.focusNode, false); + }, + + onClick: function(/*Event*/ /*===== e =====*/){ + // summary: + // Callback for when button is clicked. + // If type="submit", return true to perform submit, or false to cancel it. + // type: + // callback + return true; // Boolean + }, + + _setLabelAttr: function(/*String*/ content){ + // summary: + // Hook for set('label', ...) to work. + // description: + // Set the label (text) of the button; takes an HTML string. + this._set("label", content); + (this.containerNode||this.focusNode).innerHTML = content; + } +}); + +}); |