mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 19:00:09 +00:00 
			
		
		
		
	added action events and automatic state saving...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									3a4a276f63
								
							
						
					
					
						commit
						193086a4e4
					
				
							
								
								
									
										12
									
								
								ui/TODO.otl
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								ui/TODO.otl
									
									
									
									
									
								
							| @ -1,14 +1,16 @@ | |||||||
| Priority work | Priority work | ||||||
| 	[_] 67% Preview II | 	[_] 68% Preview II | ||||||
| 		[_] 42% save state | 		[_] 47% save state | ||||||
| 			[X] minimal: Local Storage (manual) | 			[X] minimal: Local Storage (manual) | ||||||
| 			| works across all targets (CEF, PhoneGap, browser) | 			| works across all targets (CEF, PhoneGap, browser) | ||||||
| 			[_] local JSON (file) | 			[_] local JSON (file) | ||||||
| 			[_] CouchDB | 			[_] CouchDB | ||||||
| 			[_] 0% autosave | 			[_] 33% autosave | ||||||
| 				[_] on edit | 				[X] on edit | ||||||
|  | 				[_] on navigate | ||||||
|  | 				| only save position to save time... | ||||||
| 				[_] on timer | 				[_] on timer | ||||||
| 			[X] manual save | 			[X] manual incremental save | ||||||
| 			[_] manual named save | 			[_] manual named save | ||||||
| 			[X] versions/history | 			[X] versions/history | ||||||
| 		[_] 66% load state | 		[_] 66% load state | ||||||
|  | |||||||
| @ -24,10 +24,18 @@ var ImageGrid = { | |||||||
| 	// 		call	- callable
 | 	// 		call	- callable
 | ||||||
| 	// XXX revise...
 | 	// XXX revise...
 | ||||||
| 	ACTION: function(obj, func){ | 	ACTION: function(obj, func){ | ||||||
|  | 		var base = this | ||||||
|  | 		var id = func.name != '' ? func.name : obj.id | ||||||
|  | 
 | ||||||
| 		if(func != null){ | 		if(func != null){ | ||||||
| 			obj = $.extend(obj, { | 			obj = $.extend(obj, { | ||||||
| 				id: func.name != '' ? func.name : obj.id, | 				id: id, | ||||||
| 				call: func  | 				//call: func 
 | ||||||
|  | 				call: function(){ | ||||||
|  | 					res = func.apply(base, arguments) | ||||||
|  | 					$(document).trigger(id) | ||||||
|  | 					return res | ||||||
|  | 				} | ||||||
| 			}) | 			}) | ||||||
| 		} | 		} | ||||||
| 		// add all the attrs to the function...
 | 		// add all the attrs to the function...
 | ||||||
| @ -99,7 +107,20 @@ ImageGrid.GROUP('API', | |||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 		}), | 		}), | ||||||
|  | 	ImageGrid.ACTION({ | ||||||
|  | 			doc: 'Get documentation for name.', | ||||||
|  | 			group: 'API', | ||||||
|  | 			display: false, | ||||||
|  | 		}, | ||||||
|  | 		function doc(name){ | ||||||
|  | 			return { | ||||||
|  | 				action: this[name] != null ? this[name].doc : null, | ||||||
|  | 				action_func: this[name] != null ? this[name].func_doc : null, | ||||||
|  | 				option: this.option_props[name] != null ? this.option_props[name].doc : null, | ||||||
|  | 			} | ||||||
|  | 		})) | ||||||
| 
 | 
 | ||||||
|  | ImageGrid.GROUP('State', | ||||||
| 	ImageGrid.ACTION({ | 	ImageGrid.ACTION({ | ||||||
| 			doc: 'Save state to local storage', | 			doc: 'Save state to local storage', | ||||||
| 			group: 'API', | 			group: 'API', | ||||||
| @ -182,7 +203,6 @@ ImageGrid.GROUP('API', | |||||||
| 			history.push(cur) | 			history.push(cur) | ||||||
| 			$.jStorage.set(this.option.KEY_NAME_HISTORY, history) | 			$.jStorage.set(this.option.KEY_NAME_HISTORY, history) | ||||||
| 		}), | 		}), | ||||||
| 
 |  | ||||||
| 	ImageGrid.ACTION({ | 	ImageGrid.ACTION({ | ||||||
| 			doc: 'Sync and update option values.\n\n'+ | 			doc: 'Sync and update option values.\n\n'+ | ||||||
| 					'NOTE: this is here because JS has no direct way to '+ | 					'NOTE: this is here because JS has no direct way to '+ | ||||||
| @ -200,18 +220,6 @@ ImageGrid.GROUP('API', | |||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 			return this.option	 | 			return this.option	 | ||||||
| 		}), |  | ||||||
| 	ImageGrid.ACTION({ |  | ||||||
| 			doc: 'Get documentation for name.', |  | ||||||
| 			group: 'API', |  | ||||||
| 			display: false, |  | ||||||
| 		}, |  | ||||||
| 		function doc(name){ |  | ||||||
| 			return { |  | ||||||
| 				action: this[name] != null ? this[name].doc : null, |  | ||||||
| 				action_func: this[name] != null ? this[name].func_doc : null, |  | ||||||
| 				option: this.option_props[name] != null ? this.option_props[name].doc : null, |  | ||||||
| 			} |  | ||||||
| 		})) | 		})) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -221,8 +229,10 @@ ImageGrid.TYPE('toggle', function(obj){ | |||||||
| 	// wrap the call to set the option...
 | 	// wrap the call to set the option...
 | ||||||
| 	// XXX this is context mirroring...
 | 	// XXX this is context mirroring...
 | ||||||
| 	obj.call = function(action){ | 	obj.call = function(action){ | ||||||
| 		var res = call(action) | 		//var res = call(action)
 | ||||||
| 		ImageGrid.option[obj.id] = call('?') | 		var res = call.apply(ImageGrid, [action]) | ||||||
|  | 		//ImageGrid.option[obj.id] = call('?')
 | ||||||
|  | 		ImageGrid.option[obj.id] = call.apply(ImageGrid, ['?']) | ||||||
| 		return res | 		return res | ||||||
| 	} | 	} | ||||||
| 	// add an option to store the state...
 | 	// add an option to store the state...
 | ||||||
| @ -1006,6 +1016,19 @@ function setDefaultInitialState(){ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| function setupEvents(){ | function setupEvents(){ | ||||||
|  | 	// persistence...
 | ||||||
|  | 	$(document) | ||||||
|  | 		// main modifier events...
 | ||||||
|  | 		.bind('shiftImageUp shiftImageDown reverseImageOrder '+ | ||||||
|  | 				'reverseRibbons shiftImageUpNewRibbon shiftImageDownNewRibbon',  | ||||||
|  | 				ImageGrid.saveState) | ||||||
|  | 		/* | ||||||
|  | 		// XXX should this be here?
 | ||||||
|  | 		.bind('nextImage prevImage nextScreenImages prevScreenImages '+ | ||||||
|  | 				'focusAboveRibbon focusBelowRibbon',  | ||||||
|  | 				ImageGrid.saveState) | ||||||
|  | 		*/ | ||||||
|  | 
 | ||||||
| 	// resize...
 | 	// resize...
 | ||||||
| 	$(window).resize(function() { | 	$(window).resize(function() { | ||||||
| 		// XXX HACK
 | 		// XXX HACK
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user