From 0a6f2ffdb022e9b0a2dfffd53cdb97d32536d407 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 26 Jan 2013 23:45:38 +0400 Subject: [PATCH] added history special anchors (still a bit flaky, need a rethink)... Signed-off-by: Alex A. Naanou --- index.html | 27 +++++++++++++++++++++------ magazine.js | 17 +++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 2e02862..0f725a3 100755 --- a/index.html +++ b/index.html @@ -42,7 +42,18 @@ $(document).ready(function(){ }) .bind('hashchange', function(e){ e.preventDefault() - setCurrentPage(loadURLState()) + var r = loadURLState() + // if we are dealing with history actions the browser will + // do the work for us... + if(r == 'back'){ + window.history.go(-2) + return + } else if(r == 'forward'){ + window.history.go(2) + return + } else { + setCurrentPage(r) + } }) $('.viewer') @@ -179,7 +190,7 @@ $(document).ready(function(){ Page #1
Named page

- Anchor on page #3
+ Anchor on page #3
currently navigation via existing anchors will break the layout, so use the name attribute on any other tags (see example). @@ -204,13 +215,17 @@ $(document).ready(function(){ Previous page
Next article
Previous article
+

History support

+ NOTE: this is still a bit flaky...
+ Go back
+ Go forward
- next page...
+ configuration demo next page...
-