Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
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
14 changes: 8 additions & 6 deletions js/widgets/popup.arrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
// Browser globals
factory( jQuery );
}
})( function( $ ) {
} )( function( $ ) {

var ieHack = ( $.mobile.browser.oldIE && $.mobile.browser.oldIE <= 8 ),
uiTemplate = $(
"<div class='ui-popup-arrow-guide'></div>" +
"<div class='ui-popup-arrow-container" + ( ieHack ? " ie" : "" ) + "'>" +
"<div class='ui-popup-arrow'></div>" +
"<div class='ui-popup-arrow'></div>" +
"</div>"
);

Expand Down Expand Up @@ -89,7 +89,9 @@ return $.widget( "mobile.popup", $.mobile.popup, {
// distance from the desired point. If a best-distance is passed in, return
// the minimum of the one passed in and the one calculated.
_tryAnArrow: function( p, dir, desired, s, best ) {
var result, r, diff, desiredForArrow = {}, tip = {};
var result, r, diff,
desiredForArrow = {},
tip = {};

// If the arrow has no wiggle room along the edge of the popup, it cannot
// be displayed along the requested edge without it sticking out.
Expand Down Expand Up @@ -164,7 +166,7 @@ return $.widget( "mobile.popup", $.mobile.popup, {
bgRef = {};
state = this._getPlacementState( true );
params = {
"l": { fst: "x", snd: "y", prop: "top", dimKey: "cy", oDimKey: "cx", offsetFactor: 1, tipOffset: -state.arHalf.cx, arrowOffsetFactor: 0 },
"l": { fst: "x", snd: "y", prop: "top", dimKey: "cy", oDimKey: "cx", offsetFactor: 1, tipOffset: -state.arHalf.cx, arrowOffsetFactor: 0 },
"r": { fst: "x", snd: "y", prop: "top", dimKey: "cy", oDimKey: "cx", offsetFactor: -1, tipOffset: state.arHalf.cx + state.contentBox.cx, arrowOffsetFactor: 1 },
"b": { fst: "y", snd: "x", prop: "left", dimKey: "cx", oDimKey: "cy", offsetFactor: -1, tipOffset: state.arHalf.cy + state.contentBox.cy, arrowOffsetFactor: 1 },
"t": { fst: "y", snd: "x", prop: "left", dimKey: "cx", oDimKey: "cy", offsetFactor: 1, tipOffset: -state.arHalf.cy, arrowOffsetFactor: 0 }
Expand Down Expand Up @@ -251,6 +253,6 @@ return $.widget( "mobile.popup", $.mobile.popup, {

return this._super();
}
});
} );

});
} );
130 changes: 66 additions & 64 deletions js/widgets/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
// Browser globals
factory( jQuery );
}
})( function( $ ) {
} )( function( $ ) {

function pointInRectangle( x, y, windowCoordinates ) {
return ( x >= windowCoordinates.x && x <= windowCoordinates.x + windowCoordinates.cx &&
Expand Down Expand Up @@ -133,7 +133,7 @@ $.widget( "mobile.popup", {

this._on( this.document, {
"vmousedown": "_handleDocumentVmousedown"
});
} );

// Define instance variables
$.extend( this, {
Expand All @@ -148,7 +148,7 @@ $.widget( "mobile.popup", {
_resizeData: null,
_ignoreResizeTo: 0,
_orientationchangeInProgress: false
});
} );

if ( this._page.length === 0 ) {
this._page = $( "body" );
Expand All @@ -174,7 +174,7 @@ $.widget( "mobile.popup", {
orientationchange: $.proxy( this, "_handleWindowOrientationchange" ),
resize: $.proxy( this, "_handleWindowResize" ),
keyup: $.proxy( this, "_handleWindowKeyUp" )
});
} );
this._on( this.document, { "focusin": "_handleDocumentFocusIn" } );
},

Expand All @@ -183,7 +183,7 @@ $.widget( "mobile.popup", {
wrapperClass = currentOptions.wrapperClass,
ui = {
screen: $( "<div class='ui-screen-hidden ui-popup-screen " +
this._themeClassFromOption( "ui-overlay-", currentOptions.overlayTheme ) + "'></div>" ),
this._themeClassFromOption( "ui-overlay-", currentOptions.overlayTheme ) + "'></div>" ),
placeholder: $( "<div style='display: none;'><!-- placeholder --></div>" ),
container: $( "<div class='ui-popup-container ui-popup-hidden ui-popup-truncate" +
( wrapperClass ? ( " " + wrapperClass ) : "" ) + "'></div>" )
Expand Down Expand Up @@ -254,9 +254,9 @@ $.widget( "mobile.popup", {

if ( this._resizeData ) {
if ( windowCoordinates.x === this._resizeData.windowCoordinates.x &&
windowCoordinates.y === this._resizeData.windowCoordinates.y &&
windowCoordinates.cx === this._resizeData.windowCoordinates.cx &&
windowCoordinates.cy === this._resizeData.windowCoordinates.cy ) {
windowCoordinates.y === this._resizeData.windowCoordinates.y &&
windowCoordinates.cx === this._resizeData.windowCoordinates.cx &&
windowCoordinates.cy === this._resizeData.windowCoordinates.cy ) {
// timeout not refreshed
return false;
} else {
Expand Down Expand Up @@ -304,11 +304,11 @@ $.widget( "mobile.popup", {
this._ignoreResizeTo = this._delay( "_stopIgnoringResizeEvents", 1000 );
},

_handleWindowResize: function(/* theEvent */) {
_handleWindowResize: function( /* theEvent */ ) {
if ( this._isOpen && this._ignoreResizeTo === 0 ) {
if ( isOutOfSight( this._ui.container, getWindowCoordinates( this.window ) ) &&
( this._expectResizeEvent() || this._orientationchangeInProgress ) &&
!this._ui.container.hasClass( "ui-popup-hidden" ) ) {
( this._expectResizeEvent() || this._orientationchangeInProgress ) &&
!this._ui.container.hasClass( "ui-popup-hidden" ) ) {

// effectively rapid-close the popup while leaving the screen intact
this._ui.container
Expand All @@ -318,7 +318,7 @@ $.widget( "mobile.popup", {
}
},

_handleWindowOrientationchange: function(/* theEvent */) {
_handleWindowOrientationchange: function( /* theEvent */ ) {
if ( !this._orientationchangeInProgress && this._isOpen && this._ignoreResizeTo === 0 ) {
this._expectResizeEvent();
this._orientationchangeInProgress = true;
Expand Down Expand Up @@ -434,44 +434,46 @@ $.widget( "mobile.popup", {
if ( value !== undefined ) {
ar = String( value ).split( "," );

$.each( ar, function( idx, val ) { ar[ idx ] = parseInt( val, 10 ); } );
$.each( ar, function( idx, val ) {
ar[ idx ] = parseInt( val, 10 );
} );

switch( ar.length ) {
// All values are to be the same
case 1:
if ( !isNaN( ar[ 0 ] ) ) {
tol.t = tol.r = tol.b = tol.l = ar[ 0 ];
}
break;
switch ( ar.length ) {
// All values are to be the same
case 1:
if ( !isNaN( ar[ 0 ] ) ) {
tol.t = tol.r = tol.b = tol.l = ar[ 0 ];
}
break;

// The first value denotes top/bottom tolerance, and the second value denotes left/right tolerance
case 2:
if ( !isNaN( ar[ 0 ] ) ) {
tol.t = tol.b = ar[ 0 ];
}
if ( !isNaN( ar[ 1 ] ) ) {
tol.l = tol.r = ar[ 1 ];
}
break;
// The first value denotes top/bottom tolerance, and the second value denotes left/right tolerance
case 2:
if ( !isNaN( ar[ 0 ] ) ) {
tol.t = tol.b = ar[ 0 ];
}
if ( !isNaN( ar[ 1 ] ) ) {
tol.l = tol.r = ar[ 1 ];
}
break;

// The array contains values in the order top, right, bottom, left
case 4:
if ( !isNaN( ar[ 0 ] ) ) {
tol.t = ar[ 0 ];
}
if ( !isNaN( ar[ 1 ] ) ) {
tol.r = ar[ 1 ];
}
if ( !isNaN( ar[ 2 ] ) ) {
tol.b = ar[ 2 ];
}
if ( !isNaN( ar[ 3 ] ) ) {
tol.l = ar[ 3 ];
}
break;
// The array contains values in the order top, right, bottom, left
case 4:
if ( !isNaN( ar[ 0 ] ) ) {
tol.t = ar[ 0 ];
}
if ( !isNaN( ar[ 1 ] ) ) {
tol.r = ar[ 1 ];
}
if ( !isNaN( ar[ 2 ] ) ) {
tol.b = ar[ 2 ];
}
if ( !isNaN( ar[ 3 ] ) ) {
tol.l = ar[ 3 ];
}
break;

default:
break;
default:
break;
}
}

Expand Down Expand Up @@ -560,20 +562,20 @@ $.widget( "mobile.popup", {
if ( prerequisites === self._prerequisites ) {
screenPrerequisite();
}
});
} );

prerequisites.container.done( function() {
if ( prerequisites === self._prerequisites ) {
containerPrerequisite();
}
});
} );

$.when( prerequisites.screen, prerequisites.container ).done( function() {
if ( prerequisites === self._prerequisites ) {
self._prerequisites = null;
whenDone();
}
});
} );

self._prerequisites = prerequisites;
},
Expand Down Expand Up @@ -625,7 +627,7 @@ $.widget( "mobile.popup", {
} else {
try {
dst = $( pTo );
} catch( err ) {
} catch ( err ) {
dst = null;
}
if ( dst ) {
Expand Down Expand Up @@ -672,10 +674,10 @@ $.widget( "mobile.popup", {
}
},

_safelyBlur: function( currentElement ){
_safelyBlur: function( currentElement ) {
if ( currentElement !== this.window[ 0 ] &&
currentElement.nodeName.toLowerCase() !== "body" ) {
$( currentElement ).blur();
currentElement.nodeName.toLowerCase() !== "body" ) {
$( currentElement ).blur();
}
},

Expand Down Expand Up @@ -720,7 +722,7 @@ $.widget( "mobile.popup", {
return true;
}
return false;
}());
}() );

// Count down to triggering "popupafteropen" - we have two prerequisites:
// 1. The popup window animation completes (container())
Expand Down Expand Up @@ -752,15 +754,15 @@ $.widget( "mobile.popup", {
// TODO sort out why this._page isn't working
this.element.closest( ".ui-page" ).addClass( "ui-popup-open" );
}
this._animate({
this._animate( {
additionalCondition: true,
transition: openOptions.transition,
classToRemove: "",
screenClassToAdd: "in",
containerClassToAdd: "in",
applyTransition: false,
prerequisites: this._prerequisites
});
} );
},

_closePrerequisiteScreen: function() {
Expand Down Expand Up @@ -819,7 +821,7 @@ $.widget( "mobile.popup", {
containerClassToAdd: "reverse out",
applyTransition: true,
prerequisites: this._prerequisites
});
} );
},

_unenhance: function() {
Expand Down Expand Up @@ -938,7 +940,7 @@ $.widget( "mobile.popup", {
.delegate( currentOptions.closeLinkSelector, currentOptions.closeLinkEvents, function( theEvent ) {
self.close();
theEvent.preventDefault();
});
} );

return this;
}
Expand All @@ -960,7 +962,7 @@ $.widget( "mobile.popup", {
// if the current url has no dialog hash key proceed as normal
// otherwise, if the page is a dialog simply tack on the hash key
if ( url.indexOf( hashkey ) === -1 && !currentIsDialog ) {
url = url + (url.indexOf( "#" ) > -1 ? hashkey : "#" + hashkey);
url = url + ( url.indexOf( "#" ) > -1 ? hashkey : "#" + hashkey );
} else {
url = $.mobile.path.parseLocation().hash + hashkey;
}
Expand All @@ -970,7 +972,7 @@ $.widget( "mobile.popup", {
theEvent.preventDefault();
self._open( options );
self._bindContainerClose();
});
} );

this.urlAltered = true;
$.mobile.navigate( url, { role: "dialog" } );
Expand All @@ -996,7 +998,7 @@ $.widget( "mobile.popup", {

return this;
}
});
} );

// TODO this can be moved inside the widget
$.mobile.popup.handleLink = function( $link ) {
Expand All @@ -1014,7 +1016,7 @@ $.mobile.popup.handleLink = function( $link ) {
y: offset.top + $link.outerHeight() / 2,
transition: $link.jqmData( "transition" ),
positionTo: $link.jqmData( "position-to" )
});
} );
}

//remove after delay
Expand All @@ -1029,8 +1031,8 @@ $.mobile.document.on( "pagebeforechange", function( theEvent, data ) {
$.mobile.popup.handleLink( data.options.link );
theEvent.preventDefault();
}
});
} );

return $.mobile.popup;

});
} );
Loading