mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	added app state/settings and some minor bugs squashed...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									8e06a5a3f2
								
							
						
					
					
						commit
						6df9184afe
					
				
							
								
								
									
										11
									
								
								ui/base.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								ui/base.js
									
									
									
									
									
								
							| @ -897,13 +897,14 @@ function flipHorizontal(image){ | |||||||
| 
 | 
 | ||||||
| function fitNImages(n){ | function fitNImages(n){ | ||||||
| 	var image = $('.current.image') | 	var image = $('.current.image') | ||||||
| 	var size = image.outerHeight(true) | 	var w = image.outerWidth(true) | ||||||
|  | 	var h = image.outerHeight(true) | ||||||
| 
 | 
 | ||||||
| 	var viewer = $('.viewer') | 	var viewer = $('.viewer') | ||||||
| 	var W = viewer.innerWidth() | 	var W = viewer.innerWidth() | ||||||
| 	var H = viewer.innerHeight() | 	var H = viewer.innerHeight() | ||||||
| 
 | 
 | ||||||
| 	var scale = Math.min(W / (size * n), H / size) | 	var scale = Math.min(W / (w * n), H / h) | ||||||
| 
 | 
 | ||||||
| 	// NOTE: if animating, the next two likes must be animated together...
 | 	// NOTE: if animating, the next two likes must be animated together...
 | ||||||
| 	setElementScale($('.ribbon-set'), scale) | 	setElementScale($('.ribbon-set'), scale) | ||||||
| @ -916,14 +917,16 @@ function fitNImages(n){ | |||||||
| // NOTE: here we measure image height as width may change depending on 
 | // NOTE: here we measure image height as width may change depending on 
 | ||||||
| // 		proportions...
 | // 		proportions...
 | ||||||
| function zoomIn(){ | function zoomIn(){ | ||||||
| 	var w = getScreenWidthInImages(getVisibleImageSize('height')) | 	//var w = getScreenWidthInImages(getVisibleImageSize('height'))
 | ||||||
|  | 	var w = getScreenWidthInImages() | ||||||
| 	if(w > 1){ | 	if(w > 1){ | ||||||
| 		w = w / ZOOM_SCALE | 		w = w / ZOOM_SCALE | ||||||
| 		fitNImages(w >= 1 ? w : 1) | 		fitNImages(w >= 1 ? w : 1) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| function zoomOut(){ | function zoomOut(){ | ||||||
| 	var w = getScreenWidthInImages(getVisibleImageSize('height')) | 	//var w = getScreenWidthInImages(getVisibleImageSize('height'))
 | ||||||
|  | 	var w = getScreenWidthInImages() | ||||||
| 	if(w <= MAX_SCREEN_IMAGES){ | 	if(w <= MAX_SCREEN_IMAGES){ | ||||||
| 		w = w * ZOOM_SCALE | 		w = w * ZOOM_SCALE | ||||||
| 		fitNImages(w <= MAX_SCREEN_IMAGES ? w : MAX_SCREEN_IMAGES) | 		fitNImages(w <= MAX_SCREEN_IMAGES ? w : MAX_SCREEN_IMAGES) | ||||||
|  | |||||||
| @ -62,6 +62,10 @@ var MARKED = [] | |||||||
| var IMAGE_CACHE = [] | var IMAGE_CACHE = [] | ||||||
| 
 | 
 | ||||||
| var SETTINGS = { | var SETTINGS = { | ||||||
|  | 	'theme': null, | ||||||
|  | 	'screen-images-ribbon-mode': null, | ||||||
|  | 	'screen-images-single-image-mode': null, | ||||||
|  | 	'single-image-mode-proportions': null, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -202,33 +202,34 @@ body { | |||||||
| .marks-visible.viewer:after { | .marks-visible.viewer:after { | ||||||
| 	display: block; | 	display: block; | ||||||
| 	position: absolute; | 	position: absolute; | ||||||
| 	content: "Marks visible"; | 	content: ""; | ||||||
| 	font-size: 11pt; | 	font-size: 0pt; | ||||||
| 	border: none; |  | ||||||
| 	color: blue; |  | ||||||
| 	width: auto; |  | ||||||
| 	height: auto; |  | ||||||
| 
 | 
 | ||||||
| 	top: 10px; | 	top: 10px; | ||||||
| 	right: 10px; | 	right: 10px; | ||||||
|  | 	width: 10px; | ||||||
|  | 	height: 10px; | ||||||
| 
 | 
 | ||||||
|  | 	border: solid 2px blue; | ||||||
|  | 	border-radius: 50%; | ||||||
|  | 	background: blue; | ||||||
| } | } | ||||||
| .marked-only-view.viewer:after { | .marked-only-view.viewer:after { | ||||||
| 	display: block; | 	display: block; | ||||||
| 	position: absolute; | 	position: absolute; | ||||||
| 	content: "Showing marked images only"; | 	content: ""; | ||||||
| 	font-size: 11pt; | 	font-size: 0pt; | ||||||
| 	border: none; |  | ||||||
| 	color: blue; |  | ||||||
| 	width: auto; |  | ||||||
| 	height: auto; |  | ||||||
| 
 |  | ||||||
| 	top: 10px; | 	top: 10px; | ||||||
| 	right: 10px; | 	right: 10px; | ||||||
|  | 	width: 10px; | ||||||
|  | 	height: 10px; | ||||||
| 
 | 
 | ||||||
|  | 	border: solid 2px blue; | ||||||
|  | 	border-radius: 50%; | ||||||
|  | 	background: transparent; | ||||||
| } | } | ||||||
| .marked-only-view.marks-visible.viewer:after { | .marked-only-view.marks-visible.viewer:after { | ||||||
| 	content: "Showing marked images only (marks visible)"; | 	background: blue; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* XXX should we use opacity??? */ | /* XXX should we use opacity??? */ | ||||||
|  | |||||||
| @ -172,7 +172,7 @@ var KEYBOARD_CONFIG = { | |||||||
| 			}, | 			}, | ||||||
| 
 | 
 | ||||||
| 		L: doc('Rotate image left', function(){ rotateLeft() }), | 		L: doc('Rotate image left', function(){ rotateLeft() }), | ||||||
| 		R: doc('Rotate image left', function(){ rotateRight() }), | 		R: doc('Rotate image right', function(){ rotateRight() }), | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 		// zooming...
 | 		// zooming...
 | ||||||
| @ -265,9 +265,12 @@ var KEYBOARD_CONFIG = { | |||||||
| 						var gid = getImageGID($('.current.image')) | 						var gid = getImageGID($('.current.image')) | ||||||
| 						var r = getRibbonIndex(getRibbon()) | 						var r = getRibbonIndex(getRibbon()) | ||||||
| 						var data = IMAGES[gid] | 						var data = IMAGES[gid] | ||||||
|  | 						var orientation = data.orientation | ||||||
|  | 						orientation = orientation == null ? 0 : orientation | ||||||
| 						var order = DATA.order.indexOf(gid) | 						var order = DATA.order.indexOf(gid) | ||||||
| 						var name = data.path.split('/').pop() | 						var name = data.path.split('/').pop() | ||||||
| 						alert('"'+ name +'"\n'+ | 						alert('"'+ name +'"\n'+ | ||||||
|  | 								'Orientation: '+ orientation +'deg\n'+ | ||||||
| 								'GID: '+ gid +'\n'+ | 								'GID: '+ gid +'\n'+ | ||||||
| 								'Path: "'+ data.path +'"\n'+ | 								'Path: "'+ data.path +'"\n'+ | ||||||
| 								'Order: '+ order +'\n'+ | 								'Order: '+ order +'\n'+ | ||||||
|  | |||||||
							
								
								
									
										34
									
								
								ui/modes.js
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								ui/modes.js
									
									
									
									
									
								
							| @ -13,13 +13,39 @@ | |||||||
| var toggleSingleImageMode = createCSSClassToggler('.viewer',  | var toggleSingleImageMode = createCSSClassToggler('.viewer',  | ||||||
| 		'single-image-mode', | 		'single-image-mode', | ||||||
| 		function(action){ | 		function(action){ | ||||||
|  | 			var w = getScreenWidthInImages() | ||||||
|  | 
 | ||||||
|  | 			// single image mode...
 | ||||||
| 			if(action == 'on'){ | 			if(action == 'on'){ | ||||||
| 				TRANSITION_MODE_DEFAULT = 'css' | 				TRANSITION_MODE_DEFAULT = 'css' | ||||||
| 				fitNImages(1) | 
 | ||||||
|  | 				// save things...
 | ||||||
|  | 				SETTINGS['screen-images-ribbon-mode'] = w | ||||||
|  | 
 | ||||||
|  | 				// load things...
 | ||||||
|  | 				w = SETTINGS['screen-images-single-image-mode'] | ||||||
|  | 				w = w == null ? 1 : w | ||||||
|  | 				var p = SETTINGS['single-image-mode-proportions'] | ||||||
|  | 				p = p == null ? 'square' : p | ||||||
|  | 
 | ||||||
|  | 				// set stuff...
 | ||||||
|  | 				toggleImageProportions(p) | ||||||
|  | 				fitNImages(w) | ||||||
|  | 
 | ||||||
|  | 			// ribbon mode...
 | ||||||
| 			} else { | 			} else { | ||||||
| 				TRANSITION_MODE_DEFAULT = 'animate' | 				TRANSITION_MODE_DEFAULT = 'animate' | ||||||
|  | 
 | ||||||
|  | 				// save things...
 | ||||||
|  | 				SETTINGS['screen-images-single-image-mode'] = w | ||||||
|  | 				SETTINGS['single-image-mode-proportions'] = toggleImageProportions('?') | ||||||
|  | 
 | ||||||
|  | 				// load things...
 | ||||||
|  | 				w = SETTINGS['screen-images-ribbon-mode'] | ||||||
|  | 				w = w == null ? DEFAULT_SCREEN_IMAGES : w | ||||||
|  | 
 | ||||||
| 				toggleImageProportions('square') | 				toggleImageProportions('square') | ||||||
| 				fitNImages(DEFAULT_SCREEN_IMAGES) | 				fitNImages(w) | ||||||
| 			} | 			} | ||||||
| 		}) | 		}) | ||||||
| 
 | 
 | ||||||
| @ -128,6 +154,7 @@ var toggleKeyboardHelp = createCSSClassToggler('.viewer', 'help-mode overlay', | |||||||
| 
 | 
 | ||||||
| 			// off...
 | 			// off...
 | ||||||
| 			} else { | 			} else { | ||||||
|  | 				// things to cleanup...
 | ||||||
| 				var _cleanup = function(){ | 				var _cleanup = function(){ | ||||||
| 					$('.keyboard-help').remove() | 					$('.keyboard-help').remove() | ||||||
| 					$('.viewer').removeClass('overlay') | 					$('.viewer').removeClass('overlay') | ||||||
| @ -135,11 +162,14 @@ var toggleKeyboardHelp = createCSSClassToggler('.viewer', 'help-mode overlay', | |||||||
| 					win.off('scroll', scroll_handler) | 					win.off('scroll', scroll_handler) | ||||||
| 				} | 				} | ||||||
| 
 | 
 | ||||||
|  | 				// animate things if we are not at the top...
 | ||||||
| 				if(body.scrollTop() > 0){ | 				if(body.scrollTop() > 0){ | ||||||
| 						body | 						body | ||||||
| 							.animate({ | 							.animate({ | ||||||
| 								scrollTop: 0, | 								scrollTop: 0, | ||||||
| 							}, _cleanup)  | 							}, _cleanup)  | ||||||
|  | 
 | ||||||
|  | 				// if we are at the top do things fast...
 | ||||||
| 				} else { | 				} else { | ||||||
| 					_cleanup() | 					_cleanup() | ||||||
| 				} | 				} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user