mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 19:30:07 +00:00 
			
		
		
		
	added basic modal overlay widget + some basic refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									5daaa02964
								
							
						
					
					
						commit
						8d92949e88
					
				
							
								
								
									
										57
									
								
								ui (gen4)/css/widget/overlay.css
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										57
									
								
								ui (gen4)/css/widget/overlay.css
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,57 @@ | ||||
| 
 | ||||
| .overlay { | ||||
| 	position: absolute; | ||||
| 
 | ||||
| 	width: 100%; | ||||
| 	height: 100%; | ||||
| 	top: 0px; | ||||
| 	left: 0px; | ||||
| 
 | ||||
| 	overflow: hidden; | ||||
| 
 | ||||
| 	background: rgba(0, 0, 0, 0.5); | ||||
| 
 | ||||
| 	-webkit-transform-style: preserve-3d; | ||||
| 	-moz-transform-style: preserve-3d; | ||||
| 	transform-style: preserve-3d; | ||||
| } | ||||
| .overlay~.overlay { | ||||
| 	background: rgba(0, 0, 0, 0.1); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| .overlay .content { | ||||
| 	position: relative; | ||||
| 	display: inline-block; | ||||
| 
 | ||||
| 	background: white; | ||||
| 
 | ||||
| 	top: 50%; | ||||
| 	left: 50%; | ||||
| 
 | ||||
| 	width: auto; | ||||
| 	height: auto; | ||||
| 
 | ||||
| 	min-width: 200px; | ||||
| 	max-width: 80vw; | ||||
| 	max-height: 100vh; | ||||
| 
 | ||||
| 	transform: translateY(-50%) translateX(-50%); | ||||
| 
 | ||||
| 	box-shadow: rgba(0, 0, 0, 0.1) 0.3em 0.3em 5em; | ||||
| } | ||||
| .overlay~.overlay .content { | ||||
| 	box-shadow: rgba(0, 0, 0, 0.05) 0.1em 0.1em 3em; | ||||
| } | ||||
| 
 | ||||
| /* NOTE: this does not include text...  | ||||
| 		...need a way to go around this... | ||||
| */ | ||||
| .blur>* { | ||||
| 	-webkit-filter: blur(2px); | ||||
| 	filter: blur(2px); | ||||
| } | ||||
| .blur>.overlay { | ||||
| 	-webkit-filter: none; | ||||
| 	filter: none; | ||||
| } | ||||
| @ -21,18 +21,7 @@ console.log('>>> browse') | ||||
| 
 | ||||
| // XXX
 | ||||
| var object = require('../../object') | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /*********************************************************************/ | ||||
| // helpers...
 | ||||
| 
 | ||||
| function proxyToDom(name){ | ||||
| 	return function(){  | ||||
| 		this.dom[name].apply(this.dom, arguments) | ||||
| 		return this  | ||||
| 	} | ||||
| } | ||||
| var widget = require('./widget') | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @ -308,34 +297,23 @@ var BrowserPrototype = { | ||||
| 	// 		to them handlers that stop propagation in .__init__(..).
 | ||||
| 	// 		The list of non-propagated events in defined in 
 | ||||
| 	// 		.options.nonPropagatedEvents
 | ||||
| 	trigger: function(){ | ||||
| 		var args = args2array(arguments) | ||||
| 		var evt = args.shift() | ||||
| 		 | ||||
| 		if(typeof(evt) == typeof('str')){ | ||||
| 			evt = $.Event(evt) | ||||
| 		} | ||||
| 
 | ||||
| 		evt.source = this | ||||
| 
 | ||||
| 		args.splice(0, 0, evt) | ||||
| 
 | ||||
| 		this.dom.trigger.apply(this.dom, args) | ||||
| 		return this  | ||||
| 	}, | ||||
| 	//
 | ||||
| 	// XXX triggering events from here and from jQuery/dom has a 
 | ||||
| 	// 		different effect...
 | ||||
| 	trigger: widget.triggerEventWithSource, | ||||
| 
 | ||||
| 	// proxy event api...
 | ||||
| 	on: proxyToDom('on'), | ||||
| 	one: proxyToDom('one'), | ||||
| 	off: proxyToDom('off'), | ||||
| 	bind: proxyToDom('bind'), | ||||
| 	unbind: proxyToDom('unbind'), | ||||
| 	deligate: proxyToDom('deligate'), | ||||
| 	undeligate: proxyToDom('undeligate'), | ||||
| 	on: widget.proxyToDom('on'), | ||||
| 	one: widget.proxyToDom('one'), | ||||
| 	off: widget.proxyToDom('off'), | ||||
| 	bind: widget.proxyToDom('bind'), | ||||
| 	unbind: widget.proxyToDom('unbind'), | ||||
| 	deligate: widget.proxyToDom('deligate'), | ||||
| 	undeligate: widget.proxyToDom('undeligate'), | ||||
| 
 | ||||
| 	// specific events...
 | ||||
| 	focus: proxyToDom('focus'), | ||||
| 	blur: proxyToDom('blur'), | ||||
| 	focus: widget.proxyToDom('focus'), | ||||
| 	blur: widget.proxyToDom('blur'), | ||||
| 
 | ||||
| 
 | ||||
| 	// base api...
 | ||||
|  | ||||
							
								
								
									
										115
									
								
								ui (gen4)/lib/widget/overlay.html
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										115
									
								
								ui (gen4)/lib/widget/overlay.html
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,115 @@ | ||||
| <!DOCTYPE html> | ||||
| <html> | ||||
| <link rel="stylesheet" href="../../css/widget/overlay.css"> | ||||
| <style> | ||||
| 
 | ||||
| 
 | ||||
| .container { | ||||
| 	position: absolute; | ||||
| 	box-sizing: border-box; | ||||
| 
 | ||||
| 	width: 50vw; | ||||
| 	height: 50vh; | ||||
| 	top: 10vh; | ||||
| 	right: 10vw; | ||||
| 
 | ||||
| 	border: solid 1px black; | ||||
| 
 | ||||
| 	padding: 10px; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| .overlay-content { | ||||
| 	padding: 5px; | ||||
| } | ||||
| body>.overlay-content { | ||||
| 	display: none; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /* theaming... */ | ||||
| 
 | ||||
| body.dark { | ||||
| 	background: black; | ||||
| 	color: white; | ||||
| } | ||||
| .dark ::-webkit-scrollbar-track-piece { | ||||
| 	background: rgba(255, 255, 255, 0.05); | ||||
| } | ||||
| .dark ::-webkit-scrollbar-thumb { | ||||
| 	background: rgba(255, 255, 255, 0.15); | ||||
| } | ||||
| .dark ::-webkit-scrollbar-thumb:hover { | ||||
| 	background: rgba(255, 255, 255, 0.3); | ||||
| } | ||||
| .dark .container { | ||||
| 	border: solid 1px rgba(255, 255, 255, 0.2); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| </style> | ||||
| 
 | ||||
| <script src="../../ext-lib/jquery.js"></script> | ||||
| <script src="../../ext-lib/jquery-ui.js"></script> | ||||
| 
 | ||||
| <script src="../jli.js"></script> | ||||
| <script src="../toggler.js"></script> | ||||
| 
 | ||||
| <script src="../../ext-lib/require.js"></script> | ||||
| 
 | ||||
| 
 | ||||
| <script> | ||||
| 
 | ||||
| requirejs(['../keyboard', '../../object', './overlay'], function(kbd, obj, ov){ | ||||
| 	keyboard = kbd | ||||
| 	overlay = ov | ||||
| 	object = obj | ||||
| }) | ||||
| 
 | ||||
| $(function(){ | ||||
| 
 | ||||
| }) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| var themeToggler = CSSClassToggler('body', | ||||
| 		[ | ||||
| 			'none',  | ||||
| 			'light', | ||||
| 			'dark',  | ||||
| 		], | ||||
| 		function(state){ | ||||
| 			$('#theme').text(state) | ||||
| 		}) | ||||
| 
 | ||||
| </script> | ||||
| 
 | ||||
| <body> | ||||
| 
 | ||||
| Theme: <button id="theme" onclick="themeToggler()">none</button> | ||||
| 
 | ||||
| <br> | ||||
| 
 | ||||
| <button onclick="overlay.Overlay('body', $('body>.overlay-content').clone())">Global overlay (default)</button> | ||||
| <button onclick="overlay.Overlay('.container', $('body>.overlay-content').clone())">Local overlay</button> | ||||
| 
 | ||||
| 
 | ||||
| <div class="container"> | ||||
| 	<h4>A context for an overlay...<h4> | ||||
| 	<button onclick="overlay.Overlay('.container', $('body>.overlay-content').clone())">Local overlay</button> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| <div class="overlay-content"> | ||||
| 	<h3>Overlay</h3> | ||||
| 	<button>Sub overlay</button> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| </body> | ||||
| </html> | ||||
| <!-- vim:set ts=4 sw=4 : --> | ||||
							
								
								
									
										98
									
								
								ui (gen4)/lib/widget/overlay.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										98
									
								
								ui (gen4)/lib/widget/overlay.js
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,98 @@ | ||||
| /********************************************************************** | ||||
| *  | ||||
| * | ||||
| * | ||||
| **********************************************************************/ | ||||
| 
 | ||||
| define(function(require){ var module = {} | ||||
| console.log('>>> overlay') | ||||
| 
 | ||||
| //var DEBUG = DEBUG != null ? DEBUG : true
 | ||||
| 
 | ||||
| var object = require('../../object') | ||||
| var widget = require('./widget') | ||||
| 
 | ||||
| 
 | ||||
| /*********************************************************************/ | ||||
| 
 | ||||
| var OverlayClassPrototype = { | ||||
| 	make: function(client, options){ | ||||
| 		var that = this | ||||
| 		var overlay = $('<div>') | ||||
| 			.addClass('overlay') | ||||
| 			.click(function(){ | ||||
| 				event.stopPropagation() | ||||
| 			}) | ||||
| 			.append($('<div>') | ||||
| 				.addClass('content') | ||||
| 				.click(function(){ | ||||
| 					event.stopPropagation() | ||||
| 				}) | ||||
| 				.append(client)) | ||||
| 
 | ||||
| 		return overlay | ||||
| 	}, | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| var OverlayPrototype = { | ||||
| 	dom: null, | ||||
| 
 | ||||
| 	// XXX triggering events from here and from jQuery/dom has a 
 | ||||
| 	// 		different effect...
 | ||||
| 	trigger: widget.triggerEventWithSource, | ||||
| 
 | ||||
| 	// proxy event api...
 | ||||
| 	on: widget.proxyToDom('on'), | ||||
| 	one: widget.proxyToDom('one'), | ||||
| 	off: widget.proxyToDom('off'), | ||||
| 	bind: widget.proxyToDom('bind'), | ||||
| 	unbind: widget.proxyToDom('unbind'), | ||||
| 	deligate: widget.proxyToDom('deligate'), | ||||
| 	undeligate: widget.proxyToDom('undeligate'), | ||||
| 
 | ||||
| 	// custom events...
 | ||||
| 	close: function(handler){ | ||||
| 		// trigger the event...
 | ||||
| 		if(handler == null){ | ||||
| 			this.dom.detach() | ||||
| 			if(this.parent.children('.overlay').length == 0){ | ||||
| 				this.parent.removeClass('blur') | ||||
| 			} | ||||
| 			this.trigger('close') | ||||
| 
 | ||||
| 		// register a handler...
 | ||||
| 		} else { | ||||
| 			this.on('close', handler) | ||||
| 		} | ||||
| 	}, | ||||
| 
 | ||||
| 	__init__: function(parent, client, options){ | ||||
| 		var that = this | ||||
| 		parent = this.parent = $(parent || 'body') | ||||
| 
 | ||||
| 		var dom = this.dom = this.constructor.make(client, options) | ||||
| 			.click(function(){ | ||||
| 				that.close() | ||||
| 			}) | ||||
| 
 | ||||
| 		parent | ||||
| 			.addClass('blur') | ||||
| 			.append(dom) | ||||
| 
 | ||||
| 		return this | ||||
| 	}, | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| var Overlay =  | ||||
| module.Overlay =  | ||||
| object.makeConstructor('Overlay',  | ||||
| 		OverlayClassPrototype,  | ||||
| 		OverlayPrototype) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /********************************************************************** | ||||
| * vim:set ts=4 sw=4 :                                                */ | ||||
| return module }) | ||||
							
								
								
									
										55
									
								
								ui (gen4)/lib/widget/widget.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										55
									
								
								ui (gen4)/lib/widget/widget.js
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,55 @@ | ||||
| /********************************************************************** | ||||
| *  | ||||
| * | ||||
| * | ||||
| **********************************************************************/ | ||||
| 
 | ||||
| define(function(require){ var module = {} | ||||
| console.log('>>> widget') | ||||
| 
 | ||||
| //var DEBUG = DEBUG != null ? DEBUG : true
 | ||||
| 
 | ||||
| 
 | ||||
| /*********************************************************************/ | ||||
| // helpers...
 | ||||
| 
 | ||||
| var proxyToDom = | ||||
| module.proxyToDom =  | ||||
| function(name){ | ||||
| 	return function(){  | ||||
| 		this.dom[name].apply(this.dom, arguments) | ||||
| 		return this  | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| // XXX triggering events from here and from jQuery/dom has a 
 | ||||
| // 		different effect...
 | ||||
| var triggerEventWithSource = | ||||
| module.triggerEventWithSource =  | ||||
| function(){ | ||||
| 	var args = args2array(arguments) | ||||
| 	var evt = args.shift() | ||||
| 	 | ||||
| 	if(typeof(evt) == typeof('str')){ | ||||
| 		evt = $.Event(evt) | ||||
| 	} | ||||
| 
 | ||||
| 	evt.source = this | ||||
| 
 | ||||
| 	args.splice(0, 0, evt) | ||||
| 
 | ||||
| 	this.dom.trigger.apply(this.dom, args) | ||||
| 	return this  | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /*********************************************************************/ | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /********************************************************************** | ||||
| * vim:set ts=4 sw=4 :                                                */ | ||||
| return module }) | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user