mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +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; | 	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... */ | /* DEBUG stuff... */ | ||||||
| .container-center { | .container-center { | ||||||
|  | |||||||
| @ -157,6 +157,9 @@ if(typeof(args2array) != 'function'){ | |||||||
| // 	  registered from the current object and up to the base action set
 | // 	  registered from the current object and up to the base action set
 | ||||||
| // 	  will be fired.
 | // 	  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, 
 | // NOTE: actions once defined do not depend on the inheritance hierarchy, 
 | ||||||
| // 		other than the .getHandlers(..) method. If this method is not 
 | // 		other than the .getHandlers(..) method. If this method is not 
 | ||||||
| // 		found in the inheritance chain (i.e. the link to MetaActions)
 | // 		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) | 		var handlers = getHandlers.call(this, name) | ||||||
| 			.map(function(h){ return h.apply(that, args) }) | 			.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 
 | 		// NOTE: this action will get included and called by the code 
 | ||||||
| 		// 		above and below, so no need to explicitly call func...
 | 		// 		above and below, so no need to explicitly call func...
 | ||||||
| 
 | 
 | ||||||
| 		// call handlers -- post phase...
 | 		// call handlers -- post phase...
 | ||||||
| 		// NOTE: post handlers need to get called last run pre first run post...
 | 		// 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...
 | 			// function...
 | ||||||
| 			if(h instanceof Function){ | 			if(h instanceof Function){ | ||||||
| 				//h.call(that, res)
 | 				var r = h.call(that) | ||||||
| 				h.call(that) | 				res = i == 0 ? r : res | ||||||
| 
 | 
 | ||||||
| 			// deferred...
 | 			// deferred...
 | ||||||
| 			} else if(h != null && h.resolve instanceof Function){ | 			} else if(h != null && h.resolve instanceof Function){ | ||||||
| 				//h.resolve(res)
 |  | ||||||
| 				h.resolve() | 				h.resolve() | ||||||
|  | 				res = i == 0 ? h : res | ||||||
| 			}  | 			}  | ||||||
| 		}) | 		}) | ||||||
| 
 | 
 | ||||||
| 		//return res
 | 		return res || this | ||||||
| 		return this | 		//return this
 | ||||||
| 	} | 	} | ||||||
| 	meth.__proto__ = this.__proto__ | 	meth.__proto__ = this.__proto__ | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -117,6 +117,8 @@ var USE_3D_TRANSFORM = true | |||||||
| //
 | //
 | ||||||
| // NOTE: for single state toggling, 'none' will get passed to 
 | // NOTE: for single state toggling, 'none' will get passed to 
 | ||||||
| // 		state_accessor to indicate an "empty" state...
 | // 		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
 | // 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
 | // 		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 | 			var action = b == 'next' ? null : b | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | 		e = e instanceof Function ? e.call(this) : e | ||||||
|  | 
 | ||||||
| 		// XXX is this correct???
 | 		// XXX is this correct???
 | ||||||
| 		var args = args2array(arguments).slice(2) | 		var args = args2array(arguments).slice(2) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -94,6 +94,9 @@ module.GLOBAL_KEYBOARD = { | |||||||
| 
 | 
 | ||||||
| 		// XXX testing...
 | 		// XXX testing...
 | ||||||
| 
 | 
 | ||||||
|  | 		Enter: 'toggleSingleImage', | ||||||
|  | 		B: 'toggleTheme', | ||||||
|  | 
 | ||||||
| 		Home: { | 		Home: { | ||||||
| 			default: 'firstImage', | 			default: 'firstImage', | ||||||
| 			ctrl: 'firstGlobalImage', | 			ctrl: 'firstGlobalImage', | ||||||
|  | |||||||
| @ -572,10 +572,11 @@ actions.Actions(Client, { | |||||||
| 		function(){ | 		function(){ | ||||||
| 			toggleFullscreenMode()  | 			toggleFullscreenMode()  | ||||||
| 		}], | 		}], | ||||||
| 	toggleSingleImage: ['', | 	toggleSingleImage: ['Toggle single image view',  | ||||||
| 		function(){ | 		// XXX this is wrong!!!
 | ||||||
| 			// XXX
 | 		makeCSSClassToggler( | ||||||
| 		}], | 			function(){ return this.ribbons.viewer },  | ||||||
|  | 			'single-image-mode') ], | ||||||
| 	// XXX revise this...
 | 	// XXX revise this...
 | ||||||
| 	showDevTools: ['', | 	showDevTools: ['', | ||||||
| 		function(){ | 		function(){ | ||||||
| @ -584,6 +585,14 @@ actions.Actions(Client, { | |||||||
| 			} | 			} | ||||||
| 		}], | 		}], | ||||||
| 
 | 
 | ||||||
|  | 	toggleTheme: ['',  | ||||||
|  | 		makeCSSClassToggler( | ||||||
|  | 			function(){ return this.ribbons.viewer },  | ||||||
|  | 			[ | ||||||
|  | 				'gray',  | ||||||
|  | 				'dark',  | ||||||
|  | 				'light' | ||||||
|  | 			]) ], | ||||||
| 
 | 
 | ||||||
| 	// align modes...
 | 	// align modes...
 | ||||||
| 	// XXX skip invisible ribbons (???)
 | 	// XXX skip invisible ribbons (???)
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user