added hashchange and hash state...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-01-22 19:03:26 +04:00
parent 659465d2aa
commit 4895fed07b

View File

@ -378,6 +378,7 @@ function setCurrentPage(n, W){
var W = W == null ? cur.width() : W var W = W == null ? cur.width() : W
mag.css({left: -n*W}) mag.css({left: -n*W})
window.location.hash = n
// XXX should this be here??? // XXX should this be here???
saveState() saveState()
@ -474,12 +475,24 @@ function createPage(article, template){
</script> </script>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
$(window).resize(function() { $(window)
fitNPages(PAGES_VISIBLE) .resize(function() {
}) fitNPages(PAGES_VISIBLE)
})
.bind('hashchange', function(){
// XXX this is the same as the init code below...
var n = parseInt(window.location.hash.split('#')[1])
if(n != null){
setCurrentPage(n)
} else {
alert('textual anchors not yet supported...')
}
})
$('.viewer') $('.viewer')
.swipe({ .swipe({
@ -506,11 +519,19 @@ $(document).ready(function(){
$('.button.next-article').swipe({click: nextArticle}) $('.button.next-article').swipe({click: nextArticle})
$('.button.prev-article').swipe({click: prevArticle}) $('.button.prev-article').swipe({click: prevArticle})
loadState() if(window.location.hash == ''){
loadState()
} else {
var n = parseInt(window.location.hash.split('#')[1])
if(n != null){
setCurrentPage(n)
} else {
alert('textual anchors not yet supported...')
}
}
togglePageView('on') togglePageView('on')
// hide the splash screen... // hide the splash screen...
$(window).one('webkitTransitionEnd oTransitionEnd msTransitionEnd transitionend', $(window).one('webkitTransitionEnd oTransitionEnd msTransitionEnd transitionend',
function(){ function(){