This commit is contained in:
Kin Blas 2011-01-14 13:40:04 -08:00
commit fde3aaaad5
2 changed files with 33 additions and 15 deletions

View file

@ -94,21 +94,24 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
.appendTo( listbox ),
header = $( "<div>", {
"data-role": "header",
"data-backbtn": false
"class": "ui-header ui-bar-" + theme
})
.prependTo( listbox ),
headerTitle = $( "<h1>" )
headerTitle = $( "<h1>", {
"class": "ui-title"
})
.appendTo( header ),
headerClose = $( "<a>", {
"data-iconpos": "notext",
"data-icon": "delete",
"text": o.closeText,
"href": "#"
"href": "#",
"class": "ui-btn-left"
})
.appendTo( header ),
.appendTo( header )
.buttonMarkup(),
menuType;
@ -160,17 +163,30 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
//button events
button
.bind( $.support.touch ? "touchend" : "click" , function( event ){
.bind( "touchstart" ,function( event ){
//set startTouches to cached copy of
$( this ).data( "startTouches", $.extend({}, event.originalEvent.touches[ 0 ]) );
})
.bind( $.support.touch ? "touchend" : "mouseup" , function( event ){
//if it's a scroll, don't open
if( $( this ).data( "moved" ) ){
$( this ).removeData( "moved" );
}
else{
self.open();
event.preventDefault();
}
event.preventDefault();
})
.bind( "touchmove", function(event){
$( this ).data( "moved", true );
.bind( "touchmove", function( event ){
//if touch moved enough, set data moved and don't open menu
var thisTouches = event.originalEvent.touches[ 0 ],
startTouches = $( this ).data( "startTouches" ),
deltaX = Math.abs(thisTouches.pageX - startTouches.pageX),
deltaY = Math.abs(thisTouches.pageY - startTouches.pageY);
if( deltaX > 10 || deltaY > 10 ){
$( this ).data( "moved", true );
}
});
//events for list items

View file

@ -33,7 +33,6 @@ $.widget( "mobile.slider", $.mobile.widget, {
min = (cType == 'input') ? parseFloat(control.attr('min')) : 0,
max = (cType == 'input') ? parseFloat(control.attr('max')) : control.find('option').length-1,
step = window.parseFloat(control.attr('data-step') || 1),
slider = $('<div class="ui-slider '+ selectClass +' ui-btn-down-'+ trackTheme+' ui-btn-corner-all" role="application"></div>'),
handle = $('<a href="#" class="ui-slider-handle"></a>')
.appendTo(slider)
@ -74,8 +73,11 @@ $.widget( "mobile.slider", $.mobile.widget, {
control
.addClass((cType == 'input') ? 'ui-slider-input' : 'ui-slider-switch')
.keyup(function(){
self.refresh( $(this).val() );
.change(function(){
self.refresh( ((cType == 'input') ? parseFloat(control.val()) : control[0].selectedIndex), true );
})
.keyup(function(){ // necessary?
self.refresh( ((cType == 'input') ? parseFloat(control.val()) : control[0].selectedIndex), true );
});
$(document).bind($.support.touch ? "touchmove" : "mousemove", function(event){
@ -191,7 +193,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
this.refresh();
},
refresh: function(val){
refresh: function(val, isfromControl){
if ( this.options.disabled ) { return; }
var control = this.element, percent,
@ -211,7 +213,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
percent = Math.round( ((data.pageX - this.slider.offset().left) / this.slider.width() ) * 100 );
} else {
if ( val == null ) {
val = (cType === "input") ? parseFloat(control.val()) : control[ 0 ].selectedIndex;
val = (cType === "input") ? parseFloat(control.val()) : control[0].selectedIndex;
}
percent = (parseFloat(val) - min) / (max - min) * 100;
}
@ -252,7 +254,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
} else {
control[ 0 ].selectedIndex = newval;
}
control.trigger("change");
if (!isfromControl) { control.trigger("change"); }
},
enable: function(){