| 1 |
define([ |
| 2 |
"dojo/_base/declare", |
| 3 |
"dojo/dom", |
| 4 |
"dojo/has", |
| 5 |
"../registry" |
| 6 |
], function(declare, dom, has, registry){ |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
var ButtonMixin = declare("dijit.form._ButtonMixin" + (has("dojo-bidi") ? "_NoBidi" : ""), null, { |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
label: "", |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
type: "button", |
| 35 |
|
| 36 |
__onClick: function( e){ |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
e.stopPropagation(); |
| 42 |
e.preventDefault(); |
| 43 |
if(!this.disabled){ |
| 44 |
|
| 45 |
this.valueNode.click(e); |
| 46 |
} |
| 47 |
return false; |
| 48 |
}, |
| 49 |
|
| 50 |
_onClick: function( e){ |
| 51 |
|
| 52 |
|
| 53 |
if(this.disabled){ |
| 54 |
e.stopPropagation(); |
| 55 |
e.preventDefault(); |
| 56 |
return false; |
| 57 |
} |
| 58 |
if(this.onClick(e) === false){ |
| 59 |
e.preventDefault(); |
| 60 |
} |
| 61 |
var cancelled = e.defaultPrevented; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
if(!cancelled && this.type == "submit" && !(this.valueNode || this.focusNode).form){ |
| 66 |
for(var node = this.domNode; node.parentNode; node = node.parentNode){ |
| 67 |
var widget = registry.byNode(node); |
| 68 |
if(widget && typeof widget._onSubmit == "function"){ |
| 69 |
widget._onSubmit(e); |
| 70 |
e.preventDefault(); |
| 71 |
cancelled = true; |
| 72 |
break; |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
return !cancelled; |
| 78 |
}, |
| 79 |
|
| 80 |
postCreate: function(){ |
| 81 |
this.inherited(arguments); |
| 82 |
dom.setSelectable(this.focusNode, false); |
| 83 |
}, |
| 84 |
|
| 85 |
onClick: function( ){ |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
return true; |
| 92 |
}, |
| 93 |
|
| 94 |
_setLabelAttr: function( content){ |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
this._set("label", content); |
| 100 |
var labelNode = this.containerNode || this.focusNode; |
| 101 |
labelNode.innerHTML = content; |
| 102 |
this.onLabelSet(); |
| 103 |
}, |
| 104 |
|
| 105 |
onLabelSet: function(){ |
| 106 |
} |
| 107 |
}); |
| 108 |
|
| 109 |
if(has("dojo-bidi")){ |
| 110 |
ButtonMixin = declare("dijit.form._ButtonMixin", ButtonMixin, { |
| 111 |
onLabelSet: function(){ |
| 112 |
this.inherited(arguments); |
| 113 |
var labelNode = this.containerNode || this.focusNode; |
| 114 |
this.applyTextDir(labelNode); |
| 115 |
} |
| 116 |
}); |
| 117 |
} |
| 118 |
|
| 119 |
return ButtonMixin; |
| 120 |
}); |