From f4be51c97b429444822d7396c2e70caada26ab99 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 9 Feb 2013 16:26:17 +0400 Subject: [PATCH] several minor tweeks and generalizations... Signed-off-by: Alex A. Naanou --- lib/jli.js | 11 +++++++---- magazine.js | 8 ++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/jli.js b/lib/jli.js index 2797695..e1c65ca 100755 --- a/lib/jli.js +++ b/lib/jli.js @@ -22,8 +22,8 @@ // if class_list is a list, the resulting function understands the // folowing arguments: // - : 0 for 'off' and 1 for 'on' (see below) -// - 'on' : switch mode on -// - 'off' : switch mode off +// - 'on' : switch mode on -- add class +// - 'off' : switch mode off -- remove class // - '?' : return current state ('on'|'off') // - no arguments : toggle the state // @@ -33,10 +33,13 @@ // - '?' : return current state ('on'|'off') // - no arguments : set next state in cycle // +// NOTE: a special class name 'none' means no class is set, if it is present +// in the class_list then that state will be with all other state +// classes removed. // NOTE: must be an exact match to a string given in class_list // NOTE: of only one callback is given then it will be called after the -// class change... -// a way around this is to pass an empty function as callback_b +// class change... +// a way around this is to pass an empty function as callback_b // function createCSSClassToggler(elem, class_list, callback_a, callback_b){ var bool_action = false diff --git a/magazine.js b/magazine.js index 64b174b..baefc22 100755 --- a/magazine.js +++ b/magazine.js @@ -115,6 +115,8 @@ function updateView(){ function isPageResizable(page){ if(page == null){ page = $('.current.page') + } else { + page = $(page) } if(!USE_REAL_PAGE_SIZES){ return false @@ -147,6 +149,8 @@ function isPageResizable(page){ function getPageAlign(page){ if(page == null){ page = $('.current.page') + } else { + page = $(page) } var mag = $('.magazine') @@ -191,6 +195,8 @@ function getPageScale(){ function getPageNumber(page){ if(page == null){ page = $('.current.page') + } else { + page = $(page) } return $('.page').index(page) } @@ -1126,6 +1132,7 @@ JSONMetadata = { function readMetadata(elem, res, metadata){ + elem = $(elem) if(res == null){ res = {} } @@ -1144,6 +1151,7 @@ function readMetadata(elem, res, metadata){ return res } function writeMetadata(elem, res, metadata){ + elem = $(elem) if(metadata == null){ metadata = JSONMetadata }