| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-31 10:37:21 +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') | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | var core = require('features/core') | 
					
						
							|  |  |  | var base = require('features/base') | 
					
						
							| 
									
										
										
										
											2017-03-29 17:22:58 +03:00
										 |  |  | var ui = require('features/ui') | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // XXX should we rename this to "select"???
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // target can be:
 | 
					
						
							|  |  |  | // 		'all'
 | 
					
						
							|  |  |  | // 		'loaded'
 | 
					
						
							|  |  |  | // 		'ribbon'	- current ribbon
 | 
					
						
							|  |  |  | // 		ribbon		- specific ribbon (gid)
 | 
					
						
							|  |  |  | // 		Array
 | 
					
						
							| 
									
										
										
										
											2019-10-24 04:40:45 +03:00
										 |  |  | // 		attr
 | 
					
						
							|  |  |  | // 		!attr
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2016-04-02 16:28:53 +03:00
										 |  |  | // NOTE: of no data is defined this will not have any effect...
 | 
					
						
							| 
									
										
										
										
											2016-11-28 17:56:14 +03:00
										 |  |  | // NOTE: we are not using the vanilla toggler here as it can't handle 
 | 
					
						
							|  |  |  | // 		toggling independently multiple elements...
 | 
					
						
							| 
									
										
										
										
											2018-03-22 02:46:42 +03:00
										 |  |  | // 
 | 
					
						
							|  |  |  | // XXX this is really slow on large sets of images...
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | function makeTagTogglerAction(tag){ | 
					
						
							| 
									
										
										
										
											2016-11-28 17:56:14 +03:00
										 |  |  | 	// get actual target gids...
 | 
					
						
							|  |  |  | 	var _getTarget = function(target){ | 
					
						
							| 
									
										
										
										
											2018-01-04 02:53:40 +03:00
										 |  |  | 		target = target || this.current | 
					
						
							| 
									
										
										
										
											2018-03-22 02:46:42 +03:00
										 |  |  | 		target = (target == 'all'  | 
					
						
							| 
									
										
										
										
											2018-01-04 02:53:40 +03:00
										 |  |  | 					|| target == 'loaded'  | 
					
						
							| 
									
										
										
										
											2018-03-22 02:46:42 +03:00
										 |  |  | 					|| target in this.data.ribbons) ?  | 
					
						
							| 
									
										
										
										
											2018-01-04 02:53:40 +03:00
										 |  |  | 				this.data.getImages(target) | 
					
						
							|  |  |  | 			: target == 'ribbon' ?  | 
					
						
							|  |  |  | 				this.data.getImages('current') | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 			: target | 
					
						
							| 
									
										
										
										
											2018-01-04 02:53:40 +03:00
										 |  |  | 		return target == null ? | 
					
						
							|  |  |  | 				[]	 | 
					
						
							|  |  |  | 			: target instanceof Array ?  | 
					
						
							|  |  |  | 				target  | 
					
						
							|  |  |  | 			: [target] | 
					
						
							| 
									
										
										
										
											2016-11-28 17:56:14 +03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-28 17:56:14 +03:00
										 |  |  | 	// the toggler...
 | 
					
						
							|  |  |  | 	var _tagToggler = toggler.Toggler('current', | 
					
						
							|  |  |  | 		function(target, action){ | 
					
						
							|  |  |  | 			target = _getTarget.call(this, target) | 
					
						
							|  |  |  | 			// get state...
 | 
					
						
							|  |  |  | 			if(action == null){ | 
					
						
							|  |  |  | 				var res = this.data.toggleTag(tag, target, '?') | 
					
						
							|  |  |  | 				return res.length == 1 ? res[0] : res | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-28 17:56:14 +03:00
										 |  |  | 			} else if(action == 'on'){ | 
					
						
							|  |  |  | 				this.tag(tag, target) | 
					
						
							| 
									
										
										
										
											2018-03-22 02:46:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-28 17:56:14 +03:00
										 |  |  | 			} else if(action == 'off'){ | 
					
						
							|  |  |  | 				this.untag(tag, target) | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		},  | 
					
						
							|  |  |  | 		['off', 'on']) | 
					
						
							| 
									
										
										
										
											2016-04-22 19:26:22 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-28 17:56:14 +03:00
										 |  |  | 	// the action...
 | 
					
						
							|  |  |  | 	var action = function(target, action){ | 
					
						
							| 
									
										
										
										
											2019-10-24 04:40:45 +03:00
										 |  |  | 		// gid list attr...
 | 
					
						
							|  |  |  | 		target = target in this ? | 
					
						
							|  |  |  | 			this[target] | 
					
						
							|  |  |  | 			: target | 
					
						
							|  |  |  | 		// reverse gid list attr...
 | 
					
						
							|  |  |  | 		if(typeof(target) == typeof('str') && target[0] == '!'){ | 
					
						
							|  |  |  | 			var skip = new Set(this[target.slice(1)]) | 
					
						
							|  |  |  | 			target = this.data.order | 
					
						
							|  |  |  | 				.filter(function(gid){ | 
					
						
							|  |  |  | 					return !skip.has(gid) }) } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-28 17:56:14 +03:00
										 |  |  | 		// special case: no data...
 | 
					
						
							|  |  |  | 		if(this.data == null){ | 
					
						
							|  |  |  | 			return action == '??' ? ['off', 'on'] : 'off' | 
					
						
							| 
									
										
										
										
											2016-04-22 19:26:22 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-28 17:56:14 +03:00
										 |  |  | 		// special case: multiple targets and toggle action...
 | 
					
						
							| 
									
										
										
										
											2018-12-05 18:15:37 +03:00
										 |  |  | 		// XXX do we need this???
 | 
					
						
							| 
									
										
										
										
											2016-11-28 17:56:14 +03:00
										 |  |  | 		} else if((target == 'all' || target == 'loaded' || target == 'ribbon'  | 
					
						
							|  |  |  | 					|| target instanceof Array)  | 
					
						
							|  |  |  | 				&& (action == null || action == 'next' || action == 'prev'  | 
					
						
							|  |  |  | 					|| action == '!')){ | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 			var res = [] | 
					
						
							|  |  |  | 			var that = this | 
					
						
							| 
									
										
										
										
											2018-03-22 02:46:42 +03:00
										 |  |  | 			var on = [] | 
					
						
							|  |  |  | 			var off = [] | 
					
						
							| 
									
										
										
										
											2016-11-28 17:56:14 +03:00
										 |  |  | 			target = _getTarget.call(this, target) | 
					
						
							| 
									
										
										
										
											2018-03-26 13:27:23 +03:00
										 |  |  | 			target | 
					
						
							|  |  |  | 				.forEach(function(gid){ | 
					
						
							|  |  |  | 					if((that.data.getTags(gid).indexOf(tag) < 0)  | 
					
						
							|  |  |  | 							// invert check if action is '!'...
 | 
					
						
							|  |  |  | 							+ (action == '!' ? -1 : 0)){ | 
					
						
							|  |  |  | 						on.push(gid) | 
					
						
							|  |  |  | 						res.push('on') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						off.push(gid) | 
					
						
							|  |  |  | 						res.push('off') | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			that.tag(tag, on) | 
					
						
							|  |  |  | 			that.untag(tag, off) | 
					
						
							| 
									
										
										
										
											2018-03-22 02:46:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-28 17:56:14 +03:00
										 |  |  | 			return res.length == 1 ? res[0] : res | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-28 17:56:14 +03:00
										 |  |  | 		// normal case...
 | 
					
						
							|  |  |  | 		return _tagToggler.call(this, target, action) | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// cheating a bit...
 | 
					
						
							| 
									
										
										
										
											2016-11-28 17:56:14 +03:00
										 |  |  | 	action.__proto__ = toggler.Toggler.prototype | 
					
						
							|  |  |  | 	action.constructor = toggler.Toggler | 
					
						
							|  |  |  | 	return action | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-01 02:18:45 +03:00
										 |  |  | // Build a tag toggler undo set of attrs...
 | 
					
						
							|  |  |  | // 
 | 
					
						
							|  |  |  | // This will add:
 | 
					
						
							|  |  |  | // 	'undoable'		- predicate to check if we need to undo, to handle 
 | 
					
						
							|  |  |  | // 						introspection calls correctly...
 | 
					
						
							|  |  |  | // 	'undo'			- undo function...
 | 
					
						
							|  |  |  | // 	
 | 
					
						
							| 
									
										
										
										
											2017-03-30 14:07:50 +03:00
										 |  |  | var undoTag = function(action){ | 
					
						
							|  |  |  | 	return { | 
					
						
							|  |  |  | 		// do not journal calls that have no side-effects, e.g. toggler 
 | 
					
						
							|  |  |  | 		// introspection...
 | 
					
						
							|  |  |  | 		// XXX should this be a generic predicate???
 | 
					
						
							|  |  |  | 		undoable: function(a){ | 
					
						
							| 
									
										
										
										
											2017-04-02 06:13:57 +03:00
										 |  |  | 			// handle ribbon-wide operations...
 | 
					
						
							|  |  |  | 			// NOTE: this is specific to .toggleMark(..)
 | 
					
						
							|  |  |  | 			if(a.args[0] == 'ribbon' && action == 'toggleMark'){ | 
					
						
							|  |  |  | 				a.state = this.markedInRibbon() | 
					
						
							|  |  |  | 				return true | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			// skip introspection...
 | 
					
						
							| 
									
										
										
										
											2017-03-30 14:07:50 +03:00
										 |  |  | 			return a.args.indexOf('?') < 0  | 
					
						
							| 
									
										
										
										
											2017-04-02 06:13:57 +03:00
										 |  |  | 				&& a.args.indexOf('??') < 0 | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2017-03-30 14:07:50 +03:00
										 |  |  | 		undo: function(a){ | 
					
						
							| 
									
										
										
										
											2017-04-02 06:13:57 +03:00
										 |  |  | 			// restore state...
 | 
					
						
							|  |  |  | 			if(a.state){ | 
					
						
							|  |  |  | 				this[action]('ribbon', 'off') | 
					
						
							|  |  |  | 				this[action](a.state, 'on') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// reverse state...
 | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				this[action].apply(this,  | 
					
						
							|  |  |  | 					// XXX is argument handling here too optimistic???
 | 
					
						
							|  |  |  | 					a.args.map(function(e){  | 
					
						
							|  |  |  | 						return e == 'on' ? 'off'  | 
					
						
							|  |  |  | 							: e == 'off' ? 'on' | 
					
						
							|  |  |  | 							: e }))  | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2017-03-30 14:07:50 +03:00
										 |  |  | 	} } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-31 15:41:30 +03:00
										 |  |  | // Shift marked image action constructor...
 | 
					
						
							| 
									
										
										
										
											2017-03-29 17:22:58 +03:00
										 |  |  | // 
 | 
					
						
							| 
									
										
										
										
											2017-03-31 15:41:30 +03:00
										 |  |  | // 	Shift marked images up/down
 | 
					
						
							|  |  |  | // 	shiftMarked('up')
 | 
					
						
							|  |  |  | // 	shiftMarked('down')
 | 
					
						
							|  |  |  | // 		-> action
 | 
					
						
							|  |  |  | // 
 | 
					
						
							|  |  |  | // The resulting action affects only images in current ribbon...
 | 
					
						
							|  |  |  | // 
 | 
					
						
							|  |  |  | // NOTE: this specific to marked/selected images...
 | 
					
						
							| 
									
										
										
										
											2017-03-29 17:22:58 +03:00
										 |  |  | var shiftMarked = function(direction){ | 
					
						
							|  |  |  | 	return function(ribbon){ | 
					
						
							| 
									
										
										
										
											2017-03-29 18:55:02 +03:00
										 |  |  | 		var that = this | 
					
						
							| 
									
										
										
										
											2017-03-29 17:22:58 +03:00
										 |  |  | 		var marked = this.markedInRibbon(ribbon) | 
					
						
							| 
									
										
										
										
											2017-03-29 18:55:02 +03:00
										 |  |  | 		var next  | 
					
						
							| 
									
										
										
										
											2017-03-29 17:22:58 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-29 18:55:02 +03:00
										 |  |  | 		// need to shift focus...
 | 
					
						
							|  |  |  | 		if(marked.indexOf(this.current) >= 0){ | 
					
						
							|  |  |  | 			var d = this.direction == 'right' ? 'next' : 'prev' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var getNext = function(direction){ | 
					
						
							|  |  |  | 				var next = that.data.getImage(direction) | 
					
						
							|  |  |  | 				while(next != null && marked.indexOf(next) >= 0){ | 
					
						
							|  |  |  | 					next = that.data.getImage(next, direction) | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				return next | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			next = getNext(d)  | 
					
						
							|  |  |  | 				|| getNext(d == 'next' ? 'prev' : 'next') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			next != null  | 
					
						
							|  |  |  | 				&& this.data.focusImage(next) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// shift the image...
 | 
					
						
							|  |  |  | 		this.data['shiftImage'+ direction.capitalize()](marked) | 
					
						
							| 
									
										
										
										
											2017-03-29 17:22:58 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// obey the shiftImage protocol...
 | 
					
						
							|  |  |  | 		this.shiftImage.apply(this, marked) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-02 05:47:57 +03:00
										 |  |  | // Shift undo function constructor...
 | 
					
						
							|  |  |  | // 
 | 
					
						
							| 
									
										
										
										
											2017-03-29 18:55:02 +03:00
										 |  |  | // NOTE: this is specific to shiftMarkedUp/shiftMarkedDown...
 | 
					
						
							|  |  |  | var undoShift = function(undo){ | 
					
						
							|  |  |  | 	return function(a){  | 
					
						
							|  |  |  | 		this[undo](this.data.getRibbon( | 
					
						
							|  |  |  | 			undo == 'shiftMarkedUp' ? 'next' : 'prev', | 
					
						
							|  |  |  | 			a.args.length == 0 ? a.current : a.args[0])) }} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | //---------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var ImageMarkActions = actions.Actions({ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// a shorthand...
 | 
					
						
							|  |  |  | 	// NOTE: this will return a copy...
 | 
					
						
							| 
									
										
										
										
											2018-03-26 13:27:23 +03:00
										 |  |  | 	//
 | 
					
						
							|  |  |  | 	// XXX should we add a caching scheme here???
 | 
					
						
							|  |  |  | 	// 		...it would require invalidation on tagging...
 | 
					
						
							|  |  |  | 	// 		the problem is that on large sets this may take up quite a 
 | 
					
						
							|  |  |  | 	// 		chunk of memory...
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 	get marked(){ | 
					
						
							| 
									
										
										
										
											2018-12-06 00:59:05 +03:00
										 |  |  | 		return this.data == null ? | 
					
						
							|  |  |  | 			[] | 
					
						
							| 
									
										
										
										
											2018-12-24 01:11:26 +03:00
										 |  |  | 			: this.data.sortViaOrder(this.data.tagQuery('marked')) }, | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-29 17:22:58 +03:00
										 |  |  | 	markedInRibbon: ['- Mark|Ribbon/', | 
					
						
							|  |  |  | 		function(ribbon){ | 
					
						
							|  |  |  | 			var ribbon = this.data.getRibbon(ribbon) | 
					
						
							|  |  |  | 			var images = this.data.makeSparseImages(this.data.getImages(ribbon)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			return this.data.makeSparseImages(this.marked) | 
					
						
							|  |  |  | 				// NOTE: this will also filter out undefined positions...
 | 
					
						
							|  |  |  | 				.filter(function(img, i){ return images[i] != null }) | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-14 02:29:47 +03:00
										 |  |  | 	prevMarked: ['Mark|Navigate/Previous marked image', | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 		{mode: function(target){  | 
					
						
							| 
									
										
										
										
											2017-07-23 16:38:03 +03:00
										 |  |  | 			return this.data.getImage('current', 'before', this.marked) == null && 'disabled' }}, | 
					
						
							| 
									
										
										
										
											2018-11-08 21:10:58 +03:00
										 |  |  | 		function(mode){ this.prevTagged('marked', mode) }], | 
					
						
							| 
									
										
										
										
											2017-05-14 02:29:47 +03:00
										 |  |  | 	nextMarked: ['Mark|Navigate/Next marked image', | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 		{mode: function(target){  | 
					
						
							| 
									
										
										
										
											2017-07-23 16:38:03 +03:00
										 |  |  | 			return this.data.getImage('current', 'after', this.marked) == null && 'disabled' }}, | 
					
						
							| 
									
										
										
										
											2018-11-08 21:10:58 +03:00
										 |  |  | 		function(mode){ this.nextTagged('marked', mode) }], | 
					
						
							| 
									
										
										
										
											2017-05-14 02:29:47 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	cropMarked: ['Mark|Crop/Crop $marked images', | 
					
						
							| 
									
										
										
										
											2020-05-31 20:12:58 +03:00
										 |  |  | 		{mode: function(){ | 
					
						
							| 
									
										
										
										
											2017-05-20 05:28:19 +03:00
										 |  |  | 			return this.marked.length == 0 && 'disabled' }}, | 
					
						
							| 
									
										
										
										
											2019-10-24 04:40:45 +03:00
										 |  |  | 		'crop: "marked" ...'], | 
					
						
							|  |  |  | 		//function(flatten){ this.cropTagged('marked', flatten) }],
 | 
					
						
							| 
									
										
										
										
											2018-12-06 00:59:05 +03:00
										 |  |  | 		//function(flatten){ this.cropTagged('marked', 'any', flatten) }],
 | 
					
						
							| 
									
										
										
										
											2017-09-08 22:03:16 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	removeMarkedFromCrop: ['Mark|Crop/Remove marked from crop', | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 		{mode: function(target){  | 
					
						
							| 
									
										
										
										
											2020-05-31 20:12:58 +03:00
										 |  |  | 			return (this.marked.length == 0 || !this.cropped) && 'disabled' }}, | 
					
						
							| 
									
										
										
										
											2017-11-19 01:01:44 +03:00
										 |  |  | 		'removeFromCrop: marked'], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	rotateMarkedCW: ['Mark/Rotate marked clockwise', | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 		{mode: 'cropMarked'}, | 
					
						
							| 
									
										
										
										
											2017-11-19 01:01:44 +03:00
										 |  |  | 		'rotateCW: marked'], | 
					
						
							|  |  |  | 	rotateMarkedCCW: ['Mark/Rotate marked counterclockwise', | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 		{mode: 'cropMarked'}, | 
					
						
							| 
									
										
										
										
											2017-11-19 01:01:44 +03:00
										 |  |  | 		'rotateCCW: marked'], | 
					
						
							|  |  |  | 	flipMarkedVertical: ['Mark/Flip marked vertically', | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 		{mode: 'cropMarked'}, | 
					
						
							| 
									
										
										
										
											2017-11-19 01:01:44 +03:00
										 |  |  | 		'flipVertical: marked'], | 
					
						
							|  |  |  | 	flipMarkedHorizontal: ['Mark/Flip marked horizontally', | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 		{mode: 'cropMarked'}, | 
					
						
							| 
									
										
										
										
											2017-11-19 01:01:44 +03:00
										 |  |  | 		'flipHorizontal: marked'], | 
					
						
							| 
									
										
										
										
											2017-05-14 02:29:47 +03:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // NOTE: this is usable without ribbons...
 | 
					
						
							|  |  |  | var ImageMarks =  | 
					
						
							|  |  |  | module.ImageMarks = core.ImageGridFeatures.Feature({ | 
					
						
							|  |  |  | 	title: '', | 
					
						
							|  |  |  | 	doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tag: 'image-marks', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	depends: [ | 
					
						
							|  |  |  | 		'base', | 
					
						
							|  |  |  | 	], | 
					
						
							|  |  |  | 	suggested: [ | 
					
						
							|  |  |  | 		'image-marks-edit', | 
					
						
							|  |  |  | 		'ui-image-marks', | 
					
						
							| 
									
										
										
										
											2017-07-23 16:58:31 +03:00
										 |  |  | 		'image-marks-groups', | 
					
						
							| 
									
										
										
										
											2017-05-14 02:29:47 +03:00
										 |  |  | 	], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	actions: ImageMarkActions, | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var ImageMarkEditActions = actions.Actions({ | 
					
						
							| 
									
										
										
										
											2019-10-24 04:40:45 +03:00
										 |  |  | 	// XXX should this be like .crop(..) and accept attr name???
 | 
					
						
							| 
									
										
										
										
											2017-02-09 16:44:09 +03:00
										 |  |  | 	toggleMark: ['Mark|Image/Image $mark', | 
					
						
							| 
									
										
										
										
											2019-10-24 04:40:45 +03:00
										 |  |  | 		core.doc`
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		 	Toggle mark on current image | 
					
						
							|  |  |  | 		 	.toggleMark() | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		 	Mark current ribbon | 
					
						
							|  |  |  | 		 	.toggleMark('ribbon', 'on') | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		 	Unmark all loaded images | 
					
						
							|  |  |  | 		 	.toggleMark('loaded', 'off') | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		 	Invert marks on current ribbon | 
					
						
							|  |  |  | 		 	.toggleMark('ribbon') | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		`,
 | 
					
						
							| 
									
										
										
										
											2017-03-30 14:07:50 +03:00
										 |  |  | 		undoTag('toggleMark'), | 
					
						
							| 
									
										
										
										
											2018-11-08 21:10:58 +03:00
										 |  |  | 		makeTagTogglerAction('marked')], | 
					
						
							| 
									
										
										
										
											2018-03-26 13:27:23 +03:00
										 |  |  | 	toggleMarkBlock: ['Mark/Invert $block marks', | 
					
						
							| 
									
										
										
										
											2017-03-29 20:21:26 +03:00
										 |  |  | 		core.doc`A block is a set of adjacent images either marked on unmarked
 | 
					
						
							|  |  |  | 		in the same way | 
					
						
							|  |  |  | 		`,
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 		function(target){ | 
					
						
							| 
									
										
										
										
											2017-03-29 20:21:26 +03:00
										 |  |  | 			target = this.data.getImage(target) | 
					
						
							| 
									
										
										
										
											2017-03-29 21:04:12 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			var ribbon = this.data.makeSparseImages(this.data.getImages(target)) | 
					
						
							| 
									
										
										
										
											2017-03-29 20:21:26 +03:00
										 |  |  | 			var marked = this.data.makeSparseImages(this.markedInRibbon(target)) | 
					
						
							| 
									
										
										
										
											2017-03-29 21:04:12 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-29 21:09:28 +03:00
										 |  |  | 			var c = ribbon.indexOf(target) | 
					
						
							| 
									
										
										
										
											2017-03-29 20:21:26 +03:00
										 |  |  | 			var state = !!marked[c] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var block = [target] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// pre block...
 | 
					
						
							|  |  |  | 			var i = c-1 | 
					
						
							| 
									
										
										
										
											2017-03-29 21:12:00 +03:00
										 |  |  | 			while(i >= 0  | 
					
						
							|  |  |  | 					// NOTE: we are avoiding mixing up a tag not set condition
 | 
					
						
							|  |  |  | 					// 		with image i not in ribbon...
 | 
					
						
							|  |  |  | 					&& (!ribbon[i] || !!marked[i] == state)){ | 
					
						
							| 
									
										
										
										
											2017-03-29 21:04:12 +03:00
										 |  |  | 				ribbon[i]  | 
					
						
							|  |  |  | 					&& block.splice(0, 0, ribbon[i]) | 
					
						
							| 
									
										
										
										
											2017-03-29 20:21:26 +03:00
										 |  |  | 				i-- | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// post block...
 | 
					
						
							|  |  |  | 			var i = c+1 | 
					
						
							| 
									
										
										
										
											2017-03-29 21:12:00 +03:00
										 |  |  | 			while(i < ribbon.length  | 
					
						
							|  |  |  | 					// NOTE: we are avoiding mixing up a tag not set condition
 | 
					
						
							|  |  |  | 					// 		with image i not in ribbon...
 | 
					
						
							|  |  |  | 					&& (!ribbon[i] || !!marked[i] == state)){ | 
					
						
							| 
									
										
										
										
											2017-03-29 21:04:12 +03:00
										 |  |  | 				ribbon[i]  | 
					
						
							|  |  |  | 					&& block.push(ribbon[i]) | 
					
						
							| 
									
										
										
										
											2017-03-29 20:21:26 +03:00
										 |  |  | 				i++ | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-29 20:21:26 +03:00
										 |  |  | 			// do the marking...
 | 
					
						
							|  |  |  | 			return this.toggleMark(block, state ? 'off' : 'on') | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2018-03-26 13:27:23 +03:00
										 |  |  | 	toggleMarkRibbon: ['Mark/$Invert ribbon marks',  | 
					
						
							|  |  |  | 		'toggleMark: "ribbon" ...' ], | 
					
						
							|  |  |  | 	toggleMarkLoaded: ['Mark/Invert marks',  | 
					
						
							|  |  |  | 		'toggleMark: "loaded" ...' ], | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-29 13:27:59 +03:00
										 |  |  | 	// NOTE: we do not need a menu hotkey as these are easy to access 
 | 
					
						
							|  |  |  | 	// 		directly (via ctrl-a/ctrl-shift-a)
 | 
					
						
							|  |  |  | 	markRibbon: ['Mark/Mark ribbon',  | 
					
						
							| 
									
										
										
										
											2018-03-26 13:27:23 +03:00
										 |  |  | 		'toggleMark: "ribbon" "on"' ], | 
					
						
							| 
									
										
										
										
											2018-11-29 13:27:59 +03:00
										 |  |  | 	markLoaded: ['Mark/Mark all',  | 
					
						
							| 
									
										
										
										
											2018-03-26 13:27:23 +03:00
										 |  |  | 		'toggleMark: "loaded" "on"' ], | 
					
						
							| 
									
										
										
										
											2017-07-23 16:38:03 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 	markTagged: ['- Mark/Mark images by tags', | 
					
						
							| 
									
										
										
										
											2018-12-06 00:59:05 +03:00
										 |  |  | 		function(query){ | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 			var that = this | 
					
						
							| 
									
										
										
										
											2018-12-06 00:59:05 +03:00
										 |  |  | 			this.data.tagQuery(query) | 
					
						
							|  |  |  | 				.forEach(function(gid){ | 
					
						
							|  |  |  | 					that.toggleMark(gid, 'on') }) }], | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-26 13:27:23 +03:00
										 |  |  | 	shiftMarkedUp: ['Mark/Shift marked u$p', | 
					
						
							| 
									
										
										
										
											2017-07-23 16:38:03 +03:00
										 |  |  | 		{undo: undoShift('shiftMarkedDown'), | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 			mode: 'cropMarked'}, | 
					
						
							| 
									
										
										
										
											2017-03-29 17:22:58 +03:00
										 |  |  | 		shiftMarked('up')], | 
					
						
							| 
									
										
										
										
											2017-09-08 21:32:52 +03:00
										 |  |  | 	shiftMarkedDown: ['Mark/Shift marked $down', | 
					
						
							| 
									
										
										
										
											2017-07-23 16:38:03 +03:00
										 |  |  | 		{undo: undoShift('shiftMarkedUp'), | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 			mode: 'cropMarked'}, | 
					
						
							| 
									
										
										
										
											2017-03-29 17:22:58 +03:00
										 |  |  | 		shiftMarked('down')], | 
					
						
							| 
									
										
										
										
											2017-07-23 16:38:03 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// XXX undo...
 | 
					
						
							| 
									
										
										
										
											2017-09-23 20:06:20 +03:00
										 |  |  | 	shiftMarkedAfter: ['Mark|Image/Shift marked $after', | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 		{mode: 'cropMarked'}, | 
					
						
							| 
									
										
										
										
											2017-07-23 16:38:03 +03:00
										 |  |  | 		function(target){ | 
					
						
							| 
									
										
										
										
											2017-07-23 23:03:19 +03:00
										 |  |  | 			this.shiftImageTo(this.marked, target || 'current', 'after') }], | 
					
						
							| 
									
										
										
										
											2017-07-23 16:38:03 +03:00
										 |  |  | 	// XXX undo...
 | 
					
						
							| 
									
										
										
										
											2017-09-23 20:06:20 +03:00
										 |  |  | 	shiftMarkedBefore: ['Mark|Image/Shift marked $b$efore', | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 		{mode: 'cropMarked'}, | 
					
						
							| 
									
										
										
										
											2017-07-23 16:38:03 +03:00
										 |  |  | 		function(target){ | 
					
						
							| 
									
										
										
										
											2017-07-23 23:03:19 +03:00
										 |  |  | 			this.shiftImageTo(this.marked, target || 'current', 'before') }], | 
					
						
							| 
									
										
										
										
											2018-03-26 13:27:23 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	unmarkRibbon: ['Mark/Unmark ribbon', | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 		{mode: 'cropMarked'}, | 
					
						
							| 
									
										
										
										
											2018-03-26 13:27:23 +03:00
										 |  |  | 		'toggleMark: "ribbon" "off"'], | 
					
						
							|  |  |  | 	unmarkLoaded: ['Mark/$Unmark all', | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 		{mode: 'cropMarked'}, | 
					
						
							| 
									
										
										
										
											2018-03-26 13:27:23 +03:00
										 |  |  | 		'toggleMark: "loaded" "off"'], | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-14 02:29:47 +03:00
										 |  |  | var ImageEditMarks =  | 
					
						
							|  |  |  | module.ImageEditMarks = core.ImageGridFeatures.Feature({ | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 	title: '', | 
					
						
							|  |  |  | 	doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-14 02:29:47 +03:00
										 |  |  | 	tag: 'image-marks-edit', | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-29 18:10:31 +03:00
										 |  |  | 	depends: [ | 
					
						
							| 
									
										
										
										
											2017-05-14 02:29:47 +03:00
										 |  |  | 		'tags-edit', | 
					
						
							| 
									
										
										
										
											2017-03-29 18:10:31 +03:00
										 |  |  | 	], | 
					
						
							|  |  |  | 	suggested: [ | 
					
						
							|  |  |  | 	], | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-14 02:29:47 +03:00
										 |  |  | 	actions: ImageMarkEditActions, | 
					
						
							| 
									
										
										
										
											2017-03-29 18:10:31 +03:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-14 02:29:47 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-23 16:58:31 +03:00
										 |  |  | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var ImageMarkGroupActions = actions.Actions({ | 
					
						
							|  |  |  | 	// NOTE: this will only group loaded images...
 | 
					
						
							| 
									
										
										
										
											2017-09-09 13:47:33 +03:00
										 |  |  | 	groupMarked: ['Group|Mark/-70:Group loaded marked images',  | 
					
						
							| 
									
										
										
										
											2017-07-23 16:58:31 +03:00
										 |  |  | 		{journal: true, | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 			mode: 'cropMarked'},  | 
					
						
							| 
									
										
										
										
											2017-07-23 16:58:31 +03:00
										 |  |  | 		function(){  | 
					
						
							|  |  |  | 			this.group(this.data.getImages(this.marked)) }], | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var ImageMarkGroup =  | 
					
						
							|  |  |  | module.ImageMarkGroup = core.ImageGridFeatures.Feature({ | 
					
						
							|  |  |  | 	title: '', | 
					
						
							|  |  |  | 	doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tag: 'image-marks-groups', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	depends: [ | 
					
						
							|  |  |  | 		'image-marks-edit', | 
					
						
							|  |  |  | 		'image-group-edit', | 
					
						
							|  |  |  | 	], | 
					
						
							|  |  |  | 	suggested: [ | 
					
						
							|  |  |  | 	], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	actions: ImageMarkGroupActions, | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-14 02:29:47 +03:00
										 |  |  | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-29 18:10:31 +03:00
										 |  |  | var ImageMarksUI =  | 
					
						
							|  |  |  | module.ImageMarksUI = core.ImageGridFeatures.Feature({ | 
					
						
							|  |  |  | 	title: '', | 
					
						
							|  |  |  | 	doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tag: 'ui-image-marks', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	depends: [ | 
					
						
							| 
									
										
										
										
											2017-03-29 18:55:02 +03:00
										 |  |  | 		'ui', | 
					
						
							|  |  |  | 		'image-marks', | 
					
						
							| 
									
										
										
										
											2017-03-29 18:10:31 +03:00
										 |  |  | 	], | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	handlers: [ | 
					
						
							| 
									
										
										
										
											2017-03-29 18:55:02 +03:00
										 |  |  | 		// XXX is a full reload a good thing here???
 | 
					
						
							| 
									
										
										
										
											2017-03-29 17:22:58 +03:00
										 |  |  | 		[[ | 
					
						
							| 
									
										
										
										
											2017-03-29 18:55:02 +03:00
										 |  |  | 			'shiftMarkedUp', | 
					
						
							|  |  |  | 			'shiftMarkedDown', | 
					
						
							| 
									
										
										
										
											2017-03-29 17:22:58 +03:00
										 |  |  | 		],  | 
					
						
							| 
									
										
										
										
											2017-03-29 18:55:02 +03:00
										 |  |  | 			function(ribbon){ this.reload(true) }], | 
					
						
							| 
									
										
										
										
											2017-03-29 17:22:58 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 		// XXX is this the right way to go???
 | 
					
						
							| 
									
										
										
										
											2019-10-10 18:01:55 +03:00
										 |  |  | 		['updateImage', function(_, gid, img, options){ | 
					
						
							| 
									
										
										
										
											2018-04-03 02:24:07 +03:00
										 |  |  | 			// NOTE: we are not using .toggleMark(..) here as this 
 | 
					
						
							|  |  |  | 			// 		does not need to depend on the 'edit' feature...
 | 
					
						
							| 
									
										
										
										
											2019-10-10 18:01:55 +03:00
										 |  |  | 			!(options || {}).nochrome | 
					
						
							|  |  |  | 				&& this.ribbons | 
					
						
							| 
									
										
										
										
											2018-04-03 02:24:07 +03:00
										 |  |  | 				&& this.ribbons | 
					
						
							|  |  |  | 					.toggleImageMark( | 
					
						
							|  |  |  | 						gid,  | 
					
						
							| 
									
										
										
										
											2018-11-08 21:10:58 +03:00
										 |  |  | 						'marked',  | 
					
						
							|  |  |  | 						this.data.hasTag(gid, 'marked') ? 'on' : 'off') | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 		}], | 
					
						
							|  |  |  | 	], | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //---------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var ImageBookmarkActions = actions.Actions({ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// a shorthand...
 | 
					
						
							| 
									
										
										
										
											2018-03-26 13:27:23 +03:00
										 |  |  | 	//
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 	// NOTE: this will return a copy...
 | 
					
						
							| 
									
										
										
										
											2018-03-26 13:27:23 +03:00
										 |  |  | 	//
 | 
					
						
							|  |  |  | 	// XXX should we add a caching scheme here???
 | 
					
						
							|  |  |  | 	// 		...it would require invalidation on tagging...
 | 
					
						
							|  |  |  | 	// 		the problem is that on large sets this may take up quite a 
 | 
					
						
							|  |  |  | 	// 		chunk of memory...
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 	get bookmarked(){ | 
					
						
							| 
									
										
										
										
											2018-12-06 00:59:05 +03:00
										 |  |  | 		return this.data == null ? | 
					
						
							|  |  |  | 			[] | 
					
						
							| 
									
										
										
										
											2018-12-24 01:11:26 +03:00
										 |  |  | 			: this.data.sortViaOrder(this.data.tagQuery('bookmark')) }, | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	prevBookmarked: ['Bookmark|Navigate/Previous bookmarked image', | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 		{mode: function(target){  | 
					
						
							| 
									
										
										
										
											2017-07-23 16:38:03 +03:00
										 |  |  | 			return this.data.getImage('current', 'before', this.bookmarked) == null && 'disabled' }}, | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 		function(mode){ this.prevTagged('bookmark', mode) }], | 
					
						
							|  |  |  | 	nextBookmarked: ['Bookmark|Navigate/Next bookmarked image', | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 		{mode: function(target){  | 
					
						
							| 
									
										
										
										
											2017-07-23 16:38:03 +03:00
										 |  |  | 			return this.data.getImage('current', 'after', this.bookmarked) == null && 'disabled' }}, | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 		function(mode){ this.nextTagged('bookmark', mode) }], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 16:44:09 +03:00
										 |  |  | 	cropBookmarked: ['Bookmark|Crop/Crop $bookmarked images', | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 		{mode: function(target){  | 
					
						
							| 
									
										
										
										
											2017-05-20 05:28:19 +03:00
										 |  |  | 			return this.bookmarked.length == 0 && 'disabled' }}, | 
					
						
							| 
									
										
										
										
											2019-10-24 04:40:45 +03:00
										 |  |  | 		'crop: "bookmarked" ...'], | 
					
						
							| 
									
										
										
										
											2018-12-06 00:59:05 +03:00
										 |  |  | 		//function(flatten){ this.cropTagged('bookmark', 'any', flatten) }],
 | 
					
						
							| 
									
										
										
										
											2019-10-24 04:40:45 +03:00
										 |  |  | 		//function(flatten){ this.cropTagged('bookmark', flatten) }],
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // NOTE: this is usable without ribbons...
 | 
					
						
							|  |  |  | var ImageBookmarks =  | 
					
						
							|  |  |  | module.ImageBookmarks = core.ImageGridFeatures.Feature({ | 
					
						
							|  |  |  | 	title: '', | 
					
						
							|  |  |  | 	doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tag: 'image-bookmarks', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-29 18:55:02 +03:00
										 |  |  | 	depends: [ | 
					
						
							| 
									
										
										
										
											2017-05-14 02:29:47 +03:00
										 |  |  | 		'base', | 
					
						
							| 
									
										
										
										
											2017-03-29 18:55:02 +03:00
										 |  |  | 	], | 
					
						
							|  |  |  | 	suggested: [ | 
					
						
							| 
									
										
										
										
											2017-05-14 02:29:47 +03:00
										 |  |  | 		'image-bookmarks-edit', | 
					
						
							| 
									
										
										
										
											2017-03-29 18:55:02 +03:00
										 |  |  | 		'ui-image-bookmarks', | 
					
						
							|  |  |  | 	], | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	actions: ImageBookmarkActions, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-29 18:55:02 +03:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-14 02:29:47 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var ImageBookmarkEditActions = actions.Actions({ | 
					
						
							|  |  |  | 	toggleBookmark: ['Bookmark|Image/Image $bookmark', | 
					
						
							|  |  |  | 		undoTag('toggleBookmark'), | 
					
						
							|  |  |  | 		makeTagTogglerAction('bookmark')], | 
					
						
							|  |  |  | 	// action can be:
 | 
					
						
							|  |  |  | 	// 	'on'	- toggle all on
 | 
					
						
							|  |  |  | 	// 	'off'	- toggle all off
 | 
					
						
							|  |  |  | 	// 	'next'	- toggle each image to next state
 | 
					
						
							| 
									
										
										
										
											2017-09-09 13:47:33 +03:00
										 |  |  | 	toggleBookmarkOnMarked: ['Bookmark|Mark/-70:Toggle bookmark on maked images', | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 		{mode: 'cropMarked'}, | 
					
						
							| 
									
										
										
										
											2017-05-14 02:29:47 +03:00
										 |  |  | 		function(action){  | 
					
						
							| 
									
										
										
										
											2018-12-06 00:59:05 +03:00
										 |  |  | 			return this.toggleBookmark(this.marked, action) }], | 
					
						
							| 
									
										
										
										
											2017-05-14 02:29:47 +03:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var ImageBookmarksEdit =  | 
					
						
							|  |  |  | module.ImageBookmarksEdit = core.ImageGridFeatures.Feature({ | 
					
						
							|  |  |  | 	title: '', | 
					
						
							|  |  |  | 	doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tag: 'image-bookmarks-edit', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	depends: [ | 
					
						
							|  |  |  | 		'tags-edit', | 
					
						
							|  |  |  | 	], | 
					
						
							|  |  |  | 	suggested: [ | 
					
						
							|  |  |  | 		'ui-image-bookmarks', | 
					
						
							|  |  |  | 	], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	actions: ImageBookmarkEditActions, | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-29 18:55:02 +03:00
										 |  |  | var ImageBookmarksUI =  | 
					
						
							|  |  |  | module.ImageBookmarksUI = core.ImageGridFeatures.Feature({ | 
					
						
							|  |  |  | 	title: '', | 
					
						
							|  |  |  | 	doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tag: 'ui-image-bookmarks', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	depends: [ | 
					
						
							|  |  |  | 		'ui', | 
					
						
							|  |  |  | 		'image-bookmarks', | 
					
						
							|  |  |  | 	], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 	handlers: [ | 
					
						
							|  |  |  | 		// XXX is this the right way to go???
 | 
					
						
							| 
									
										
										
										
											2019-10-10 18:01:55 +03:00
										 |  |  | 		['updateImage', function(_, gid, img, options){ | 
					
						
							|  |  |  | 			!(options || {}).nochrome | 
					
						
							|  |  |  | 				&& this.ribbons | 
					
						
							| 
									
										
										
										
											2018-04-03 02:24:07 +03:00
										 |  |  | 				&& this.ribbons | 
					
						
							|  |  |  | 					.toggleImageMark( | 
					
						
							|  |  |  | 						gid,  | 
					
						
							|  |  |  | 						'bookmark',  | 
					
						
							|  |  |  | 						this.data.hasTag(gid, 'bookmark') ? 'on' : 'off') | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | 		}], | 
					
						
							|  |  |  | 	], | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-23 16:58:31 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-02 19:30:48 +03:00
										 |  |  | //---------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | core.ImageGridFeatures.Feature('marks', [ | 
					
						
							|  |  |  | 	'image-marks', | 
					
						
							|  |  |  | 	'image-bookmarks', | 
					
						
							|  |  |  | ]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 03:34:20 +03:00
										 |  |  | /********************************************************************** | 
					
						
							| 
									
										
										
										
											2016-08-20 22:49:36 +03:00
										 |  |  | * vim:set ts=4 sw=4 :                               */ return module }) |