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