several minor tweeks and generalizations...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-02-09 16:26:17 +04:00
parent ba3efdb181
commit f4be51c97b
2 changed files with 15 additions and 4 deletions

View File

@ -22,8 +22,8 @@
// if class_list is a list, the resulting function understands the // if class_list is a list, the resulting function understands the
// folowing arguments: // folowing arguments:
// - <index> : 0 for 'off' and 1 for 'on' (see below) // - <index> : 0 for 'off' and 1 for 'on' (see below)
// - 'on' : switch mode on // - 'on' : switch mode on -- add class
// - 'off' : switch mode off // - 'off' : switch mode off -- remove class
// - '?' : return current state ('on'|'off') // - '?' : return current state ('on'|'off')
// - no arguments : toggle the state // - no arguments : toggle the state
// //
@ -33,10 +33,13 @@
// - '?' : return current state ('on'|'off') // - '?' : return current state ('on'|'off')
// - no arguments : set next state in cycle // - 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: <class-name> must be an exact match to a string given in class_list // NOTE: <class-name> 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 // NOTE: of only one callback is given then it will be called after the
// class change... // class change...
// a way around this is to pass an empty function as callback_b // a way around this is to pass an empty function as callback_b
// //
function createCSSClassToggler(elem, class_list, callback_a, callback_b){ function createCSSClassToggler(elem, class_list, callback_a, callback_b){
var bool_action = false var bool_action = false

View File

@ -115,6 +115,8 @@ function updateView(){
function isPageResizable(page){ function isPageResizable(page){
if(page == null){ if(page == null){
page = $('.current.page') page = $('.current.page')
} else {
page = $(page)
} }
if(!USE_REAL_PAGE_SIZES){ if(!USE_REAL_PAGE_SIZES){
return false return false
@ -147,6 +149,8 @@ function isPageResizable(page){
function getPageAlign(page){ function getPageAlign(page){
if(page == null){ if(page == null){
page = $('.current.page') page = $('.current.page')
} else {
page = $(page)
} }
var mag = $('.magazine') var mag = $('.magazine')
@ -191,6 +195,8 @@ function getPageScale(){
function getPageNumber(page){ function getPageNumber(page){
if(page == null){ if(page == null){
page = $('.current.page') page = $('.current.page')
} else {
page = $(page)
} }
return $('.page').index(page) return $('.page').index(page)
} }
@ -1126,6 +1132,7 @@ JSONMetadata = {
function readMetadata(elem, res, metadata){ function readMetadata(elem, res, metadata){
elem = $(elem)
if(res == null){ if(res == null){
res = {} res = {}
} }
@ -1144,6 +1151,7 @@ function readMetadata(elem, res, metadata){
return res return res
} }
function writeMetadata(elem, res, metadata){ function writeMetadata(elem, res, metadata){
elem = $(elem)
if(metadata == null){ if(metadata == null){
metadata = JSONMetadata metadata = JSONMetadata
} }