From 0dbf94195bda5087f6f31e2950b899ae84ba4120 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 2 Feb 2013 06:46:33 +0400 Subject: [PATCH] updated editor... Signed-off-by: Alex A. Naanou --- TODO.otl | 9 ++++++++- editor.html | 16 +++++++++++++++- magazine.js | 24 ++++++++++++++---------- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/TODO.otl b/TODO.otl index b77c775..01813cd 100755 --- a/TODO.otl +++ b/TODO.otl @@ -6,7 +6,7 @@ [_] BUG: no drag threshold on excludedElements (TouchSwipe) | stalled... [_] 75% general todo - [_] 0% add two main page themes: + [_] 0% add two main page themes (global/local applicable): [_] light [_] dark [_] JSON: add page URLs as an alternative to direct content... @@ -56,6 +56,13 @@ [_] BUG: href to existing anchors will mess up layout... | need to find out how can we disable anchor links from actually | going to the anchor... + [X] 100% templates + [X] page number + [X] current page + | this is not really a template... + | + | XXX should this be a real template... + [X] magazine title [X] Editor: decide weather to make the editor toolbar oriented or floating bars around context... [X] add in-page live templates... | elements that will get generated content, like page numbers etc. diff --git a/editor.html b/editor.html index 2c16445..683cfa2 100755 --- a/editor.html +++ b/editor.html @@ -52,6 +52,10 @@ $(document).ready(function(){ .on('pageMoved articleMoved', resetNavigator) .on('pageRemoved articleRemoved', resetNavigator) + // templates... + .on('pageCreated articleCreated magazineCreated ' + + 'pageMoved pageRemoved articleMoved articleRemoved', runMagazineTemplates) + // user interactions... .swipe({ swipeStatus: swipeHandler, @@ -167,7 +171,9 @@ $(document).ready(function(){
@@ -271,6 +277,12 @@ $(document).ready(function(){

Templates...

+ + Magazine title: [MAGAZINE NAME]
+ +
[ARTICLE INDEX]
+ +
[PAGE NUMBER]
@@ -282,6 +294,8 @@ $(document).ready(function(){
Column 2
+ +
[PAGE NUMBER]
diff --git a/magazine.js b/magazine.js index a922f4e..4656871 100755 --- a/magazine.js +++ b/magazine.js @@ -1172,6 +1172,8 @@ function createCoverPage(data){ /*********************************************** editor: templates ***/ +// NOTE: for these to be self-aplicable they must only replace the content +// of the matched elements and not touch the element itself. var MagazineTemplates = { // setup titles... @@ -1181,7 +1183,15 @@ var MagazineTemplates = { || 'PortableMag') }, - // index... + // setup page numbers... + '.page-number-text': function(elem){ + elem.each(function(_, e){ + var e = $(e) + e.text(getPageNumber(e.parents('.page'))) + }) + }, + + // magazine index... '.article-index': function(elem){ var list = $('
    ') var mag = $('.magazine') @@ -1207,20 +1217,14 @@ var MagazineTemplates = { || 'Magazine'))) root.append(list) elem + // remove the original content... .html('') // cover... .append(root) - }, - - // setup page numbers... - '.page-number-text': function(elem){ - elem.each(function(_, e){ - var e = $(e) - e.text(getPageNumber(e.parents('.page'))) - }) - } + } } + // XXX call this on page edits... function runMagazineTemplates(){ for(var tpl in MagazineTemplates){