fixed a feature that made me make the same mistake three times...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-02-26 18:55:20 +04:00
parent 16968d7876
commit 21fca66036
3 changed files with 19 additions and 5 deletions

View File

@ -1,5 +1,5 @@
[_] 37% Priority work [_] 37% Priority work
[_] 65% general todo [_] 66% general todo
[_] 37% Version 1.0 checklist (migration to layout.html) [_] 37% Version 1.0 checklist (migration to layout.html)
[X] page scaling for full page view [X] page scaling for full page view
[X] top/bottom toolbars [X] top/bottom toolbars
@ -88,7 +88,7 @@
[_] scrollend [_] scrollend
[_] 0% snap [_] 0% snap
[_] snapped [_] snapped
[_] BUG: full-page-view-mode class does not apply to some elements... [X] BUG: full-page-view-mode class does not apply to some elements...
| - toolbars | - toolbars
| - bookmarks | - bookmarks
[_] BUG: #URLs do not all work in the new index... [_] BUG: #URLs do not all work in the new index...

View File

@ -23,7 +23,7 @@ var toggleThemes = createCSSClassToggler('.chrome', [
var togglePageFitMode = createCSSClassToggler( var togglePageFitMode = createCSSClassToggler(
'.chrome', '.chrome',
'.page-fit-to-viewer', 'page-fit-to-viewer',
function(action){ function(action){
if(action == 'on'){ if(action == 'on'){
var n = getPageNumber() var n = getPageNumber()
@ -39,7 +39,7 @@ var togglePageFitMode = createCSSClassToggler(
var togglePageView = createCSSClassToggler( var togglePageView = createCSSClassToggler(
'.chrome', '.chrome',
'.full-page-view-mode', 'full-page-view-mode',
function(action){ function(action){
var view = $('.viewer') var view = $('.viewer')
var page = $('.page') var page = $('.page')

View File

@ -41,13 +41,27 @@
// 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
// // NOTE: due to several times I've repeated the same mistake of forgetting
// to write the classes without leading dots, this now will normalize
// the class list, so now this will correctly treat both dotted
// and non-dotted class names...
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
if(typeof(class_list) == typeof('')){ if(typeof(class_list) == typeof('')){
class_list = ['none', class_list] class_list = ['none', class_list]
bool_action = true bool_action = true
} }
// Normalize classes -- remove the dot from class names...
// NOTE: this is here because I've made the error of including a
// leading "." almost every time I use this after I forget
// the UI...
class_list = $(class_list).map(function(i, e){
return $(e.split(' ')).map(function(i, c){
c = c.trim()
return c[0] == '.' ? c.slice(1) : c
}).toArray().join(' ')
}).toArray()
// normalize the callbacks...
if(callback_b == null){ if(callback_b == null){
var callback_pre = null var callback_pre = null
var callback_post = callback_a var callback_post = callback_a