Skip to content
Permalink
Browse files

spinner: changed data list to support any DOM container not just <ul>

  • Loading branch information
Ca-Phun Ung
Ca-Phun Ung committed Aug 30, 2008
1 parent 7c33681 commit 66d90af2415a8fd5f6ad93b7553cb9d34e92064c
Showing with 22 additions and 12 deletions.
  1. +12 −7 tests/visual/spinner.html
  2. +10 −5 ui/ui.spinner.js
@@ -69,13 +69,6 @@
padding: 0;
}

ul.ui-spinner-box {
height: 1.2em;
line-height: 1.2em;
margin: 0;
padding: 0;
}

.ui-spinner-up,
.ui-spinner-down {
width: 10%;
@@ -103,6 +96,18 @@
background: #FEFEFE;
}

.ui-spinner-list {
height: 1.2em;
line-height: 1.2em;
margin: 0;
padding: 0;
}

.ui-spinner-listitem {
margin: 0;
padding: 0;
}

</style>
</head>

@@ -25,10 +25,12 @@ $.widget('ui.spinner', {
}

// data list: set contraints to object length and step size
if (this.element.is('ul')) {
if (this.element.children().length > 1) {
this.element.addClass('ui-spinner-list');
$('>*', this.element).addClass('ui-spinner-listitem');
this.options.stepping = 1;
this.options.min = 0;
this.options.max = $('li', this.element).length-1;
this.options.max = $('>*', this.element).length-1;
}

//Initialize needed constants
@@ -121,7 +123,7 @@ $.widget('ui.spinner', {
.end();

// data list: fix height of data list spinner
if (this.element.is('ul')) {
if (this.element.hasClass('ui-spinner-list')) {
this.element.parent().css('height', this.element.outerHeight());
}

@@ -216,7 +218,7 @@ $.widget('ui.spinner', {
);
},
_animate: function(d) {
if (this.element.is('ul') && ((d == 'up' && this._getValue() <= this.options.max) || (d == 'down' && this._getValue() >= this.options.min)) ) {
if (this.element.hasClass('ui-spinner-list') && ((d == 'up' && this._getValue() <= this.options.max) || (d == 'down' && this._getValue() >= this.options.min)) ) {
this.element.animate({marginTop: '-' + this._getValue() * this.element.outerHeight() }, {
duration: 'fast',
queue: false
@@ -243,14 +245,17 @@ $.widget('ui.spinner', {
this.element.unmousewheel();
}
this.element
.removeClass('ui-spinner-box')
.removeClass('ui-spinner-box ui-spinner-list')
.removeAttr('disabled')
.removeAttr('autocomplete')
.removeData('spinner')
.unbind('.spinner')
.siblings()
.remove()
.end()
.children()
.removeClass('ui-spinner-listitem')
.end()
.parent()
.removeClass('ui-spinner ui-spinner-disabled')
.before(this.element.clone())

0 comments on commit 66d90af

Please sign in to comment.
You can’t perform that action at this time.