| 
									
										
										
										
											2016-03-12 06:24:35 +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
										 |  |  | /*********************************************************************/ | 
					
						
							| 
									
										
										
										
											2016-03-12 06:24:35 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | var toggler = require('lib/toggler') | 
					
						
							|  |  |  | var actions = require('lib/actions') | 
					
						
							|  |  |  | var features = require('lib/features') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var core = require('features/core') | 
					
						
							|  |  |  | var base = require('features/base') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-14 18:31:10 +03:00
										 |  |  | var widgets = require('features/ui-widgets') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-29 03:09:31 +03:00
										 |  |  | var browse = require('lib/widget/browse') | 
					
						
							|  |  |  | var overlay = require('lib/widget/overlay') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-12 06:24:35 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-30 15:24:01 +03:00
										 |  |  | // NOTE: this uses ui-chrome-hidden workspace to set the initial state
 | 
					
						
							|  |  |  | // 		of the slideshow workspace.
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2016-03-29 05:17:50 +03:00
										 |  |  | // XXX would be a good idea to add provision for a timer to indicate 
 | 
					
						
							|  |  |  | // 		slideshow progress/status... 
 | 
					
						
							| 
									
										
										
										
											2016-04-14 18:37:10 +03:00
										 |  |  | // 			- make this a separate feature with a toggler
 | 
					
						
							| 
									
										
										
										
											2017-11-27 01:20:35 +03:00
										 |  |  | // XXX might be a good idea to add "slideshow hold", for example while 
 | 
					
						
							|  |  |  | // 		mouse down...
 | 
					
						
							| 
									
										
										
										
											2016-03-12 06:24:35 +03:00
										 |  |  | var SlideshowActions = actions.Actions({ | 
					
						
							|  |  |  | 	config: { | 
					
						
							| 
									
										
										
										
											2016-03-29 05:22:36 +03:00
										 |  |  | 		'slideshow-looping': 'on', | 
					
						
							|  |  |  | 		'slideshow-direction': 'forward', | 
					
						
							|  |  |  | 		'slideshow-interval': '3s', | 
					
						
							|  |  |  | 		'slideshow-intervals': [ | 
					
						
							| 
									
										
										
										
											2016-03-27 20:07:48 +03:00
										 |  |  | 			'0.2s', | 
					
						
							| 
									
										
										
										
											2016-03-29 03:09:31 +03:00
										 |  |  | 			'1s', | 
					
						
							| 
									
										
										
										
											2016-03-27 20:07:48 +03:00
										 |  |  | 			'3s', | 
					
						
							|  |  |  | 			'5s', | 
					
						
							|  |  |  | 			'7s', | 
					
						
							|  |  |  | 		], | 
					
						
							| 
									
										
										
										
											2019-11-14 06:36:14 +03:00
										 |  |  | 		'slideshow-interval-max-count': 7, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'slideshow-pause-on-blur': true, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-12 06:24:35 +03:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-27 07:22:08 +03:00
										 |  |  | 	toggleSlideshow: ['Slideshow/$Slideshow quick toggle', | 
					
						
							| 
									
										
										
										
											2016-03-28 21:46:05 +03:00
										 |  |  | 		toggler.CSSClassToggler( | 
					
						
							| 
									
										
										
										
											2017-05-16 00:26:37 +03:00
										 |  |  | 			function(){ return this.dom },  | 
					
						
							| 
									
										
										
										
											2016-03-28 21:46:05 +03:00
										 |  |  | 			'slideshow-running', | 
					
						
							|  |  |  | 			function(state){ | 
					
						
							|  |  |  | 				// start...
 | 
					
						
							|  |  |  | 				if(state == 'on'){ | 
					
						
							|  |  |  | 					var that = this | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					// reset the timer...
 | 
					
						
							|  |  |  | 					// NOTE: this means we were in a slideshow mode so we do not
 | 
					
						
							|  |  |  | 					// 		need to prepare...
 | 
					
						
							| 
									
										
										
										
											2017-11-26 07:56:26 +03:00
										 |  |  | 					if(this.__slideshow_timer){ | 
					
						
							|  |  |  | 						this.__slideshow_timer != 'suspended' | 
					
						
							|  |  |  | 							&& clearInterval(this.__slideshow_timer) | 
					
						
							|  |  |  | 						delete this.__slideshow_timer | 
					
						
							| 
									
										
										
										
											2016-03-28 21:46:05 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 					// prepare for the slideshow...
 | 
					
						
							|  |  |  | 					} else { | 
					
						
							| 
									
										
										
										
											2016-05-07 00:47:52 +03:00
										 |  |  | 						// single image mode...
 | 
					
						
							|  |  |  | 						this.toggleSingleImage('on') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-29 00:31:50 +03:00
										 |  |  | 						// save current workspace...
 | 
					
						
							| 
									
										
										
										
											2016-05-07 00:47:52 +03:00
										 |  |  | 						this.pushWorkspace() | 
					
						
							| 
									
										
										
										
											2016-03-29 00:31:50 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-29 05:17:50 +03:00
										 |  |  | 						// construct the slideshow workspace if it does
 | 
					
						
							|  |  |  | 						// not exist...
 | 
					
						
							|  |  |  | 						//
 | 
					
						
							|  |  |  | 						// NOTE: this is partially redundant with the 
 | 
					
						
							|  |  |  | 						// 		loadWorkspace.pre handler in the feature...
 | 
					
						
							| 
									
										
										
										
											2016-03-29 00:31:50 +03:00
										 |  |  | 						if(this.workspaces['slideshow'] == null){ | 
					
						
							| 
									
										
										
										
											2016-03-30 15:24:01 +03:00
										 |  |  | 							this.loadWorkspace('ui-chrome-hidden')  | 
					
						
							| 
									
										
										
										
											2016-03-29 00:31:50 +03:00
										 |  |  | 							this.saveWorkspace('slideshow')  | 
					
						
							| 
									
										
										
										
											2016-03-29 05:17:50 +03:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2016-03-29 00:31:50 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 						// load the slideshow workspace...
 | 
					
						
							| 
									
										
										
										
											2016-03-29 05:17:50 +03:00
										 |  |  | 						this.loadWorkspace('slideshow') | 
					
						
							| 
									
										
										
										
											2016-03-28 21:46:05 +03:00
										 |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-15 03:55:36 +03:00
										 |  |  | 					// disable getting in/out of single image mode via clicks... 
 | 
					
						
							|  |  |  | 					if(this.config['single-image-toggle-on-click']){ | 
					
						
							|  |  |  | 						this.config['single-image-toggle-on-click'] = false | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-03-14 03:11:31 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-28 21:46:05 +03:00
										 |  |  | 					// start the timer... 
 | 
					
						
							| 
									
										
										
										
											2017-11-26 07:56:26 +03:00
										 |  |  | 					this.__slideshow_timer = setInterval(function(){ | 
					
						
							| 
									
										
										
										
											2016-03-28 21:46:05 +03:00
										 |  |  | 						var cur = that.current | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 						// next step...
 | 
					
						
							| 
									
										
										
										
											2016-03-29 05:22:36 +03:00
										 |  |  | 						that.config['slideshow-direction'] == 'forward' ? | 
					
						
							| 
									
										
										
										
											2016-03-28 21:46:05 +03:00
										 |  |  | 							that.nextImage() | 
					
						
							|  |  |  | 							: that.prevImage() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 						// we have reached the end...
 | 
					
						
							| 
									
										
										
										
											2016-03-29 03:09:31 +03:00
										 |  |  | 						if(that.current == cur){ | 
					
						
							|  |  |  | 							// loop...
 | 
					
						
							| 
									
										
										
										
											2016-03-29 05:22:36 +03:00
										 |  |  | 							if(that.config['slideshow-looping'] == 'on'){ | 
					
						
							|  |  |  | 								that.config['slideshow-direction'] == 'forward' ? | 
					
						
							| 
									
										
										
										
											2016-03-29 03:09:31 +03:00
										 |  |  | 									that.firstImage() | 
					
						
							|  |  |  | 									: that.lastImage() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							// stop...
 | 
					
						
							|  |  |  | 							} else { | 
					
						
							|  |  |  | 								that.toggleSlideshow('off') | 
					
						
							|  |  |  | 							} | 
					
						
							| 
									
										
										
										
											2016-03-28 21:46:05 +03:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2016-03-29 05:22:36 +03:00
										 |  |  | 					}, Date.str2ms(this.config['slideshow-interval'] || '3s')) | 
					
						
							| 
									
										
										
										
											2016-03-28 21:46:05 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				// stop...
 | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					// stop timer...
 | 
					
						
							| 
									
										
										
										
											2017-11-26 07:56:26 +03:00
										 |  |  | 					this.__slideshow_timer | 
					
						
							|  |  |  | 						&& clearInterval(this.__slideshow_timer) | 
					
						
							|  |  |  | 					delete this.__slideshow_timer | 
					
						
							| 
									
										
										
										
											2016-03-28 21:46:05 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-29 05:17:50 +03:00
										 |  |  | 					// restore the original workspace...
 | 
					
						
							| 
									
										
										
										
											2016-05-07 00:47:52 +03:00
										 |  |  | 					this.popWorkspace() | 
					
						
							| 
									
										
										
										
											2016-03-27 20:07:48 +03:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-03-28 21:46:05 +03:00
										 |  |  | 			})], | 
					
						
							| 
									
										
										
										
											2016-03-29 03:09:31 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-27 01:20:35 +03:00
										 |  |  | 	// XXX should this reflect slideshow state???? (ready, running, paused???)
 | 
					
						
							| 
									
										
										
										
											2017-09-06 07:20:31 +03:00
										 |  |  | 	slideshowDialog: ['Slideshow/Slideshow...', | 
					
						
							|  |  |  | 		widgets.makeUIDialog(function(){ | 
					
						
							|  |  |  | 			var that = this | 
					
						
							| 
									
										
										
										
											2019-11-14 06:36:14 +03:00
										 |  |  | 			var spec | 
					
						
							| 
									
										
										
										
											2019-11-14 03:29:30 +03:00
										 |  |  | 			return browse.makeLister(null,  | 
					
						
							|  |  |  | 				function(path, make){ | 
					
						
							|  |  |  | 					// fields...
 | 
					
						
							| 
									
										
										
										
											2019-11-15 17:14:55 +03:00
										 |  |  | 					that.showEditor(make,  | 
					
						
							| 
									
										
										
										
											2019-11-14 03:29:30 +03:00
										 |  |  | 						spec = spec  | 
					
						
							|  |  |  | 							|| [ | 
					
						
							|  |  |  | 								{ title: '$Interval: ',  | 
					
						
							|  |  |  | 									type: 'configToggle', | 
					
						
							|  |  |  | 									key: 'slideshow-interval', | 
					
						
							|  |  |  | 									values_key: 'slideshow-intervals', | 
					
						
							| 
									
										
										
										
											2019-11-14 06:36:14 +03:00
										 |  |  | 									nonstrict: true, | 
					
						
							| 
									
										
										
										
											2019-11-14 03:29:30 +03:00
										 |  |  | 									list: function(cur, set){ | 
					
						
							| 
									
										
										
										
											2019-11-14 06:36:14 +03:00
										 |  |  | 										this.slideshowIntervalDialog() | 
					
						
							|  |  |  | 											.close(function(){ set() }) }, }, | 
					
						
							| 
									
										
										
										
											2019-11-14 03:29:30 +03:00
										 |  |  | 								{ title: '$Direction: ', | 
					
						
							|  |  |  | 									type: 'toggler', | 
					
						
							| 
									
										
										
										
											2019-11-14 06:36:14 +03:00
										 |  |  | 									toggler: 'toggleSlideshowDirection',  | 
					
						
							|  |  |  | 									live_update: true, }, | 
					
						
							| 
									
										
										
										
											2019-11-14 03:29:30 +03:00
										 |  |  | 								{ title: '$Looping: ', | 
					
						
							|  |  |  | 									type: 'toggler', | 
					
						
							| 
									
										
										
										
											2019-11-14 06:36:14 +03:00
										 |  |  | 									toggler: 'toggleSlideshowLooping',  | 
					
						
							|  |  |  | 									live_update: true, }, ]) | 
					
						
							| 
									
										
										
										
											2019-11-14 03:29:30 +03:00
										 |  |  | 					// Start/stop...
 | 
					
						
							|  |  |  | 					make([function(){  | 
					
						
							|  |  |  | 							return that.toggleSlideshow('?') == 'on' ? '$Stop' : '$Start' }],  | 
					
						
							|  |  |  | 						{ open: function(){ | 
					
						
							|  |  |  | 								that.toggleSlideshow() | 
					
						
							|  |  |  | 								make.dialog.close() } }) | 
					
						
							|  |  |  | 				},{ | 
					
						
							|  |  |  | 					path: that.toggleSlideshow('?') == 'on' ? 'Stop' : 'Start', | 
					
						
							|  |  |  | 					cls: 'table-view tail-action', | 
					
						
							|  |  |  | 				}) })], | 
					
						
							| 
									
										
										
										
											2019-08-01 18:45:29 +03:00
										 |  |  | 	slideshowButtonAction: ['- Slideshow/', | 
					
						
							| 
									
										
										
										
											2019-08-01 19:21:33 +03:00
										 |  |  | 		core.doc`Slideshow button action
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		This differs from .toggleSlideshow() in that it also handles the paused | 
					
						
							|  |  |  | 		timer/slideshow state according to the following FSM: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			off <--> on <--- paused | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		i.e. if the slideshow is paused it will resume it otherwise stop/start. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		NOTE: this is not a toggler. | 
					
						
							| 
									
										
										
										
											2019-08-01 18:45:29 +03:00
										 |  |  | 		`,
 | 
					
						
							|  |  |  | 		function(){ | 
					
						
							|  |  |  | 			return this.toggleSlideshowTimer('?') == 'paused' ? | 
					
						
							|  |  |  | 				(this.toggleSlideshowTimer() && 'on') | 
					
						
							|  |  |  | 				: this.toggleSlideshow() }], | 
					
						
							| 
									
										
										
										
											2017-09-06 07:20:31 +03:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	// settings...
 | 
					
						
							| 
									
										
										
										
											2017-11-27 07:22:08 +03:00
										 |  |  | 	// NOTE: these are disabled as they are repeated in the slideshow dialog...
 | 
					
						
							|  |  |  | 	slideshowIntervalDialog: ['- Slideshow/Slideshow $interval...', | 
					
						
							| 
									
										
										
										
											2019-11-14 15:06:34 +03:00
										 |  |  | 		widgets.makeUIDialog(function(){ | 
					
						
							| 
									
										
										
										
											2017-09-06 07:20:31 +03:00
										 |  |  | 			var that = this | 
					
						
							| 
									
										
										
										
											2019-11-14 15:06:34 +03:00
										 |  |  | 			return widgets.makeConfigListEditor( | 
					
						
							| 
									
										
										
										
											2017-09-06 07:20:31 +03:00
										 |  |  | 				that,  | 
					
						
							|  |  |  | 				'slideshow-intervals', | 
					
						
							|  |  |  | 				'slideshow-interval',  | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					length_limit: that.config['slideshow-interval-max-count'], | 
					
						
							|  |  |  | 					check: Date.str2ms, | 
					
						
							|  |  |  | 					unique: Date.str2ms, | 
					
						
							| 
									
										
										
										
											2018-08-08 03:55:38 +03:00
										 |  |  | 					normalize: function(e){ return e.trim() }, | 
					
						
							| 
									
										
										
										
											2017-09-06 07:20:31 +03:00
										 |  |  | 					sort: function(a, b){ | 
					
						
							|  |  |  | 						return Date.str2ms(a) - Date.str2ms(b) }, | 
					
						
							| 
									
										
										
										
											2019-11-14 15:06:34 +03:00
										 |  |  | 				}) })], | 
					
						
							| 
									
										
										
										
											2017-11-27 07:22:08 +03:00
										 |  |  | 	toggleSlideshowDirection: ['- Slideshow/Slideshow $direction', | 
					
						
							| 
									
										
										
										
											2017-09-06 07:20:31 +03:00
										 |  |  | 		core.makeConfigToggler('slideshow-direction', ['forward', 'reverse'])], | 
					
						
							| 
									
										
										
										
											2017-11-27 07:22:08 +03:00
										 |  |  | 	toggleSlideshowLooping: ['- Slideshow/Slideshow $looping', | 
					
						
							| 
									
										
										
										
											2017-09-06 07:20:31 +03:00
										 |  |  | 		core.makeConfigToggler('slideshow-looping', ['on', 'off'])], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-01 19:21:33 +03:00
										 |  |  | 	toggleSlideshowPauseOnBlur: ['Interface|Slideshow/Slideshow pause on app blur', | 
					
						
							|  |  |  | 		core.makeConfigToggler('slideshow-pause-on-blur', ['on', 'off'])], | 
					
						
							| 
									
										
										
										
											2017-11-27 07:22:08 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 	resetSlideshowTimer: ['- Slideshow/Reset slideshow timer', | 
					
						
							| 
									
										
										
										
											2016-03-27 20:07:48 +03:00
										 |  |  | 		function(){ | 
					
						
							| 
									
										
										
										
											2019-11-14 15:06:34 +03:00
										 |  |  | 			this.__slideshow_timer  | 
					
						
							|  |  |  | 				&& this.toggleSlideshowTimer('?') != 'paused' | 
					
						
							|  |  |  | 				&& this.toggleSlideshow('on') }], | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 	suspendSlideshowTimer: ['- Slideshow/Suspend slideshow timer', | 
					
						
							| 
									
										
										
										
											2016-03-29 03:09:31 +03:00
										 |  |  | 		function(){ | 
					
						
							| 
									
										
										
										
											2017-11-26 07:56:26 +03:00
										 |  |  | 			if(this.__slideshow_timer){ | 
					
						
							|  |  |  | 				clearInterval(this.__slideshow_timer) | 
					
						
							| 
									
										
										
										
											2019-11-14 15:06:34 +03:00
										 |  |  | 				this.__slideshow_timer = 'suspended' } }], | 
					
						
							| 
									
										
										
										
											2019-11-14 06:36:14 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-01 18:45:29 +03:00
										 |  |  | 	toggleSlideshowTimer: ['Slideshow/Pause or resume running slideshow', | 
					
						
							| 
									
										
										
										
											2017-11-26 07:56:26 +03:00
										 |  |  | 		core.doc`
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		NOTE: this will have no effect if the slideshow is not running... | 
					
						
							|  |  |  | 		`,
 | 
					
						
							| 
									
										
										
										
											2020-05-20 20:31:19 +03:00
										 |  |  | 		{mode: function(){ return this.toggleSlideshow('?') == 'off' && 'disabled' }}, | 
					
						
							| 
									
										
										
										
											2017-11-26 07:56:26 +03:00
										 |  |  | 		toggler.Toggler(null,  | 
					
						
							|  |  |  | 			function(_, state){  | 
					
						
							|  |  |  | 				if(state == null){ | 
					
						
							| 
									
										
										
										
											2019-08-01 18:45:29 +03:00
										 |  |  | 					return this.__slideshow_timer == 'suspended' ?  | 
					
						
							|  |  |  | 							'paused'  | 
					
						
							|  |  |  | 						: !!this.__slideshow_timer ?  | 
					
						
							|  |  |  | 							'running' | 
					
						
							| 
									
										
										
										
											2017-11-26 07:56:26 +03:00
										 |  |  | 						: 'off' | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if(this.toggleSlideshow('?') != 'on'){ | 
					
						
							|  |  |  | 					return | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// handle state changing...
 | 
					
						
							|  |  |  | 				if(state == 'paused' || state == 'off'){ | 
					
						
							|  |  |  | 					this.suspendSlideshowTimer() | 
					
						
							|  |  |  | 					return 'paused' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2019-11-14 15:06:34 +03:00
										 |  |  | 					this.toggleSlideshow('on')  | 
					
						
							| 
									
										
										
										
											2017-11-26 07:56:26 +03:00
										 |  |  | 					return 'running' | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			},  | 
					
						
							|  |  |  | 			// XXX should we return different sets of states when 
 | 
					
						
							|  |  |  | 			// 		slideshow is running and when not?
 | 
					
						
							|  |  |  | 			// 		...the problem is what to return when slideshow is 
 | 
					
						
							|  |  |  | 			// 		not running???
 | 
					
						
							|  |  |  | 			['paused', 'running', 'off'])], | 
					
						
							| 
									
										
										
										
											2017-09-06 07:20:31 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	resetSlideshowWorkspace: ['Slideshow/Reset workspace', | 
					
						
							|  |  |  | 		function(){ delete this.workspaces['slideshow'] }], | 
					
						
							| 
									
										
										
										
											2016-03-12 06:24:35 +03:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var Slideshow =  | 
					
						
							|  |  |  | module.Slideshow = core.ImageGridFeatures.Feature({ | 
					
						
							|  |  |  | 	title: '', | 
					
						
							|  |  |  | 	doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tag: 'ui-slideshow', | 
					
						
							|  |  |  | 	depends: [ | 
					
						
							|  |  |  | 		'ui', | 
					
						
							| 
									
										
										
										
											2018-10-26 13:59:53 +03:00
										 |  |  | 		'ui-control', | 
					
						
							| 
									
										
										
										
											2019-11-14 15:06:34 +03:00
										 |  |  | 		'ui-editor', | 
					
						
							| 
									
										
										
										
											2016-04-26 04:08:02 +03:00
										 |  |  | 		'ui-single-image', | 
					
						
							| 
									
										
										
										
											2016-03-12 06:24:35 +03:00
										 |  |  | 	], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	actions: SlideshowActions, | 
					
						
							| 
									
										
										
										
											2016-03-29 00:31:50 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	handlers: [ | 
					
						
							| 
									
										
										
										
											2016-03-29 05:17:50 +03:00
										 |  |  | 		// add a placeholder for slideshow workspace, this is to make the
 | 
					
						
							|  |  |  | 		// workspace toggler show it as one of the options...
 | 
					
						
							|  |  |  | 		//
 | 
					
						
							|  |  |  | 		// NOTE: the slideshow workspace will get populated either on 
 | 
					
						
							|  |  |  | 		// 		loading it for the first time or on first running a 
 | 
					
						
							|  |  |  | 		// 		slideshow...
 | 
					
						
							|  |  |  | 		['start', | 
					
						
							|  |  |  | 			function(){  | 
					
						
							|  |  |  | 				if(this.workspaces['slideshow'] == null){ | 
					
						
							|  |  |  | 					this.workspaces['slideshow'] = null | 
					
						
							|  |  |  | 				}  | 
					
						
							|  |  |  | 			}], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-27 01:20:35 +03:00
										 |  |  | 		['load', | 
					
						
							|  |  |  | 			function(){ this.toggleSlideshow('off') }], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-15 03:55:36 +03:00
										 |  |  | 		// - build the slideshow workspace for the first time if it's not
 | 
					
						
							|  |  |  | 		// 		present yet (is null)...
 | 
					
						
							|  |  |  | 		// - restore .config['single-image-toggle-on-click']
 | 
					
						
							| 
									
										
										
										
											2016-03-29 05:17:50 +03:00
										 |  |  | 		['loadWorkspace.pre', | 
					
						
							|  |  |  | 			function(workspace){ | 
					
						
							| 
									
										
										
										
											2017-03-15 03:55:36 +03:00
										 |  |  | 				// going out of slideshow -> restore settings...
 | 
					
						
							|  |  |  | 				var data = this.workspaces[workspace] || {}  | 
					
						
							|  |  |  | 				if(this.workspace == 'slideshow'){ | 
					
						
							|  |  |  | 					if(!('single-image-toggle-on-click' in data)){ | 
					
						
							|  |  |  | 						delete this.config['single-image-toggle-on-click'] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						this.config['single-image-toggle-on-click'] =  | 
					
						
							|  |  |  | 							data['single-image-toggle-on-click'] | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// going into slideshow for first time -> setup...
 | 
					
						
							| 
									
										
										
										
											2016-03-29 05:17:50 +03:00
										 |  |  | 				if(workspace == 'slideshow' && this.workspaces['slideshow'] == null){ | 
					
						
							|  |  |  | 					return function(){ | 
					
						
							| 
									
										
										
										
											2016-03-30 15:24:01 +03:00
										 |  |  | 						this.loadWorkspace('ui-chrome-hidden')  | 
					
						
							| 
									
										
										
										
											2016-03-29 05:17:50 +03:00
										 |  |  | 						this.saveWorkspace('slideshow')  | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// do not leave the viewer in slideshow mode...
 | 
					
						
							| 
									
										
										
										
											2016-03-29 00:31:50 +03:00
										 |  |  | 		['stop', | 
					
						
							| 
									
										
										
										
											2017-11-27 07:22:08 +03:00
										 |  |  | 			function(){ this.toggleSlideshow('off') }], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-01 19:21:33 +03:00
										 |  |  | 		// slideshow pause on click or blur...
 | 
					
						
							| 
									
										
										
										
											2017-11-27 07:22:08 +03:00
										 |  |  | 		['toggleSlideshow', | 
					
						
							|  |  |  | 			function(){ | 
					
						
							|  |  |  | 				var that = this | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if(!this.dom){ | 
					
						
							|  |  |  | 					return | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-01 18:45:29 +03:00
										 |  |  | 				var running = this.toggleSlideshow('?') == 'on'  | 
					
						
							| 
									
										
										
										
											2018-10-26 13:59:53 +03:00
										 |  |  | 				var toggle_debounce = false | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-01 18:45:29 +03:00
										 |  |  | 				// toggle on click...
 | 
					
						
							| 
									
										
										
										
											2018-10-26 13:59:53 +03:00
										 |  |  | 				var toggle = this.__slideshow_toggle_handler | 
					
						
							|  |  |  | 					= this.__slideshow_toggle_handler | 
					
						
							| 
									
										
										
										
											2017-11-27 07:22:08 +03:00
										 |  |  | 						|| function(){ | 
					
						
							| 
									
										
										
										
											2018-10-26 13:59:53 +03:00
										 |  |  | 							if(!toggle_debounce){ | 
					
						
							|  |  |  | 								that.toggleSlideshowTimer()  | 
					
						
							|  |  |  | 								toggle_debounce = true | 
					
						
							|  |  |  | 								setTimeout(function(){  | 
					
						
							|  |  |  | 									toggle_debounce = false  | 
					
						
							| 
									
										
										
										
											2019-08-01 18:45:29 +03:00
										 |  |  | 								}, that.config['image-click-debounce-timeout'] || 100) } } | 
					
						
							|  |  |  | 				running ? | 
					
						
							|  |  |  | 					this.dom.on('click', toggle) | 
					
						
							|  |  |  | 					: this.dom.off('click', toggle) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// toggle on blur/focus...
 | 
					
						
							| 
									
										
										
										
											2019-08-01 19:21:33 +03:00
										 |  |  | 				if(this.config['slideshow-pause-on-blur'] !== false){ | 
					
						
							|  |  |  | 					var user_paused = false | 
					
						
							|  |  |  | 					var focus_debounce = false | 
					
						
							|  |  |  | 					var blur = this.__slideshow_blur_handler | 
					
						
							|  |  |  | 						= this.__slideshow_blur_handler | 
					
						
							|  |  |  | 							|| function(){ | 
					
						
							|  |  |  | 								if(!focus_debounce){ | 
					
						
							|  |  |  | 									user_paused = that.toggleSlideshowTimer('?') == 'paused'  | 
					
						
							|  |  |  | 									that.toggleSlideshowTimer('paused')  | 
					
						
							|  |  |  | 									focus_debounce = true } } | 
					
						
							|  |  |  | 					var focus = this.__slideshow_focus_handler | 
					
						
							|  |  |  | 						= this.__slideshow_focus_handler | 
					
						
							|  |  |  | 							|| function(){ | 
					
						
							|  |  |  | 								focus_debounce = false | 
					
						
							|  |  |  | 								user_paused  | 
					
						
							|  |  |  | 									|| that.toggleSlideshowTimer('running') } | 
					
						
							|  |  |  | 					running ? | 
					
						
							|  |  |  | 						this.dom | 
					
						
							|  |  |  | 							.on('blur', blur) | 
					
						
							|  |  |  | 							.on('focus', focus) | 
					
						
							|  |  |  | 						: this.dom | 
					
						
							|  |  |  | 							.off('blur', blur) | 
					
						
							|  |  |  | 							.off('focus', focus) | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-04-12 01:23:22 +03:00
										 |  |  | 			}], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// pause/resume slideshow on modal stuff...
 | 
					
						
							|  |  |  | 		['firstModalOpen', | 
					
						
							|  |  |  | 			function(){  | 
					
						
							|  |  |  | 				if(this.toggleSlideshow('?') == 'on'  | 
					
						
							|  |  |  | 						&& this.toggleSlideshowTimer('?') == 'running'){ | 
					
						
							|  |  |  | 					this.toggleSlideshowTimer('paused')  | 
					
						
							|  |  |  | 					this.one('lastModalClose', function(){ | 
					
						
							|  |  |  | 						this.toggleSlideshowTimer('running') }) | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}], | 
					
						
							| 
									
										
										
										
											2016-03-29 00:31:50 +03:00
										 |  |  | 	], | 
					
						
							| 
									
										
										
										
											2016-03-12 06:24:35 +03:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /********************************************************************** | 
					
						
							| 
									
										
										
										
											2016-08-20 22:49:36 +03:00
										 |  |  | * vim:set ts=4 sw=4 :                               */ return module }) |