|
From: <pe...@us...> - 2012-08-12 19:39:36
|
Revision: 945
http://openautomation.svn.sourceforge.net/openautomation/?rev=945&view=rev
Author: peuter
Date: 2012-08-12 19:39:29 +0000 (Sun, 12 Aug 2012)
Log Message:
-----------
* fix for browser history usage and back button
Modified Paths:
--------------
CometVisu/trunk/visu/lib/templateengine.js
Modified: CometVisu/trunk/visu/lib/templateengine.js
===================================================================
--- CometVisu/trunk/visu/lib/templateengine.js 2012-08-12 19:03:51 UTC (rev 944)
+++ CometVisu/trunk/visu/lib/templateengine.js 2012-08-12 19:39:29 UTC (rev 945)
@@ -385,10 +385,10 @@
// reaction on browser back button
window.onpopstate = function(e) {
// where do we come frome?
- lastpage = $('body').data("lastpage")
+ lastpage = e.state;
if (lastpage) {
- // browser back button takes us one level higher
- scrollToPage(lastpage);
+ // browser back button takes back to the last page
+ scrollToPage(lastpage,0,true);
}
}
@@ -548,7 +548,7 @@
return retval;
}
-function scrollToPage( page_id, speed ) {
+function scrollToPage( page_id, speed, skipHistory ) {
$('.activePage').removeClass('activePage');
$('.pagejump.active').removeClass('active');
if (page_id.match(/^id_[0-9_]+$/)==null) {
@@ -563,21 +563,9 @@
$('#'+page_id).addClass('pageActive activePage'); // show new page
$('#'+page_id+'_navbar').addClass('navbarActive');
- // which is the parent of target page_id?
- // => set this id as lastpage in url for window.onpopstate handling
- var path = page_id.split( '_' );
- if (path.length > 2) {
- var parentPage=getParentPage($('#'+page_id));
- if (parentPage!=null)
- $('body').data("lastpage", parentPage.attr("id"));
- }
- else {
- // top level
- $('body').data("lastpage", page_id);
- }
-
// push new state to history
- window.history.pushState(page_id, page_id, window.location.href);
+ if (skipHistory==undefined)
+ window.history.pushState(page_id, page_id, window.location.href);
main_scroll.seekTo( $('#'+page_id), speed ); // scroll to it
var pagedivs=$('div', '#'+page_id);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|