mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-11-03 21:00:14 +00:00 
			
		
		
		
	added recently opened list diaolg (ctrl-H) and now choice widget supports default value...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									c0767e20aa
								
							
						
					
					
						commit
						8da1eb0fab
					
				@ -1126,7 +1126,7 @@ function updateImage(image, gid, size){
 | 
				
			|||||||
		img_data = STUB_IMAGE_DATA
 | 
							img_data = STUB_IMAGE_DATA
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/* XXX does not seem to be needing this...
 | 
				
			||||||
	// set the current class...
 | 
						// set the current class...
 | 
				
			||||||
	if(gid == DATA.current){
 | 
						if(gid == DATA.current){
 | 
				
			||||||
		image.addClass('current')
 | 
							image.addClass('current')
 | 
				
			||||||
 | 
				
			|||||||
@ -53,7 +53,7 @@ var KEYBOARD_CONFIG = {
 | 
				
			|||||||
					return false
 | 
										return false
 | 
				
			||||||
				}),
 | 
									}),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		F5: doc('Reload viewer', 
 | 
							F5: doc('Full reload viewer', 
 | 
				
			||||||
			function(){ 
 | 
								function(){ 
 | 
				
			||||||
				reload() 
 | 
									reload() 
 | 
				
			||||||
				return false
 | 
									return false
 | 
				
			||||||
@ -228,8 +228,9 @@ var KEYBOARD_CONFIG = {
 | 
				
			|||||||
	//
 | 
						//
 | 
				
			||||||
	'.single-ribbon-mode:not(.single-image-mode), .marked-only-view:not(.single-image-mode)': {
 | 
						'.single-ribbon-mode:not(.single-image-mode), .marked-only-view:not(.single-image-mode)': {
 | 
				
			||||||
		title: 'Cropped ribbon views',
 | 
							title: 'Cropped ribbon views',
 | 
				
			||||||
		doc: 'To crop marked images press <b>shift-F2</b> and for '+
 | 
							doc: 'To crop marked images press <b>shift-F2</b> for '+
 | 
				
			||||||
			'single ribbon crop view press <b>F3</b>.'+
 | 
								'single ribbon crop view press <b>F3</b> and to open the crop '+
 | 
				
			||||||
 | 
								'dialog for more options press <b>C</b>.'+
 | 
				
			||||||
			'<p>NOTE: toggling crop views is only possible from ribbon view.',
 | 
								'<p>NOTE: toggling crop views is only possible from ribbon view.',
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Esc: {
 | 
							Esc: {
 | 
				
			||||||
@ -332,7 +333,7 @@ var KEYBOARD_CONFIG = {
 | 
				
			|||||||
		'#9': doc('Fit nine images', function(){ fitNImages(9) }),
 | 
							'#9': doc('Fit nine images', function(){ fitNImages(9) }),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// cropping...
 | 
							// cropping...
 | 
				
			||||||
		C: doc('Show data crop dialog', cropImagesDialog),
 | 
							C: doc('Show ribbon crop dialog', cropImagesDialog),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// XXX add a non FXX key for macs...
 | 
							// XXX add a non FXX key for macs...
 | 
				
			||||||
		F2: {
 | 
							F2: {
 | 
				
			||||||
@ -513,16 +514,22 @@ var KEYBOARD_CONFIG = {
 | 
				
			|||||||
						reverseImageOrder() 
 | 
											reverseImageOrder() 
 | 
				
			||||||
					}),
 | 
										}),
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		H: doc('Flip image horizontally', 
 | 
							H: {
 | 
				
			||||||
			function(){ 
 | 
								   default: doc('Flip image horizontally', 
 | 
				
			||||||
				var o = getImage().attr('orientation')
 | 
										function(){ 
 | 
				
			||||||
				// need to rotate relative to user, not relative to image...
 | 
											var o = getImage().attr('orientation')
 | 
				
			||||||
				if(o == 90 || o == 270){
 | 
											// need to rotate relative to user, not relative to image...
 | 
				
			||||||
				   flipVertical() 
 | 
											if(o == 90 || o == 270){
 | 
				
			||||||
				} else {
 | 
											   flipVertical() 
 | 
				
			||||||
					flipHorizontal() 
 | 
											} else {
 | 
				
			||||||
				}
 | 
												flipHorizontal() 
 | 
				
			||||||
			}),
 | 
											}
 | 
				
			||||||
 | 
										}),
 | 
				
			||||||
 | 
									ctrl: doc('Show recently opend urls',
 | 
				
			||||||
 | 
										function(){
 | 
				
			||||||
 | 
											recentlyOpenedDialog()
 | 
				
			||||||
 | 
										}),
 | 
				
			||||||
 | 
							   },
 | 
				
			||||||
		V: doc('Flip image vertically', 
 | 
							V: doc('Flip image vertically', 
 | 
				
			||||||
			function(){ 
 | 
								function(){ 
 | 
				
			||||||
				var o = getImage().attr('orientation')
 | 
									var o = getImage().attr('orientation')
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										50
									
								
								ui/ui.js
									
									
									
									
									
								
							
							
						
						
									
										50
									
								
								ui/ui.js
									
									
									
									
									
								
							@ -554,6 +554,9 @@ var FIELD_TYPES = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// format: 
 | 
						// format: 
 | 
				
			||||||
	// 		['a', 'b', 'c', ...]
 | 
						// 		['a', 'b', 'c', ...]
 | 
				
			||||||
 | 
						//
 | 
				
			||||||
 | 
						// an item can be of the folowing format:
 | 
				
			||||||
 | 
						// 		<text> ['|' 'default' ]
 | 
				
			||||||
	choice: {
 | 
						choice: {
 | 
				
			||||||
		type: 'choice',
 | 
							type: 'choice',
 | 
				
			||||||
		text: null,
 | 
							text: null,
 | 
				
			||||||
@ -569,22 +572,43 @@ var FIELD_TYPES = {
 | 
				
			|||||||
			return typeof(val) == typeof([]) && val.constructor.name == 'Array'
 | 
								return typeof(val) == typeof([]) && val.constructor.name == 'Array'
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		set: function(field, value){
 | 
							set: function(field, value){
 | 
				
			||||||
			var t = field.find('.text').text()
 | 
								var t = field.find('.text').html()
 | 
				
			||||||
			t = t == '' ? Math.random()+'' : t
 | 
								t = t == '' ? Math.random()+'' : t
 | 
				
			||||||
			var item = field.find('.item').last()
 | 
								var item = field.find('.item').last()
 | 
				
			||||||
			for(var i=0; i < value.length; i++){
 | 
								for(var i=0; i < value.length; i++){
 | 
				
			||||||
				item.find('.value')
 | 
									var txt = value[i]
 | 
				
			||||||
					.val(value[i])
 | 
					
 | 
				
			||||||
 | 
									// get options...
 | 
				
			||||||
 | 
									var opts = txt.split(/\|/g)
 | 
				
			||||||
 | 
									txt = opts[0].trim()
 | 
				
			||||||
 | 
									opts = opts
 | 
				
			||||||
 | 
										.slice(1)
 | 
				
			||||||
 | 
										.map(function(e){ return e.trim() })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									var val = item.find('.value')
 | 
				
			||||||
 | 
									val.val(txt)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									// set checked state...
 | 
				
			||||||
 | 
									if(opts.indexOf('default') >= 0){
 | 
				
			||||||
 | 
										val.prop('checked', true)
 | 
				
			||||||
 | 
										opts.splice(opts.indexOf('default'), 1)
 | 
				
			||||||
 | 
									} else {
 | 
				
			||||||
 | 
										val.prop('checked', false)
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				item.find('.item-text')
 | 
									item.find('.item-text')
 | 
				
			||||||
					.text(value[i])
 | 
										.html(txt)
 | 
				
			||||||
				item.appendTo(field)
 | 
									item.appendTo(field)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				item = item.clone()
 | 
									item = item.clone()
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			field.find('.value')
 | 
								var values = field.find('.value')
 | 
				
			||||||
				.attr('name', t)
 | 
									.attr('name', t)
 | 
				
			||||||
				.first()
 | 
								// set the default...
 | 
				
			||||||
					.attr('checked', '')
 | 
								if(values.filter(':checked').length == 0){
 | 
				
			||||||
 | 
									values.first()
 | 
				
			||||||
 | 
										.prop('checked', true)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		get: function(field){ 
 | 
							get: function(field){ 
 | 
				
			||||||
			return $(field).find('.value:checked').val()
 | 
								return $(field).find('.value:checked').val()
 | 
				
			||||||
@ -739,7 +763,7 @@ function formDialog(root, message, config, btn, cls){
 | 
				
			|||||||
					text = t.replace(/\\\|/g, '|')
 | 
										text = t.replace(/\\\|/g, '|')
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				// setup text and data...
 | 
									// setup text and data...
 | 
				
			||||||
				html.find('.text').text(text)
 | 
									html.find('.text').html(text)
 | 
				
			||||||
				field.set(html, config[t])
 | 
									field.set(html, config[t])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				// NOTE: this is here to isolate t and field.get values...
 | 
									// NOTE: this is here to isolate t and field.get values...
 | 
				
			||||||
@ -797,9 +821,13 @@ function formDialog(root, message, config, btn, cls){
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	setTimeout(function(){ 
 | 
						setTimeout(function(){ 
 | 
				
			||||||
		form.find('.field input').first()
 | 
							var e = form.find('.field input:checked')
 | 
				
			||||||
			.focus()
 | 
							if(e.length > 0){
 | 
				
			||||||
			.select()
 | 
								e.focus()
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								form.find('.field input').first()
 | 
				
			||||||
 | 
									.focus()
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}, 100)
 | 
						}, 100)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return res
 | 
						return res
 | 
				
			||||||
 | 
				
			|||||||
@ -115,6 +115,62 @@ var loadURLHistoryNext = makeURLHistoryLoader(getURLHistoryNext, 'at last URL')
 | 
				
			|||||||
var loadURLHistoryPrev = makeURLHistoryLoader(getURLHistoryPrev, 'at first URL')
 | 
					var loadURLHistoryPrev = makeURLHistoryLoader(getURLHistoryPrev, 'at first URL')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// NOTE: this can accept either path or history index...
 | 
				
			||||||
 | 
					// NOTE: this will not reload an already loaded url...
 | 
				
			||||||
 | 
					function loadURLHistoryAt(a){
 | 
				
			||||||
 | 
						a = a < 0 ? BASE_URL_HISTORY + a : a
 | 
				
			||||||
 | 
						var url = typeof(a) == typeof(123) ? Math.min(a < 0 ? 0 : a, BASE_URL_HISTORY.length-1) : a
 | 
				
			||||||
 | 
						if(url != BASE_URL){
 | 
				
			||||||
 | 
							statusNotify(loadDir(url))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return url
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**********************************************************************
 | 
				
			||||||
 | 
					* Dialogs...
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function recentlyOpenedDialog(){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						updateStatus('Recently opened...').show()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var dict = {}
 | 
				
			||||||
 | 
						var title = '<b>Recently opened:</b>'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var cfg = {}
 | 
				
			||||||
 | 
						cfg[title] = BASE_URL_HISTORY.map(function(e){
 | 
				
			||||||
 | 
							if(e == BASE_URL){
 | 
				
			||||||
 | 
								var ee = e.italics()
 | 
				
			||||||
 | 
								dict[ee] = e
 | 
				
			||||||
 | 
								return ee + ' | default'
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							dict[e] = e
 | 
				
			||||||
 | 
							return e
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						formDialog(null, '', 
 | 
				
			||||||
 | 
								cfg,
 | 
				
			||||||
 | 
								'OK', 
 | 
				
			||||||
 | 
								'recentlyOpenedDialog')
 | 
				
			||||||
 | 
							.done(function(res){
 | 
				
			||||||
 | 
								res = dict[res[title]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								loadURLHistoryAt(res)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if(res == BASE_URL){
 | 
				
			||||||
 | 
									showStatusQ('Already at: '+res+'...')
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									showStatusQ('Opening: '+res+'...')
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
							.fail(function(){
 | 
				
			||||||
 | 
								showStatusQ('Keeping current...')
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					/**********************************************************************
 | 
				
			||||||
* vim:set ts=4 sw=4 :                                                */
 | 
					* vim:set ts=4 sw=4 :                                                */
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user