Skip to content

Instantly share code, notes, and snippets.

@mchristie
Created October 28, 2011 09:17
Show Gist options
  • Save mchristie/1321936 to your computer and use it in GitHub Desktop.
Save mchristie/1321936 to your computer and use it in GitHub Desktop.
ui.changePage = function(url, isBack)
{
if (ui.clickPrevent) return false;
ui.clickPrevent = true;
setTimeout(function(){ ui.clickPrevent = false;}, 1000);
try {
if(device.platform.indexOf('iPhone') !== -1 || device.platform.indexOf('iPad') !== -1){
window.plugins.googleAnalyticsPlugin.trackPageview('/' + url);
}else{
window.plugins.analytics.trackPageView('/' + url,
function(e){
console.log('Track Event Success ' + e);
},
function(e){
console.log('Track Event Failed ' + e);
}
);
}
} catch(e) {
console.log('googleAnalyticsPlugin.trackPageview threw exception');
}
ui.previousPage = ui.currentPage;
ui.currentPage = url;
if (url != ui.historyStack[ui.historyStack.length-1]) ui.historyStack.push(url);
var urlVars = url.split('#');
url = urlVars[0];
id = urlVars[1];
if (url.indexOf('.html') == -1) url = url+'.html';
if (url == 'articlePage.html' && id)
{
ui.isImageZoomed = false;
ui.onPageChangeFunction = ui.showArticle;
ui.tempIpc_id = id;
if (ui.currentArticlePage == 'a')
{
url = 'articlePageB.html'
ui.currentArticlePage = 'b'
}
else
{
url = 'articlePageA.html'
ui.currentArticlePage = 'a'
}
}
else if (url == 'gallery.html')
{
ui.onPageChangeFunction = ui.showGallery;
ui.tempIpc_id = id;
}
else if (url == 'galleryLarge.html')
{
ui.onPageChangeFunction = ui.showGalleryLarge;
ui.tempIpc_id = id;
}
else if (url == 'videoPage.html')
{
// Device callback stuff
}
else
{
ui.clearOnPageChangeFunction()
}
$.mobile.changePage( url, {
transition: 'slide',
role: 'page',
reverse: isBack
} );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment