| 
									
										
										
										
											2014-07-21 16:38:06 +04:00
										 |  |  | /********************************************************************** | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | **********************************************************************/ | 
					
						
							| 
									
										
										
										
											2016-05-02 17:08:40 +03:00
										 |  |  | // Pre-setup...
 | 
					
						
							| 
									
										
										
										
											2014-07-21 16:38:06 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-02 15:12:18 +03:00
										 |  |  | // Add node_modules path outside of the packed nwjs code...
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This keeps the large node module set outside the zip thus speeding
 | 
					
						
							|  |  |  | // up the loading process significantly...
 | 
					
						
							| 
									
										
										
										
											2016-05-02 17:08:40 +03:00
										 |  |  | if((typeof(process) != 'undefined' ? process : {}).__nwjs){ | 
					
						
							| 
									
										
										
										
											2016-05-02 15:12:18 +03:00
										 |  |  | 	var path = require('path') | 
					
						
							|  |  |  | 	require('app-module-path') | 
					
						
							|  |  |  | 		.addPath(path.dirname(process.execPath) + '/node_modules/') | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-26 05:49:50 +03:00
										 |  |  | //*
 | 
					
						
							|  |  |  | // Setup modules loaded from npm...
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // XXX for some reason this breaks in browser if run after the if below...
 | 
					
						
							|  |  |  | // XXX not sure if this strategy is correct...
 | 
					
						
							|  |  |  | // 		...most likely this is not actually a good idea, need to think of
 | 
					
						
							|  |  |  | // 		a way of organizing things without so much manual hoop jumping...
 | 
					
						
							|  |  |  | var requirejs_cfg = { | 
					
						
							|  |  |  | 	paths: { | 
					
						
							|  |  |  | 		// XXX one approach to avoid at least this section is to copy the
 | 
					
						
							|  |  |  | 		// 		modules to lib/*, this way we'll need the map section below
 | 
					
						
							|  |  |  | 		// 		only...	(without automation this also sounds bad)
 | 
					
						
							|  |  |  | 		'lib/object': './node_modules/ig-object/object', | 
					
						
							| 
									
										
										
										
											2016-08-26 06:14:49 +03:00
										 |  |  | 		'lib/actions': './node_modules/ig-actions/actions', | 
					
						
							| 
									
										
										
										
											2016-08-26 05:49:50 +03:00
										 |  |  | 		'lib/features': './node_modules/ig-features/features', | 
					
						
							| 
									
										
										
										
											2016-08-31 15:02:09 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		//'lib/keyboard': './node_modules/ig-keyboard/keyboard',
 | 
					
						
							| 
									
										
										
										
											2016-08-26 05:49:50 +03:00
										 |  |  | 	},	 | 
					
						
							|  |  |  | 	map: { | 
					
						
							|  |  |  | 		'*': { | 
					
						
							|  |  |  | 			// back-refs
 | 
					
						
							|  |  |  | 			// ...these enable the npm modules reference each other in 
 | 
					
						
							|  |  |  | 			// a cross-platform manner....
 | 
					
						
							|  |  |  | 			'ig-object': 'lib/object', | 
					
						
							|  |  |  | 			'ig-actions': 'lib/actions', | 
					
						
							|  |  |  | 			'ig-features': 'lib/features', | 
					
						
							| 
									
										
										
										
											2016-08-31 15:02:09 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			//'ig-keyboard': 'lib/keyboard',
 | 
					
						
							| 
									
										
										
										
											2016-08-26 05:49:50 +03:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | // config the browser version of requirejs...
 | 
					
						
							|  |  |  | requirejs.config(requirejs_cfg) | 
					
						
							|  |  |  | //*/
 | 
					
						
							| 
									
										
										
										
											2016-05-02 15:12:18 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-02 17:08:40 +03:00
										 |  |  | // Setup requirejs if we are in node/nw...
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // NOTE: no need to do this in browser...
 | 
					
						
							| 
									
										
										
										
											2016-05-28 16:29:57 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | // XXX this will create a second requirejs instance with node 
 | 
					
						
							|  |  |  | // 		compatibility...
 | 
					
						
							|  |  |  | // 		...would be nice if we could avoid this...
 | 
					
						
							|  |  |  | // XXX setting nodeRequire on existing requirejs will change how 
 | 
					
						
							|  |  |  | // 		everything is loaded...
 | 
					
						
							| 
									
										
										
										
											2016-05-02 17:08:40 +03:00
										 |  |  | if(typeof(process) != 'undefined'){ | 
					
						
							| 
									
										
										
										
											2016-08-26 05:49:50 +03:00
										 |  |  | 	requirejs =  | 
					
						
							| 
									
										
										
										
											2016-05-28 16:29:57 +03:00
										 |  |  | 	global.requirejs =  | 
					
						
							|  |  |  | 	window.requirejs =  | 
					
						
							| 
									
										
										
										
											2016-08-26 05:49:50 +03:00
										 |  |  | 		// XXX for some reason we can't just use the browser requirejs 
 | 
					
						
							|  |  |  | 		// 		even if we pass it nodeRequire, it still can't pass the
 | 
					
						
							|  |  |  | 		// 		node stuff to node...
 | 
					
						
							| 
									
										
										
										
											2016-05-28 16:29:57 +03:00
										 |  |  | 		require('requirejs') | 
					
						
							| 
									
										
										
										
											2016-05-29 19:50:37 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-26 05:49:50 +03:00
										 |  |  | 	// config the node version of requirejs...
 | 
					
						
							|  |  |  | 	requirejs.config(requirejs_cfg) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	nodeRequire = | 
					
						
							| 
									
										
										
										
											2016-05-29 19:50:37 +03:00
										 |  |  | 	global.nodeRequire =  | 
					
						
							|  |  |  | 	window.nodeRequire = | 
					
						
							|  |  |  | 		require | 
					
						
							| 
									
										
										
										
											2014-12-28 03:47:44 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-26 05:49:50 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-02 17:08:40 +03:00
										 |  |  | /*********************************************************************/ | 
					
						
							| 
									
										
										
										
											2016-08-20 22:49:36 +03:00
										 |  |  | (typeof(define)[0]=='u'?function(f){module.exports=f(require)}:define)( | 
					
						
							|  |  |  | function(require){ var module={} // makes module AMD/node compatible...
 | 
					
						
							|  |  |  | /*********************************************************************/ | 
					
						
							| 
									
										
										
										
											2014-07-21 16:38:06 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-01 16:12:10 +03:00
										 |  |  | var viewer = require('imagegrid/viewer') | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-02 02:55:03 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-21 16:38:06 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $(function(){ | 
					
						
							| 
									
										
										
										
											2014-10-20 06:52:13 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-08 07:56:01 +03:00
										 |  |  | 	// list all loaded modules...
 | 
					
						
							| 
									
										
										
										
											2015-12-13 19:31:03 +03:00
										 |  |  | 	var m = requirejs.s.contexts._.defined | 
					
						
							|  |  |  | 	m = Object.keys(m).filter(function(e){ return m[e] != null }) | 
					
						
							|  |  |  | 	console.log('Modules (%d):', m.length, m) | 
					
						
							| 
									
										
										
										
											2015-12-08 07:56:01 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-21 23:53:55 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-03 03:01:51 +03:00
										 |  |  | 	// setup actions...
 | 
					
						
							| 
									
										
										
										
											2016-05-27 18:56:08 +03:00
										 |  |  | 	window.ig =  | 
					
						
							|  |  |  | 	window.ImageGrid =  | 
					
						
							|  |  |  | 		viewer.ImageGridFeatures | 
					
						
							|  |  |  | 			.setup([ | 
					
						
							|  |  |  | 				'viewer-testing', | 
					
						
							| 
									
										
										
										
											2015-12-11 10:55:27 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-27 18:56:08 +03:00
										 |  |  | 				'demo', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-27 18:56:08 +03:00
										 |  |  | 				// XXX this is not for production...
 | 
					
						
							|  |  |  | 				'experiments', | 
					
						
							| 
									
										
										
										
											2016-05-28 16:29:57 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-03 02:21:33 +03:00
										 |  |  | 				//'-commandline',
 | 
					
						
							| 
									
										
										
										
											2016-12-14 02:06:50 +03:00
										 |  |  | 				//'-ui-partial-ribbons',
 | 
					
						
							| 
									
										
										
										
											2016-07-03 02:21:33 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-28 16:29:57 +03:00
										 |  |  | 				// XXX BUG: disabling features on this level does not 
 | 
					
						
							|  |  |  | 				// 		work, yet works deeper down...
 | 
					
						
							|  |  |  | 				// 			Example:
 | 
					
						
							|  |  |  | 				// 				'-ui' // will throw an error:
 | 
					
						
							|  |  |  | 				// 					  //	Feature "-ui" not loaded...
 | 
					
						
							| 
									
										
										
										
											2016-05-27 18:56:08 +03:00
										 |  |  | 			]) | 
					
						
							| 
									
										
										
										
											2015-12-11 10:55:27 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 	// used to switch experimental actions on (set to true) or off (unset or false)...
 | 
					
						
							| 
									
										
										
										
											2016-05-27 18:56:08 +03:00
										 |  |  | 	//ig.experimental = true
 | 
					
						
							| 
									
										
										
										
											2015-12-31 22:23:32 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-13 19:31:03 +03:00
										 |  |  | 	// report stuff...
 | 
					
						
							|  |  |  | 	// XXX we also have .conflicts and .missing
 | 
					
						
							| 
									
										
										
										
											2016-05-27 18:56:08 +03:00
										 |  |  | 	ig.features.excluded.length > 0  | 
					
						
							| 
									
										
										
										
											2015-12-13 19:31:03 +03:00
										 |  |  | 		&& console.warn('Features excluded (%d):', | 
					
						
							| 
									
										
										
										
											2016-05-27 18:56:08 +03:00
										 |  |  | 			ig.features.excluded.length,  | 
					
						
							|  |  |  | 			ig.features.excluded) | 
					
						
							|  |  |  | 	ig.features.disabled.length > 0  | 
					
						
							| 
									
										
										
										
											2016-05-11 05:00:40 +03:00
										 |  |  | 		&& console.log('Features disabled (%d):', | 
					
						
							| 
									
										
										
										
											2016-05-27 18:56:08 +03:00
										 |  |  | 			ig.features.disabled.length,  | 
					
						
							|  |  |  | 			ig.features.disabled) | 
					
						
							| 
									
										
										
										
											2015-12-13 19:31:03 +03:00
										 |  |  | 	console.log('Features not applicable (%d):',  | 
					
						
							| 
									
										
										
										
											2016-05-27 18:56:08 +03:00
										 |  |  | 		ig.features.unapplicable.length,  | 
					
						
							|  |  |  | 		ig.features.unapplicable) | 
					
						
							| 
									
										
										
										
											2015-12-13 19:31:03 +03:00
										 |  |  | 	console.log('Features loaded (%d):', | 
					
						
							| 
									
										
										
										
											2016-05-27 18:56:08 +03:00
										 |  |  | 		ig.features.features.length,  | 
					
						
							|  |  |  | 		ig.features.features) | 
					
						
							| 
									
										
										
										
											2015-12-11 10:55:27 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-04 23:00:34 +03:00
										 |  |  | 	// XXX STUB...
 | 
					
						
							|  |  |  | 	ig.logger = ig.logger || { | 
					
						
							|  |  |  | 		root: true, | 
					
						
							|  |  |  | 		message: null, | 
					
						
							| 
									
										
										
										
											2016-11-15 18:29:33 +03:00
										 |  |  | 		log: null, | 
					
						
							| 
									
										
										
										
											2016-11-04 23:00:34 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		emit: function(e, v){  | 
					
						
							|  |  |  | 			var msg = this.message | 
					
						
							| 
									
										
										
										
											2016-11-15 18:29:33 +03:00
										 |  |  | 			var log = this.log = this.log || [] | 
					
						
							| 
									
										
										
										
											2016-11-04 23:00:34 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-15 18:29:33 +03:00
										 |  |  | 			// report progress...
 | 
					
						
							| 
									
										
										
										
											2016-11-04 23:00:34 +03:00
										 |  |  | 			// XXX HACK -- need meaningful status...
 | 
					
						
							|  |  |  | 			if(e == 'queued'  | 
					
						
							|  |  |  | 					|| e == 'found'){ | 
					
						
							|  |  |  | 				ig.showProgress(msg || ['Progress', e], '+0', '+1') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			} else if(e == 'loaded' || e == 'done' || e == 'written'  | 
					
						
							| 
									
										
										
										
											2016-12-14 03:44:33 +03:00
										 |  |  | 					|| e == 'index'){ | 
					
						
							|  |  |  | 				ig.showProgress(msg || ['Progress', e], '+1') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			} else if(e == 'skipping' || e == 'skipped'){ | 
					
						
							|  |  |  | 				// XXX if everything is skipped the indicator does not 
 | 
					
						
							|  |  |  | 				// 		get hidden...
 | 
					
						
							|  |  |  | 				//ig.showProgress(msg || ['Progress', e], '+0', '-1')
 | 
					
						
							| 
									
										
										
										
											2016-11-04 23:00:34 +03:00
										 |  |  | 				ig.showProgress(msg || ['Progress', e], '+1') | 
					
						
							| 
									
										
										
										
											2016-11-15 18:29:33 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// XXX STUB...
 | 
					
						
							|  |  |  | 			} else if(e == 'error' ){ | 
					
						
							|  |  |  | 				ig.showProgress(['Error'].concat(msg), '+0', '+1') | 
					
						
							|  |  |  | 				console.log('    '+ (msg || []).join(': ') + ':', e, v)  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				// console...
 | 
					
						
							|  |  |  | 				console.log('    '+ (msg || []).join(': ') + ':', e, v)  | 
					
						
							| 
									
										
										
										
											2016-11-04 23:00:34 +03:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-11-15 18:29:33 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// XXX
 | 
					
						
							|  |  |  | 			//log.push([msg, e, v])
 | 
					
						
							| 
									
										
										
										
											2016-11-04 23:00:34 +03:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		push: function(msg){ | 
					
						
							|  |  |  | 			if(msg == null){ | 
					
						
							|  |  |  | 				return this | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var logger = Object.create(this) | 
					
						
							|  |  |  | 			logger.root = false | 
					
						
							|  |  |  | 			logger.message = logger.message == null ? [msg] : logger.message.concat([msg]) | 
					
						
							| 
									
										
										
										
											2016-11-15 18:29:33 +03:00
										 |  |  | 			logger.log = this.log = this.log || [] | 
					
						
							| 
									
										
										
										
											2016-11-04 23:00:34 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			return logger | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		pop: function(){ | 
					
						
							|  |  |  | 			return !this.__proto__.root ? this.__proto__ : this	 | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-10-20 06:52:13 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-02 21:06:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-03 03:01:51 +03:00
										 |  |  | 	// setup the viewer...
 | 
					
						
							| 
									
										
										
										
											2016-05-27 18:56:08 +03:00
										 |  |  | 	ig | 
					
						
							| 
									
										
										
										
											2015-12-14 02:49:04 +03:00
										 |  |  | 		.load({ viewer: $('.viewer') }) | 
					
						
							| 
									
										
										
										
											2015-12-11 10:55:27 +03:00
										 |  |  | 		.start() | 
					
						
							| 
									
										
										
										
											2015-12-10 00:24:43 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-11 10:55:27 +03:00
										 |  |  | 	// load some testing data if nothing else loaded...
 | 
					
						
							| 
									
										
										
										
											2016-05-27 18:56:08 +03:00
										 |  |  | 	if(!ig.url_history || Object.keys(ig.url_history).length == 0){ | 
					
						
							| 
									
										
										
										
											2015-12-10 00:24:43 +03:00
										 |  |  | 		// NOTE: we can (and do) load this in parts...
 | 
					
						
							| 
									
										
										
										
											2016-05-27 18:56:08 +03:00
										 |  |  | 		ig.loadDemoIndex() | 
					
						
							| 
									
										
										
										
											2016-04-02 16:28:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-10 00:24:43 +03:00
										 |  |  | 			// this is needed when loading legacy sources that do not have tags
 | 
					
						
							|  |  |  | 			// synced...
 | 
					
						
							|  |  |  | 			// do not do for actual data...
 | 
					
						
							|  |  |  | 			//.syncTags()
 | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-07-21 16:38:06 +04:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /********************************************************************** | 
					
						
							|  |  |  | * vim:set ts=4 sw=4 :                                                */ | 
					
						
							|  |  |  | return module }) | 
					
						
							| 
									
										
										
										
											2016-05-28 16:29:57 +03:00
										 |  |  | //})
 |