mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-19 07:20:24 +00:00
whitespace and missing semicolon in setTimeout for non webkit animationComplete
This commit is contained in:
parent
4830ac9e9b
commit
8b5f083974
1 changed files with 58 additions and 58 deletions
|
|
@ -27,7 +27,7 @@
|
|||
var splitkey = '&' + $.mobile.subPageUrlKey;
|
||||
return path && path.split( splitkey )[0].split( dialogHashKey )[0];
|
||||
},
|
||||
|
||||
|
||||
//set location hash to path
|
||||
set: function( path ){
|
||||
location.hash = path;
|
||||
|
|
@ -39,32 +39,32 @@
|
|||
setOrigin: function(){
|
||||
path.origin = path.get( location.protocol + '//' + location.host + location.pathname );
|
||||
},
|
||||
|
||||
|
||||
//prefix a relative url with the current path
|
||||
makeAbsolute: function( url ){
|
||||
return path.get() + url;
|
||||
},
|
||||
|
||||
|
||||
//return a url path with the window's location protocol/hostname removed
|
||||
clean: function( url ){
|
||||
return url.replace( location.protocol + "//" + location.host, "");
|
||||
},
|
||||
|
||||
|
||||
//just return the url without an initial #
|
||||
stripHash: function( url ){
|
||||
return url.replace( /^#/, "" );
|
||||
},
|
||||
|
||||
|
||||
//check whether a url is referencing the same domain, or an external domain or different protocol
|
||||
//could be mailto, etc
|
||||
isExternal: function( url ){
|
||||
return path.hasProtocol( path.clean( url ) );
|
||||
},
|
||||
|
||||
|
||||
hasProtocol: function( url ){
|
||||
return /^(:?\w+:)/.test( url );
|
||||
},
|
||||
|
||||
|
||||
//check if the url is relative
|
||||
isRelative: function( url ){
|
||||
return /^[^\/|#]/.test( url ) && !path.hasProtocol( url );
|
||||
|
|
@ -73,46 +73,46 @@
|
|||
|
||||
//will be defined when a link is clicked and given an active class
|
||||
$activeClickedLink = null,
|
||||
|
||||
|
||||
//urlHistory is purely here to make guesses at whether the back or forward button was clicked
|
||||
//and provide an appropriate transition
|
||||
urlHistory = {
|
||||
//array of pages that are visited during a single page load. each has a url and optional transition
|
||||
stack: [],
|
||||
|
||||
|
||||
//maintain an index number for the active page in the stack
|
||||
activeIndex: 0,
|
||||
|
||||
|
||||
//get active
|
||||
getActive: function(){
|
||||
return urlHistory.stack[ urlHistory.activeIndex ];
|
||||
},
|
||||
|
||||
|
||||
getPrev: function(){
|
||||
return urlHistory.stack[ urlHistory.activeIndex - 1 ];
|
||||
},
|
||||
|
||||
|
||||
getNext: function(){
|
||||
return urlHistory.stack[ urlHistory.activeIndex + 1 ];
|
||||
},
|
||||
|
||||
|
||||
// addNew is used whenever a new page is added
|
||||
addNew: function( url, transition ){
|
||||
//if there's forward history, wipe it
|
||||
if( urlHistory.getNext() ){
|
||||
urlHistory.clearForward();
|
||||
}
|
||||
|
||||
|
||||
urlHistory.stack.push( {url : url, transition: transition } );
|
||||
|
||||
|
||||
urlHistory.activeIndex = urlHistory.stack.length - 1;
|
||||
},
|
||||
|
||||
|
||||
//wipe urls ahead of active index
|
||||
clearForward: function(){
|
||||
urlHistory.stack = urlHistory.stack.slice( 0, urlHistory.activeIndex + 1 );
|
||||
},
|
||||
|
||||
|
||||
//enable/disable hashchange event listener
|
||||
//toggled internally when location.hash is updated to match the url of a successful page load
|
||||
listeningEnabled: true
|
||||
|
|
@ -123,7 +123,7 @@
|
|||
|
||||
//contains role for next page, if defined on clicked link via data-rel
|
||||
nextPageRole = null,
|
||||
|
||||
|
||||
//nonsense hash change key for dialogs, so they create a history entry
|
||||
dialogHashKey = "&ui-state=dialog";
|
||||
|
||||
|
|
@ -214,7 +214,7 @@
|
|||
}
|
||||
else{
|
||||
// defer execution for consistency between webkit/non webkit
|
||||
setTimeout(callback, 0)
|
||||
setTimeout(callback, 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -225,17 +225,17 @@
|
|||
//update location.hash, with or without triggering hashchange event
|
||||
//TODO - deprecate this one at 1.0
|
||||
$.mobile.updateHash = path.set;
|
||||
|
||||
|
||||
//expose path object on $.mobile
|
||||
$.mobile.path = path;
|
||||
|
||||
|
||||
//expose base object on $.mobile
|
||||
$.mobile.base = base;
|
||||
|
||||
//url stack, useful when plugins need to be aware of previous pages viewed
|
||||
//TODO: deprecate this one at 1.0
|
||||
$.mobile.urlstack = urlHistory.stack;
|
||||
|
||||
|
||||
//history stack
|
||||
$.mobile.urlHistory = urlHistory;
|
||||
|
||||
|
|
@ -255,19 +255,19 @@
|
|||
currPage = urlHistory.getActive(),
|
||||
back = false,
|
||||
forward = false;
|
||||
|
||||
|
||||
|
||||
|
||||
// If we are trying to transition to the same page that we are currently on ignore the request.
|
||||
// an illegal same page request is defined by the current page being the same as the url, as long as there's history
|
||||
// and to is not an array or object (those are allowed to be "same")
|
||||
if( currPage && urlHistory.stack.length > 1 && currPage.url === url && !toIsArray && !toIsObject ) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if the changePage was sent from a hashChange event
|
||||
// guess if it came from the history menu
|
||||
if( fromHashChange ){
|
||||
|
||||
|
||||
// check if url is in history and if it's ahead or behind current page
|
||||
$.each( urlHistory.stack, function( i ){
|
||||
//if the url is in the stack, it's a forward or a back
|
||||
|
|
@ -281,7 +281,7 @@
|
|||
urlHistory.activeIndex = i;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//if it's a back, use reverse animation
|
||||
if( back ){
|
||||
reverse = true;
|
||||
|
|
@ -291,7 +291,7 @@
|
|||
transition = transition || urlHistory.getActive().transition;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( toIsObject && to.url ){
|
||||
url = to.url,
|
||||
|
|
@ -303,7 +303,7 @@
|
|||
if($.type( data ) == "object" ){
|
||||
data = $.param(data);
|
||||
}
|
||||
|
||||
|
||||
url += "?" + data;
|
||||
data = undefined;
|
||||
}
|
||||
|
|
@ -329,8 +329,8 @@
|
|||
var currScroll = $window.scrollTop(),
|
||||
perspectiveTransitions = ["flip"],
|
||||
pageContainerClasses = [];
|
||||
|
||||
//support deep-links to generated sub-pages
|
||||
|
||||
//support deep-links to generated sub-pages
|
||||
if( url.indexOf( "&" + $.mobile.subPageUrlKey ) > -1 ){
|
||||
to = $( "[data-url='" + url + "']" );
|
||||
}
|
||||
|
|
@ -351,16 +351,16 @@
|
|||
path.set( url );
|
||||
urlHistory.listeningEnabled = true;
|
||||
}
|
||||
|
||||
|
||||
//add page to history stack if it's not back or forward
|
||||
if( !back && !forward ){
|
||||
urlHistory.addNew( url, transition );
|
||||
}
|
||||
|
||||
|
||||
removeActiveLinkClass();
|
||||
|
||||
//jump to top or prev scroll, sometimes on iOS the page has not rendered yet. I could only get by this with a setTimeout, but would like to avoid that.
|
||||
$.mobile.silentScroll( to.data( 'lastScroll' ) );
|
||||
$.mobile.silentScroll( to.data( 'lastScroll' ) );
|
||||
reFocus( to );
|
||||
|
||||
//trigger show/hide events, allow preventing focus change through return false
|
||||
|
|
@ -387,8 +387,8 @@
|
|||
|
||||
pageContainerClasses = [];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(transition && (transition !== 'none')){
|
||||
$.mobile.pageLoading( true );
|
||||
|
|
@ -402,7 +402,7 @@
|
|||
* This is in a setTimeout because we were often seeing pages in not animate across but rather go straight to
|
||||
* the 'to' page. The loadComplete would still fire, so the browser thought it was applying the animation. From
|
||||
* what I could tell this was a problem with the classes not being applied yet.
|
||||
*/
|
||||
*/
|
||||
setTimeout(function() { from.addClass( transition + " out " + ( reverse ? "reverse" : "" ) );
|
||||
to.addClass( $.mobile.activePageClass + " " + transition +
|
||||
" in " + ( reverse ? "reverse" : "" ) ); } , 0);
|
||||
|
|
@ -452,7 +452,7 @@
|
|||
fileUrl = toIDfileurl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ensure a transition has been set where pop is undefined
|
||||
defaultTransition();
|
||||
|
||||
|
|
@ -477,23 +477,23 @@
|
|||
type: type,
|
||||
data: data,
|
||||
success: function( html ) {
|
||||
|
||||
//pre-parse html to check for a data-url,
|
||||
|
||||
//pre-parse html to check for a data-url,
|
||||
//use it as the new fileUrl, base path, etc
|
||||
var redirectLoc = / data-url="(.*)"/.test( html ) && RegExp.$1;
|
||||
|
||||
if( redirectLoc ){
|
||||
if(base){
|
||||
base.set( redirectLoc );
|
||||
}
|
||||
}
|
||||
url = fileUrl = path.makeAbsolute( path.getFilePath( redirectLoc ) );
|
||||
}
|
||||
else {
|
||||
if(base){
|
||||
base.set(fileUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var all = $("<div></div>");
|
||||
//workaround to allow scripts to execute when included in page divs
|
||||
all.get(0).innerHTML = html;
|
||||
|
|
@ -514,7 +514,7 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//append to page and enhance
|
||||
to
|
||||
.attr( "data-url", fileUrl )
|
||||
|
|
@ -577,22 +577,22 @@
|
|||
|
||||
//click routing - direct to HTTP or Ajax, accordingly
|
||||
$( "a" ).live( "click", function(event) {
|
||||
|
||||
|
||||
var $this = $(this),
|
||||
//get href, remove same-domain protocol and host
|
||||
url = path.clean( $this.attr( "href" ) ),
|
||||
|
||||
|
||||
//check if it's external
|
||||
isExternal = path.isExternal( url ) || $this.is( "[rel='external']" ),
|
||||
|
||||
|
||||
//if target attr is specified we mimic _blank... for now
|
||||
hasTarget = $this.is( "[target]" );
|
||||
|
||||
|
||||
//if there's a data-rel=back attr, go back in history
|
||||
if( $this.is( "[data-rel='back']" ) ){
|
||||
window.history.back();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if( url === "#" ){
|
||||
//for links created purely for interaction - ignore
|
||||
|
|
@ -619,11 +619,11 @@
|
|||
//use ajax
|
||||
var transition = $this.data( "transition" ),
|
||||
direction = $this.data("direction"),
|
||||
reverse = direction && direction == "reverse" ||
|
||||
reverse = direction && direction == "reverse" ||
|
||||
// deprecated - remove by 1.0
|
||||
$this.data( "back" );
|
||||
|
||||
//this may need to be more specific as we use data-rel more
|
||||
|
||||
//this may need to be more specific as we use data-rel more
|
||||
nextPageRole = $this.attr( "data-rel" );
|
||||
|
||||
//if it's a relative href, prefix href with base url
|
||||
|
|
@ -648,16 +648,16 @@
|
|||
!$.mobile.ajaxLinksEnabled ) ){
|
||||
return;
|
||||
}
|
||||
|
||||
var to = path.stripHash( location.hash ),
|
||||
transition = triggered ? false : undefined;
|
||||
|
||||
//make sure that hash changes that produce a dialog url do nothing
|
||||
var to = path.stripHash( location.hash ),
|
||||
transition = triggered ? false : undefined;
|
||||
|
||||
//make sure that hash changes that produce a dialog url do nothing
|
||||
if( urlHistory.stack.length > 1 &&
|
||||
to.indexOf( dialogHashKey ) > -1 &&
|
||||
!$.mobile.activePage.is( ".ui-dialog" ) ){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//if to is defined, use it
|
||||
if ( to ){
|
||||
|
|
|
|||
Loading…
Reference in a new issue