some tweaking and cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-10-18 04:44:03 +04:00
parent 84da434226
commit d1db72b938
2 changed files with 5 additions and 132 deletions

View File

@ -99,138 +99,8 @@ var USE_3D_TRANSFORM = true
// we are changing into but the changes are not yet made.
// NOTE: if the pre-callback explicitly returns false, then the change will
// not be made.
/*
function createCSSClassToggler(elem, class_list, callback_a, callback_b){
var bool_action = false
if(typeof(class_list) == typeof('')){
class_list = ['none', class_list]
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(_, e){
return $(e.split(' ')).map(function(_, c){
c = c.trim()
return c[0] == '.' ? c.slice(1) : c
}).toArray().join(' ')
}).toArray()
// normalize the callbacks...
if(callback_b == null){
var callback_pre = null
var callback_post = callback_a
} else {
var callback_pre = callback_a
var callback_post = callback_b
}
// XXX make this generic...
var func = function(a, b){
if(b == null){
var action = a == 'next' ? null : a
var e = elem
} else {
var e = a
var action = b == 'next' ? null : b
}
var args = args2array(arguments).slice(2)
e = $(e)
// option number...
if(typeof(action) == typeof(1)){
// range check...
if(action < 0 || action >= class_list.length){
return null
}
if(bool_action){
action = action == 0 ? 'off' : 'on'
} else {
action = class_list[action]
}
}
// we need to get the current state...
if(action == null || action == '?' || action == '!'){
// get current state...
var cur = 'none'
for(var i=0; i < class_list.length; i++){
if(e.hasClass(class_list[i])){
cur = class_list[i]
break
}
}
// just asking for info...
if(action == '?'){
return bool_action ? (cur == 'none' ? 'off' : 'on') : cur
}
// force reload of current state...
if(action == '!'){
action = bool_action ? (cur == 'none' ? 'off' : 'on') : cur
}
// invalid action...
} else if((bool_action && ['on', 'off'].indexOf(action) == -1)
|| (!bool_action && class_list.indexOf(action) == -1)){
return null
}
var cls = bool_action ? class_list[1] : action
// get the right class...
if(action == null){
var i = class_list.indexOf(cur)+1
i = i == -1 ? 0 : i
i = i == class_list.length ? 0 : i
cls = class_list[i]
if(bool_action){
action = cls == 'none' ? 'off' : 'on'
} else {
action = cls
}
}
// NOTE: the callbacks are passed the same this as the calling
// function, this will enable them to act as metods correctly
// pre callback...
if(callback_pre != null){
if(callback_pre.apply(this, [action, e].concat(args)) === false){
// XXX should we return action here???
//return
return func('?')
}
}
// update the element...
e.removeClass(class_list.join(' '))
if(cls != 'none' && action != 'off'){
e.addClass(cls)
}
// post callback...
if(callback_post != null){
callback_post.apply(this, [action, e].concat(args))
}
return action
}
func.class_list = class_list
if(bool_action){
func.doc = 'With no arguments this will toggle between "on" and '+
'"off".\n'+
'If either "on" or "off" are given then this will switch '+
'to that mode.\n'+
'If "?" is given, this will return either "on" or "off" '+
'depending on the current state.'
}else{
func.doc = 'With no arguments this will toggle between '+
class_list +' in cycle.\n' +
'if any of the state names or its number is given then that '+
'state is switched on.'+
'If "?" is given, this will return the current state.'
}
return func
}
*/
//
// XXX revize/update this doc for makeToggler(..)
// Make a generic toggler function/method...

View File

@ -482,6 +482,9 @@ actions.Actions(Client, {
fitSeven: ['Fit seven images', function(){ this.fitImage(7) }],
fitEight: ['Fit eight images', function(){ this.fitImage(8) }],
fitNine: ['Fit nine images', function(){ this.fitImage(9) }],
fitTen: ['Fit ten images', function(){ this.fitImage(10) }],
fitEleven: ['Fit eleven images', function(){ this.fitImage(11) }],
fitTwelve: ['Fit twelve images', function(){ this.fitImage(12) }],
// XXX
fitMax: ['Fit the maximum number of images',