mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	more work on metadata view, still dealing with problems...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									8c7e8e08f3
								
							
						
					
					
						commit
						6ed2d1ebd5
					
				| @ -292,6 +292,8 @@ module.MetadataReader = core.ImageGridFeatures.Feature({ | |||||||
| // 			- ...
 | // 			- ...
 | ||||||
| var MetadataUIActions = actions.Actions({ | var MetadataUIActions = actions.Actions({ | ||||||
| 	config: { | 	config: { | ||||||
|  | 		'metadata-preview-size': 150, | ||||||
|  | 
 | ||||||
| 		'metadata-auto-select-modes': [ | 		'metadata-auto-select-modes': [ | ||||||
| 			'none', | 			'none', | ||||||
| 			'on select', | 			'on select', | ||||||
| @ -341,13 +343,20 @@ var MetadataUIActions = actions.Actions({ | |||||||
| 	//
 | 	//
 | ||||||
| 	// XXX should we replace 'mode' with nested set of metadata???
 | 	// XXX should we replace 'mode' with nested set of metadata???
 | ||||||
| 	// XXX make this support multiple images...
 | 	// XXX make this support multiple images...
 | ||||||
| 	showMetadata: ['Image/Metadata2...', | 	// XXX make things editable only in when edit is loaded...
 | ||||||
|  | 	showMetadata: ['Image/Metadata...', | ||||||
| 		widgets.makeUIDialog(function(image, mode){ | 		widgets.makeUIDialog(function(image, mode){ | ||||||
| 			var that = this | 			var that = this | ||||||
| 			image = this.data.getImage(image) | 			image = this.data.getImage(image) | ||||||
| 			mode = mode || 'disabled' | 			mode = mode || 'disabled' | ||||||
| 			data = this.images[image] | 			data = this.images[image] | ||||||
| 
 | 
 | ||||||
|  | 			var preview_size = this.config['metadata-preview-size'] || 150 | ||||||
|  | 
 | ||||||
|  | 			var _normalize = typeof(path) != 'undefined' ?  | ||||||
|  | 				path.normalize | ||||||
|  | 				: function(e){ return e.replace(/\/\.\//, '') } | ||||||
|  | 
 | ||||||
| 			return browse.makeLister(null,  | 			return browse.makeLister(null,  | ||||||
| 				function(p, make){ | 				function(p, make){ | ||||||
| 					// helper...
 | 					// helper...
 | ||||||
| @ -355,8 +364,21 @@ var MetadataUIActions = actions.Actions({ | |||||||
| 					// 		this is done to keep the ref to make(..) up-to-date...
 | 					// 		this is done to keep the ref to make(..) up-to-date...
 | ||||||
| 					make.dialog.wait = function(){ | 					make.dialog.wait = function(){ | ||||||
| 						make.Separator() | 						make.Separator() | ||||||
| 						make.Spinner()  | 						make.Spinner() } | ||||||
| 					} | 					// XXX BUG: this when attached is stealing marks from 
 | ||||||
|  | 					// 		the original image in ribbon and sows them in 
 | ||||||
|  | 					// 		the dialog...
 | ||||||
|  | 					// 		...need to avoid both!
 | ||||||
|  | 					make.dialog.updatePreview = function(){ | ||||||
|  | 						var preview = this.preview = this.preview || that.ribbons.createImage(image) | ||||||
|  | 						return that.ribbons.updateImage(preview, image, preview_size, false, | ||||||
|  | 							function([p]){ | ||||||
|  | 								p.classList.add('clone', 'preview') | ||||||
|  | 								p.style.height = preview_size +'px' | ||||||
|  | 								p.style.width = preview_size +'px' | ||||||
|  | 							}) } | ||||||
|  | 
 | ||||||
|  | 					make(['Preview:', this.updatePreview()]) | ||||||
| 
 | 
 | ||||||
| 					// essentials...
 | 					// essentials...
 | ||||||
| 					make(['$GID: ', image]) | 					make(['$GID: ', image]) | ||||||
| @ -384,9 +406,6 @@ var MetadataUIActions = actions.Actions({ | |||||||
| 
 | 
 | ||||||
| 					if(data){ | 					if(data){ | ||||||
| 						// some abstractions...
 | 						// some abstractions...
 | ||||||
| 						var _normalize = typeof(path) != 'undefined' ?  |  | ||||||
| 							path.normalize |  | ||||||
| 							: function(e){ return e.replace(/\/\.\//, '') } |  | ||||||
| 						var _basename = typeof(path) != 'undefined' ? | 						var _basename = typeof(path) != 'undefined' ? | ||||||
| 							path.basename | 							path.basename | ||||||
| 							: function(e){ return e.split(/[\\\/]/g).pop() } | 							: function(e){ return e.split(/[\\\/]/g).pop() } | ||||||
| @ -445,6 +464,8 @@ var MetadataUIActions = actions.Actions({ | |||||||
| 					cls: 'table-view', | 					cls: 'table-view', | ||||||
| 					showDisabled: false, | 					showDisabled: false, | ||||||
| 				}) | 				}) | ||||||
|  | 				.on('attached', function(){ | ||||||
|  | 					this.updatePreview() }) | ||||||
| 				// select value of current item...
 | 				// select value of current item...
 | ||||||
| 				.on('select', function(evt, elem){ | 				.on('select', function(evt, elem){ | ||||||
| 					that.config['metadata-auto-select-mode'] == 'on select' | 					that.config['metadata-auto-select-mode'] == 'on select' | ||||||
| @ -452,6 +473,8 @@ var MetadataUIActions = actions.Actions({ | |||||||
| 				.close(function(){ | 				.close(function(){ | ||||||
| 					// XXX handle comment and tag changes...
 | 					// XXX handle comment and tag changes...
 | ||||||
| 					// XXX
 | 					// XXX
 | ||||||
|  | 
 | ||||||
|  | 					that.refresh(image) | ||||||
| 				}) | 				}) | ||||||
| 		})], | 		})], | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -94,7 +94,7 @@ var Ribbons = { | |||||||
| 	//placeRibbon: null,
 | 	//placeRibbon: null,
 | ||||||
| 	//placeImage: null,
 | 	//placeImage: null,
 | ||||||
| 
 | 
 | ||||||
| 	updateImageIndicators: null, | 	callImageUpdaters: null, | ||||||
| 	_loadImagePreviewURL: null, | 	_loadImagePreviewURL: null, | ||||||
| 	//load_img_sync: null,
 | 	//load_img_sync: null,
 | ||||||
| 	updateImage: null, | 	updateImage: null, | ||||||
|  | |||||||
| @ -348,7 +348,8 @@ module.uiContainer = function(func){ | |||||||
| // 	- mark the action as a container
 | // 	- mark the action as a container
 | ||||||
| //
 | //
 | ||||||
| // The container will:
 | // The container will:
 | ||||||
| // 	- trigger the client's close event on close
 | // 	- trigger client's 'attached' event when attached to container
 | ||||||
|  | // 	- trigger client's 'close' event on close
 | ||||||
| //
 | //
 | ||||||
| // XXX not sure how the click is handled here...
 | // XXX not sure how the click is handled here...
 | ||||||
| // XXX pass options???
 | // XXX pass options???
 | ||||||
| @ -398,6 +399,7 @@ module.makeUIContainer = function(make){ | |||||||
| 				// XXX is this the right way to go???
 | 				// XXX is this the right way to go???
 | ||||||
| 				.on('click', function(evt){  | 				.on('click', function(evt){  | ||||||
| 					that.modal && that.modal.focus() }) | 					that.modal && that.modal.focus() }) | ||||||
|  | 				.trigger('attached', o) | ||||||
| 
 | 
 | ||||||
| 		return o | 		return o | ||||||
| 			// focus the new dialog...
 | 			// focus the new dialog...
 | ||||||
|  | |||||||
| @ -168,6 +168,7 @@ var VirtualImagesUIActions = actions.Actions({ | |||||||
| 					text.scrollHeight, | 					text.scrollHeight, | ||||||
| 					text.scrollWidth) | 					text.scrollWidth) | ||||||
| 			var s = R/r | 			var s = R/r | ||||||
|  | 
 | ||||||
| 			text.style.fontSize = `${ 100*s }%` | 			text.style.fontSize = `${ 100*s }%` | ||||||
| 			// prioritize width... 
 | 			// prioritize width... 
 | ||||||
| 			text.style.width = '100%' | 			text.style.width = '100%' | ||||||
| @ -191,6 +192,7 @@ var VirtualImagesUIActions = actions.Actions({ | |||||||
| 				: dom }], | 				: dom }], | ||||||
| 
 | 
 | ||||||
| 	// XXX add text format selection...
 | 	// XXX add text format selection...
 | ||||||
|  | 	// XXX make things editable only when edit is loaded...
 | ||||||
| 	metadataSection: [ | 	metadataSection: [ | ||||||
| 		{ sortedActionPriority: 80 }, | 		{ sortedActionPriority: 80 }, | ||||||
| 		function(make, gid, image){ | 		function(make, gid, image){ | ||||||
| @ -206,6 +208,7 @@ var VirtualImagesUIActions = actions.Actions({ | |||||||
| 				reset_on_commit: false, | 				reset_on_commit: false, | ||||||
| 				editdone: function(evt, value){ | 				editdone: function(evt, value){ | ||||||
| 					image.text = value  | 					image.text = value  | ||||||
|  | 					make.dialog.updatePreview() | ||||||
| 					that.refresh(gid) | 					that.refresh(gid) | ||||||
| 				}, | 				}, | ||||||
| 			}) | 			}) | ||||||
|  | |||||||
| @ -591,12 +591,12 @@ var BaseRibbonsPrototype = { | |||||||
| 		// get the base image...
 | 		// get the base image...
 | ||||||
| 		// current...
 | 		// current...
 | ||||||
| 		if(target == null || target == 'current') { | 		if(target == null || target == 'current') { | ||||||
| 			img = this.viewer.find('.current.image') | 			img = this.viewer.find('.current'+IMAGE) | ||||||
| 
 | 
 | ||||||
| 		// gid...
 | 		// gid...
 | ||||||
| 		} else if(typeof(target) == typeof('str')){ | 		} else if(typeof(target) == typeof('str')){ | ||||||
| 			//return this.viewer.find('.image[gid="'+JSON.stringify(target)+'"]')
 | 			//return this.viewer.find('.image[gid="'+JSON.stringify(target)+'"]')
 | ||||||
| 			img = this.viewer.find('.image[gid='+JSON.stringify(target)+']') | 			img = this.viewer.find(IMAGE+'[gid='+JSON.stringify(target)+']') | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		// we got a collection...
 | 		// we got a collection...
 | ||||||
| @ -1447,18 +1447,16 @@ var RibbonsPrototype = { | |||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
| 	// XXX is .__image_updaters the right way to go???
 | 	// XXX is .__image_updaters the right way to go???
 | ||||||
| 	updateImageIndicators: function(gid, image){ | 	callImageUpdaters: function(gid, image){ | ||||||
| 		gid = gid == null ? this.elemGID() : gid | 		gid = gid == null ? this.elemGID() : gid | ||||||
| 		image = image == null ? this.getImage() : $(image) | 		image = image == null ? this.getImage() : $(image) | ||||||
| 
 | 
 | ||||||
| 		// collect marks...
 | 		// collect marks...
 | ||||||
| 		image.after(this.getImageMarks(gid)) | 		image.after(this.getImageMarks(gid)) | ||||||
| 
 | 
 | ||||||
| 		if(this.__image_updaters != null){ | 		;(this.__image_updaters || []) | ||||||
| 			this.__image_updaters.forEach(function(update){ | 			.forEach(function(update){ | ||||||
| 				update(gid, image) | 				update(gid, image) }) | ||||||
| 			}) |  | ||||||
| 		} |  | ||||||
| 
 | 
 | ||||||
| 		return image | 		return image | ||||||
| 	}, | 	}, | ||||||
| @ -1496,6 +1494,8 @@ var RibbonsPrototype = { | |||||||
| 	//
 | 	//
 | ||||||
| 	// NOTE: this can update collections of images by passing either a 
 | 	// NOTE: this can update collections of images by passing either a 
 | ||||||
| 	// 		list of gids, images or a jQuery collection...
 | 	// 		list of gids, images or a jQuery collection...
 | ||||||
|  | 	// NOTE: pre_updaters_callback if given is called after image is fully
 | ||||||
|  | 	// 		constructed but before .callImageUpdaters(..) is called...
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// If this is set to true image previews will be loaded synchronously...
 | 	// If this is set to true image previews will be loaded synchronously...
 | ||||||
| 	load_img_sync: false, | 	load_img_sync: false, | ||||||
| @ -1513,14 +1513,14 @@ var RibbonsPrototype = { | |||||||
| 	// 		._loadImagePreviewURL(..)
 | 	// 		._loadImagePreviewURL(..)
 | ||||||
| 	// 		.correctImageProportionsForRotation(..)
 | 	// 		.correctImageProportionsForRotation(..)
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// 		.updateImageIndicators(..)
 | 	// 		.callImageUpdaters(..)
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// XXX add options for images to preload and only then do the update...
 | 	// XXX add options for images to preload and only then do the update...
 | ||||||
| 	// XXX really slow for very large numbers of input images/gids...
 | 	// XXX really slow for very large numbers of input images/gids...
 | ||||||
| 	// XXX add support for basic image templating here...
 | 	// XXX add support for basic image templating here...
 | ||||||
| 	// 		...templates for blank images, text blocks and other stuff,
 | 	// 		...templates for blank images, text blocks and other stuff,
 | ||||||
| 	// 		this would best be done by simply filling in SVG templates...
 | 	// 		this would best be done by simply filling in SVG templates...
 | ||||||
| 	updateImage: function(image, gid, size, sync, callback){ | 	updateImage: function(image, gid, size, sync, pre_updaters_callback){ | ||||||
| 		var that = this | 		var that = this | ||||||
| 		var imgs = this.viewer.find(IMAGE) | 		var imgs = this.viewer.find(IMAGE) | ||||||
| 
 | 
 | ||||||
| @ -1546,7 +1546,6 @@ var RibbonsPrototype = { | |||||||
| 		size = size == null ? this.getVisibleImageSize('max') : size | 		size = size == null ? this.getVisibleImageSize('max') : size | ||||||
| 
 | 
 | ||||||
| 		var update = {} | 		var update = {} | ||||||
| 		//var marks = {}
 |  | ||||||
| 
 | 
 | ||||||
| 		// build update data...
 | 		// build update data...
 | ||||||
| 		image.map(function(_, image){ | 		image.map(function(_, image){ | ||||||
| @ -1563,7 +1562,6 @@ var RibbonsPrototype = { | |||||||
| 				style: {}, | 				style: {}, | ||||||
| 			} | 			} | ||||||
| 			var reset_preview = false | 			var reset_preview = false | ||||||
| 			//var will_change = []
 |  | ||||||
| 
 | 
 | ||||||
| 			// same image -- update...
 | 			// same image -- update...
 | ||||||
| 			if(old_gid == gid || gid == null){ | 			if(old_gid == gid || gid == null){ | ||||||
| @ -1573,11 +1571,8 @@ var RibbonsPrototype = { | |||||||
| 			// reuse for different image -- reconstruct...
 | 			// reuse for different image -- reconstruct...
 | ||||||
| 			} else { | 			} else { | ||||||
| 				// remove old marks...
 | 				// remove old marks...
 | ||||||
| 				if(typeof(old_gid) == typeof('str')){ | 				typeof(old_gid) == typeof('str') | ||||||
| 					// XXX
 | 					&& that.getImageMarks(old_gid).remove() | ||||||
| 					//marks[old_gid] = that.getImageMarks(old_gid)
 |  | ||||||
| 					that.getImageMarks(old_gid).remove() |  | ||||||
| 				} |  | ||||||
| 				// reset gid...
 | 				// reset gid...
 | ||||||
| 				data.attrs = { | 				data.attrs = { | ||||||
| 					gid: JSON.stringify(gid) | 					gid: JSON.stringify(gid) | ||||||
| @ -1649,17 +1644,8 @@ var RibbonsPrototype = { | |||||||
| 					}, 0) | 					}, 0) | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 
 |  | ||||||
| 			callback  |  | ||||||
| 				&& callback.call(that, image, data) |  | ||||||
| 
 |  | ||||||
| 			//image[0].style.willChange = will_change.join(', ')
 |  | ||||||
| 		}) | 		}) | ||||||
| 
 | 
 | ||||||
| 		// clear marks...
 |  | ||||||
| 		//Object.values(marks)
 |  | ||||||
| 		//	.forEach(function(m){ m.remove() })
 |  | ||||||
| 
 |  | ||||||
| 		var W = this.viewer.innerWidth() | 		var W = this.viewer.innerWidth() | ||||||
| 		var H = this.viewer.innerHeight() | 		var H = this.viewer.innerHeight() | ||||||
| 
 | 
 | ||||||
| @ -1675,9 +1661,9 @@ var RibbonsPrototype = { | |||||||
| 			css && img.css(css) | 			css && img.css(css) | ||||||
| 
 | 
 | ||||||
| 			that.correctImageProportionsForRotation(img, W, H) | 			that.correctImageProportionsForRotation(img, W, H) | ||||||
| 			that.updateImageIndicators(data.gid, img) | 			pre_updaters_callback  | ||||||
| 
 | 				&& pre_updaters_callback.call(that, image, data) | ||||||
| 			//_img.style.willChange = '' 
 | 			that.callImageUpdaters(data.gid, img) | ||||||
| 
 | 
 | ||||||
| 			return _img | 			return _img | ||||||
| 		})) | 		})) | ||||||
| @ -2228,7 +2214,7 @@ var RibbonsPrototype = { | |||||||
| 	// NOTE: overflowing offset will focus first/last image.
 | 	// NOTE: overflowing offset will focus first/last image.
 | ||||||
| 	focusImage: function(target){ | 	focusImage: function(target){ | ||||||
| 		var cur = this.viewer | 		var cur = this.viewer | ||||||
| 			.find('.current.image') | 			.find('.current'+IMAGE) | ||||||
| 		var next = this.getImage(target) | 		var next = this.getImage(target) | ||||||
| 
 | 
 | ||||||
| 		cur.removeClass('current') | 		cur.removeClass('current') | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user