| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | /********************************************************************** | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | **********************************************************************/ | 
					
						
							| 
									
										
										
										
											2016-08-21 02:19:24 +03:00
										 |  |  | ((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define) | 
					
						
							|  |  |  | (function(require){ var module={} // make module AMD/node compatible...
 | 
					
						
							| 
									
										
										
										
											2016-08-20 22:49:36 +03:00
										 |  |  | /*********************************************************************/ | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | var keyboard = require('lib/keyboard') | 
					
						
							| 
									
										
										
										
											2016-11-08 17:27:27 +03:00
										 |  |  | var toggler = require('lib/toggler') | 
					
						
							| 
									
										
										
										
											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-11-08 21:16:33 +03:00
										 |  |  | // Format:
 | 
					
						
							|  |  |  | // 	{
 | 
					
						
							|  |  |  | // 		<button-text>: [
 | 
					
						
							|  |  |  | // 			<class>, // optional
 | 
					
						
							|  |  |  | // 			<info>, // optional
 | 
					
						
							|  |  |  | // 			<code>,
 | 
					
						
							|  |  |  | // 		],
 | 
					
						
							|  |  |  | // 		...
 | 
					
						
							|  |  |  | // 	}
 | 
					
						
							|  |  |  | var makeButtonControls = | 
					
						
							|  |  |  | module.makeButtonControls = | 
					
						
							|  |  |  | function(context, cls, data){ | 
					
						
							| 
									
										
										
										
											2016-11-10 05:18:44 +03:00
										 |  |  | 	cls = cls instanceof Array ? cls : cls.split(/\s+/g) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-08 21:16:33 +03:00
										 |  |  | 	// remove old versions...
 | 
					
						
							| 
									
										
										
										
											2016-11-10 05:18:44 +03:00
										 |  |  | 	context.ribbons.viewer.find('.'+ cls.join('.')).remove() | 
					
						
							| 
									
										
										
										
											2016-11-08 21:16:33 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// make container...
 | 
					
						
							|  |  |  | 	var controls = $('<div>') | 
					
						
							| 
									
										
										
										
											2016-11-10 05:18:44 +03:00
										 |  |  | 		.addClass('buttons '+ cls.join('.')) | 
					
						
							| 
									
										
										
										
											2016-11-08 21:16:33 +03:00
										 |  |  | 		.on('mouseover', function(){ | 
					
						
							|  |  |  | 			var t = $(event.target) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var info = t.attr('info') || t.parents('[info]').attr('info') || '' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-09 04:53:42 +03:00
										 |  |  | 			context.showStatusBarInfo | 
					
						
							|  |  |  | 				&& context.showStatusBarInfo(info) | 
					
						
							| 
									
										
										
										
											2016-11-08 21:16:33 +03:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2016-11-23 03:16:17 +03:00
										 |  |  | 		.on('mouseout', function(){ | 
					
						
							| 
									
										
										
										
											2016-11-09 04:53:42 +03:00
										 |  |  | 			context.showStatusBarInfo | 
					
						
							|  |  |  | 				&& context.showStatusBarInfo() | 
					
						
							| 
									
										
										
										
											2016-11-08 21:16:33 +03:00
										 |  |  | 		}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// make buttons...
 | 
					
						
							|  |  |  | 	Object.keys(data).forEach(function(k){ | 
					
						
							| 
									
										
										
										
											2016-11-16 04:57:31 +03:00
										 |  |  | 		// spacer...
 | 
					
						
							|  |  |  | 		if(typeof(data[k]) == typeof('str')  | 
					
						
							|  |  |  | 				&& /--+/.test(data[k])){ | 
					
						
							|  |  |  | 			k = ' ' | 
					
						
							|  |  |  | 			var cls = 'spacer' | 
					
						
							|  |  |  | 			var doc = '' | 
					
						
							|  |  |  | 			var func = function(){} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// normal element...
 | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			var e = data[k].slice() | 
					
						
							|  |  |  | 			var code = e.pop() | 
					
						
							|  |  |  | 			code = typeof(code) == typeof('str') ? | 
					
						
							|  |  |  | 				keyboard.parseActionCall(code)  | 
					
						
							|  |  |  | 				: code | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var func = code instanceof Function ?  | 
					
						
							|  |  |  | 				code  | 
					
						
							|  |  |  | 				: function(){  | 
					
						
							|  |  |  | 					context[code.action].apply(context, code.arguments) } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var cls = e[0] || code.action || ''  | 
					
						
							|  |  |  | 			var doc = e[1] || code.doc || e[0] || '' | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-11-08 21:16:33 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		controls | 
					
						
							|  |  |  | 			.append($('<div>') | 
					
						
							|  |  |  | 				.addClass('button ' + cls) | 
					
						
							|  |  |  | 				.html(k) | 
					
						
							|  |  |  | 				.attr('info', doc) | 
					
						
							| 
									
										
										
										
											2016-11-23 03:16:17 +03:00
										 |  |  | 				.click('click', function(){ | 
					
						
							|  |  |  | 					context.showStatusBarInfo | 
					
						
							|  |  |  | 						&& context.showStatusBarInfo() | 
					
						
							|  |  |  | 				}) | 
					
						
							| 
									
										
										
										
											2016-11-08 21:16:33 +03:00
										 |  |  | 				.click(func)) | 
					
						
							|  |  |  | 	}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	controls | 
					
						
							|  |  |  | 		.appendTo(context.ribbons.viewer) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-10 05:34:15 +03:00
										 |  |  | // XXX write docs:
 | 
					
						
							|  |  |  | // 		- cls can be 
 | 
					
						
							|  |  |  | // 			- a single class (str)
 | 
					
						
							|  |  |  | // 			- space separated multiple classes (str)
 | 
					
						
							|  |  |  | // 			- list of classes
 | 
					
						
							|  |  |  | // 		- if cfg is not given then cls[0] is used for it
 | 
					
						
							|  |  |  | // 		- parent can be an element, a getter function or null (defaults to viewer)
 | 
					
						
							| 
									
										
										
										
											2016-11-10 05:18:44 +03:00
										 |  |  | var makeButtonControlsToggler = | 
					
						
							|  |  |  | module.makeButtonControlsToggler = | 
					
						
							| 
									
										
										
										
											2016-11-10 05:34:15 +03:00
										 |  |  | function(cls, cfg, parent){ | 
					
						
							| 
									
										
										
										
											2016-11-10 05:18:44 +03:00
										 |  |  | 	cls = cls instanceof Array ? cls : cls.split(/\s+/g) | 
					
						
							|  |  |  | 	cfg = cfg || cls[0] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return toggler.Toggler(null, | 
					
						
							|  |  |  | 		function(){  | 
					
						
							| 
									
										
										
										
											2016-11-10 05:34:15 +03:00
										 |  |  | 			parent = parent == null ? this.ribbons.viewer | 
					
						
							|  |  |  | 				: parent instanceof Function ? parent.call(this)  | 
					
						
							|  |  |  | 				: parent | 
					
						
							| 
									
										
										
										
											2017-03-28 07:54:24 +03:00
										 |  |  | 			return parent.find('.'+ cls.join('.')).length > 0 ? 'on' : 'off'  | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-11-10 05:18:44 +03:00
										 |  |  | 		['off', 'on'], | 
					
						
							|  |  |  | 		function(state){ | 
					
						
							|  |  |  | 			if(state == 'on'){ | 
					
						
							|  |  |  | 				var config = this.config[cfg] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				config  | 
					
						
							|  |  |  | 					&& makeButtonControls(this, cls, config) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				this.ribbons.viewer.find('.'+ cls.join('.')).remove() | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-08 21:16:33 +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...
 | 
					
						
							| 
									
										
										
										
											2017-01-15 00:49:19 +03:00
										 |  |  | var editItem = | 
					
						
							|  |  |  | module.editItem = | 
					
						
							|  |  |  | function(list, elem, callback, options){ | 
					
						
							| 
									
										
										
										
											2016-04-17 05:02:37 +03:00
										 |  |  | 	return elem | 
					
						
							| 
									
										
										
										
											2017-01-15 00:49:19 +03:00
										 |  |  | 		.makeEditable(options  | 
					
						
							|  |  |  | 			|| { | 
					
						
							|  |  |  | 				activate: true, | 
					
						
							|  |  |  | 				clear_on_edit: true, | 
					
						
							|  |  |  | 				blur_on_abort: false, | 
					
						
							|  |  |  | 				blur_on_commit: false, | 
					
						
							|  |  |  | 			}) | 
					
						
							| 
									
										
										
										
											2017-01-25 22:22:33 +03:00
										 |  |  | 		.on('edit-commit', callback || function(){}) | 
					
						
							|  |  |  | 		.on('edit-abort edit-commit', function(_, text){ | 
					
						
							| 
									
										
										
										
											2016-04-17 05:02:37 +03:00
										 |  |  | 			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...
 | 
					
						
							| 
									
										
										
										
											2017-01-15 00:49:19 +03:00
										 |  |  | 				.then(function(){ list.select(elem.text()) }) | 
					
						
							| 
									
										
										
										
											2016-04-17 05:02:37 +03:00
										 |  |  | 		}) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-15 00:49:19 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | //---------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-25 22:22:33 +03:00
										 |  |  | // Edit list in .config...
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This will update value_path in .config with the opened item value.
 | 
					
						
							|  |  |  | // 
 | 
					
						
							| 
									
										
										
										
											2017-01-15 00:49:19 +03:00
										 |  |  | var makeConfigListEditor =  | 
					
						
							|  |  |  | module.makeConfigListEditor = | 
					
						
							| 
									
										
										
										
											2017-01-25 22:22:33 +03:00
										 |  |  | function(actions, path, value_path, options){ | 
					
						
							| 
									
										
										
										
											2017-01-15 00:49:19 +03:00
										 |  |  | 	path = path.split('.') | 
					
						
							|  |  |  | 	var key = path.pop() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-25 22:22:33 +03:00
										 |  |  | 	options = options ? Object.create(options) : {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var stateValue = function(value){ | 
					
						
							|  |  |  | 		var path = value_path instanceof Function ? | 
					
						
							|  |  |  | 			value_path(value) | 
					
						
							|  |  |  | 			: value_path.split('.') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		var key = path.pop() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-15 00:49:19 +03:00
										 |  |  | 		var target = actions.config | 
					
						
							|  |  |  | 		path.forEach(function(p){ | 
					
						
							|  |  |  | 			target = target[p] = target[p] || {} | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-25 22:22:33 +03:00
										 |  |  | 		if(value){ | 
					
						
							|  |  |  | 			target[key] = value | 
					
						
							| 
									
										
										
										
											2017-01-15 00:49:19 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2017-01-25 22:22:33 +03:00
										 |  |  | 			return target[key] | 
					
						
							| 
									
										
										
										
											2017-01-15 00:49:19 +03:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-01-25 22:22:33 +03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	var save = function(value){ | 
					
						
							|  |  |  | 		stateValue(value) | 
					
						
							|  |  |  | 		dialog.close() | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(value_path  | 
					
						
							|  |  |  | 			&& (options.overflow == null  | 
					
						
							|  |  |  | 				|| options.overflow == 'save')){ | 
					
						
							|  |  |  | 		options.overflow = save | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// set the path...
 | 
					
						
							|  |  |  | 	if(value_path && !options.path){ | 
					
						
							|  |  |  | 		options.path = stateValue() | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var dialog = browse.makeListEditor(function(lst){ | 
					
						
							|  |  |  | 			var target = actions.config | 
					
						
							|  |  |  | 			path.forEach(function(p){ | 
					
						
							|  |  |  | 				target = target[p] = target[p] || {} | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// get...
 | 
					
						
							|  |  |  | 			if(lst === undefined){ | 
					
						
							|  |  |  | 				return target[key] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// set...
 | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				target[key] = lst | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}, options) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	value_path | 
					
						
							|  |  |  | 		&& dialog.open(function(){ | 
					
						
							|  |  |  | 			save(dialog.selected) | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return dialog | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-25 22:22:33 +03:00
										 |  |  | // Wrapper around makeListEditor(..) enabling it to be used as an event
 | 
					
						
							|  |  |  | // item handler...
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // For example this returns a function directly usable as list item event
 | 
					
						
							|  |  |  | // handler...
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // NOTE: this will select the element in the parent dialog via it's first 
 | 
					
						
							|  |  |  | // 		.text element...
 | 
					
						
							| 
									
										
										
										
											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 = { | 
					
						
							| 
									
										
										
										
											2017-01-25 22:22:33 +03:00
										 |  |  | 			path: value_key instanceof Function ? | 
					
						
							|  |  |  | 				value_key() | 
					
						
							|  |  |  | 				: actions.config[value_key], | 
					
						
							| 
									
										
										
										
											2016-04-16 03:41:45 +03:00
										 |  |  | 			// NOTE: this is called when adding a new value and 
 | 
					
						
							|  |  |  | 			// 		list maximum length is reached...
 | 
					
						
							| 
									
										
										
										
											2017-01-25 22:22:33 +03:00
										 |  |  | 			overflow: 'save',  | 
					
						
							| 
									
										
										
										
											2016-04-16 03:41:45 +03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		options.__proto__ = dfl_options | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-25 22:22:33 +03:00
										 |  |  | 		var o = makeConfigListEditor(actions, list_key, value_key, options) | 
					
						
							|  |  |  | 			// update parent menu...
 | 
					
						
							|  |  |  | 			.open(function(){ | 
					
						
							|  |  |  | 				list  | 
					
						
							|  |  |  | 					&& list.update() | 
					
						
							|  |  |  | 						.then(function(){  | 
					
						
							|  |  |  | 							txt != '' | 
					
						
							|  |  |  | 								&& list.select(txt)  | 
					
						
							|  |  |  | 						}) | 
					
						
							|  |  |  | 			}) | 
					
						
							| 
									
										
										
										
											2016-06-06 18:46:23 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		actions.Overlay(o) | 
					
						
							| 
									
										
										
										
											2017-01-25 22:22:33 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		return o | 
					
						
							| 
									
										
										
										
											2016-04-16 03:41:45 +03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-31 02:51:06 +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...
 | 
					
						
							| 
									
										
										
										
											2017-01-30 05:37:55 +03:00
										 |  |  | 			.close(function(evt, mode){ o.client.trigger('close', mode) }) | 
					
						
							| 
									
										
										
										
											2016-04-30 20:14:39 +03:00
										 |  |  | 			.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???
 | 
					
						
							| 
									
										
										
										
											2016-06-08 18:10:39 +03:00
										 |  |  | 				.on('click', function(evt){  | 
					
						
							|  |  |  | 					that.modal && 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-26 04:53:17 +03:00
										 |  |  | 		var dialog = make.apply(this, args) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if(!dialog){ | 
					
						
							|  |  |  | 			return dialog | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 		return this[container].apply(this,  | 
					
						
							| 
									
										
										
										
											2017-01-26 04:53:17 +03:00
										 |  |  | 				[dialog].concat(cargs)) | 
					
						
							| 
									
										
										
										
											2016-04-30 16:58:00 +03:00
										 |  |  | 			.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 | 
					
						
							| 
									
										
										
										
											2017-01-13 06:55:43 +03:00
										 |  |  | 		options = options || {} | 
					
						
							|  |  |  | 		var parent = options.parentElement  | 
					
						
							| 
									
										
										
										
											2016-05-07 16:15:18 +03:00
										 |  |  | 		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', | 
					
						
							| 
									
										
										
										
											2016-11-08 17:27:27 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		'ui-overlay-blur': 'on', | 
					
						
							| 
									
										
										
										
											2017-01-20 01:12:48 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// used by UI to set the user confirm action timeout...
 | 
					
						
							|  |  |  | 		'ui-confirm-timeout': 2000, | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-12 16:29:32 +03:00
										 |  |  | 	// introspection...
 | 
					
						
							| 
									
										
										
										
											2017-01-05 23:00:49 +03:00
										 |  |  | 	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)) }, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-30 05:01:50 +03:00
										 |  |  | 	// XXX this knows about action priority and shortcut marker...
 | 
					
						
							| 
									
										
										
										
											2016-12-12 16:29:32 +03:00
										 |  |  | 	// XXX should these be more like .getDoc(..) and support lists of actions???
 | 
					
						
							|  |  |  | 	getDocPath: ['- Interface/', | 
					
						
							|  |  |  | 		function(action, clean, join){ | 
					
						
							|  |  |  | 			clean = clean == null ? true : clean | 
					
						
							|  |  |  | 			join = join == null ? '/' : join | 
					
						
							|  |  |  | 			var path = (this.getDoc(action)[action].shift() || action) | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 			path = clean ? path.replace(/^- /, '') : path | 
					
						
							|  |  |  | 			path = path | 
					
						
							| 
									
										
										
										
											2016-12-12 16:29:32 +03:00
										 |  |  | 				.split(/[\\\/]/g) | 
					
						
							|  |  |  | 				// remove priority...
 | 
					
						
							|  |  |  | 				.map(function(e){ | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 					return clean ?  | 
					
						
							| 
									
										
										
										
											2017-01-30 05:01:50 +03:00
										 |  |  | 						e | 
					
						
							|  |  |  | 							.replace(/^[-+]?[0-9]+:\s*/, '') | 
					
						
							|  |  |  | 							.replace(/\$(\w)/g, '$1') | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 						: e }) | 
					
						
							| 
									
										
										
										
											2016-12-12 16:29:32 +03:00
										 |  |  | 			return join ? path.join('/') : path | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 	getDocBaseDir: ['- Interface/', | 
					
						
							|  |  |  | 		function(action, clean, join){ | 
					
						
							|  |  |  | 			clean = clean == null ? true : clean | 
					
						
							|  |  |  | 			join = join == null ? '/' : join | 
					
						
							|  |  |  | 			var path = this.getDocPath(action, clean, false) | 
					
						
							|  |  |  | 				// drop the title...
 | 
					
						
							|  |  |  | 				.slice(0, -1) | 
					
						
							|  |  |  | 			return join ? path.join('/') : path | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 	getDocTitle: ['- Interface/', | 
					
						
							|  |  |  | 		function(action, clean){ | 
					
						
							|  |  |  | 			clean = clean == null ? true : clean | 
					
						
							|  |  |  | 		   	return this.getDocPath(action, clean, false).pop()  | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-08 14:30:35 +03:00
										 |  |  | 	// Get modal container...
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// Protocol:
 | 
					
						
							| 
									
										
										
										
											2017-01-27 06:48:24 +03:00
										 |  |  | 	// 	- get the last (top) modal widgets (CSS selector: .modal-widget)
 | 
					
						
							| 
									
										
										
										
											2016-05-08 14:30:35 +03:00
										 |  |  | 	// 	- 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-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-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 { | 
					
						
							| 
									
										
										
										
											2017-01-24 00:14:31 +03:00
										 |  |  | 						this.dom.trigger('close', 'reject') | 
					
						
							| 
									
										
										
										
											2016-05-03 01:43:43 +03:00
										 |  |  | 						this.dom.remove() | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					return this | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			dialog.on('blur', function(){ | 
					
						
							| 
									
										
										
										
											2017-01-24 00:14:31 +03:00
										 |  |  | 				panel.close('reject') | 
					
						
							| 
									
										
										
										
											2016-05-03 01:43:43 +03:00
										 |  |  | 			}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			return panel | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 		})], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-21 23:39:41 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 	// Helper for creating lists fast...
 | 
					
						
							|  |  |  | 	showList: ['- Interface/',  | 
					
						
							| 
									
										
										
										
											2017-01-31 02:51:06 +03:00
										 |  |  | 		core.doc`Show list dialog...
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			.showList(<list>, <options>) | 
					
						
							|  |  |  | 				-> dialog | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		See browse.makeList(..) / browse.Items.List(..) for more info. | 
					
						
							|  |  |  | 		`,
 | 
					
						
							| 
									
										
										
										
											2017-01-21 23:39:41 +03:00
										 |  |  | 		makeUIDialog(function(list, options){ | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 			return browse.makeList(null, list, options) })], | 
					
						
							| 
									
										
										
										
											2017-01-31 02:51:06 +03:00
										 |  |  | 	showActionList: ['- Interface/',  | 
					
						
							|  |  |  | 		core.doc`Show list of actions dialog...
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			.showActionList(<list>, <options>) | 
					
						
							|  |  |  | 				-> dialog | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Like .showList(..) but understands keyboard.parseActionCall(..) syntax, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Options format: | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				// arguments and what to replace them with, this is used
 | 
					
						
							|  |  |  | 				// to define templates in the list and pass real values 
 | 
					
						
							|  |  |  | 				// via the dict.
 | 
					
						
							|  |  |  | 				args_dict: { | 
					
						
							|  |  |  | 					<arg>: <value>, | 
					
						
							|  |  |  | 					... | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// Same format .showList(..) understands...
 | 
					
						
							|  |  |  | 				... | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		`,
 | 
					
						
							|  |  |  | 		makeUIDialog(function(list, options){ | 
					
						
							|  |  |  | 			var that = this | 
					
						
							|  |  |  | 			list = list instanceof Function ? list.call(this) : list | 
					
						
							|  |  |  | 			options = options || {} | 
					
						
							|  |  |  | 			var args_dict = options.args_dict || {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var loaders = {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			list.forEach(function(m){ | 
					
						
							|  |  |  | 				var a = keyboard.parseActionCall(m) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if(a.action in that){ | 
					
						
							|  |  |  | 					var args = a.arguments | 
					
						
							|  |  |  | 						.map(function(a){  | 
					
						
							|  |  |  | 							return args_dict[a] !== undefined ?  | 
					
						
							|  |  |  | 								args_dict[a]  | 
					
						
							|  |  |  | 								: a }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					// the callback...
 | 
					
						
							|  |  |  | 					loaders[a.doc != '' ?  | 
					
						
							|  |  |  | 							a.doc  | 
					
						
							|  |  |  | 							: that.getDocTitle(a.action)] = | 
					
						
							|  |  |  | 						function(){ | 
					
						
							|  |  |  | 							return that[a.action].apply(that, args) } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// non-actions...
 | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					loaders[m] = null | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			return browse.makeList(null, loaders, options) | 
					
						
							|  |  |  | 		})], | 
					
						
							| 
									
										
										
										
											2017-01-24 05:34:15 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-24 06:14:38 +03:00
										 |  |  | 	// Show doc for action...
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							| 
									
										
										
										
											2017-01-29 00:51:13 +03:00
										 |  |  | 	// XXX STUB...
 | 
					
						
							| 
									
										
										
										
											2017-01-24 05:34:15 +03:00
										 |  |  | 	// XXX this needs to:
 | 
					
						
							|  |  |  | 	// 		- be a widget
 | 
					
						
							|  |  |  | 	// 		- handle focus
 | 
					
						
							|  |  |  | 	// 		- handle keyboard
 | 
					
						
							|  |  |  | 	// 		- handle search...
 | 
					
						
							| 
									
										
										
										
											2017-01-24 06:14:38 +03:00
										 |  |  | 	// 		- format action links/references...
 | 
					
						
							|  |  |  | 	// 		- markdown???
 | 
					
						
							| 
									
										
										
										
											2017-01-24 05:34:15 +03:00
										 |  |  | 	// 		- ...
 | 
					
						
							| 
									
										
										
										
											2017-01-24 06:14:38 +03:00
										 |  |  | 	// XXX use pWiki???
 | 
					
						
							|  |  |  | 	// XXX should we have navigation???
 | 
					
						
							|  |  |  | 	// 		...i.e. opening links is done in the viewer and we have 
 | 
					
						
							|  |  |  | 	// 		ability to go back and forth...
 | 
					
						
							|  |  |  | 	showDoc: ['Help/Action help...', | 
					
						
							| 
									
										
										
										
											2017-01-24 05:34:15 +03:00
										 |  |  | 		makeUIDialog(function(actions){ | 
					
						
							| 
									
										
										
										
											2017-01-25 23:34:01 +03:00
										 |  |  | 			var that = this | 
					
						
							| 
									
										
										
										
											2017-01-29 00:58:25 +03:00
										 |  |  | 			actions = actions || this.actions.sort() | 
					
						
							| 
									
										
										
										
											2017-01-24 05:34:15 +03:00
										 |  |  | 			actions = actions instanceof Array ? actions : [actions] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var doc = this.getDoc(actions) | 
					
						
							|  |  |  | 			var res = $('<div>') | 
					
						
							|  |  |  | 				.addClass('help-dialog') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			actions.forEach(function(action){ | 
					
						
							|  |  |  | 				res.append($('<div class="action">') | 
					
						
							|  |  |  | 					.prop('tabindex', true) | 
					
						
							| 
									
										
										
										
											2017-01-24 06:14:38 +03:00
										 |  |  | 					.append($('<h2>') | 
					
						
							|  |  |  | 						.text(doc[action][2])) | 
					
						
							|  |  |  | 					.append($('<i>') | 
					
						
							|  |  |  | 						.text(doc[action][0])) | 
					
						
							| 
									
										
										
										
											2017-01-25 23:34:01 +03:00
										 |  |  | 					.append($('<div>') | 
					
						
							| 
									
										
										
										
											2017-01-27 06:48:24 +03:00
										 |  |  | 						.text('Features: '  | 
					
						
							|  |  |  | 							+ that.getHandlerSourceTags(action) | 
					
						
							|  |  |  | 								.join(', '))) | 
					
						
							| 
									
										
										
										
											2017-01-24 05:34:15 +03:00
										 |  |  | 					.append($('<hr>')) | 
					
						
							| 
									
										
										
										
											2017-01-25 23:45:12 +03:00
										 |  |  | 					// parse the action doc...
 | 
					
						
							| 
									
										
										
										
											2017-01-24 06:14:38 +03:00
										 |  |  | 					.append($('<pre>') | 
					
						
							|  |  |  | 						.html((doc[action][1] || '') | 
					
						
							|  |  |  | 							// html stuff...
 | 
					
						
							|  |  |  | 							.replace(/&/g, '&') | 
					
						
							|  |  |  | 							.replace(/</g, '<') | 
					
						
							|  |  |  | 							.replace(/>/g, '>') | 
					
						
							|  |  |  | 							// normalize tabs -- convert tabs and tabbed 
 | 
					
						
							|  |  |  | 							// spaces into 4 spaces...
 | 
					
						
							|  |  |  | 							// NOTE: the code internally uses only tabs, 
 | 
					
						
							|  |  |  | 							// 		but this will help make the view 
 | 
					
						
							|  |  |  | 							// 		consistent.
 | 
					
						
							|  |  |  | 							.replace(/ {0,3}\t/g, '    ') | 
					
						
							|  |  |  | 							// comments...
 | 
					
						
							|  |  |  | 							.replace(/(\/\/.*)\n/g, '<span class="comment">$1</span>\n') | 
					
						
							|  |  |  | 							// notes...
 | 
					
						
							|  |  |  | 							.replace(/NOTE:/g, '<b>NOTE:</b>') | 
					
						
							|  |  |  | 							.replace(/XXX/g, '<span class="warning">XXX</span>') | 
					
						
							|  |  |  | 							// action links...
 | 
					
						
							|  |  |  | 							.replace(/(\s)(\.([\w_]+[\w\d_]*)\([^)]*\))/g,  | 
					
						
							| 
									
										
										
										
											2017-01-25 23:45:12 +03:00
										 |  |  | 								function(match, a, b, c){ | 
					
						
							|  |  |  | 									return c == action ? | 
					
						
							|  |  |  | 										`${a}<i>${b}</i>` | 
					
						
							| 
									
										
										
										
											2017-01-25 23:51:17 +03:00
										 |  |  | 										: `${a}<a href="#" onclick="ig.showDoc('${c}')">${b}</a>` | 
					
						
							| 
									
										
										
										
											2017-01-25 23:45:12 +03:00
										 |  |  | 								}) | 
					
						
							| 
									
										
										
										
											2017-01-24 05:34:15 +03:00
										 |  |  | 					))) | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			return res | 
					
						
							|  |  |  | 		})], | 
					
						
							| 
									
										
										
										
											2017-01-21 23:39:41 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-24 06:21:15 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-20 06:11:00 +03:00
										 |  |  | 	listDialogs: ['Interface/Dialog/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
										 |  |  | 			}) | 
					
						
							|  |  |  | 		})], | 
					
						
							| 
									
										
										
										
											2016-11-08 17:30:40 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 03:06:06 +03:00
										 |  |  | 	toggleOverlayBlur: ['Interface/Dialog overlay blur', | 
					
						
							| 
									
										
										
										
											2016-11-08 17:27:27 +03:00
										 |  |  | 		toggler.CSSClassToggler( | 
					
						
							|  |  |  | 			function(){ return this.ribbons.viewer },  | 
					
						
							|  |  |  | 			'overlay-blur-enabled', | 
					
						
							|  |  |  | 			function(state){ this.config['ui-overlay-blur'] = state }) ], | 
					
						
							| 
									
										
										
										
											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: [ | 
					
						
							| 
									
										
										
										
											2016-11-08 17:27:27 +03:00
										 |  |  | 		['start', | 
					
						
							|  |  |  | 			function(){ | 
					
						
							|  |  |  | 				this.config['ui-overlay-blur'] | 
					
						
							|  |  |  | 					&& this.toggleOverlayBlur(this.config['ui-overlay-blur']) | 
					
						
							|  |  |  | 			}], | 
					
						
							| 
									
										
										
										
											2016-05-14 19:12:54 +03:00
										 |  |  | 		['__call__',  | 
					
						
							|  |  |  | 			function(res, action){ | 
					
						
							| 
									
										
										
										
											2017-01-05 23:00:49 +03:00
										 |  |  | 				//if(res instanceof jQuery || res instanceof widget.Widget){
 | 
					
						
							|  |  |  | 				//	var elem = (res.dom || res)
 | 
					
						
							|  |  |  | 				if(res instanceof widget.Widget){ | 
					
						
							|  |  |  | 					var elem = res.dom | 
					
						
							| 
									
										
										
										
											2016-05-14 19:12:54 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 23:00:49 +03:00
										 |  |  | 					!elem.attr('keep-dialog-title')  | 
					
						
							| 
									
										
										
										
											2017-01-17 21:48:31 +03:00
										 |  |  | 						&& !this.getActionAttr(action, 'keepDialogTitle') | 
					
						
							|  |  |  | 						&& elem.attr('dialog-title', this.getDocTitle(action)) | 
					
						
							| 
									
										
										
										
											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': [ | 
					
						
							| 
									
										
										
										
											2017-01-28 01:09:05 +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',
 | 
					
						
							| 
									
										
										
										
											2017-01-28 01:09:05 +03:00
										 |  |  | 			'80:$Edit', | 
					
						
							|  |  |  | 			'70:$Navigate', | 
					
						
							|  |  |  | 			'60:$Image', | 
					
						
							|  |  |  | 			'50:$Ribbon', | 
					
						
							|  |  |  | 			'40:$Crop', | 
					
						
							| 
									
										
										
										
											2017-01-30 00:11:57 +03:00
										 |  |  | 				'Crop/80:Crop $marked images', | 
					
						
							|  |  |  | 				'Crop/80:Crop $bookmarked images', | 
					
						
							| 
									
										
										
										
											2016-12-30 04:24:38 +03:00
										 |  |  | 				// NOTE: we can also add separators here...
 | 
					
						
							|  |  |  | 				//'Crop/70:---',
 | 
					
						
							| 
									
										
										
										
											2017-02-07 02:59:04 +03:00
										 |  |  | 				'Crop/60:$Crop', | 
					
						
							| 
									
										
										
										
											2017-01-30 00:11:57 +03:00
										 |  |  | 				'Crop/50:$Flatten', | 
					
						
							| 
									
										
										
										
											2016-12-29 23:23:05 +03:00
										 |  |  | 				// ...
 | 
					
						
							|  |  |  | 				'Crop/-80:Uncrop and keep crop image order', | 
					
						
							|  |  |  | 				'Crop/-81:Uncrop all', | 
					
						
							| 
									
										
										
										
											2017-01-30 00:11:57 +03:00
										 |  |  | 				'Crop/-82:$Uncrop', | 
					
						
							| 
									
										
										
										
											2017-01-30 05:01:50 +03:00
										 |  |  | 			// ...
 | 
					
						
							| 
									
										
										
										
											2017-01-11 22:32:16 +03:00
										 |  |  | 			'-40:Interface', | 
					
						
							| 
									
										
										
										
											2017-01-28 01:09:05 +03:00
										 |  |  | 			'-50:$Workspace', | 
					
						
							| 
									
										
										
										
											2017-01-11 22:32:16 +03:00
										 |  |  | 			'-60:System', | 
					
						
							| 
									
										
										
										
											2017-01-28 01:09:05 +03:00
										 |  |  | 			'-70:$Help', | 
					
						
							| 
									
										
										
										
											2016-12-30 04:24:38 +03:00
										 |  |  | 			'-80:---', | 
					
						
							|  |  |  | 			'-90:Development', | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 			'-90:Test', | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 		], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'browse-actions-settings': { | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 			showDisabled: true, | 
					
						
							|  |  |  | 			showHidden: false, | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 			showEmpty: false, | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2017-01-03 02:55:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		'browse-actions-keys': true, | 
					
						
							| 
									
										
										
										
											2017-01-28 01:09:05 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		'browse-actions-shortcut-marker': '\\$(\\w)', | 
					
						
							| 
									
										
										
										
											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:
 | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 	// 	- leading '- ' in path to indicate a hidden/disabled element.
 | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 	// 		Example: 
 | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 	// 			'- Path/To/Element'			(disabled/hidden)
 | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 	// 			'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.
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 	// Action mode (disabled/hidden) and also be controlled dynamically:
 | 
					
						
							|  |  |  | 	// 	- .browseMode() action method is called with actions as base.
 | 
					
						
							| 
									
										
										
										
											2016-12-29 23:23:05 +03:00
										 |  |  | 	//		Example:
 | 
					
						
							|  |  |  | 	//			someAction: ['Path/To/Some action',
 | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 	//				{browseMode: function(){ ... }},
 | 
					
						
							| 
									
										
										
										
											2016-12-29 23:23:05 +03:00
										 |  |  | 	//				function(){
 | 
					
						
							|  |  |  | 	//					...
 | 
					
						
							|  |  |  | 	//				}],
 | 
					
						
							| 
									
										
										
										
											2016-12-31 23:30:14 +03:00
										 |  |  | 	//			someOtherAction: ['Path/To/Some action',
 | 
					
						
							|  |  |  | 	//				// alias
 | 
					
						
							|  |  |  | 	//				{browseMode: 'someAction'},
 | 
					
						
							|  |  |  | 	//				function(){
 | 
					
						
							|  |  |  | 	//					...
 | 
					
						
							|  |  |  | 	//				}],
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	//		.browseMode can be:
 | 
					
						
							|  |  |  | 	//			<function>			- action method.
 | 
					
						
							|  |  |  | 	//			<action-name>		- alias, name of action to get the
 | 
					
						
							|  |  |  | 	//									method from.
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 	//		.browseMode() can return:
 | 
					
						
							|  |  |  | 	//			'disabled'		- item will be disabled.
 | 
					
						
							|  |  |  | 	//			'hidden'		- item will be both hidden and disabled.
 | 
					
						
							| 
									
										
										
										
											2016-12-29 23:23:05 +03:00
										 |  |  | 	//
 | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 	//		NOTE: disabling in path has priority over .browseMode(), thus
 | 
					
						
							|  |  |  | 	//			it is possible to hide/disable an enabled item but not
 | 
					
						
							|  |  |  | 	//			possible to enable a disabled by default path.
 | 
					
						
							|  |  |  | 	//		NOTE: .browseMode() can be defined in any action in chain,
 | 
					
						
							|  |  |  | 	//			though only the last one is called...
 | 
					
						
							| 
									
										
										
										
											2016-12-29 23:23:05 +03:00
										 |  |  | 	//
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 	// options format:
 | 
					
						
							|  |  |  | 	// 	{
 | 
					
						
							|  |  |  | 	// 		callback: <function>,
 | 
					
						
							|  |  |  | 	// 		no_disabled: false,
 | 
					
						
							|  |  |  | 	// 		no_hidden: false,
 | 
					
						
							|  |  |  | 	// 	}
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 	// 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-12-20 06:11:00 +03:00
										 |  |  | 	browseActions: ['Interface/Dialog/Actions...', | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 		makeUIDialog(function(path, options){ | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 			var actions = this | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 			var priority = /^(-?[0-9]+)\s*:\s*/ | 
					
						
							| 
									
										
										
										
											2017-01-28 01:09:05 +03:00
										 |  |  | 			var marker = RegExp(this.config['browse-actions-shortcut-marker'], 'g') | 
					
						
							|  |  |  | 			marker = marker || RegExp(marker, 'g') | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 			var dialog | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 			options = options || {} | 
					
						
							| 
									
										
										
										
											2016-05-14 01:46:43 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-04 19:05:19 +03:00
										 |  |  | 			// prepare the config...
 | 
					
						
							|  |  |  | 			var cfg = { | 
					
						
							|  |  |  | 				cls: 'browse-actions', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				path: path, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				flat: false, | 
					
						
							|  |  |  | 				traversable: true, | 
					
						
							|  |  |  | 				pathPrefix: '/', | 
					
						
							|  |  |  | 				fullPathEdit: true, | 
					
						
							| 
									
										
										
										
											2017-01-28 01:09:05 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				item_shortcut_marker: marker, | 
					
						
							| 
									
										
										
										
											2017-01-04 19:05:19 +03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			cfg.__proto__ = this.config['browse-actions-settings'] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-03 02:55:25 +03:00
										 |  |  | 			// get keys for each action...
 | 
					
						
							| 
									
										
										
										
											2017-01-05 03:06:06 +03:00
										 |  |  | 			var keys = this.getKeysForAction ? this.getKeysForAction() : {} | 
					
						
							| 
									
										
										
										
											2017-01-03 02:55:25 +03:00
										 |  |  | 			// Get keys for action...
 | 
					
						
							|  |  |  | 			var getKeys = function(action){ | 
					
						
							| 
									
										
										
										
											2017-01-05 03:06:06 +03:00
										 |  |  | 				return (keys[action] || []).join(' / ') } | 
					
						
							| 
									
										
										
										
											2017-01-03 02:55:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 { | 
					
						
							| 
									
										
										
										
											2017-02-09 16:44:09 +03:00
										 |  |  | 					var t = text.replace(priority, '') | 
					
						
							|  |  |  | 					t = (marker ? t.replace(marker, '$1') : t).trim() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 					for(var e in level){ | 
					
						
							| 
									
										
										
										
											2017-01-28 01:09:05 +03:00
										 |  |  | 						var n = e.replace(priority, '') | 
					
						
							|  |  |  | 						n = (marker ? n.replace(marker, '$1') : n).trim() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 16:44:09 +03:00
										 |  |  | 						if(n == t){ | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 							return [e, level[e]] | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				return [] | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-03 02:55:25 +03:00
										 |  |  | 			// Get action browse mode (disabled or hidden)...
 | 
					
						
							| 
									
										
										
										
											2016-12-31 23:30:14 +03:00
										 |  |  | 			var getMode = function(action){ | 
					
						
							|  |  |  | 				var m = action | 
					
						
							|  |  |  | 				var visited = [m] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// handle aliases...
 | 
					
						
							|  |  |  | 				do { | 
					
						
							| 
									
										
										
										
											2017-01-03 02:55:25 +03:00
										 |  |  | 					m = actions.getActionAttr(m, 'browseMode') | 
					
						
							| 
									
										
										
										
											2016-12-31 23:30:14 +03:00
										 |  |  | 					// check for loops...
 | 
					
						
							|  |  |  | 					if(m && visited[m] != null){ | 
					
						
							|  |  |  | 						m = null | 
					
						
							|  |  |  | 						break | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					visited.push(m) | 
					
						
							|  |  |  | 				} while(typeof(m) == typeof('str')) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				return m ? m.call(actions) : undefined | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2017-01-24 00:14:31 +03:00
										 |  |  | 						.on('close', function(evt, reason){  | 
					
						
							|  |  |  | 							reason != 'reject' | 
					
						
							| 
									
										
										
										
											2017-01-24 04:07:13 +03:00
										 |  |  | 								&& dialog.close(reason) }) | 
					
						
							| 
									
										
										
										
											2016-05-14 03:59:06 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				// if it's not a dialog, don't wait...
 | 
					
						
							|  |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 					dialog.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...
 | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 			// XXX normalize actions -- whitespace, '!', args...
 | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 			var buildTree = function(path, leaf, action, mode, tree){ | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 				path = path.slice() | 
					
						
							|  |  |  | 				// build leaf...
 | 
					
						
							|  |  |  | 				if(path.length == 0){ | 
					
						
							|  |  |  | 					leaf.split(/\|/g) | 
					
						
							|  |  |  | 						.forEach(function(leaf){ | 
					
						
							|  |  |  | 							var l = getItem(tree, leaf)[0] | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 							tree[l || leaf] = action != null ? [action, mode] : action | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 						}) | 
					
						
							|  |  |  | 					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...
 | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 						buildTree(path, leaf, action, mode, branch) | 
					
						
							| 
									
										
										
										
											2016-05-14 22:50:26 +03:00
										 |  |  | 					}) | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// Action tree...
 | 
					
						
							|  |  |  | 			//
 | 
					
						
							|  |  |  | 			// Format:
 | 
					
						
							|  |  |  | 			// 	{
 | 
					
						
							|  |  |  | 			// 		<name>: <tree>,
 | 
					
						
							|  |  |  | 			//
 | 
					
						
							|  |  |  | 			// 		<name>: [
 | 
					
						
							|  |  |  | 			// 			<action-name>,
 | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 			// 			// mode...
 | 
					
						
							|  |  |  | 			// 			'disabled' | 'hidden',
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 			// 		],
 | 
					
						
							|  |  |  | 			//
 | 
					
						
							|  |  |  | 			// 		...
 | 
					
						
							|  |  |  | 			// 	}
 | 
					
						
							|  |  |  | 			//
 | 
					
						
							|  |  |  | 			// 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
										 |  |  | 			}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-29 23:23:05 +03:00
										 |  |  | 			// build the tree...
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 			var paths = this.getPath() | 
					
						
							|  |  |  | 			Object.keys(paths).forEach(function(key){ | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 				// handle mode flag...
 | 
					
						
							| 
									
										
										
										
											2016-12-29 23:23:05 +03:00
										 |  |  | 				var action = paths[key][0] | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 				var mode = key.split(/^- /) | 
					
						
							|  |  |  | 				var path = mode.pop() | 
					
						
							|  |  |  | 				mode = mode.length > 0 ? 'hidden' : null | 
					
						
							| 
									
										
										
										
											2016-12-29 23:23:05 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 				path = path.split(/[\\\/]/g) | 
					
						
							|  |  |  | 				var leaf = path.pop() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 				buildTree(path, leaf, action, mode, 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] | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 					var mode = cur[1] | 
					
						
							| 
									
										
										
										
											2016-12-29 23:23:05 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 					// handle live modes...
 | 
					
						
							| 
									
										
										
										
											2016-12-31 23:30:14 +03:00
										 |  |  | 					mode = mode || getMode(action) | 
					
						
							| 
									
										
										
										
											2016-12-29 23:23:05 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 					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'] | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 					// build toggler states...
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 					states.forEach(function(state){ | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 						make(state, {  | 
					
						
							|  |  |  | 								// NOTE: if something is hidden 
 | 
					
						
							|  |  |  | 								// 		it is also disabled...
 | 
					
						
							|  |  |  | 								// 		...this is by design.
 | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 								disabled: options.no_disabled ?  | 
					
						
							|  |  |  | 									false  | 
					
						
							|  |  |  | 									: (mode == 'hidden' || mode == 'disabled'), | 
					
						
							|  |  |  | 								hidden: options.no_hidden ?  | 
					
						
							|  |  |  | 									false | 
					
						
							|  |  |  | 									: mode == 'hidden', | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 							}) | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 							// XXX need to normalize state -- comments, whitespace, etc...
 | 
					
						
							|  |  |  | 							.attr('keys', getKeys(action +': "'+ state +'"')) | 
					
						
							| 
									
										
										
										
											2017-01-03 02:55:25 +03:00
										 |  |  | 							.addClass([ | 
					
						
							|  |  |  | 									state == cur_state ? 'selected highlighted' : '', | 
					
						
							|  |  |  | 									mode == 'hidden' ? mode : '' | 
					
						
							|  |  |  | 								].join(' ')) | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 							.on('open', function(){ | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 								options.callback ? | 
					
						
							|  |  |  | 									options.callback.call(actions, action) | 
					
						
							|  |  |  | 									: actions[action](state) | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 								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] | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 								var mode = cur[key][1] | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 								// handle live modes...
 | 
					
						
							| 
									
										
										
										
											2016-12-31 23:30:14 +03:00
										 |  |  | 								mode = mode || getMode(action) | 
					
						
							| 
									
										
										
										
											2016-12-29 23:23:05 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 + '/', {  | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 										// NOTE: if something is hidden 
 | 
					
						
							|  |  |  | 										// 		it is also disabled...
 | 
					
						
							|  |  |  | 										// 		...this is by design.
 | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 										disabled: options.no_disabled ?  | 
					
						
							|  |  |  | 											false  | 
					
						
							|  |  |  | 											: (mode == 'hidden' || mode == 'disabled'), | 
					
						
							|  |  |  | 										hidden: options.no_hidden ?  | 
					
						
							|  |  |  | 											false | 
					
						
							|  |  |  | 											: mode == 'hidden', | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 										buttons: [ | 
					
						
							|  |  |  | 											[actions[action]('?'),  | 
					
						
							|  |  |  | 												function(){ | 
					
						
							|  |  |  | 													actions[action]() | 
					
						
							|  |  |  | 													that.update() | 
					
						
							|  |  |  | 													that.select('"'+ text +'"') | 
					
						
							| 
									
										
										
										
											2017-01-03 02:55:25 +03:00
										 |  |  | 												}], | 
					
						
							|  |  |  | 											//[getKeys(action)],
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 										]}) | 
					
						
							| 
									
										
										
										
											2017-01-24 05:34:15 +03:00
										 |  |  | 										.attr({ | 
					
						
							|  |  |  | 											keys: getKeys(action), | 
					
						
							|  |  |  | 											action: action, | 
					
						
							|  |  |  | 										}) | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 										.addClass(mode == 'hidden' ? mode : '') | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 										.on('open', function(){ | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 											options.callback ? | 
					
						
							|  |  |  | 												options.callback.call(actions, action) | 
					
						
							|  |  |  | 												: 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 { | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 									make(text, { | 
					
						
							|  |  |  | 											// NOTE: if something is hidden 
 | 
					
						
							|  |  |  | 											// 		it is also disabled...
 | 
					
						
							|  |  |  | 											// 		...this is by design.
 | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 											disabled: options.no_disabled ?  | 
					
						
							|  |  |  | 												false  | 
					
						
							|  |  |  | 												: (mode == 'hidden' || mode == 'disabled'), | 
					
						
							|  |  |  | 									   		hidden: options.no_hidden ?  | 
					
						
							|  |  |  | 												false | 
					
						
							|  |  |  | 												: mode == 'hidden', | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 										}) | 
					
						
							| 
									
										
										
										
											2017-01-24 05:34:15 +03:00
										 |  |  | 										.attr({ | 
					
						
							|  |  |  | 											keys: getKeys(action), | 
					
						
							|  |  |  | 											action: action, | 
					
						
							|  |  |  | 										}) | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 										.on('open', function(){ | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 											options.callback ? | 
					
						
							|  |  |  | 												options.callback.call(actions, action) | 
					
						
							|  |  |  | 												: 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)){ | 
					
						
							| 
									
										
										
										
											2017-01-28 01:09:05 +03:00
										 |  |  | 								var p = '/'+ path.concat([text]).join('/') +'/' | 
					
						
							|  |  |  | 								p = marker ? p.replace(marker, '$1') : p | 
					
						
							| 
									
										
										
										
											2017-01-22 01:39:46 +03:00
										 |  |  | 								make(text + '/', { push_on_open: true }) | 
					
						
							| 
									
										
										
										
											2017-01-28 01:09:05 +03:00
										 |  |  | 									.attr({ | 
					
						
							|  |  |  | 										keys: [ | 
					
						
							|  |  |  | 											getKeys('browseActions: "'+ p +'"'),  | 
					
						
							|  |  |  | 											getKeys('browseActions!: "'+ p +'"'),  | 
					
						
							|  |  |  | 										].filter(function(e){ return e.trim() != '' }).join(' / '), | 
					
						
							|  |  |  | 									}) | 
					
						
							| 
									
										
										
										
											2016-12-30 04:24:38 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 							// item: line...
 | 
					
						
							|  |  |  | 							} else if(text == '---'){ | 
					
						
							|  |  |  | 								make(text) | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 							} | 
					
						
							|  |  |  | 						}) | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-01-04 19:05:19 +03:00
										 |  |  | 			}, | 
					
						
							|  |  |  | 			 cfg) | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 			// save show disabled state to .config...
 | 
					
						
							|  |  |  | 			.on('close', function(){ | 
					
						
							|  |  |  | 				var config = actions.config['browse-actions-settings']  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				config.showDisabled = dialog.options.showDisabled | 
					
						
							| 
									
										
										
										
											2016-12-30 03:21:09 +03:00
										 |  |  | 				config.showHidden = dialog.options.showHidden | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 			}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-03 02:55:25 +03:00
										 |  |  | 			this.config['browse-actions-keys']  | 
					
						
							|  |  |  | 				&& dialog.dom.addClass('show-keys') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-24 05:34:15 +03:00
										 |  |  | 			// handle '?' button to browse path...
 | 
					
						
							|  |  |  | 			dialog.showDoc = function(){ | 
					
						
							|  |  |  | 				var action = dialog.select('!').attr('action') | 
					
						
							|  |  |  | 				action  | 
					
						
							|  |  |  | 					&& actions.showDoc(action) | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			dialog.keyboard.handler('General', '?', 'showDoc') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-13 23:44:09 +03:00
										 |  |  | 			return dialog | 
					
						
							|  |  |  | 		})], | 
					
						
							| 
									
										
										
										
											2017-01-03 02:55:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	toggleBrowseActionKeys: ['Interface/Show keys in menu', | 
					
						
							|  |  |  | 		core.makeConfigToggler( | 
					
						
							|  |  |  | 			'browse-actions-keys',  | 
					
						
							|  |  |  | 			[true, false], | 
					
						
							|  |  |  | 			function(state){ | 
					
						
							|  |  |  | 				this.modal.client.dom.hasClass('browse-actions') | 
					
						
							|  |  |  | 					&& this.modal.client.dom[state ? 'addClass' : 'removeClass']('show-keys') | 
					
						
							|  |  |  | 			})], | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 	], | 
					
						
							| 
									
										
										
										
											2017-01-03 02:55:25 +03:00
										 |  |  | 	suggested: [ | 
					
						
							|  |  |  | 		'keyboard', | 
					
						
							|  |  |  | 	], | 
					
						
							| 
									
										
										
										
											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', | 
					
						
							| 
									
										
										
										
											2017-04-10 14:46:31 +03:00
										 |  |  | 			function(_, gid){ | 
					
						
							| 
									
										
										
										
											2016-03-05 02:45:02 +03:00
										 |  |  | 				var that = this | 
					
						
							| 
									
										
										
										
											2017-04-13 17:28:20 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-05 02:45:02 +03:00
										 |  |  | 				var img = this.ribbons.getImage(gid) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				!img.data('context-menu')  | 
					
						
							|  |  |  | 					&& img | 
					
						
							|  |  |  | 						.data('context-menu', true) | 
					
						
							|  |  |  | 						.on('contextmenu', function(){ | 
					
						
							|  |  |  | 							event.preventDefault() | 
					
						
							|  |  |  | 							event.stopPropagation() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-13 17:28:20 +03:00
										 |  |  | 							var g = gid || that.ribbons.getElemGID(img) | 
					
						
							| 
									
										
										
										
											2017-04-10 14:46:31 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 							that | 
					
						
							| 
									
										
										
										
											2017-04-13 17:28:20 +03:00
										 |  |  | 								.focusImage(g) | 
					
						
							| 
									
										
										
										
											2017-04-10 14:46:31 +03:00
										 |  |  | 								.browseActions('/Image/') | 
					
						
							| 
									
										
										
										
											2016-03-05 02:45:02 +03:00
										 |  |  | 						}) | 
					
						
							|  |  |  | 			}], | 
					
						
							|  |  |  | 		['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
										 |  |  | //---------------------------------------------------------------------
 | 
					
						
							| 
									
										
										
										
											2016-11-09 04:53:42 +03:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2016-11-15 23:05:46 +03:00
										 |  |  | var ButtonsActions = actions.Actions({ | 
					
						
							| 
									
										
										
										
											2016-11-08 18:57:11 +03:00
										 |  |  | 	config: { | 
					
						
							| 
									
										
										
										
											2016-11-15 22:15:14 +03:00
										 |  |  | 		'main-buttons-state': 'on', | 
					
						
							| 
									
										
										
										
											2017-03-09 02:35:28 +03:00
										 |  |  | 		// Format:
 | 
					
						
							|  |  |  | 		// 	{
 | 
					
						
							|  |  |  | 		// 		<html>: [
 | 
					
						
							|  |  |  | 		// 			<css-class>,
 | 
					
						
							|  |  |  | 		// 			// Button info (optional)
 | 
					
						
							|  |  |  | 		// 			<info>,
 | 
					
						
							|  |  |  | 		// 			<code>,
 | 
					
						
							|  |  |  | 		// 		],
 | 
					
						
							|  |  |  | 		// 		...
 | 
					
						
							|  |  |  | 		// 	}
 | 
					
						
							| 
									
										
										
										
											2016-11-15 22:15:14 +03:00
										 |  |  | 		'main-buttons': { | 
					
						
							| 
									
										
										
										
											2016-11-16 04:57:31 +03:00
										 |  |  | 			'☰': ['menu', 'browseActions -- Action menu...'], | 
					
						
							|  |  |  | 			'C<sub/>': ['crop', 'browseActions: "Crop/" -- Crop menu...'], | 
					
						
							| 
									
										
										
										
											2017-03-14 03:11:31 +03:00
										 |  |  | 			//'⛶': ['view', 'toggleSingleImage -- Single image / ribbon toggle'],
 | 
					
						
							| 
									
										
										
										
											2016-11-08 21:16:33 +03:00
										 |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-11-15 22:15:14 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// XXX not sure about these yet...
 | 
					
						
							|  |  |  | 		'secondary-buttons-state': 'off', | 
					
						
							|  |  |  | 		'secondary-buttons': { | 
					
						
							| 
									
										
										
										
											2016-11-16 04:57:31 +03:00
										 |  |  | 			//'Z<sub/>': ['zoom', 'browseActions: "Zoom/" -- Zoom menu...'],
 | 
					
						
							|  |  |  | 			//'+': ['zoom-in', 'zoomIn -- Zoom in'],
 | 
					
						
							|  |  |  | 			//'-': ['zoom-out', 'zoomOut -- Zoom out'],
 | 
					
						
							|  |  |  | 			//'⛭': ['ui-settings', 'browseActions: "Interface/" -- Interface settings...'],
 | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'app-buttons': { | 
					
						
							|  |  |  | 			'⛭': ['ui-settings', 'browseActions: "Interface/" -- Interface settings...'], | 
					
						
							| 
									
										
										
										
											2016-11-15 22:15:14 +03:00
										 |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-11-15 23:05:46 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-16 00:14:09 +03:00
										 |  |  | 		'side-buttons-state': 'off', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-15 23:05:46 +03:00
										 |  |  | 		'side-buttons-left': { | 
					
						
							|  |  |  | 			'-': ['zoom-out', 'zoomOut -- Zoom out'], | 
					
						
							| 
									
										
										
										
											2016-11-16 00:14:09 +03:00
										 |  |  | 			'↥': ['up', 'shiftImageUp -- Shift image up'], | 
					
						
							| 
									
										
										
										
											2016-11-16 04:57:31 +03:00
										 |  |  | 			'⦉': ['left', 'prevImage -- Previous image'], | 
					
						
							| 
									
										
										
										
											2016-11-16 00:14:09 +03:00
										 |  |  | 			'↧': ['down', 'shiftImageDown -- Shift image down'], | 
					
						
							| 
									
										
										
										
											2016-11-15 23:05:46 +03:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 		'side-buttons-right': { | 
					
						
							|  |  |  | 			'+': ['zoom-in', 'zoomIn -- Zoom in'], | 
					
						
							| 
									
										
										
										
											2016-11-16 00:14:09 +03:00
										 |  |  | 			'↥': ['up', 'shiftImageUp -- Shift image up'], | 
					
						
							| 
									
										
										
										
											2016-11-16 04:57:31 +03:00
										 |  |  | 			'⦊': ['right', 'nextImage -- Next image'], | 
					
						
							| 
									
										
										
										
											2016-11-16 00:14:09 +03:00
										 |  |  | 			'↧': ['down', 'shiftImageDown -- Shift image down'], | 
					
						
							| 
									
										
										
										
											2016-11-15 23:05:46 +03:00
										 |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-11-08 18:57:11 +03:00
										 |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 03:06:06 +03:00
										 |  |  | 	toggleMainButtons: ['Interface/Main buttons', | 
					
						
							| 
									
										
										
										
											2016-11-15 22:15:14 +03:00
										 |  |  | 		makeButtonControlsToggler('main-buttons')], | 
					
						
							| 
									
										
										
										
											2017-01-05 03:06:06 +03:00
										 |  |  | 	toggleSecondaryButtons: ['Interface/Secondary buttons', | 
					
						
							| 
									
										
										
										
											2016-11-15 22:15:14 +03:00
										 |  |  | 		makeButtonControlsToggler('secondary-buttons')], | 
					
						
							| 
									
										
										
										
											2017-01-05 03:06:06 +03:00
										 |  |  | 	toggleAppButtons: ['Interface/App buttons', | 
					
						
							| 
									
										
										
										
											2016-11-16 04:57:31 +03:00
										 |  |  | 		makeButtonControlsToggler('app-buttons')], | 
					
						
							| 
									
										
										
										
											2017-01-05 03:06:06 +03:00
										 |  |  | 	toggleSideButtons: ['Interface/Side buttons',  | 
					
						
							| 
									
										
										
										
											2016-11-16 04:57:31 +03:00
										 |  |  | 		(function(){ | 
					
						
							|  |  |  | 			var left = makeButtonControlsToggler('side-buttons-left') | 
					
						
							|  |  |  | 			var right = makeButtonControlsToggler('side-buttons-right') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			return core.makeConfigToggler('side-buttons-state',  | 
					
						
							|  |  |  | 				['on', 'off'],  | 
					
						
							|  |  |  | 				function(){ | 
					
						
							|  |  |  | 					left.apply(this, arguments)  | 
					
						
							|  |  |  | 					right.apply(this, arguments)  | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 		})()], | 
					
						
							| 
									
										
										
										
											2016-11-09 04:53:42 +03:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-15 23:05:46 +03:00
										 |  |  | var Buttons =  | 
					
						
							|  |  |  | module.Buttons = core.ImageGridFeatures.Feature({ | 
					
						
							| 
									
										
										
										
											2016-11-09 04:53:42 +03:00
										 |  |  | 	title: '', | 
					
						
							|  |  |  | 	doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-15 22:15:14 +03:00
										 |  |  | 	tag: 'ui-buttons', | 
					
						
							| 
									
										
										
										
											2016-11-09 04:53:42 +03:00
										 |  |  | 	depends: [ | 
					
						
							|  |  |  | 		'ui', | 
					
						
							|  |  |  | 	], | 
					
						
							|  |  |  | 	suggested: [ | 
					
						
							|  |  |  | 		// needed for reporting info in .makeButtonControls(..)
 | 
					
						
							|  |  |  | 		'ui-status-bar', | 
					
						
							|  |  |  | 	], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-15 23:05:46 +03:00
										 |  |  | 	actions: ButtonsActions, | 
					
						
							| 
									
										
										
										
											2016-11-09 04:53:42 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	handlers: [ | 
					
						
							| 
									
										
										
										
											2016-11-16 04:57:31 +03:00
										 |  |  | 		['start.pre',  | 
					
						
							| 
									
										
										
										
											2016-11-20 01:11:30 +03:00
										 |  |  | 			function(){  | 
					
						
							|  |  |  | 				this.toggleAppButtons('on') | 
					
						
							|  |  |  | 		   	}], | 
					
						
							|  |  |  | 		// NOTE: these need to be loaded AFTER the .config has been loaded...
 | 
					
						
							|  |  |  | 		['start',  | 
					
						
							| 
									
										
										
										
											2016-11-09 04:53:42 +03:00
										 |  |  | 			function(){  | 
					
						
							| 
									
										
										
										
											2016-11-15 22:15:14 +03:00
										 |  |  | 				this.toggleMainButtons(this.config['main-buttons-state'] || 'on') | 
					
						
							| 
									
										
										
										
											2016-11-16 00:14:09 +03:00
										 |  |  | 				this.toggleSecondaryButtons(this.config['secondary-buttons-state'] || 'on') | 
					
						
							|  |  |  | 				this.toggleSideButtons(this.config['side-buttons-state'] || 'on') | 
					
						
							|  |  |  | 		   	}], | 
					
						
							| 
									
										
										
										
											2016-11-28 20:18:34 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// update crop button status...
 | 
					
						
							|  |  |  | 		['load clear reload',  | 
					
						
							| 
									
										
										
										
											2016-11-09 04:53:42 +03:00
										 |  |  | 			function(){ | 
					
						
							| 
									
										
										
										
											2016-11-15 22:15:14 +03:00
										 |  |  | 				$('.main-buttons.buttons .crop.button sub') | 
					
						
							|  |  |  | 					.text(this.crop_stack ? this.crop_stack.length : '') }], | 
					
						
							| 
									
										
										
										
											2016-11-28 20:18:34 +03:00
										 |  |  | 		// update zoom button status...
 | 
					
						
							| 
									
										
										
										
											2016-11-15 22:15:14 +03:00
										 |  |  | 		['setScale',  | 
					
						
							|  |  |  | 			function(){ | 
					
						
							|  |  |  | 				$('.secondary-buttons.buttons .zoom.button sub') | 
					
						
							|  |  |  | 					.text(Math.round(this.screenwidth)) }], | 
					
						
							| 
									
										
										
										
											2016-11-09 04:53:42 +03:00
										 |  |  | 	], | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //---------------------------------------------------------------------
 | 
					
						
							|  |  |  | // XXX make this not applicable to production...
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var WidgetTestActions = actions.Actions({ | 
					
						
							| 
									
										
										
										
											2017-01-27 17:33:21 +03:00
										 |  |  | 	testAction: ['Test/Test action', | 
					
						
							| 
									
										
										
										
											2016-11-08 17:27:27 +03:00
										 |  |  | 		function(){ | 
					
						
							|  |  |  | 			console.log('>>>', [].slice.call(arguments)) | 
					
						
							|  |  |  | 			return function(){ | 
					
						
							|  |  |  | 				console.log('<<<', [].slice.call(arguments)) }}], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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...
 | 
					
						
							| 
									
										
										
										
											2017-01-27 17:33:21 +03:00
										 |  |  | 	testDrawer: ['Test/99: D$rawer 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, | 
					
						
							|  |  |  | 			})], | 
					
						
							| 
									
										
										
										
											2017-01-27 08:26:10 +03:00
										 |  |  | 	// XXX show new features...
 | 
					
						
							| 
									
										
										
										
											2017-01-27 17:33:21 +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 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-27 17:33:21 +03:00
										 |  |  | 				make('select last')  | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 					.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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-27 17:33:21 +03:00
										 |  |  | 				make('nested dialog...', | 
					
						
							|  |  |  | 					{ | 
					
						
							|  |  |  | 						shortcut_key: 'n', | 
					
						
							|  |  |  | 					}) | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 					.on('open', function(){ | 
					
						
							|  |  |  | 						actions.testBrowse() | 
					
						
							|  |  |  | 					}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				make('---') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-23 03:42:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-27 17:33:21 +03:00
										 |  |  | 				make('$close parent') | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 					.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...') | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 		})], | 
					
						
							| 
									
										
										
										
											2017-01-27 17:33:21 +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.' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-30 05:01:50 +03:00
										 |  |  | 				var res = [] | 
					
						
							| 
									
										
										
										
											2016-06-01 21:19:24 +03:00
										 |  |  | 				words | 
					
						
							| 
									
										
										
										
											2016-06-01 23:03:47 +03:00
										 |  |  | 					.split(/\s+/g) | 
					
						
							| 
									
										
										
										
											2016-06-01 21:19:24 +03:00
										 |  |  | 					.unique() | 
					
						
							|  |  |  | 					.forEach(function(c){  | 
					
						
							| 
									
										
										
										
											2017-01-30 05:01:50 +03:00
										 |  |  | 						var e = 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) | 
					
						
							|  |  |  | 							}) | 
					
						
							| 
									
										
										
										
											2017-01-30 05:01:50 +03:00
										 |  |  | 						res.push(e[0]) | 
					
						
							| 
									
										
										
										
											2016-06-01 21:19:24 +03:00
										 |  |  | 					}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-30 05:01:50 +03:00
										 |  |  | 				$(res).parent() | 
					
						
							|  |  |  | 					.append($('<div>') | 
					
						
							|  |  |  | 						.sortable() | 
					
						
							|  |  |  | 						.append($(res))) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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...') | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 		})], | 
					
						
							| 
									
										
										
										
											2017-02-01 20:39:44 +03:00
										 |  |  | 	testBrowsrItems: ['Test/-99: Demo browse $items...', | 
					
						
							|  |  |  | 		makeUIDialog(function(){ | 
					
						
							|  |  |  | 			var actions = this | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-01 23:40:52 +03:00
										 |  |  | 			var editable_list = ['x', 'y', 'z'] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-01 20:39:44 +03:00
										 |  |  | 			return browse.makeLister(null, function(path, make){ | 
					
						
							|  |  |  | 				var that = this | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				make.Heading('Heading:', { | 
					
						
							|  |  |  | 					doc: 'Heading doc string...', | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 07:36:25 +03:00
										 |  |  | 				make.Group([ | 
					
						
							|  |  |  | 					make('Normal item'), | 
					
						
							| 
									
										
										
										
											2017-02-01 20:39:44 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 07:36:25 +03:00
										 |  |  | 					// this is the same as make('...')
 | 
					
						
							|  |  |  | 					make.Separator(), | 
					
						
							| 
									
										
										
										
											2017-02-01 23:36:09 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 07:36:25 +03:00
										 |  |  | 					make.Editable('Editable (Select to edit)'), | 
					
						
							| 
									
										
										
										
											2017-02-01 20:39:44 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 07:36:25 +03:00
										 |  |  | 					make.Editable('Editable (Enter to edit, cleared)...', { | 
					
						
							|  |  |  | 						start_on: 'open', | 
					
						
							|  |  |  | 						clear_on_edit: true, | 
					
						
							|  |  |  | 					}), | 
					
						
							|  |  |  | 				]) | 
					
						
							| 
									
										
										
										
											2017-02-01 20:39:44 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-01 23:36:09 +03:00
										 |  |  | 				make.Heading('List:') | 
					
						
							| 
									
										
										
										
											2017-02-01 20:39:44 +03:00
										 |  |  | 				make.List(['a', 'b', 'c']) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-01 23:36:57 +03:00
										 |  |  | 				make.Heading(' Editable list:') | 
					
						
							| 
									
										
										
										
											2017-02-01 23:40:52 +03:00
										 |  |  | 				make.EditableList(editable_list) | 
					
						
							| 
									
										
										
										
											2017-02-01 20:39:44 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 02:37:34 +03:00
										 |  |  | 				make.Heading('More:') | 
					
						
							|  |  |  | 				make.Action('Editable list demos...') | 
					
						
							|  |  |  | 					.on('open', function(){ actions.testList() }) | 
					
						
							|  |  |  | 				make.Action('Pinned list demo...') | 
					
						
							|  |  |  | 					.on('open', function(){ actions.testPinnedList() }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-01 20:39:44 +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() | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 			// NOTE: this is not a dialog event, it is defined by the 
 | 
					
						
							|  |  |  | 			// 		container to notify us that we are closing...
 | 
					
						
							|  |  |  | 			.on('close', function(){ | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 		})], | 
					
						
							|  |  |  | 	testList: ['Test/-99: Demo $lists editors in dialog...', | 
					
						
							| 
									
										
										
										
											2017-01-27 08:26:10 +03:00
										 |  |  | 		makeUIDialog(function(){ | 
					
						
							|  |  |  | 			var actions = this | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// NOTE: passing things other than strings into a list editor
 | 
					
						
							|  |  |  | 			// 		is not supported...
 | 
					
						
							|  |  |  | 			var numbers = ['1', '2', '3', '4'] | 
					
						
							|  |  |  | 			var letters = ['a', 'b', 'c', 'd'] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			return browse.makeLister(null, function(path, make){ | 
					
						
							|  |  |  | 				var that = this | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-30 20:01:24 +03:00
										 |  |  | 				make.Heading('Numbers:', { | 
					
						
							| 
									
										
										
										
											2017-01-27 08:26:10 +03:00
										 |  |  | 					doc: 'List editor with all the buttons enabled...', | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 				make.EditableList(numbers, {  | 
					
						
							|  |  |  | 					list_id: 'numbers', | 
					
						
							|  |  |  | 					item_order_buttons: true, | 
					
						
							|  |  |  | 					to_top_button: true, | 
					
						
							|  |  |  | 					to_bottom_button: true, | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-30 20:01:24 +03:00
										 |  |  | 				make.Heading('Letters:', { | 
					
						
							| 
									
										
										
										
											2017-01-30 05:37:55 +03:00
										 |  |  | 					doc: 'Sortable list, use sort handle to the right to sort...' | 
					
						
							|  |  |  | 				}) | 
					
						
							| 
									
										
										
										
											2017-01-30 05:01:50 +03:00
										 |  |  | 				make.EditableList(letters, {  | 
					
						
							|  |  |  | 					list_id: 'letters',  | 
					
						
							|  |  |  | 					sortable: 'y', | 
					
						
							|  |  |  | 				}) | 
					
						
							| 
									
										
										
										
											2017-01-27 08:26:10 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				// NOTE: the dialog's .parent is not yet set at this point...
 | 
					
						
							| 
									
										
										
										
											2016-04-30 03:38:52 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-27 08:26:10 +03:00
										 |  |  | 				// 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() | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 			// 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(core.doc`Lists:
 | 
					
						
							|  |  |  | 				- Numbers: ${numbers.join(', ')} | 
					
						
							|  |  |  | 				- Letters: ${letters.join(', ')}`)
 | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 		})], | 
					
						
							| 
									
										
										
										
											2017-02-01 19:25:58 +03:00
										 |  |  | 	testPinnedList: ['Test/-99: Demo $pinned lists in dialog...', | 
					
						
							|  |  |  | 		makeUIDialog(function(){ | 
					
						
							|  |  |  | 			var actions = this | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// NOTE: passing things other than strings into a list editor
 | 
					
						
							|  |  |  | 			// 		is not supported...
 | 
					
						
							| 
									
										
										
										
											2017-02-02 04:19:43 +03:00
										 |  |  | 			var pins = ['b', 'a'] | 
					
						
							| 
									
										
										
										
											2017-02-01 19:25:58 +03:00
										 |  |  | 			var letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			return browse.makeLister(null, function(path, make){ | 
					
						
							|  |  |  | 				var that = this | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				make.Heading('Numbers:', { | 
					
						
							|  |  |  | 					doc: 'List editor with all the buttons enabled...', | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 				make.EditablePinnedList(letters, pins, {  | 
					
						
							|  |  |  | 					list_id: 'letters', | 
					
						
							| 
									
										
										
										
											2017-02-02 04:19:43 +03:00
										 |  |  | 					//pins_sortable: false,
 | 
					
						
							| 
									
										
										
										
											2017-02-01 19:25:58 +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() | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 			// NOTE: this is not a dialog event, it is defined by the 
 | 
					
						
							|  |  |  | 			// 		container to notify us that we are closing...
 | 
					
						
							|  |  |  | 			.on('close', function(){ | 
					
						
							| 
									
										
										
										
											2017-02-02 03:25:58 +03:00
										 |  |  | 				console.log(core.doc`Lists:
 | 
					
						
							|  |  |  | 				- Pins: ${pins.join(', ')} | 
					
						
							|  |  |  | 				- Letters: ${letters.join(', ')}`)
 | 
					
						
							| 
									
										
										
										
											2017-02-01 19:25:58 +03:00
										 |  |  | 			}) | 
					
						
							|  |  |  | 		})], | 
					
						
							| 
									
										
										
										
											2016-10-28 18:13:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-27 17:33:21 +03:00
										 |  |  | 	testProgress: ['Test/Demo $progress bar...', | 
					
						
							| 
									
										
										
										
											2016-10-28 18:13:42 +03:00
										 |  |  | 		function(text){ | 
					
						
							|  |  |  | 			var done = 0 | 
					
						
							|  |  |  | 			var max = 10 | 
					
						
							|  |  |  | 			var text = text || 'Progress bar demo' | 
					
						
							|  |  |  | 			var that = this | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			this.showProgress(text) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var step = function(){ | 
					
						
							|  |  |  | 				that.showProgress(text, done++, max) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				max = done < 8 ? max + 5  | 
					
						
							|  |  |  | 					: max <= 50 && done < 30 ? max + 2  | 
					
						
							|  |  |  | 					: done > 30 ? max - 3 | 
					
						
							|  |  |  | 					: max | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// NOTE: we add 10 here to compensate for changing max value...
 | 
					
						
							|  |  |  | 				done < max+10 | 
					
						
							|  |  |  | 					&& setTimeout(step, 200)  | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			setTimeout(step, 1000) | 
					
						
							|  |  |  | 		}],  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-23 13:16:28 +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, | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-07 07:32:31 +03:00
										 |  |  | 			var data = this.data.crop(this.data.getTaggedByAll(tag), true) | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-07 07:32:31 +03:00
										 |  |  | 			var b = new core.ImageGrid() | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// 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()
 | 
					
						
							|  |  |  | 				.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') }], | 
					
						
							| 
									
										
										
										
											2016-12-27 06:18:04 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	makePartitionAfter: ['Test/Make Partition after image', | 
					
						
							|  |  |  | 		function(image, text){ | 
					
						
							| 
									
										
										
										
											2016-12-28 02:31:15 +03:00
										 |  |  | 			var gid = this.data.getImage(image || 'current') | 
					
						
							|  |  |  | 			var attrs = { | 
					
						
							|  |  |  | 				gid: gid | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-12-27 06:18:04 +03:00
										 |  |  | 			if(text){ | 
					
						
							|  |  |  | 				attrs.text = text | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-12-28 02:31:15 +03:00
										 |  |  | 			this.ribbons.getImage(gid) | 
					
						
							| 
									
										
										
										
											2016-12-27 06:18:04 +03:00
										 |  |  | 				.after($('<span>') | 
					
						
							|  |  |  | 					.addClass('mark partition') | 
					
						
							|  |  |  | 					.attr(attrs)) | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2016-12-28 02:31:15 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-28 20:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-24 23:15:03 +03:00
										 |  |  | 	// action constructor for testing...
 | 
					
						
							|  |  |  | 	makeAction: ['- Test/', | 
					
						
							|  |  |  | 		function(name){ | 
					
						
							|  |  |  | 			this[name] = actions.Action.apply(actions.Action, arguments) }], | 
					
						
							| 
									
										
										
										
											2016-12-28 23:36:32 +03:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var WidgetTest =  | 
					
						
							|  |  |  | module.WidgetTest = core.ImageGridFeatures.Feature({ | 
					
						
							|  |  |  | 	title: '', | 
					
						
							|  |  |  | 	doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tag: 'ui-widget-test', | 
					
						
							|  |  |  | 	depends: [ | 
					
						
							|  |  |  | 		'ui-browse-actions', | 
					
						
							|  |  |  | 	], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	actions: WidgetTestActions, | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | /********************************************************************** | 
					
						
							| 
									
										
										
										
											2016-08-20 22:49:36 +03:00
										 |  |  | * vim:set ts=4 sw=4 :                               */ return module }) |