Spinner: For DOM based spinners, the height is now calculated based on number of children.

This commit is contained in:
Ca-Phun Ung 2008-08-30 20:01:23 +00:00
parent 66d90af241
commit 9248368f20
2 changed files with 19 additions and 21 deletions

View File

@ -10,7 +10,7 @@
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function(){
var opts = { var opts = {
's1': {}, 's1': {},
's2': {stepping: 0.25}, 's2': {stepping: 0.25},
@ -31,6 +31,7 @@ $(function(){
</script> </script>
<style type="text/css"> <style type="text/css">
body body
{ {
background: #fff; background: #fff;
@ -96,13 +97,7 @@ label {
background: #FEFEFE; background: #FEFEFE;
} }
.ui-spinner-list { .ui-spinner-list,
height: 1.2em;
line-height: 1.2em;
margin: 0;
padding: 0;
}
.ui-spinner-listitem { .ui-spinner-listitem {
margin: 0; margin: 0;
padding: 0; padding: 0;
@ -186,6 +181,5 @@ label {
<hr /> <hr />
</body> </body>
</html> </html>

View File

@ -24,15 +24,6 @@ $.widget('ui.spinner', {
this._decimals = s.slice(s.indexOf('.')+1, s.length).length; this._decimals = s.slice(s.indexOf('.')+1, s.length).length;
} }
// data list: set contraints to object length and step size
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 = $('>*', this.element).length-1;
}
//Initialize needed constants //Initialize needed constants
var self = this; var self = this;
this.element this.element
@ -122,9 +113,22 @@ $.widget('ui.spinner', {
}) })
.end(); .end();
// data list: fix height of data list spinner // DataList: Set contraints for object length and step size.
if (this.element.hasClass('ui-spinner-list')) { // Manipulate height of spinner.
this.element.parent().css('height', this.element.outerHeight()); this._items = this.element.children().length;
if (this._items > 1) {
this.element
.addClass('ui-spinner-list')
.css('height', this.element.outerHeight()/this._items)
.children()
.addClass('ui-spinner-listitem')
.end()
.parent()
.css('height', this.element.outerHeight())
.end();
this.options.stepping = 1;
this.options.min = 0;
this.options.max = this._items-1;
} }
this.element this.element