mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
added action return value support + started work on toggler actions...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c0252494e1
commit
b88be66316
@ -78,6 +78,15 @@
|
||||
transition: none;
|
||||
}
|
||||
|
||||
/* XXX think of a way not to use !important */
|
||||
.viewer.single-image-mode .ribbon {
|
||||
-webkit-transition: none !important;
|
||||
-moz-transition: none !important;
|
||||
-ms-transition: none !important;
|
||||
-o-transition: none !important;
|
||||
transition: none !important;
|
||||
}
|
||||
|
||||
|
||||
/* DEBUG stuff... */
|
||||
.container-center {
|
||||
|
||||
@ -157,6 +157,9 @@ if(typeof(args2array) != 'function'){
|
||||
// registered from the current object and up to the base action set
|
||||
// will be fired.
|
||||
//
|
||||
// - an action will return the last deepest action's return, if that
|
||||
// return is null, then the action set is returned.
|
||||
//
|
||||
// NOTE: actions once defined do not depend on the inheritance hierarchy,
|
||||
// other than the .getHandlers(..) method. If this method is not
|
||||
// found in the inheritance chain (i.e. the link to MetaActions)
|
||||
@ -210,26 +213,29 @@ function Action(name, doc, ldoc, func){
|
||||
var handlers = getHandlers.call(this, name)
|
||||
.map(function(h){ return h.apply(that, args) })
|
||||
|
||||
// XXX use the last return as result...
|
||||
var res = handlers.slice(-1)[0]
|
||||
|
||||
// NOTE: this action will get included and called by the code
|
||||
// above and below, so no need to explicitly call func...
|
||||
|
||||
// call handlers -- post phase...
|
||||
// NOTE: post handlers need to get called last run pre first run post...
|
||||
handlers.reverse().forEach(function(h){
|
||||
handlers.reverse().forEach(function(h, i){
|
||||
// function...
|
||||
if(h instanceof Function){
|
||||
//h.call(that, res)
|
||||
h.call(that)
|
||||
var r = h.call(that)
|
||||
res = i == 0 ? r : res
|
||||
|
||||
// deferred...
|
||||
} else if(h != null && h.resolve instanceof Function){
|
||||
//h.resolve(res)
|
||||
h.resolve()
|
||||
res = i == 0 ? h : res
|
||||
}
|
||||
})
|
||||
|
||||
//return res
|
||||
return this
|
||||
return res || this
|
||||
//return this
|
||||
}
|
||||
meth.__proto__ = this.__proto__
|
||||
|
||||
|
||||
@ -117,6 +117,8 @@ var USE_3D_TRANSFORM = true
|
||||
//
|
||||
// NOTE: for single state toggling, 'none' will get passed to
|
||||
// state_accessor to indicate an "empty" state...
|
||||
// NOTE: if elem is a function it will be called in the same context as
|
||||
// the toggler and is expected to return the element.
|
||||
//
|
||||
// XXX technically we do not need both elem and state_accessor here, the
|
||||
// later is enough, but as strict mode is not stable enough (sometimes
|
||||
@ -153,6 +155,8 @@ function makeToggler(elem, state_accessor, states, callback_a, callback_b){
|
||||
var action = b == 'next' ? null : b
|
||||
}
|
||||
|
||||
e = e instanceof Function ? e.call(this) : e
|
||||
|
||||
// XXX is this correct???
|
||||
var args = args2array(arguments).slice(2)
|
||||
|
||||
|
||||
@ -94,6 +94,9 @@ module.GLOBAL_KEYBOARD = {
|
||||
|
||||
// XXX testing...
|
||||
|
||||
Enter: 'toggleSingleImage',
|
||||
B: 'toggleTheme',
|
||||
|
||||
Home: {
|
||||
default: 'firstImage',
|
||||
ctrl: 'firstGlobalImage',
|
||||
|
||||
@ -572,10 +572,11 @@ actions.Actions(Client, {
|
||||
function(){
|
||||
toggleFullscreenMode()
|
||||
}],
|
||||
toggleSingleImage: ['',
|
||||
function(){
|
||||
// XXX
|
||||
}],
|
||||
toggleSingleImage: ['Toggle single image view',
|
||||
// XXX this is wrong!!!
|
||||
makeCSSClassToggler(
|
||||
function(){ return this.ribbons.viewer },
|
||||
'single-image-mode') ],
|
||||
// XXX revise this...
|
||||
showDevTools: ['',
|
||||
function(){
|
||||
@ -584,6 +585,14 @@ actions.Actions(Client, {
|
||||
}
|
||||
}],
|
||||
|
||||
toggleTheme: ['',
|
||||
makeCSSClassToggler(
|
||||
function(){ return this.ribbons.viewer },
|
||||
[
|
||||
'gray',
|
||||
'dark',
|
||||
'light'
|
||||
]) ],
|
||||
|
||||
// align modes...
|
||||
// XXX skip invisible ribbons (???)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user