summaryrefslogtreecommitdiff
path: root/js/dojo/dojox/mobile/Button.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/dojo/dojox/mobile/Button.js')
-rw-r--r--js/dojo/dojox/mobile/Button.js78
1 files changed, 78 insertions, 0 deletions
diff --git a/js/dojo/dojox/mobile/Button.js b/js/dojo/dojox/mobile/Button.js
new file mode 100644
index 0000000..b5d196a
--- /dev/null
+++ b/js/dojo/dojox/mobile/Button.js
@@ -0,0 +1,78 @@
+//>>built
+define("dojox/mobile/Button", [
+ "dojo/_base/array",
+ "dojo/_base/declare",
+ "dojo/dom-class",
+ "dojo/dom-construct",
+ "dijit/_WidgetBase",
+ "dijit/form/_ButtonMixin",
+ "dijit/form/_FormWidgetMixin"
+],
+ function(array, declare, domClass, domConstruct, WidgetBase, ButtonMixin, FormWidgetMixin){
+
+ /*=====
+ WidgetBase = dijit._WidgetBase;
+ FormWidgetMixin = dijit.form._FormWidgetMixin;
+ ButtonMixin = dijit.form._ButtonMixin;
+ =====*/
+ return declare("dojox.mobile.Button", [WidgetBase, FormWidgetMixin, ButtonMixin], {
+ // summary:
+ // Non-templated BUTTON widget with a thin API wrapper for click events and setting the label
+ //
+ // 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 dojoType="dijit.form.Button" onClick="...">Hello world</button>
+
+ baseClass: "mblButton",
+
+ // Override automatic assigning type --> node, it causes exception on IE.
+ // Instead, type must be specified as this.type when the node is created, as part of the original DOM
+ _setTypeAttr: null,
+
+ // duration: Number
+ // duration of selection, milliseconds or -1 for no post-click CSS styling
+ duration: 1000,
+
+ _onClick: function(e){
+ var ret = this.inherited(arguments);
+ if(ret && this.duration >= 0){ // if its not a button with a state, then emulate press styles
+ var button = this.focusNode || this.domNode;
+ var newStateClasses = (this.baseClass+' '+this["class"]).split(" ");
+ newStateClasses = array.map(newStateClasses, function(c){ return c+"Selected"; });
+ domClass.add(button, newStateClasses);
+ setTimeout(function(){
+ domClass.remove(button, newStateClasses);
+ }, this.duration);
+ }
+ return ret;
+ },
+
+ isFocusable: function(){ return false; },
+
+ buildRendering: function(){
+ if(!this.srcNodeRef){
+ this.srcNodeRef = domConstruct.create("button", {"type": this.type});
+ }else if(this._cv){
+ var n = this.srcNodeRef.firstChild;
+ if(n && n.nodeType === 3){
+ n.nodeValue = this._cv(n.nodeValue);
+ }
+ }
+ this.inherited(arguments);
+ this.focusNode = this.domNode;
+ },
+
+ postCreate: function(){
+ this.inherited(arguments);
+ this.connect(this.domNode, "onclick", "_onClick");
+ },
+
+ _setLabelAttr: function(/*String*/ content){
+ this.inherited(arguments, [this._cv ? this._cv(content) : content]);
+ }
+ });
+
+});