Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Support transparent dialog backgrounds #2380

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions js/jquery.mobile.event.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

// add new event shortcuts
$.each( ( "touchstart touchmove touchend orientationchange throttledresize " +
"tap taphold swipe swipeleft swiperight scrollstart scrollstop" ).split( " " ), function( i, name ) {
"tap taphold swipe swipeleft swiperight swipeup swipedown scrollstart scrollstop" ).split( " " ), function( i, name ) {

$.fn[ name ] = function( fn ) {
return fn ? this.bind( name, fn ) : this.trigger( name );
Expand Down Expand Up @@ -125,15 +125,19 @@ $.event.special.swipe = {

setup: function() {
var thisObject = this,
$this = $( thisObject );
$this = $( thisObject ),
touching = false;

$this.bind( touchStartEvent, function( event ) {
if (touching == true) return;
touching = true;
var data = event.originalEvent.touches ?
event.originalEvent.touches[ 0 ] : event,
start = {
time: ( new Date() ).getTime(),
coords: [ data.pageX, data.pageY ],
origin: $( event.target )
origin: $( event.target ),
touchcount: event.originalEvent.touches ? event.originalEvent.touches.length : 1
},
stop;

Expand All @@ -159,15 +163,31 @@ $.event.special.swipe = {

$this.bind( touchMoveEvent, moveHandler )
.one( touchStopEvent, function( event ) {
touching=false;
$this.unbind( touchMoveEvent, moveHandler );

if ( start && stop ) {
var eventdata = {start:start, stop:stop};

if ( stop.time - start.time < $.event.special.swipe.durationThreshold &&
Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.horizontalDistanceThreshold &&
Math.abs( start.coords[ 1 ] - stop.coords[ 1 ] ) < $.event.special.swipe.verticalDistanceThreshold ) {

start.origin.trigger( "swipe" )
.trigger( start.coords[0] > stop.coords[ 0 ] ? "swipeleft" : "swiperight" );

eventdata.direction = start.coords[0] > stop.coords[ 0 ] ? "left" : "right";

start.origin.trigger( "swipe", eventdata )
.trigger( "swipe"+eventdata.direction , eventdata);
}

if ( stop.time - start.time < $.event.special.swipe.durationThreshold &&
Math.abs( start.coords[ 1 ] - stop.coords[ 1 ] ) > $.event.special.swipe.horizontalDistanceThreshold &&
Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) < $.event.special.swipe.verticalDistanceThreshold ) {

eventdata.direction = start.coords[1] > stop.coords[ 1 ] ? "up" : "down";

start.origin.trigger( "swipe", eventdata )
.trigger( "swipe"+eventdata.direction , eventdata);

}
}
start = stop = undefined;
Expand Down Expand Up @@ -290,7 +310,9 @@ $.each({
scrollstop: "scrollstart",
taphold: "tap",
swipeleft: "swipe",
swiperight: "swipe"
swiperight: "swipe",
swipeup: "swipe",
swipedown: "swipe"
}, function( event, sourceEvent ) {

$.event.special[ event ] = {
Expand Down
10 changes: 8 additions & 2 deletions js/jquery.mobile.transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ function css3TransitionHandler( name, reverse, $to, $from ) {

$to.add( $from ).removeClass( "out in reverse " + name );

if ( $from ) {
$from.removeClass( $.mobile.activePageClass );
if ( $from ) {
$from.removeClass($.mobile.activePageClass);
if ($to.attr("data-role") == "dialog") {
$from.addClass("ui-dialog-background");
}
if ($from.attr("data-role") == "dialog") {
$to.removeClass("ui-dialog-background");
}
}

$to.parent().removeClass( viewportClass );
Expand Down
3 changes: 2 additions & 1 deletion themes/default/jquery.mobile.dialog.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
.ui-dialog { min-height: 480px; }
.ui-dialog .ui-header, .ui-dialog .ui-content, .ui-dialog .ui-footer { margin: 15px; position: relative; }
.ui-dialog .ui-header, .ui-dialog .ui-footer { z-index: 10; width: auto; }
.ui-dialog .ui-content, .ui-dialog .ui-footer { margin-top: -15px; }
.ui-dialog .ui-content, .ui-dialog .ui-footer { margin-top: -15px; }
.ui-mobile .ui-dialog-background { display: block; }