r987 - in branches/dev/spinner: tests ui
Author:
pazu2k@gmail.com
Date: Fri Nov 21 00:37:06 2008
New Revision: 987
Modified:
branches/dev/spinner/tests/spinner.js
branches/dev/spinner/ui/ui.spinner.js
Log:
spinner: removed duplicate test for defaults. changed defaults for items,
max & min to null to match tests.
Modified: branches/dev/spinner/tests/spinner.js
==============================================================================
--- branches/dev/spinner/tests/spinner.js (original)
+++ branches/dev/spinner/tests/spinner.js Fri Nov 21 00:37:06 2008
@@ -84,25 +84,6 @@
});
-test("defaults", function() {
- expect(12);
- el = $("#spin").spinner();
-
- equals(el.data("currency.spinner"), false, "currency");
- equals(el.data("disabled.spinner"), false, "disabled");
- equals(el.data("incremental.spinner"), true, "incremental");
- equals(el.data("max.spinner"), undefined, "max");
- equals(el.data("min.spinner"), undefined, "min");
- equals(el.data("start.spinner"), 0, "start");
- equals(el.data("stepping.spinner"), 1, "stepping");
- equals(el.data("decimals.spinner"), 0, "decimals");
- equals(el.data("format.spinner"), '%', "format");
- equals(el.data("items.spinner"), false, "items");
- equals(el.data("group.spinner"), '', "group");
- equals(el.data("point.spinner"), '.', "point");
-
-});
-
test("set defaults on init", function() {
expect(7);
el = $("#spin").spinner({ currency:"��", disabled:true,
incremental:false, max:200, min:-100, start:50, stepping:2 });
Modified: branches/dev/spinner/ui/ui.spinner.js
==============================================================================
--- branches/dev/spinner/ui/ui.spinner.js (original)
+++ branches/dev/spinner/ui/ui.spinner.js Fri Nov 21 00:37:06 2008
@@ -17,7 +17,7 @@
this._trigger('init', null, this.ui(null));
// perform data bind on generic objects
- if (typeof this.options.items[0] == 'object'
&& !this.element.is('input')) {
+ if (this.options.items != null && typeof this.options.items[0]
== 'object' && !this.element.is('input')) {
var data = this.options.items;
for (var i=0; i<data.length; i++) {
this._addItem(data[i]);
@@ -190,10 +190,10 @@
},
_constrain: function() {
- if (this.options.min != undefined && this._getValue() <
this.options.min) {
+ if (this.options.min != null && this._getValue() < this.options.min) {
this._setValue(this.options.min);
}
- if (this.options.max != undefined && this._getValue() >
this.options.max) {
+ if (this.options.max != null && this._getValue() > this.options.max) {
this._setValue(this.options.max);
}
},
@@ -261,7 +261,7 @@
//Home key goes to min, if defined, else to start
this._setValue(this.options.min || this.options.start);
}
- if (event.keyCode == KEYS.END && this.options.max != undefined) {
+ if (event.keyCode == KEYS.END && this.options.max != null) {
//End key goes to maximum
this._setValue(this.options.max);
}
@@ -404,9 +404,11 @@
incremental: true,
currency: false,
format: '%',
- items: [],
group: '',
- point: '.'
+ point: '.',
+ items: null,
+ max: null,
+ min: null
},
format: {
currency: function(num, sym, group, pt) {