| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | /********************************************************************** | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | **********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | define(function(require){ var module = {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //var DEBUG = DEBUG != null ? DEBUG : true
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | var keyboard = require('lib/keyboard') | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | var actions = require('lib/actions') | 
					
						
							|  |  |  | var features = require('lib/features') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-01 16:12:10 +03:00
										 |  |  | var data = require('imagegrid/data') | 
					
						
							|  |  |  | var images = require('imagegrid/images') | 
					
						
							|  |  |  | var ribbons = require('imagegrid/ribbons') | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | var core = require('features/core') | 
					
						
							|  |  |  | var base = require('features/base') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var widget = require('lib/widget/widget') | 
					
						
							|  |  |  | var browse = require('lib/widget/browse') | 
					
						
							|  |  |  | var overlay = require('lib/widget/overlay') | 
					
						
							|  |  |  | var drawer = require('lib/widget/drawer') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-05 04:48:24 +03:00
										 |  |  | var browseWalk = require('lib/widget/browse-walk') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | /*********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-17 05:02:37 +03:00
										 |  |  | // XXX make the selector more accurate...
 | 
					
						
							|  |  |  | // 		...at this point this will select the first elem with text which
 | 
					
						
							|  |  |  | // 		can be a different elem...
 | 
					
						
							|  |  |  | var makeEditableItem = | 
					
						
							|  |  |  | module.makeEditableItem = | 
					
						
							| 
									
										
										
										
											2016-04-17 05:22:40 +03:00
										 |  |  | function(list, item, elem, callback, options){ | 
					
						
							| 
									
										
										
										
											2016-04-17 05:02:37 +03:00
										 |  |  | 	return elem | 
					
						
							|  |  |  | 		.makeEditable({ | 
					
						
							| 
									
										
										
										
											2016-06-07 04:28:56 +03:00
										 |  |  | 			activate: true, | 
					
						
							| 
									
										
										
										
											2016-04-17 05:02:37 +03:00
										 |  |  | 			clear_on_edit: false, | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 		.on('edit-done', callback || function(){}) | 
					
						
							|  |  |  | 		.on('edit-aborted edit-done', function(_, text){ | 
					
						
							|  |  |  | 			list.update() | 
					
						
							|  |  |  | 				// XXX make the selector more accurate...
 | 
					
						
							|  |  |  | 				// 		...at this point this will select the first elem
 | 
					
						
							|  |  |  | 				// 		with text which can be a different elem...
 | 
					
						
							| 
									
										
										
										
											2016-04-17 05:22:40 +03:00
										 |  |  | 				.then(function(){ list.select(item.text()) }) | 
					
						
							| 
									
										
										
										
											2016-04-17 05:02:37 +03:00
										 |  |  | 		}) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | // Options format:
 | 
					
						
							|  |  |  | // 	{
 | 
					
						
							|  |  |  | // 		new_button: <text>|<bool>,
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 		length_limit: <number>,
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 		// check input value...
 | 
					
						
							|  |  |  | // 		check: function(value){ ... },
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 		// if true only unique values will be stored...
 | 
					
						
							|  |  |  | // 		// if a function this will be used to normalize the values before
 | 
					
						
							|  |  |  | // 		// uniqueness check is performed...
 | 
					
						
							|  |  |  | // 		unique: <bool>|function(value){ ... },
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 		// if true sort values...
 | 
					
						
							|  |  |  | // 		// if function will be used as cmp for sorting...
 | 
					
						
							|  |  |  | // 		sort: <bool> || function(a, b){ ... },
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 		// this is called when a new value is added via new_button but 
 | 
					
						
							|  |  |  | // 		// list length limit is reached...
 | 
					
						
							|  |  |  | // 		callback: function(selected){ ... },
 | 
					
						
							| 
									
										
										
										
											2016-04-16 04:17:34 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | // 		// see: itemButtons doc in browse.js for more info...
 | 
					
						
							|  |  |  | // 		itemButtons: [..]
 | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | // 	}
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // XXX add sort buttons: up/down/top/bottom...
 | 
					
						
							|  |  |  | // XXX make this more generic...
 | 
					
						
							| 
									
										
										
										
											2016-04-30 03:43:27 +03:00
										 |  |  | // XXX currently using this also requires the use of makeUIDialog(..),
 | 
					
						
							|  |  |  | // 		can this be simpler???
 | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | var makeConfigListEditor =  | 
					
						
							|  |  |  | module.makeConfigListEditor = | 
					
						
							|  |  |  | function(actions, list_key, options){ | 
					
						
							|  |  |  | 	options = options || {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var new_button = options.new_button | 
					
						
							|  |  |  | 	new_button = new_button === true ? 'New...' : new_button | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var _makeEditable = function(elem){ | 
					
						
							| 
									
										
										
										
											2016-04-17 00:58:21 +03:00
										 |  |  | 		return $(elem).find('.text') | 
					
						
							| 
									
										
										
										
											2016-06-07 04:03:56 +03:00
										 |  |  | 			.makeEditable({ | 
					
						
							| 
									
										
										
										
											2016-06-07 04:28:56 +03:00
										 |  |  | 				activate: true, | 
					
						
							| 
									
										
										
										
											2016-06-07 04:03:56 +03:00
										 |  |  | 				blur_on_abort: false, | 
					
						
							|  |  |  | 				blur_on_commit: false, | 
					
						
							|  |  |  | 			}) | 
					
						
							| 
									
										
										
										
											2016-04-17 00:58:21 +03:00
										 |  |  | 			.on('edit-aborted', function(){ | 
					
						
							| 
									
										
										
										
											2016-06-07 04:03:56 +03:00
										 |  |  | 				list.select(null)	 | 
					
						
							| 
									
										
										
										
											2016-04-17 00:58:21 +03:00
										 |  |  | 				list.update() | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 			.on('edit-done', function(evt, text){ | 
					
						
							|  |  |  | 				var txt = $(this).text() | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-17 00:58:21 +03:00
										 |  |  | 				// invalid format...
 | 
					
						
							|  |  |  | 				if(options.check && !options.check(txt)){ | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | 					list.update() | 
					
						
							| 
									
										
										
										
											2016-04-17 00:58:21 +03:00
										 |  |  | 					return | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-17 00:58:21 +03:00
										 |  |  | 				// list length limit
 | 
					
						
							|  |  |  | 				if(options.length_limit  | 
					
						
							|  |  |  | 					&& (lst.length >= options.length_limit)){ | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-17 00:58:21 +03:00
										 |  |  | 					options.callback && options.callback.call(list, txt) | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-17 00:58:21 +03:00
										 |  |  | 					return | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-17 00:58:21 +03:00
										 |  |  | 				// prevent editing non-arrays...
 | 
					
						
							|  |  |  | 				if(!(actions.config[list_key] instanceof Array)){ | 
					
						
							|  |  |  | 					return | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-04-16 04:17:34 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-17 00:58:21 +03:00
										 |  |  | 				// save the new version...
 | 
					
						
							|  |  |  | 				actions.config[list_key] = actions.config[list_key].slice() | 
					
						
							|  |  |  | 				// add new value and sort list...
 | 
					
						
							|  |  |  | 				actions.config[list_key] | 
					
						
							|  |  |  | 					.push(txt) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// unique...
 | 
					
						
							| 
									
										
										
										
											2016-04-18 03:05:48 +03:00
										 |  |  | 				if(options.unique == null || options.unique === true){ | 
					
						
							| 
									
										
										
										
											2016-04-17 00:58:21 +03:00
										 |  |  | 					actions.config[list_key] = actions.config[list_key] | 
					
						
							| 
									
										
										
										
											2016-04-18 03:05:48 +03:00
										 |  |  | 						.unique() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// unique normalized...
 | 
					
						
							|  |  |  | 				} else if( typeof(options.unique) == typeof(function(){})){ | 
					
						
							|  |  |  | 					actions.config[list_key] = actions.config[list_key] | 
					
						
							|  |  |  | 						.unique(options.unique)  | 
					
						
							| 
									
										
										
										
											2016-04-17 00:58:21 +03:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-17 00:58:21 +03:00
										 |  |  | 				// sort...
 | 
					
						
							|  |  |  | 				if(options.sort){ | 
					
						
							|  |  |  | 					actions.config[list_key] = actions.config[list_key] | 
					
						
							|  |  |  | 						.sort(typeof(options.sort) == typeof(function(){}) ?  | 
					
						
							|  |  |  | 							options.sort  | 
					
						
							|  |  |  | 							: undefined) | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-17 00:58:21 +03:00
										 |  |  | 				// update the list data...
 | 
					
						
							|  |  |  | 				list.options.data  | 
					
						
							|  |  |  | 					= actions.config[list_key] | 
					
						
							|  |  |  | 						.concat(new_button ? [ new_button ] : []) | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-17 00:58:21 +03:00
										 |  |  | 				// update list and select new value...
 | 
					
						
							|  |  |  | 				list.update() | 
					
						
							|  |  |  | 					.done(function(){ | 
					
						
							|  |  |  | 						list.select('"'+txt+'"') | 
					
						
							|  |  |  | 					}) | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | 			}) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var to_remove = [] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-06 18:46:23 +03:00
										 |  |  | 	var lst = list_key instanceof Function ? list_key()  | 
					
						
							|  |  |  | 		: list_key instanceof Array ? list_key  | 
					
						
							|  |  |  | 		: actions.config[list_key] | 
					
						
							| 
									
										
										
										
											2016-04-16 04:17:34 +03:00
										 |  |  | 	lst = lst instanceof Array ? lst : Object.keys(lst) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 19:59:29 +03:00
										 |  |  | 	var list = browse.makeList(null,  | 
					
						
							|  |  |  | 			lst.concat(new_button ? [ new_button ] : []),  | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				path: options.path, | 
					
						
							|  |  |  | 				itemButtons: options.itemButtons || [ | 
					
						
							|  |  |  | 					// mark for removal...
 | 
					
						
							|  |  |  | 					['×',  | 
					
						
							|  |  |  | 						function(p){ | 
					
						
							|  |  |  | 							var e = this.filter('"'+p+'"', false) | 
					
						
							|  |  |  | 								.toggleClass('strike-out') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							if(e.hasClass('strike-out')){ | 
					
						
							|  |  |  | 								to_remove.indexOf(p) < 0  | 
					
						
							|  |  |  | 									&& to_remove.push(p) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							} else { | 
					
						
							|  |  |  | 								var i = to_remove.indexOf(p) | 
					
						
							|  |  |  | 								if(i >= 0){ | 
					
						
							|  |  |  | 									to_remove.splice(i, 1) | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						}], | 
					
						
							|  |  |  | 					// XXX add shift up/down/top/bottom and other buttons (optional)...
 | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 			}) | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | 		// select the new_button item...
 | 
					
						
							|  |  |  | 		.on('select', function(evt, elem){ | 
					
						
							|  |  |  | 			if(new_button && $(elem).find('.text').text() == new_button){ | 
					
						
							|  |  |  | 				_makeEditable(elem) | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2016-04-17 00:58:21 +03:00
										 |  |  | 		// restore striked-out items...
 | 
					
						
							|  |  |  | 		.on('update', function(){ | 
					
						
							|  |  |  | 			to_remove.forEach(function(e){ | 
					
						
							|  |  |  | 				list.filter('"'+ e +'"') | 
					
						
							|  |  |  | 					.toggleClass('strike-out') | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2016-04-16 03:41:45 +03:00
										 |  |  | 		.open(function(evt, path){ | 
					
						
							|  |  |  | 			// we clicked the 'New' button -- select it...
 | 
					
						
							|  |  |  | 			if(new_button && (path == new_button || path == '')){ | 
					
						
							|  |  |  | 				list.select(new_button) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				options.callback && options.callback.call(list, path) | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 		.on('close', function(){ | 
					
						
							| 
									
										
										
										
											2016-04-16 04:17:34 +03:00
										 |  |  | 			// prevent editing non-arrays...
 | 
					
						
							|  |  |  | 			if(!(actions.config[list_key] instanceof Array)){ | 
					
						
							|  |  |  | 				return | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | 			// remove striked items...
 | 
					
						
							|  |  |  | 			to_remove.forEach(function(e){ | 
					
						
							|  |  |  | 				var lst = actions.config[list_key].slice() | 
					
						
							|  |  |  | 				lst.splice(lst.indexOf(e), 1) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				actions.config[list_key] = lst | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-16 03:41:45 +03:00
										 |  |  | 			// sort...
 | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | 			if(options.sort){ | 
					
						
							|  |  |  | 				actions.config[list_key] = actions.config[list_key] | 
					
						
							|  |  |  | 					.sort(options.sort !== true ? options.sort : undefined) | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	new_button && list.dom.addClass('tail-action') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 	return list | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-16 03:41:45 +03:00
										 |  |  | // XXX should this be more generic...
 | 
					
						
							| 
									
										
										
										
											2016-04-30 03:43:27 +03:00
										 |  |  | // XXX currently using this also requires the use of makeUIDialog(..),
 | 
					
						
							|  |  |  | // 		can this be simpler???
 | 
					
						
							| 
									
										
										
										
											2016-04-16 03:41:45 +03:00
										 |  |  | var makeNestedConfigListEditor =  | 
					
						
							|  |  |  | module.makeNestedConfigListEditor = | 
					
						
							| 
									
										
										
										
											2016-04-30 05:25:43 +03:00
										 |  |  | function(actions, list, list_key, value_key, options){ | 
					
						
							| 
									
										
										
										
											2016-04-18 03:05:48 +03:00
										 |  |  | 	options = options || {} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-16 03:41:45 +03:00
										 |  |  | 	return function(){ | 
					
						
							|  |  |  | 		var txt = $(this).find('.text').first().text() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		var dfl_options = { | 
					
						
							|  |  |  | 			new_button: 'New...', | 
					
						
							|  |  |  | 			length_limit: 10, | 
					
						
							|  |  |  | 			// NOTE: this is called when adding a new value and 
 | 
					
						
							|  |  |  | 			// 		list maximum length is reached...
 | 
					
						
							|  |  |  | 			callback: function(value){ | 
					
						
							| 
									
										
										
										
											2016-04-17 05:02:37 +03:00
										 |  |  | 				if(typeof(value_key) == typeof(function(){})){ | 
					
						
							|  |  |  | 					value_key(value) | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					actions.config[value_key] = value | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-04-16 03:41:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 05:25:43 +03:00
										 |  |  | 				o.parent.close() | 
					
						
							| 
									
										
										
										
											2016-04-16 03:41:45 +03:00
										 |  |  | 			}, | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		options.__proto__ = dfl_options | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 05:25:43 +03:00
										 |  |  | 		var o = makeConfigListEditor(actions, list_key, options) | 
					
						
							| 
									
										
										
										
											2016-04-16 03:41:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-06 18:46:23 +03:00
										 |  |  | 		// update menu...
 | 
					
						
							| 
									
										
										
										
											2016-04-30 05:25:43 +03:00
										 |  |  | 		o.open(function(){ | 
					
						
							|  |  |  | 			list.update() | 
					
						
							|  |  |  | 			list.select(txt) | 
					
						
							| 
									
										
										
										
											2016-04-16 03:41:45 +03:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2016-06-06 18:46:23 +03:00
										 |  |  | 		// select default...
 | 
					
						
							|  |  |  | 		o.on('update', function(){ | 
					
						
							| 
									
										
										
										
											2016-04-30 05:25:43 +03:00
										 |  |  | 			if(typeof(value_key) == typeof(function(){})){ | 
					
						
							|  |  |  | 				o.select(value_key()) | 
					
						
							| 
									
										
										
										
											2016-04-17 05:02:37 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 05:25:43 +03:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				o.select(actions.config[value_key]) | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-06-06 18:46:23 +03:00
										 |  |  | 		}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		actions.Overlay(o) | 
					
						
							| 
									
										
										
										
											2016-04-16 03:41:45 +03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | /*********************************************************************/ | 
					
						
							|  |  |  | // Dialogs and containers...
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | // Mark an action as a container...
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // NOTE: the marked action must comply with the container protocol
 | 
					
						
							|  |  |  | // 		(see: makeUIContainer(..) for more info)
 | 
					
						
							|  |  |  | var uiContainer = | 
					
						
							|  |  |  | module.uiContainer = function(func){ | 
					
						
							|  |  |  | 	func.__container__ = true | 
					
						
							|  |  |  | 	return func | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Make a container constructor wrapper...
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This will:
 | 
					
						
							|  |  |  | // 	- mark the action as a container
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // The container will:
 | 
					
						
							|  |  |  | // 	- trigger the client's close event on close
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | // XXX not sure how the click is handled here...
 | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | // XXX pass options???
 | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | var makeUIContainer = | 
					
						
							|  |  |  | module.makeUIContainer = function(make){ | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 	return uiContainer(function(){ | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 		var that = this | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 		var o = make.apply(this, arguments) | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 20:14:39 +03:00
										 |  |  | 		o | 
					
						
							|  |  |  | 			// notify the client that we are closing...
 | 
					
						
							|  |  |  | 			.close(function(){ o.client.trigger('close') }) | 
					
						
							|  |  |  | 			.client | 
					
						
							|  |  |  | 				// NOTE: strictly this is the responsibility of the client
 | 
					
						
							|  |  |  | 				// 		but it is less error prone to just in case also do
 | 
					
						
							|  |  |  | 				// 		this here...
 | 
					
						
							|  |  |  | 				.on('close', function(evt){ evt.stopPropagation() }) | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 				// Compensate for click focusing the parent dialog when
 | 
					
						
							|  |  |  | 				// a child is created...
 | 
					
						
							|  |  |  | 				// XXX is this the right way to go???
 | 
					
						
							|  |  |  | 				.on('click', function(evt){ that.modal.focus() }) | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		return o | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 	}) | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Mark action as a dialog...
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | var uiDialog = | 
					
						
							|  |  |  | module.uiDialog = function(func){ | 
					
						
							|  |  |  | 	func.__dialog__ = true | 
					
						
							|  |  |  | 	return func | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Make a dialog constructor wrapper...
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 	Make a dialog action...
 | 
					
						
							|  |  |  | // 	 makeUIDialog(constructor)
 | 
					
						
							|  |  |  | // 	 makeUIDialog(constructor, ...)
 | 
					
						
							|  |  |  | // 		-> dialog
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //	Make a dialog action with a specific default container...
 | 
					
						
							|  |  |  | // 	 makeUIDialog(container, constructor)
 | 
					
						
							|  |  |  | // 	 makeUIDialog(container, constructor, ...)
 | 
					
						
							|  |  |  | // 		-> dialog
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This dialog will:
 | 
					
						
							|  |  |  | // 	- consume the first action argument if it's a container name to 
 | 
					
						
							|  |  |  | // 		override the default container...
 | 
					
						
							|  |  |  | // 	- if no container defined explicitly the default container is used
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // NOTE: arguments after the constructor will be passed to the container.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // XXX do we need a means to reuse containers, e.g. ??? 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | var makeUIDialog = | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | module.makeUIDialog = function(a, b){ | 
					
						
							|  |  |  | 	var args = [].slice.call(arguments) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// container name (optional)...
 | 
					
						
							|  |  |  | 	var dfl = typeof(args[0]) == typeof('str') ? | 
					
						
							|  |  |  | 			args.shift() | 
					
						
							|  |  |  | 			: null | 
					
						
							|  |  |  | 	// constructor...
 | 
					
						
							|  |  |  | 	var make = args.shift() | 
					
						
							|  |  |  | 	// rest of the args to be passed to the container...
 | 
					
						
							|  |  |  | 	var cargs = args | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return uiDialog(function(){ | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 		var args = [].slice.call(arguments) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 		// see if the first arg is a container spec...
 | 
					
						
							| 
									
										
										
										
											2016-05-14 23:09:54 +03:00
										 |  |  | 		var container = this.isUIContainer(args[0]) ? | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 			args.shift() | 
					
						
							|  |  |  | 			: (dfl || this.config['ui-default-container'] || 'Overlay') | 
					
						
							| 
									
										
										
										
											2016-04-30 07:02:20 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 		return this[container].apply(this,  | 
					
						
							|  |  |  | 				[make.apply(this, args)].concat(cargs)) | 
					
						
							|  |  |  | 			.client | 
					
						
							|  |  |  | 	}) | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-07 16:15:18 +03:00
										 |  |  | var makeDrawer = function(direction){ | 
					
						
							|  |  |  | 	return makeUIContainer(function(dialog, options){ | 
					
						
							| 
									
										
										
										
											2016-05-08 15:58:22 +03:00
										 |  |  | 		var that = this | 
					
						
							| 
									
										
										
										
											2016-05-07 16:15:18 +03:00
										 |  |  | 		var parent = (options || {}).parentElement  | 
					
						
							|  |  |  | 		parent = parent ? $(parent) : this.ribbons.viewer  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		options.direction = direction || 'bottom' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-08 14:43:13 +03:00
										 |  |  | 		var d = drawer.Drawer(parent, dialog, options) | 
					
						
							|  |  |  | 			// focus top modal on exit...
 | 
					
						
							|  |  |  | 			.on('close', function(){ | 
					
						
							|  |  |  | 				var o = that.modal | 
					
						
							|  |  |  | 				o && o.focus()	 | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-07 16:15:18 +03:00
										 |  |  | 		// we need to clear other ui elements, like the status bar...
 | 
					
						
							|  |  |  | 		// XXX is this the right way to go???
 | 
					
						
							|  |  |  | 		d.dom.css({ | 
					
						
							|  |  |  | 			'z-index': 5000, | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return d | 
					
						
							|  |  |  | 	}) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | //---------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var DialogsActions = actions.Actions({ | 
					
						
							|  |  |  | 	config: { | 
					
						
							|  |  |  | 		'ui-default-container': 'Overlay', | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// a bit of introspection...
 | 
					
						
							|  |  |  | 	get uiContainers(){  | 
					
						
							|  |  |  | 		return this.actions.filter(this.isUIContainer.bind(this)) }, | 
					
						
							|  |  |  | 	get uiDialogs(){ | 
					
						
							|  |  |  | 		return this.actions.filter(this.isUIDialog.bind(this)) }, | 
					
						
							|  |  |  | 	get uiElements(){  | 
					
						
							|  |  |  | 		return this.actions.filter(this.isUIElement.bind(this)) }, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-08 14:30:35 +03:00
										 |  |  | 	// Get modal container...
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// Protocol:
 | 
					
						
							|  |  |  | 	// 	- get the last modal widgets (CSS selector: .modal-widget)
 | 
					
						
							|  |  |  | 	// 	- return one of the following:
 | 
					
						
							|  |  |  | 	// 		.data('widget-controller')
 | 
					
						
							|  |  |  | 	// 		element
 | 
					
						
							|  |  |  | 	// 		null
 | 
					
						
							|  |  |  | 	get modal(){ | 
					
						
							|  |  |  | 		var modal = this.ribbons.viewer | 
					
						
							| 
									
										
										
										
											2016-05-08 14:43:13 +03:00
										 |  |  | 			.find('.modal-widget') | 
					
						
							| 
									
										
										
										
											2016-05-08 14:30:35 +03:00
										 |  |  | 				.last() | 
					
						
							|  |  |  | 		return modal.data('widget-controller')  | 
					
						
							|  |  |  | 			|| (modal.length > 0 && modal)  | 
					
						
							|  |  |  | 			|| null | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// testers...
 | 
					
						
							|  |  |  | 	isUIContainer: ['- Interface/', | 
					
						
							|  |  |  | 		actions.doWithRootAction(function(action){ | 
					
						
							| 
									
										
										
										
											2016-05-14 23:09:54 +03:00
										 |  |  | 			return action != null | 
					
						
							|  |  |  | 				&& action.__container__ == true })], | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 	isUIDialog: ['- Interface/', | 
					
						
							|  |  |  | 		actions.doWithRootAction(function(action){ | 
					
						
							| 
									
										
										
										
											2016-05-14 23:09:54 +03:00
										 |  |  | 			return action != null  | 
					
						
							|  |  |  | 				&& action.__dialog__ == true })], | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 	isUIElement: ['- Interface/', | 
					
						
							|  |  |  | 		actions.doWithRootAction(function(action){ | 
					
						
							| 
									
										
										
										
											2016-05-14 23:09:54 +03:00
										 |  |  | 			return action != null  | 
					
						
							|  |  |  | 				&& (action.__dialog__ == true || action.__container__ == true) })], | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// container constructors...
 | 
					
						
							|  |  |  | 	Overlay: ['- Interface/', | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 		makeUIContainer(function(dialog, options){ | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 			var that = this | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 			return overlay.Overlay(this.ribbons.viewer, dialog, options) | 
					
						
							| 
									
										
										
										
											2016-05-08 14:43:13 +03:00
										 |  |  | 				// focus top modal on exit...
 | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 				.on('close', function(){ | 
					
						
							| 
									
										
										
										
											2016-05-08 14:43:13 +03:00
										 |  |  | 					var o = that.modal | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 					o && o.focus()	 | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 		})], | 
					
						
							| 
									
										
										
										
											2016-05-08 14:30:35 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 	Drawer: ['- Interface/', | 
					
						
							| 
									
										
										
										
											2016-05-07 16:15:18 +03:00
										 |  |  | 		makeDrawer('bottom')], | 
					
						
							| 
									
										
										
										
											2016-05-02 03:49:34 +03:00
										 |  |  | 	BottomDrawer: ['- Interface/', | 
					
						
							| 
									
										
										
										
											2016-05-07 16:15:18 +03:00
										 |  |  | 		makeDrawer('bottom')], | 
					
						
							| 
									
										
										
										
											2016-05-08 14:30:35 +03:00
										 |  |  | 	TopDrawer: ['- Interface/', | 
					
						
							|  |  |  | 		makeDrawer('top')], | 
					
						
							| 
									
										
										
										
											2016-05-07 16:15:18 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-03 01:43:43 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// like panel but drop down from mouse location or specified position
 | 
					
						
							|  |  |  | 	DropDown: ['- Interface/', | 
					
						
							|  |  |  | 		makeUIContainer(function(dialog, options){ | 
					
						
							|  |  |  | 			// XXX
 | 
					
						
							|  |  |  | 			console.error('Not yet implemented.') | 
					
						
							|  |  |  | 		})], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// XXX STUB -- need a real panel with real docking and closing 
 | 
					
						
							|  |  |  | 	// 		ability... 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 18:39:14 +03:00
										 |  |  | 	// XXX need to:
 | 
					
						
							|  |  |  | 	// 		- dock panels
 | 
					
						
							|  |  |  | 	// 		- save panel state (position, collapse, dock, ...)
 | 
					
						
							|  |  |  | 	// 		- restore panel state
 | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 	Panel: ['- Interface/', | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 		makeUIContainer(function(dialog, options){ | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 			// XXX
 | 
					
						
							| 
									
										
										
										
											2016-05-03 01:43:43 +03:00
										 |  |  | 			//console.error('Not yet implemented.')
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-08 14:30:35 +03:00
										 |  |  | 			// minimal container...
 | 
					
						
							| 
									
										
										
										
											2016-05-03 01:43:43 +03:00
										 |  |  | 			var panel = { | 
					
						
							|  |  |  | 				client: dialog, | 
					
						
							|  |  |  | 				dom: $('<div>') | 
					
						
							|  |  |  | 					.append(dialog.dom || dialog) | 
					
						
							|  |  |  | 					.appendTo(this.ribbons.viewer) | 
					
						
							|  |  |  | 					.draggable(), | 
					
						
							|  |  |  | 				close: function(func){ | 
					
						
							|  |  |  | 					if(func){ | 
					
						
							|  |  |  | 						this.dom.on('close', func) | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						this.dom.trigger('close') | 
					
						
							|  |  |  | 						this.dom.remove() | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					return this | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			dialog.on('blur', function(){ | 
					
						
							|  |  |  | 				panel.close() | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			return panel | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 		})], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 	listDialogs: ['Interface/Dialog list...', | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 		makeUIDialog(function(){ | 
					
						
							|  |  |  | 			var actions = this | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			return browse.makeLister(null, function(path, make){ | 
					
						
							|  |  |  | 				var that = this | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				actions.uiDialogs.forEach(function(dialog){ | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 					var doc = actions.getDoc(dialog)[dialog][0] | 
					
						
							|  |  |  | 					var txt = ((doc | 
					
						
							|  |  |  | 							.split(/[\\\/]/g) | 
					
						
							|  |  |  | 							.pop() || ('.'+ dialog +'(..)')) | 
					
						
							|  |  |  | 								// mark item as disabled...
 | 
					
						
							|  |  |  | 								+ (/^- .*$/.test(doc) ? ' (disabled)' : '')) | 
					
						
							|  |  |  | 						.replace(/^-?[0-9]+\s*:\s*/, '') | 
					
						
							|  |  |  | 						.trim() | 
					
						
							|  |  |  | 					make(txt) | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 						.on('open', function(){ | 
					
						
							|  |  |  | 							actions[dialog]() | 
					
						
							|  |  |  | 						}) | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-04 19:26:26 +03:00
										 |  |  | 				make.done() | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 			}) | 
					
						
							|  |  |  | 		})], | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var Dialogs =  | 
					
						
							|  |  |  | module.Dialogs = core.ImageGridFeatures.Feature({ | 
					
						
							|  |  |  | 	title: '', | 
					
						
							|  |  |  | 	doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tag: 'ui-dialogs', | 
					
						
							|  |  |  | 	depends: [ | 
					
						
							|  |  |  | 		'ui', | 
					
						
							|  |  |  | 	], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	actions: DialogsActions, | 
					
						
							| 
									
										
										
										
											2016-05-14 19:12:54 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	handlers: [ | 
					
						
							|  |  |  | 		['__call__',  | 
					
						
							|  |  |  | 			function(res, action){ | 
					
						
							|  |  |  | 				if(res instanceof jQuery || (res instanceof widget.Widget)){ | 
					
						
							|  |  |  | 					var elem = (res.dom || res) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-15 03:19:38 +03:00
										 |  |  | 					!elem.attr('dialog-title')  | 
					
						
							|  |  |  | 						&& elem.attr( | 
					
						
							|  |  |  | 							'dialog-title', | 
					
						
							|  |  |  | 							(this.getDoc(action)[action].shift() || action) | 
					
						
							|  |  |  | 								.split(/[\\\/]/g).pop()) | 
					
						
							| 
									
										
										
										
											2016-05-14 19:12:54 +03:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			}], | 
					
						
							|  |  |  | 	], | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | /*********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | // NOTE: yes, this is a funny name ;)
 | 
					
						
							| 
									
										
										
										
											2016-05-15 03:19:38 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | // XXX should we also add a hide-path config feature???
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:44:07 +03:00
										 |  |  | var BrowseActionsActions = actions.Actions({ | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 	config: { | 
					
						
							|  |  |  | 		'action-category-order': [ | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 			'99:File', | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 				// NOTE: we can order any sub-tree we want in the same 
 | 
					
						
							|  |  |  | 				// 		manner as the root...
 | 
					
						
							|  |  |  | 				'File/-80:Clear viewer', | 
					
						
							|  |  |  | 				'File/-90:Close viewer', | 
					
						
							| 
									
										
										
										
											2016-05-15 03:19:38 +03:00
										 |  |  | 				// NOTE: non existing elements will not get drawn...
 | 
					
						
							|  |  |  | 				//'File/-99:moo',
 | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 			'80:Edit', | 
					
						
							|  |  |  | 			'70:Navigate', | 
					
						
							|  |  |  | 			'60:Image', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			'-50:Interface', | 
					
						
							|  |  |  | 			'-60:Workspace', | 
					
						
							|  |  |  | 			'-70:System', | 
					
						
							|  |  |  | 			'-80:Development', | 
					
						
							|  |  |  | 			'-90:Test', | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 		], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'browse-actions-settings': { | 
					
						
							|  |  |  | 			showDisabled: false, | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 			showEmpty: false, | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 	// Browse actions dialog...
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// This uses action definition to build and present an action tree.
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// This supports the following element syntax:
 | 
					
						
							|  |  |  | 	// 	- leading '- ' in path to indicate disabled element.
 | 
					
						
							|  |  |  | 	// 		Example: 
 | 
					
						
							|  |  |  | 	// 			'- Path/To/Element'			(disabled)
 | 
					
						
							|  |  |  | 	// 			'Path/To/Other element'		(enabled)
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// 	- leading path element number followed by colon to indicate 
 | 
					
						
							|  |  |  | 	// 	  element priority on level.
 | 
					
						
							|  |  |  | 	// 		Example:
 | 
					
						
							|  |  |  | 	// 			'Path/99: To/50:Element'
 | 
					
						
							|  |  |  | 	// 	  NOTE: multiple path elements may have multiple priorities.
 | 
					
						
							|  |  |  | 	// 	  NOTE: an item with positive priority will be above and item 
 | 
					
						
							|  |  |  | 	// 	  		with less or no priority.
 | 
					
						
							|  |  |  | 	// 	  NOTE: an item with negative priority will be below any item 
 | 
					
						
							|  |  |  | 	// 	  		with greater or no priority.
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// NOTE: if the action returns an instance of overlay.Overlay this
 | 
					
						
							|  |  |  | 	// 		will not close right away but rather bind to:
 | 
					
						
							|  |  |  | 	// 			overlay.close			-> self.focus()
 | 
					
						
							|  |  |  | 	// 			overlay.client.open		-> self.close()
 | 
					
						
							|  |  |  | 	// NOTE: we are not using the browse.PathList(..) here as we need 
 | 
					
						
							|  |  |  | 	// 		custom controls and special path handling...
 | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 	// NOTE: this will keep the first instance title it encounters, this
 | 
					
						
							|  |  |  | 	// 		if a later instance includes a priority, it will be ignored.
 | 
					
						
							|  |  |  | 	// 		This may happen if several actions are in the same path and
 | 
					
						
							|  |  |  | 	// 		each one set a different priority in that path...
 | 
					
						
							|  |  |  | 	// 		...to avoid this use .config['action-category-order'] to set
 | 
					
						
							|  |  |  | 	// 		base order/priorities...
 | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 	//
 | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 	// XXX can we do a deep search on '/' -- find any nested action???
 | 
					
						
							| 
									
										
										
										
											2016-05-14 19:12:54 +03:00
										 |  |  | 	browseActions: ['Interface/Actions...', | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 		makeUIDialog(function(path){ | 
					
						
							|  |  |  | 			var actions = this | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 			var priority = /^(-?[0-9]+)\s*:\s*/ | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 			var dialog | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 			// Get item from tree level taking into account additional 
 | 
					
						
							|  |  |  | 			// syntax like prioority...
 | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 			// returns:
 | 
					
						
							|  |  |  | 			// 	[<existing-text>, <new-level>]
 | 
					
						
							|  |  |  | 			var getItem = function(level, text){ | 
					
						
							|  |  |  | 				// direct match...
 | 
					
						
							|  |  |  | 				if(text in level){ | 
					
						
							|  |  |  | 					return [text, level[text]] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// check if it's a priority path... 
 | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					for(var e in level){ | 
					
						
							|  |  |  | 						if(e.replace(priority, '').trim() == text){ | 
					
						
							|  |  |  | 							return [e, level[e]] | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				return [] | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// Wait for dialog...
 | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 			var waitFor = (function(child){ | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 				// we got a widget, wait for it to close...
 | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 				if(child instanceof widget.Widget){ | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 					child | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 						.on('open', function(){ dialog.parent.close() }) | 
					
						
							|  |  |  | 						// XXX is this a hack???
 | 
					
						
							|  |  |  | 						// 		...for some reason when clicking child 
 | 
					
						
							|  |  |  | 						// 		loses focus while when opening via keyboard
 | 
					
						
							|  |  |  | 						// 		everything is OK...
 | 
					
						
							|  |  |  | 						.one('update', function(){ child.focus() }) | 
					
						
							|  |  |  | 						.parent | 
					
						
							|  |  |  | 							.on('close', function(){ dialog.parent.focus() }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// if it's not a dialog, don't wait...
 | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					dialog.parent.close() | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 				return child | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 			}).bind(this) | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 			// Tree builder...
 | 
					
						
							|  |  |  | 			var buildTree = function(path, leaf, action, disabled, tree){ | 
					
						
							|  |  |  | 				path = path.slice() | 
					
						
							|  |  |  | 				// build leaf...
 | 
					
						
							|  |  |  | 				if(path.length == 0){ | 
					
						
							|  |  |  | 					leaf.split(/\|/g) | 
					
						
							|  |  |  | 						.forEach(function(leaf){ | 
					
						
							|  |  |  | 							var l = getItem(tree, leaf)[0] | 
					
						
							|  |  |  | 							tree[l || leaf] = action != null ? [action, disabled] : action | 
					
						
							|  |  |  | 						}) | 
					
						
							|  |  |  | 					return | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				// build alternative paths...
 | 
					
						
							|  |  |  | 				var p = path.shift() || '' | 
					
						
							|  |  |  | 				p.split(/\|/g) | 
					
						
							|  |  |  | 					.forEach(function(e){ | 
					
						
							|  |  |  | 						// build branch element...
 | 
					
						
							|  |  |  | 						var branch = getItem(tree, e) | 
					
						
							|  |  |  | 						branch = tree[branch[0] || e] = branch[1] || {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 						// build sub-branch...
 | 
					
						
							|  |  |  | 						buildTree(path, leaf, action, disabled, branch) | 
					
						
							|  |  |  | 					}) | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// Action tree...
 | 
					
						
							|  |  |  | 			//
 | 
					
						
							|  |  |  | 			// Format:
 | 
					
						
							|  |  |  | 			// 	{
 | 
					
						
							|  |  |  | 			// 		<name>: <tree>,
 | 
					
						
							|  |  |  | 			//
 | 
					
						
							|  |  |  | 			// 		<name>: [
 | 
					
						
							|  |  |  | 			// 			<action-name>,
 | 
					
						
							|  |  |  | 			// 			<disabled>,
 | 
					
						
							|  |  |  | 			// 		],
 | 
					
						
							|  |  |  | 			//
 | 
					
						
							|  |  |  | 			// 		...
 | 
					
						
							|  |  |  | 			// 	}
 | 
					
						
							|  |  |  | 			//
 | 
					
						
							|  |  |  | 			// NOTE: this is created once per call, so to refresh the 
 | 
					
						
							|  |  |  | 			// 		actions tree we'll need to re-open the dialog...
 | 
					
						
							|  |  |  | 			var tree = {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// pre-order the main categories...
 | 
					
						
							|  |  |  | 			// NOTE: pre_order can be a list of long paths...
 | 
					
						
							|  |  |  | 			var pre_order = this.config['action-category-order'] || [] | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 			pre_order.forEach(function(key){ | 
					
						
							|  |  |  | 				var path = key.split(/[\\\/]/g) | 
					
						
							|  |  |  | 				var leaf = path.pop() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				buildTree(path, leaf, null, null, tree) | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 			}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// buld the tree...
 | 
					
						
							|  |  |  | 			var paths = this.getPath() | 
					
						
							|  |  |  | 			Object.keys(paths).forEach(function(key){ | 
					
						
							|  |  |  | 				// handle disabled flag...
 | 
					
						
							|  |  |  | 				var disabled = key.split(/^- /) | 
					
						
							|  |  |  | 				var path = disabled.pop() | 
					
						
							|  |  |  | 				disabled = disabled.length > 0 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				path = path.split(/[\\\/]/g) | 
					
						
							|  |  |  | 				var leaf = path.pop() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 				buildTree(path, leaf, paths[key][0], disabled, tree) | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 			}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 			//console.log('!!!!', tree)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 			// now for the dialog...
 | 
					
						
							|  |  |  | 			dialog = browse.makeLister(null, function(path, make){ | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 				var that = this | 
					
						
							|  |  |  | 				var cur = tree | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// get level...
 | 
					
						
							|  |  |  | 				// NOTE: we need to get the level till first '*'...
 | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 				// NOTE: this needs to account for leading priority of 
 | 
					
						
							|  |  |  | 				// 		an element...
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 				var rest = path.slice() | 
					
						
							|  |  |  | 				while(rest.length > 0 && !('*' in cur)){ | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 					cur = getItem(cur, rest.shift()).pop() || {} | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 				// render current level...
 | 
					
						
							|  |  |  | 				// NOTE: we can be at one of several level types, each 
 | 
					
						
							|  |  |  | 				// 		is rendered in a different way...
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 				// Level: toggler states -- get states and list them...
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 				if(cur instanceof Array  | 
					
						
							|  |  |  | 						&& actions.isToggler && actions.isToggler(cur[0])){ | 
					
						
							|  |  |  | 					var action = cur[0] | 
					
						
							|  |  |  | 					var disabled = cur[1] | 
					
						
							|  |  |  | 					 | 
					
						
							|  |  |  | 					var cur_state = actions[action]('?') | 
					
						
							|  |  |  | 					var states = actions[action]('??') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					// handle on/off togglers...
 | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 					// XXX should the toggler directly return 'on'/'off'???
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 					if(states.length == 2  | 
					
						
							|  |  |  | 							&& states.indexOf('none') >= 0  | 
					
						
							|  |  |  | 							&& (cur_state == 'on' || cur_state == 'off')){ | 
					
						
							|  |  |  | 						states = ['on', 'off'] | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 					// build states...
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 					states.forEach(function(state){ | 
					
						
							|  |  |  | 						make(state, { disabled: disabled }) | 
					
						
							|  |  |  | 							.addClass(state == cur_state ? 'selected highlighted' : '') | 
					
						
							|  |  |  | 							.on('open', function(){ | 
					
						
							|  |  |  | 								actions[action](state) | 
					
						
							|  |  |  | 								that.pop() | 
					
						
							|  |  |  | 							}) | 
					
						
							|  |  |  | 					}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 				// Level: lister -- hand control to lister...
 | 
					
						
							|  |  |  | 				// NOTE: path might be a partial path, the rest of it is
 | 
					
						
							|  |  |  | 				// 		handled by the lister...
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 				} else if('*' in cur){ | 
					
						
							|  |  |  | 					actions[cur['*'][0]](path, make) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 				// Level: normal -- list actions...
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 				} else { | 
					
						
							|  |  |  | 					var level = Object.keys(cur) | 
					
						
							|  |  |  | 					level | 
					
						
							|  |  |  | 						.slice() | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 						// sort according to item priority: 'NN: <text>'
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 						//	NN > 0		- is sorted above the non-prioritized
 | 
					
						
							|  |  |  | 						//					elements, the greater the number 
 | 
					
						
							|  |  |  | 						//					the higher the element
 | 
					
						
							|  |  |  | 						//	NN < 0		- is sorted below the non-prioritized
 | 
					
						
							|  |  |  | 						//					elements, the lower the number 
 | 
					
						
							|  |  |  | 						//					the lower the element
 | 
					
						
							|  |  |  | 						.sort(function(a, b){ | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 							var ai = priority.exec(a) | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 							ai = ai ? ai.pop()*1 : null | 
					
						
							|  |  |  | 							ai = ai > 0 ? -ai | 
					
						
							|  |  |  | 								: ai < 0 ? -ai + level.length | 
					
						
							|  |  |  | 								: level.indexOf(a) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 							var bi = priority.exec(b) | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 							bi = bi ? bi.pop()*1 : null | 
					
						
							|  |  |  | 							bi = bi > 0 ? -bi | 
					
						
							|  |  |  | 								: bi < 0 ? -bi + level.length | 
					
						
							|  |  |  | 								: level.indexOf(b) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							return ai - bi | 
					
						
							|  |  |  | 						}) | 
					
						
							|  |  |  | 						.forEach(function(key){ | 
					
						
							|  |  |  | 							// remove the order...
 | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 							var text = key.replace(priority, '').trim() | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 							// Item: action...
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 							if(cur[key] instanceof Array){ | 
					
						
							|  |  |  | 								var action = cur[key][0] | 
					
						
							|  |  |  | 								var disabled = cur[key][1] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 								// Action: toggler -> add toggle button...
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 								if(actions.isToggler && actions.isToggler(action)){ | 
					
						
							|  |  |  | 									make(text + '/', {  | 
					
						
							|  |  |  | 										disabled: disabled,  | 
					
						
							|  |  |  | 										buttons: [ | 
					
						
							|  |  |  | 											[actions[action]('?'),  | 
					
						
							|  |  |  | 												function(){ | 
					
						
							|  |  |  | 													actions[action]() | 
					
						
							|  |  |  | 													that.update() | 
					
						
							|  |  |  | 													that.select('"'+ text +'"') | 
					
						
							|  |  |  | 												}] | 
					
						
							|  |  |  | 										]}) | 
					
						
							|  |  |  | 										.on('open', function(){ | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 											// XXX can this open a dialog???
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 											actions[action]() | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 											that.update() | 
					
						
							|  |  |  | 											that.select('"'+ text +'"') | 
					
						
							|  |  |  | 										}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 								// Action: normal...
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 								} else { | 
					
						
							|  |  |  | 									make(text, { disabled: disabled }) | 
					
						
							|  |  |  | 										.on('open', function(){ | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 											waitFor(actions[action]()) | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 										}) | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 							// Item: dir...
 | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 							} else if(actions.config['browse-actions-settings'].showEmpty  | 
					
						
							|  |  |  | 									|| (cur[key] != null | 
					
						
							|  |  |  | 										&& Object.keys(cur[key]).length > 0)){ | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 								make(text + '/') | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						}) | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}, { | 
					
						
							|  |  |  | 				path: path, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				flat: false, | 
					
						
							|  |  |  | 				traversable: true, | 
					
						
							|  |  |  | 				pathPrefix: '/', | 
					
						
							|  |  |  | 				fullPathEdit: true, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				showDisabled: actions.config['browse-actions-settings'].showDisabled, | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 			// save show disabled state to .config...
 | 
					
						
							|  |  |  | 			.on('close', function(){ | 
					
						
							|  |  |  | 				var config = actions.config['browse-actions-settings']  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				config.showDisabled = dialog.options.showDisabled | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			return dialog | 
					
						
							|  |  |  | 		})], | 
					
						
							| 
									
										
										
										
											2015-12-17 03:44:07 +03:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var BrowseActions =  | 
					
						
							|  |  |  | module.BrowseActions = core.ImageGridFeatures.Feature({ | 
					
						
							|  |  |  | 	title: '', | 
					
						
							|  |  |  | 	doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tag: 'ui-browse-actions', | 
					
						
							|  |  |  | 	depends: [ | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 		'ui', | 
					
						
							|  |  |  | 		'ui-dialogs', | 
					
						
							| 
									
										
										
										
											2015-12-17 03:44:07 +03:00
										 |  |  | 	], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	actions: BrowseActionsActions, | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-05 02:45:02 +03:00
										 |  |  | //---------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var ContextActionMenu =  | 
					
						
							|  |  |  | module.ContextActionMenu = core.ImageGridFeatures.Feature({ | 
					
						
							|  |  |  | 	title: '', | 
					
						
							|  |  |  | 	doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tag: 'ui-context-action-menu', | 
					
						
							|  |  |  | 	depends: [ | 
					
						
							|  |  |  | 		'ui-browse-actions', | 
					
						
							|  |  |  | 	], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	handlers: [ | 
					
						
							|  |  |  | 		['updateImage', | 
					
						
							|  |  |  | 			function(){ | 
					
						
							|  |  |  | 				var that = this | 
					
						
							|  |  |  | 				var img = this.ribbons.getImage(gid) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				!img.data('context-menu')  | 
					
						
							|  |  |  | 					&& img | 
					
						
							|  |  |  | 						.data('context-menu', true) | 
					
						
							|  |  |  | 						.on('contextmenu', function(){ | 
					
						
							|  |  |  | 							event.preventDefault() | 
					
						
							|  |  |  | 							event.stopPropagation() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							that.browseActions('/Image/') | 
					
						
							|  |  |  | 						}) | 
					
						
							|  |  |  | 			}], | 
					
						
							|  |  |  | 		['load', | 
					
						
							|  |  |  | 			function(){ | 
					
						
							|  |  |  | 				var that = this | 
					
						
							|  |  |  | 				var viewer = this.ribbons.viewer | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				!viewer.data('context-menu')  | 
					
						
							|  |  |  | 					&& viewer | 
					
						
							|  |  |  | 						.data('context-menu', true) | 
					
						
							|  |  |  | 						.on('contextmenu', function(){ | 
					
						
							|  |  |  | 							event.preventDefault() | 
					
						
							|  |  |  | 							event.stopPropagation() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							that.browseActions() | 
					
						
							|  |  |  | 						}) | 
					
						
							|  |  |  | 			}], | 
					
						
							|  |  |  | 	], | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:44:07 +03:00
										 |  |  | //---------------------------------------------------------------------
 | 
					
						
							|  |  |  | // XXX make this not applicable to production...
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var WidgetTestActions = actions.Actions({ | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 	// Usage Examples:
 | 
					
						
							|  |  |  | 	// 	.testDrawer()						- show html in base drawer...
 | 
					
						
							|  |  |  | 	// 	.testDrawer('Header', 'paragraph')	- show html with custom text...
 | 
					
						
							|  |  |  | 	// 	.testDrawer('Overlay')				- show html in overlay...
 | 
					
						
							|  |  |  | 	// 	.testDrawer('Overlay', 'Header', 'paragraph')
 | 
					
						
							|  |  |  | 	// 										- show html in overlay with 
 | 
					
						
							|  |  |  | 	// 										  custom text...
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 	testDrawer: ['Test/99: Drawer widget test...', | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 		makeUIDialog('Drawer',  | 
					
						
							|  |  |  | 			function(h, txt){ | 
					
						
							|  |  |  | 				return $('<div>') | 
					
						
							| 
									
										
										
										
											2016-04-30 18:39:14 +03:00
										 |  |  | 					.css({ | 
					
						
							|  |  |  | 						position: 'relative', | 
					
						
							|  |  |  | 						background: 'white', | 
					
						
							|  |  |  | 						height: '300px', | 
					
						
							|  |  |  | 						padding: '20px', | 
					
						
							|  |  |  | 					}) | 
					
						
							|  |  |  | 					.append($('<h1>') | 
					
						
							|  |  |  | 						.text(h || 'Drawer test...')) | 
					
						
							|  |  |  | 					.append($('<p>') | 
					
						
							|  |  |  | 						.text(txt || 'With some text.')) | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 			}, | 
					
						
							|  |  |  | 			// pass custom configuration to container...
 | 
					
						
							|  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2016-04-30 18:39:14 +03:00
										 |  |  | 				background: 'white', | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 				focusable: true, | 
					
						
							|  |  |  | 			})], | 
					
						
							| 
									
										
										
										
											2016-05-14 19:12:54 +03:00
										 |  |  | 	testBrowse: ['Test/-99: Demo new style dialog...', | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 		makeUIDialog(function(){ | 
					
						
							|  |  |  | 			var actions = this | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			console.log('>>> args:', [].slice.call(arguments)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			return browse.makeLister(null, function(path, make){ | 
					
						
							|  |  |  | 				var that = this | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				make('select last') | 
					
						
							|  |  |  | 					.on('open', function(){ | 
					
						
							|  |  |  | 						that.select(-1) | 
					
						
							|  |  |  | 					}) | 
					
						
							|  |  |  | 					 | 
					
						
							|  |  |  | 				make('do nothing') | 
					
						
							| 
									
										
										
										
											2016-04-30 19:59:29 +03:00
										 |  |  | 					.addClass('selected') | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				make('nested dialog...') | 
					
						
							|  |  |  | 					.on('open', function(){ | 
					
						
							|  |  |  | 						actions.testBrowse() | 
					
						
							|  |  |  | 					}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				make('---') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-23 03:42:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 				make('close parent') | 
					
						
							|  |  |  | 					.on('open', function(){ | 
					
						
							|  |  |  | 						that.parent.close() | 
					
						
							|  |  |  | 					}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-23 03:42:53 +03:00
										 |  |  | 				make('...') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-04 19:26:26 +03:00
										 |  |  | 				// NOTE: the dialog's .parent is not yet set at this point...
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// This will finalize the dialog...
 | 
					
						
							|  |  |  | 				//
 | 
					
						
							|  |  |  | 				// NOTE: this is not needed here as the dialog is drawn
 | 
					
						
							|  |  |  | 				// 		on sync, but for async dialogs this will align
 | 
					
						
							|  |  |  | 				// 		the selected field correctly.
 | 
					
						
							|  |  |  | 				make.done() | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 			}) | 
					
						
							|  |  |  | 			// NOTE: this is not a dialog event, it is defined by the 
 | 
					
						
							|  |  |  | 			// 		container to notify us that we are closing...
 | 
					
						
							|  |  |  | 			.on('close', function(){ | 
					
						
							|  |  |  | 				console.log('Dialog closing...') | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 		})], | 
					
						
							| 
									
										
										
										
											2016-06-01 21:39:32 +03:00
										 |  |  | 	testBrowseCloud: ['Test/Demo cloud dialog...', | 
					
						
							| 
									
										
										
										
											2016-06-01 21:19:24 +03:00
										 |  |  | 		makeUIDialog(function(){ | 
					
						
							|  |  |  | 			var actions = this | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			console.log('>>> args:', [].slice.call(arguments)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-01 21:39:32 +03:00
										 |  |  | 			return browse.makeLister(null, function(path, make){ | 
					
						
							| 
									
										
										
										
											2016-06-01 21:19:24 +03:00
										 |  |  | 				var that = this | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				var words = 'Lorem ipsum dolor sit amet, audiam sensibus ' | 
					
						
							|  |  |  | 					+'an mea. Accusam blandit ius in, te magna dolorum ' | 
					
						
							|  |  |  | 					+'moderatius pro, sit id dicant imperdiet definiebas. ' | 
					
						
							|  |  |  | 					+'Ad duo quod mediocrem, movet laudem discere te mel, ' | 
					
						
							|  |  |  | 					+'sea ipsum habemus gloriatur at. Sonet prodesset ' | 
					
						
							|  |  |  | 					+'democritum in vis, brute vitae recusabo pri ad, ' | 
					
						
							|  |  |  | 					+'--- ' | 
					
						
							|  |  |  | 					+'latine civibus efficiantur at his. At duo lorem ' | 
					
						
							|  |  |  | 					+'legimus, errem constituam contentiones sed ne, ' | 
					
						
							|  |  |  | 					+'cu has corpora definitionem.' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				words | 
					
						
							| 
									
										
										
										
											2016-06-01 23:03:47 +03:00
										 |  |  | 					.split(/\s+/g) | 
					
						
							| 
									
										
										
										
											2016-06-01 21:19:24 +03:00
										 |  |  | 					.unique() | 
					
						
							|  |  |  | 					.forEach(function(c){  | 
					
						
							|  |  |  | 						make(c)  | 
					
						
							| 
									
										
										
										
											2016-06-01 23:03:47 +03:00
										 |  |  | 							// toggle opacity...
 | 
					
						
							|  |  |  | 							.on('open', function(){ | 
					
						
							|  |  |  | 								var e = $(this).find('.text') | 
					
						
							|  |  |  | 								e.css('opacity',  | 
					
						
							|  |  |  | 									e.css('opacity') == 0.3 ? '' : 0.3) | 
					
						
							|  |  |  | 							}) | 
					
						
							| 
									
										
										
										
											2016-06-01 21:19:24 +03:00
										 |  |  | 					}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				make.done() | 
					
						
							| 
									
										
										
										
											2016-06-01 23:03:47 +03:00
										 |  |  | 			},  | 
					
						
							|  |  |  | 			// make the dialog a cloud...
 | 
					
						
							|  |  |  | 			{ cloudView: true }) | 
					
						
							| 
									
										
										
										
											2016-06-01 21:19:24 +03:00
										 |  |  | 			// NOTE: this is not a dialog event, it is defined by the 
 | 
					
						
							|  |  |  | 			// 		container to notify us that we are closing...
 | 
					
						
							|  |  |  | 			.on('close', function(){ | 
					
						
							|  |  |  | 				console.log('Dialog closing...') | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 		})], | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-01 02:11:30 +03:00
										 |  |  | 	// XXX make this a toggler....
 | 
					
						
							|  |  |  | 	partitionByMonth: ['Test/', | 
					
						
							|  |  |  | 		function(){ | 
					
						
							|  |  |  | 			var that = this | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			this.toggleImageSort('?') != 'Date' && this.sortImages('Date') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			this.on('updateImage', function(_, gid){ this.placeMonthPartition(gid) }) | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 	// XXX this should be .updateImage(..) in a real feature...
 | 
					
						
							|  |  |  | 	placeMonthPartition: ['Test/', | 
					
						
							|  |  |  | 		function(image){ | 
					
						
							|  |  |  | 			var month = [ | 
					
						
							|  |  |  | 				'January', 'February', 'March', 'April', | 
					
						
							|  |  |  | 				'May', 'June', 'July', 'August', | 
					
						
							|  |  |  | 				'September', 'October', 'November', 'December' | 
					
						
							|  |  |  | 			] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var gid = this.data.getImage(image) | 
					
						
							|  |  |  | 			var next = this.data.getImage(gid, 'next') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			cur = this.images[gid]	 | 
					
						
							|  |  |  | 			next = this.images[next] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if(cur && next && cur.birthtime.getMonth() != next.birthtime.getMonth()){ | 
					
						
							|  |  |  | 				this.ribbons.getImageMarks(gid).filter('.partition').remove() | 
					
						
							|  |  |  | 				this.ribbons.getImage(gid) | 
					
						
							|  |  |  | 					.after(this.ribbons.setElemGID($('<div class="mark partition">'), gid) | 
					
						
							|  |  |  | 						.attr('text', month[next.birthtime.getMonth()])) | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 	// XXX this is just a test...
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 	embededListerTest: ['Test/50: Lister test (embeded)/*', | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 		function(path, make){ | 
					
						
							|  |  |  | 			make('a/') | 
					
						
							|  |  |  | 			make('b/') | 
					
						
							|  |  |  | 			make('c/') | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 	floatingListerTest: ['Test/50:Lister test (floating)...', | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 		function(path){ | 
					
						
							|  |  |  | 			// we got an argument and can exit...
 | 
					
						
							|  |  |  | 			if(path){ | 
					
						
							|  |  |  | 				console.log('PATH:', path) | 
					
						
							|  |  |  | 				return | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// load the UI...
 | 
					
						
							|  |  |  | 			var that = this | 
					
						
							|  |  |  | 			var list = function(path, make){ | 
					
						
							|  |  |  | 				 | 
					
						
							|  |  |  | 				make('a/') | 
					
						
							|  |  |  | 				make('b/') | 
					
						
							|  |  |  | 				make('c/') | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var o = overlay.Overlay(this.ribbons.viewer,  | 
					
						
							|  |  |  | 				browse.makePathList(null, { | 
					
						
							|  |  |  | 					'a/*': list, | 
					
						
							|  |  |  | 					'b/*': list, | 
					
						
							|  |  |  | 					'c/*': list, | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 					.open(function(evt, path){  | 
					
						
							|  |  |  | 						o.close()  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 						that.floatingListerTest(path) | 
					
						
							|  |  |  | 					})) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			return o | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 19:59:29 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// XXX migrate to the dialog framework...
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 	// XXX use this.ribbons.viewer as base...
 | 
					
						
							|  |  |  | 	// XXX BUG: when using this.ribbons.viewer as base some actions leak
 | 
					
						
							|  |  |  | 	// 		between the two viewers...
 | 
					
						
							|  |  |  | 	showTaggedInDrawer: ['- Test/Show tagged in drawer', | 
					
						
							|  |  |  | 		function(tag){ | 
					
						
							|  |  |  | 			tag = tag || 'bookmark' | 
					
						
							|  |  |  | 			var that = this | 
					
						
							|  |  |  | 			var H = '200px' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var viewer = $('<div class="viewer">') | 
					
						
							|  |  |  | 				.css({ | 
					
						
							|  |  |  | 					height: H, | 
					
						
							|  |  |  | 					background: 'black', | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 			// XXX use this.ribbons.viewer as base...
 | 
					
						
							|  |  |  | 			// XXX when using viewer zoom and other stuff get leaked...
 | 
					
						
							|  |  |  | 			var widget = drawer.Drawer($('body'),  | 
					
						
							|  |  |  | 				$('<div>') | 
					
						
							|  |  |  | 					.css({ | 
					
						
							|  |  |  | 						position: 'relative', | 
					
						
							|  |  |  | 						height: H, | 
					
						
							|  |  |  | 					}) | 
					
						
							|  |  |  | 					.append(viewer), | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					focusable: true, | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var data = this.data.crop(a.data.getTaggedByAll(tag), true) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var b = actions.Actions() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// used switch experimental actions on (set to true) or off (unset or false)...
 | 
					
						
							|  |  |  | 			//a.experimental = true
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// setup actions...
 | 
					
						
							| 
									
										
										
										
											2016-01-08 04:25:54 +03:00
										 |  |  | 			core.ImageGridFeatures.setup(b, [ | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 				'viewer-testing', | 
					
						
							|  |  |  | 			]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// setup the viewer...
 | 
					
						
							|  |  |  | 			// XXX for some reason if we load this with data and images
 | 
					
						
							|  |  |  | 			// 		the images will not show up...
 | 
					
						
							|  |  |  | 			b.load({ | 
					
						
							|  |  |  | 					viewer: viewer, | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// load some testing data...
 | 
					
						
							|  |  |  | 			// NOTE: we can (and do) load this in parts...
 | 
					
						
							|  |  |  | 			b | 
					
						
							|  |  |  | 				.load({ | 
					
						
							|  |  |  | 					data: data, | 
					
						
							|  |  |  | 					images: this.images,  | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 				// this is needed when loading legacy sources that do not have tags
 | 
					
						
							|  |  |  | 				// synced...
 | 
					
						
							|  |  |  | 				// do not do for actual data...
 | 
					
						
							|  |  |  | 				//.syncTags()
 | 
					
						
							|  |  |  | 				.setEmptyMsg('No images bookmarked...') | 
					
						
							|  |  |  | 				.fitImage(1) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// link navigation...
 | 
					
						
							|  |  |  | 				.on('focusImage', function(){ | 
					
						
							|  |  |  | 					that.focusImage(this.current) | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// XXX setup keyboard...
 | 
					
						
							|  |  |  | 			var keyboard = require('lib/keyboard') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// XXX move this to the .config...
 | 
					
						
							|  |  |  | 			var kb = { | 
					
						
							|  |  |  | 				'Basic Control': { | 
					
						
							|  |  |  | 					pattern: '*', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					Home: { | 
					
						
							|  |  |  | 						default: 'firstImage!', | 
					
						
							|  |  |  | 					}, | 
					
						
							|  |  |  | 					End: { | 
					
						
							|  |  |  | 						default: 'lastImage!', | 
					
						
							|  |  |  | 					}, | 
					
						
							|  |  |  | 					Left: { | 
					
						
							|  |  |  | 						default: 'prevImage!', | 
					
						
							|  |  |  | 						ctrl: 'prevScreen!', | 
					
						
							|  |  |  | 						// XXX need to prevent default on mac + browser...
 | 
					
						
							|  |  |  | 						meta: 'prevScreen!', | 
					
						
							|  |  |  | 					}, | 
					
						
							|  |  |  | 					PgUp: 'prevScreen!', | 
					
						
							|  |  |  | 					PgDown: 'nextScreen!', | 
					
						
							|  |  |  | 					Right: { | 
					
						
							|  |  |  | 						default: 'nextImage!', | 
					
						
							|  |  |  | 						ctrl: 'nextScreen!', | 
					
						
							|  |  |  | 						// XXX need to prevent default on mac + browser...
 | 
					
						
							|  |  |  | 						meta: 'nextScreen!', | 
					
						
							|  |  |  | 					}, | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			widget.dom | 
					
						
							|  |  |  | 				// XXX
 | 
					
						
							|  |  |  | 				.keydown( | 
					
						
							|  |  |  | 					keyboard.dropRepeatingkeys( | 
					
						
							|  |  |  | 						keyboard.makeKeyboardHandler( | 
					
						
							|  |  |  | 							kb, | 
					
						
							|  |  |  | 							function(k){ | 
					
						
							|  |  |  | 								window.DEBUG && console.log(k) | 
					
						
							|  |  |  | 							}, | 
					
						
							|  |  |  | 							b),  | 
					
						
							|  |  |  | 						function(){  | 
					
						
							|  |  |  | 							return that.config['max-key-repeat-rate'] | 
					
						
							|  |  |  | 						})) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// XXX STUB
 | 
					
						
							|  |  |  | 			window.b = b | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			return b | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 	showBookmarkedInDrawer: ['Test/Show bookmarked in drawer', | 
					
						
							|  |  |  | 		function(){ this.showTaggedInDrawer('bookmark') }], | 
					
						
							|  |  |  | 	showSelectedInDrawer: ['Test/Show selected in drawer', | 
					
						
							|  |  |  | 		function(){ this.showTaggedInDrawer('selected') }], | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:44:07 +03:00
										 |  |  | var WidgetTest =  | 
					
						
							|  |  |  | module.WidgetTest = core.ImageGridFeatures.Feature({ | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 	title: '', | 
					
						
							|  |  |  | 	doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:44:07 +03:00
										 |  |  | 	tag: 'ui-widget-test', | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 	depends: [ | 
					
						
							| 
									
										
										
										
											2015-12-17 03:44:07 +03:00
										 |  |  | 		'ui-browse-actions', | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 	], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:44:07 +03:00
										 |  |  | 	actions: WidgetTestActions, | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-04 05:23:29 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | /********************************************************************** | 
					
						
							|  |  |  | * vim:set ts=4 sw=4 :                                                */ | 
					
						
							|  |  |  | return module }) |