mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	added secondary (contextmenu) action to buttons...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									e61403a06b
								
							
						
					
					
						commit
						e879072675
					
				| @ -37,6 +37,17 @@ var browseWalk = require('lib/widget/browse-walk') | |||||||
| // 			<info>, // optional
 | // 			<info>, // optional
 | ||||||
| // 			<code>,
 | // 			<code>,
 | ||||||
| // 		],
 | // 		],
 | ||||||
|  | //
 | ||||||
|  | // 		<button-text>: [
 | ||||||
|  | // 			<class>, // optional
 | ||||||
|  | // 			<info>, // optional
 | ||||||
|  | // 			[
 | ||||||
|  | // 				// primary action (click / tap)...
 | ||||||
|  | // 				<primary>,
 | ||||||
|  | // 				// secondary action (contextmenu -- right-clock / long-tap)...
 | ||||||
|  | // 				<secondary>,
 | ||||||
|  | // 			]
 | ||||||
|  | // 		],
 | ||||||
| // 		...
 | // 		...
 | ||||||
| // 	}
 | // 	}
 | ||||||
| var makeButtonControls = | var makeButtonControls = | ||||||
| @ -71,23 +82,47 @@ function(context, cls, data){ | |||||||
| 			k = ' ' | 			k = ' ' | ||||||
| 			var cls = 'spacer' | 			var cls = 'spacer' | ||||||
| 			var doc = '' | 			var doc = '' | ||||||
| 			var func = function(){} | 			var click = function(){} | ||||||
|  | 			var menu = function(){} | ||||||
| 
 | 
 | ||||||
| 		// normal element...
 | 		// normal element...
 | ||||||
| 		} else { | 		} else { | ||||||
| 			var e = data[k].slice() | 			var e = data[k].slice() | ||||||
| 			var code = e.pop() | 			var primary = e.pop() | ||||||
| 			code = typeof(code) == typeof('str') ? | 			var secondary = (primary instanceof Array && primary.length > 1) ?  | ||||||
| 				keyboard.parseActionCall(code)  | 				primary.pop()  | ||||||
| 				: code | 				: null | ||||||
|  | 			secondary = typeof(secondary) == typeof('str') ? | ||||||
|  | 				keyboard.parseActionCall(secondary)  | ||||||
|  | 				: secondary | ||||||
|  | 			primary = primary instanceof Array ? primary.shift() : primary | ||||||
|  | 			primary = typeof(primary) == typeof('str') ? | ||||||
|  | 				keyboard.parseActionCall(primary)  | ||||||
|  | 				: primary | ||||||
| 
 | 
 | ||||||
| 			var func = code instanceof Function ?  | 			var click = primary instanceof Function ?  | ||||||
| 				code  | 				primary  | ||||||
| 				: function(){  | 				: function(evt){  | ||||||
| 					context[code.action].apply(context, code.arguments) } | 					evt.stopPropagation() | ||||||
|  | 					evt.preventDefault() | ||||||
|  | 					context[primary.action].apply(context, primary.arguments) } | ||||||
|  | 			var menu = secondary instanceof Function ? | ||||||
|  | 					secondary | ||||||
|  | 				: secondary ?  | ||||||
|  | 					function(evt){  | ||||||
|  | 						evt.stopPropagation() | ||||||
|  | 						evt.preventDefault() | ||||||
|  | 						context[secondary.action].apply(context, secondary.arguments) } | ||||||
|  | 				: click | ||||||
| 
 | 
 | ||||||
| 			var cls = e[0] || code.action || ''  | 			var cls = e[0]  | ||||||
| 			var doc = e[1] || code.doc || e[0] || '' | 				|| primary.action  | ||||||
|  | 				|| ''  | ||||||
|  | 			var doc = e[1]  | ||||||
|  | 				|| (primary.doc  | ||||||
|  | 					+ (secondary ? ' / '+ secondary.doc : '')) | ||||||
|  | 				|| e[0]  | ||||||
|  | 				|| '' | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		controls | 		controls | ||||||
| @ -99,7 +134,8 @@ function(context, cls, data){ | |||||||
| 					context.showStatusBarInfo | 					context.showStatusBarInfo | ||||||
| 						&& context.showStatusBarInfo() | 						&& context.showStatusBarInfo() | ||||||
| 				}) | 				}) | ||||||
| 				.click(func)) | 				.click(click) | ||||||
|  | 				.on('contextmenu', menu)) | ||||||
| 	}) | 	}) | ||||||
| 
 | 
 | ||||||
| 	controls | 	controls | ||||||
| @ -1750,6 +1786,7 @@ module.ContextActionMenu = core.ImageGridFeatures.Feature({ | |||||||
| 
 | 
 | ||||||
| //---------------------------------------------------------------------
 | //---------------------------------------------------------------------
 | ||||||
| 	 | 	 | ||||||
|  | // XXX add context menu action to buttons...
 | ||||||
| var ButtonsActions = actions.Actions({ | var ButtonsActions = actions.Actions({ | ||||||
| 	config: { | 	config: { | ||||||
| 		'main-buttons-state': 'on', | 		'main-buttons-state': 'on', | ||||||
| @ -1761,11 +1798,25 @@ var ButtonsActions = actions.Actions({ | |||||||
| 		// 			<info>,
 | 		// 			<info>,
 | ||||||
| 		// 			<code>,
 | 		// 			<code>,
 | ||||||
| 		// 		],
 | 		// 		],
 | ||||||
|  | 		//
 | ||||||
|  | 		// 		<html>: [
 | ||||||
|  | 		// 			<css-class>,
 | ||||||
|  | 		// 			// Button info (optional)
 | ||||||
|  | 		// 			<info>,
 | ||||||
|  | 		// 			[
 | ||||||
|  | 		// 				<primary>,
 | ||||||
|  | 		// 				<secondary>,
 | ||||||
|  | 		// 			]
 | ||||||
|  | 		// 		],
 | ||||||
| 		// 		...
 | 		// 		...
 | ||||||
| 		// 	}
 | 		// 	}
 | ||||||
|  | 		//
 | ||||||
| 		'main-buttons': { | 		'main-buttons': { | ||||||
| 			'☰': ['menu', 'browseActions -- Action menu...'], | 			'☰': ['menu', 'browseActions -- Action menu...'], | ||||||
| 			'◲<sub/><sup/>': ['collections', 'browseCollections -- Collections...'], | 			'◲<sub/><sup/>': ['collections', [ | ||||||
|  | 				'browseCollections -- Collections...', | ||||||
|  | 				'browseActions: "/Collections/" -- Collection menu...', | ||||||
|  | 			]], | ||||||
| 			'C<sub/>': ['crop', 'browseActions: "Crop/" -- Crop menu...'], | 			'C<sub/>': ['crop', 'browseActions: "Crop/" -- Crop menu...'], | ||||||
| 			//'▤<sub/>': ['collections', 'browseCollections -- Collections...'],
 | 			//'▤<sub/>': ['collections', 'browseCollections -- Collections...'],
 | ||||||
| 			//'⛶': ['view', 'toggleSingleImage -- Single image / ribbon toggle'],
 | 			//'⛶': ['view', 'toggleSingleImage -- Single image / ribbon toggle'],
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user