Skip to content

Commit

Permalink
Button and subclasses: initial updates to remove deprecated API's, refs
Browse files Browse the repository at this point in the history
#4, #5

- remove dijit-legacy-requires and ${nameAttrSetting}.
- remove deprecated methods (Button.setLabel, ToggleButton.setChecked)
- still need to convert Button and DropDownButton templates to be simple <button> nodes, rather than having hidden <input>.
  • Loading branch information
wkeese committed Apr 30, 2013
1 parent ea1703e commit a69f538
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 38 deletions.
23 changes: 3 additions & 20 deletions form/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,16 @@ define([
"require",
"dojo/_base/declare", // declare
"dojo/dom-class", // domClass.toggle
"dojo/has", // has("dijit-legacy-requires")
"dojo/_base/kernel", // kernel.deprecated
"dojo/has", // has("dojo-bidi")
"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){
"dojo/text!./templates/Button.html" // TODO for 2.0: convert this and DropDownButton to plain <button> node
], function(require, declare, domClass, has, lang, _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
});
}

var Button = declare("dijit.form.Button" + (has("dojo-bidi") ? "_NoBidi" : ""), [_FormWidget, _ButtonMixin], {
// summary:
// Basically the same thing as a normal HTML button, but with special styling.
Expand Down Expand Up @@ -84,13 +74,6 @@ define([
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.
Expand Down
9 changes: 4 additions & 5 deletions form/ComboButton.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
define([
"dojo/_base/declare", // declare
"dojo/keys", // keys
"../focus", // focus.focus()
"./DropDownButton",
"dojo/text!./templates/ComboButton.html"
], function(declare, keys, focus, DropDownButton, template){
], function(declare, keys, DropDownButton, template){

// module:
// dijit/form/ComboButton
Expand Down Expand Up @@ -53,7 +52,7 @@ define([
// summary:
// Handler for right arrow key when focus is on left part of button
if(evt.keyCode == keys[this.isLeftToRight() ? "RIGHT_ARROW" : "LEFT_ARROW"]){
focus.focus(this._popupStateNode);
this._popupStateNode.focus();
evt.stopPropagation();
evt.preventDefault();
}
Expand All @@ -63,7 +62,7 @@ define([
// summary:
// Handler for left arrow key when focus is on right part of button
if(evt.keyCode == keys[this.isLeftToRight() ? "LEFT_ARROW" : "RIGHT_ARROW"]){
focus.focus(this.titleNode);
this.titleNode.focus();
evt.stopPropagation();
evt.preventDefault();
}
Expand All @@ -76,7 +75,7 @@ define([
// position:
// "start" or "end"
if(!this.disabled){
focus.focus(position == "start" ? this.titleNode : this._popupStateNode);
(position == "start" ? this.titleNode : this._popupStateNode).focus();
}
}
});
Expand Down
12 changes: 2 additions & 10 deletions form/ToggleButton.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
define([
"dojo/_base/declare", // declare
"dojo/_base/kernel", // kernel.deprecated
"./Button",
"./_ToggleButtonMixin"
], function(declare, kernel, Button, _ToggleButtonMixin){
], function(declare, Button, _ToggleButtonMixin){

// module:
// dijit/form/ToggleButton
Expand All @@ -14,13 +13,6 @@ define([
// A templated button widget that can be in two states (checked or not).
// Can be base class for things like tabs or checkbox or radio buttons.

baseClass: "dijitToggleButton",

setChecked: function(/*Boolean*/ checked){
// summary:
// Deprecated. Use set('checked', true/false) instead.
kernel.deprecated("setChecked("+checked+") is deprecated. Use set('checked',"+checked+") instead.", "", "2.0");
this.set('checked', checked);
}
baseClass: "dijitToggleButton"
});
});
2 changes: 1 addition & 1 deletion form/templates/Button.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
></span
></span
></span
><input ${!nameAttrSetting} type="${type}" value="${value}" class="dijitOffScreen"
><input type="${type}" value="${value}" class="dijitOffScreen"
data-dojo-attach-event="onclick:_onClick"
tabIndex="-1" role="presentation" data-dojo-attach-point="valueNode"
/></span>
2 changes: 1 addition & 1 deletion form/templates/ComboButton.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
><div class="dijitReset dijitArrowButtonChar" role="presentation">&#9660;</div
></td
><td style="display:none !important;"
><input ${!nameAttrSetting} type="${type}" value="${value}" data-dojo-attach-point="valueNode" role="presentation"
><input type="${type}" value="${value}" data-dojo-attach-point="valueNode" role="presentation"
data-dojo-attach-event="onclick:_onClick"
/></td></tr></tbody
></table>
2 changes: 1 addition & 1 deletion form/templates/DropDownButton.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
><span class="dijitReset dijitInline dijitArrowButtonChar">&#9660;</span
></span
></span
><input ${!nameAttrSetting} type="${type}" value="${value}" class="dijitOffScreen" tabIndex="-1"
><input type="${type}" value="${value}" class="dijitOffScreen" tabIndex="-1"
data-dojo-attach-event="onclick:_onClick"
data-dojo-attach-point="valueNode" role="presentation"
/></span>

0 comments on commit a69f538

Please sign in to comment.