]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/_ButtonMixin.js.uncompressed.js
1 define("dijit/form/_ButtonMixin", [
2 "dojo/_base/declare", // declare
3 "dojo/dom", // dom.setSelectable
4 "dojo/_base/event", // event.stop
5 "../registry" // registry.byNode
6 ], function(declare
, dom
, event
, registry
){
9 // dijit/form/_ButtonMixin
11 // A mixin to add a thin standard API wrapper to a normal HTML button
13 return declare("dijit.form._ButtonMixin", null, {
15 // A mixin to add a thin standard API wrapper to a normal HTML button
17 // A label should always be specified (through innerHTML) or the label attribute.
19 // focusNode (required): this node receives focus
20 // valueNode (optional): this node's value gets submitted with FORM elements
21 // containerNode (optional): this node gets the innerHTML assignment for label
23 // | <button data-dojo-type="dijit.form.Button" onClick="...">Hello world</button>
26 // | var button1 = new dijit.form.Button({label: "hello world", onClick: foo});
27 // | dojo.body().appendChild(button1.domNode);
30 // Content to display in button.
33 // type: [const] String
34 // Type of button (submit, reset, button, checkbox, radio)
37 _onClick: function(/*Event*/ e
){
39 // Internal function to handle click actions
44 var preventDefault
= this.onClick(e
) === false; // user click actions
45 if(!preventDefault
&& this.type
== "submit" && !(this.valueNode
||this.focusNode
).form
){ // see if a non-form widget needs to be signalled
46 for(var node
=this.domNode
; node
.parentNode
; node
=node
.parentNode
){
47 var widget
=registry
.byNode(node
);
48 if(widget
&& typeof widget
._onSubmit
== "function"){
50 preventDefault
= true;
58 return !preventDefault
;
61 postCreate: function(){
62 this.inherited(arguments
);
63 dom
.setSelectable(this.focusNode
, false);
66 onClick: function(/*Event*/ /*===== e =====*/){
68 // Callback for when button is clicked.
69 // If type="submit", return true to perform submit, or false to cancel it.
72 return true; // Boolean
75 _setLabelAttr: function(/*String*/ content
){
77 // Hook for set('label', ...) to work.
79 // Set the label (text) of the button; takes an HTML string.
80 this._set("label", content
);
81 (this.containerNode
||this.focusNode
).innerHTML
= content
;