diff --git a/TODO.otl b/TODO.otl index 477351a..c678d3a 100755 --- a/TODO.otl +++ b/TODO.otl @@ -1,13 +1,13 @@ Priority work - [_] 5% basic features - [_] 42% basic article navigation + [_] 10% basic features + [_] 85% basic article navigation [X] next page [X] prev page [X] show previews [_] show global navigation bar - [_] go home - [_] go to article start - [_] go to article end + [X] go home + [X] go to prev article + [X] go to next article [_] global navigation bar [_] real previews | use zoom to show a ribbon... diff --git a/magazine.html b/magazine.html index 244272e..b74ec44 100755 --- a/magazine.html +++ b/magazine.html @@ -24,8 +24,7 @@ $(document).ready(function(){ }, click: function(evt, elem){ if($(elem).hasClass('page')){ - var pages = $('.page') - setCurrentPage(pages.index(elem)) + setCurrentPage(elem) } return true } @@ -57,7 +56,7 @@ function swipeUpdate(evt, phase, direction, distance){ mag.css({'-webkit-transition-duration': orig_duration}) } else if ( phase == 'cancel') { - setCurrentPage(pages.index($('.current.page'))) + setCurrentPage() } else if ( phase =='end' ) { // see which page is closer to the middle of the screen and set it... @@ -75,11 +74,15 @@ function swipeUpdate(evt, phase, direction, distance){ function setCurrentPage(n){ + var cur if(n == null){ cur = $('.current.page') + n = $('.page').index(cur) + } else if(typeof(n) == typeof(1)) { + cur = $($('.page')[n]) } else { - var pages = $('.page') - var cur = $(pages[n]) + cur = n + n = $('.page').index(cur) } $('.current.page').removeClass('current') @@ -104,27 +107,31 @@ function prevPage(){ } +function goToMagazineCover(){ + setCurrentPage(0) +} +function goToArticleCover(){ + setCurrentPage($('.current.page').parents('.article').children('.page').first()) +} + function nextArticle(){ - var pages = $('.page') var cur = $('.current.page').parents('.article') // we are at the magazine cover cover... if(cur.length == 0){ - var a = $('.article .page:first-child').first() - return setCurrentPage(pages.index(a)) + return setCurrentPage( + $('.article .page:first-child').first()) } // just find the next one... var articles = $('.article') return setCurrentPage( - pages.index( - $(articles[Math.min(articles.index(cur)+1, articles.length-1)]) - .children('.page') - .first())) + $(articles[Math.min(articles.index(cur)+1, articles.length-1)]) + .children('.page') + .first()) } // XXX this is almost exactly the same as nextArticle... function prevArticle(){ - var pages = $('.page') var cur = $('.current.page').parents('.article') // we are at the magazine cover cover... if(cur.length == 0){ @@ -133,10 +140,9 @@ function prevArticle(){ // just find the prev one... var articles = $('.article') return setCurrentPage( - pages.index( - $(articles[Math.max(articles.index(cur)-1, 0)]) - .children('.page') - .first())) + $(articles[Math.max(articles.index(cur)-1, 0)]) + .children('.page') + .first()) } @@ -189,6 +195,8 @@ function fitNPages(n){ } + + // XXX create magazine... function createMagazine(){ }