mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-11-03 21:00:14 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			369 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			HTML
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			369 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			HTML
		
	
	
		
			Executable File
		
	
	
	
	
<!DOCTYPE html>
 | 
						|
<html>
 | 
						|
<link rel="stylesheet" href="browse-dialog.css">
 | 
						|
<style>
 | 
						|
 | 
						|
/* scrollbar setup... */
 | 
						|
::-webkit-scrollbar {
 | 
						|
	width: 10px;
 | 
						|
	height: 10px;
 | 
						|
}
 | 
						|
::-webkit-scrollbar-button {
 | 
						|
	display: none;
 | 
						|
}
 | 
						|
::-webkit-scrollbar-track {
 | 
						|
}
 | 
						|
::-webkit-scrollbar-track-piece {
 | 
						|
	background: transparent;
 | 
						|
}
 | 
						|
::-webkit-scrollbar-track-piece {
 | 
						|
	background: rgba(0, 0, 0, 0.05);
 | 
						|
}
 | 
						|
::-webkit-scrollbar-thumb {
 | 
						|
	background: rgba(0, 0, 0, 0.15);
 | 
						|
}
 | 
						|
::-webkit-scrollbar-thumb:hover {
 | 
						|
	background: rgba(0, 0, 0, 0.3);
 | 
						|
}
 | 
						|
::-webkit-scrollbar-corner {
 | 
						|
}
 | 
						|
::-webkit-resizer {
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
/* testbed... */
 | 
						|
 | 
						|
.container {
 | 
						|
	display: inline-block;
 | 
						|
	position: absolute;
 | 
						|
 | 
						|
	top: 100px;
 | 
						|
	left: 300px;
 | 
						|
 | 
						|
	box-shadow: rgba(0,0,0,0.5) 0.1em 0.1em 0.4em;
 | 
						|
 | 
						|
	/* make the container expand only to a certain size, then scroll */
 | 
						|
	/* XXX need to:
 | 
						|
		- shorten path to fit width
 | 
						|
			i.e. manage width manually when at max-width...
 | 
						|
	*/
 | 
						|
	max-height: 60vh;
 | 
						|
	max-width: 60vw;
 | 
						|
	height: auto;
 | 
						|
	width: auto;
 | 
						|
	overflow-y: auto;
 | 
						|
	overflow-x: hidden;
 | 
						|
}
 | 
						|
 | 
						|
.container.flat {
 | 
						|
	left: 700px;
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
.container.flat2 {
 | 
						|
	left: 700px;
 | 
						|
	top: 400px;
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
/* 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="../lib/jli.js"></script>
 | 
						|
<script src="../lib/toggler.js"></script>
 | 
						|
 | 
						|
<script src="../ext-lib/require.js"></script>
 | 
						|
 | 
						|
 | 
						|
<!--script src="browse-dialog.js"></script-->
 | 
						|
 | 
						|
<script>
 | 
						|
 | 
						|
var TREE = {
 | 
						|
	dir_a: {},
 | 
						|
	dir_b: {
 | 
						|
		file1: 'this is a file',
 | 
						|
		file2: 'this is a file',
 | 
						|
		file3: 'this is a file',
 | 
						|
	},
 | 
						|
	dir_c: {
 | 
						|
		file1: 'this is a file',
 | 
						|
		dir_b: {
 | 
						|
			file1: 'this is a file',
 | 
						|
		},
 | 
						|
		dir_c: {},
 | 
						|
		dir_d: {},
 | 
						|
		dir_e: {},
 | 
						|
		dir_f: {},
 | 
						|
		dir_g: {},
 | 
						|
		dir_h: {},
 | 
						|
		dir_i: {},
 | 
						|
		dir_j: {},
 | 
						|
		dir_k: {},
 | 
						|
		dir_l: {},
 | 
						|
		dir_m: {},
 | 
						|
		dir_o: {},
 | 
						|
		dir_p: {},
 | 
						|
		dir_q: {},
 | 
						|
		dir_r: {},
 | 
						|
		dir_s: {},
 | 
						|
		dir_t: {},
 | 
						|
		dir_u: {},
 | 
						|
	},
 | 
						|
	file: 'this is a file',
 | 
						|
}
 | 
						|
// add some recursion for testing...
 | 
						|
TREE.dir_d = TREE.dir_c.dir_b
 | 
						|
TREE.dir_a.tree = TREE
 | 
						|
TREE.dir_c.tree = TREE
 | 
						|
TREE.dir_c.dir_b.tree = TREE
 | 
						|
 | 
						|
 | 
						|
 | 
						|
//---
 | 
						|
 | 
						|
var use_disabled = true
 | 
						|
var show_files = false
 | 
						|
 | 
						|
requirejs(['../lib/keyboard', '../object', './browse-dialog'], function(k, o, br){
 | 
						|
	keyboard = k
 | 
						|
	object = o
 | 
						|
	browser = br
 | 
						|
 | 
						|
	// Tree demo...
 | 
						|
	b = browser.Browser($('.container.tree'), {
 | 
						|
			path: '/dir_a/tree/dir_c/',
 | 
						|
 | 
						|
			list: function(path, make){
 | 
						|
				var cur = TREE
 | 
						|
				path.forEach(function(p){
 | 
						|
					cur = cur[p]
 | 
						|
				})
 | 
						|
 | 
						|
				return Object.keys(cur)
 | 
						|
					// remove all strings...
 | 
						|
					.filter(function(k){
 | 
						|
						return show_files || typeof(cur[k]) != typeof('str')
 | 
						|
					})
 | 
						|
					.map(function(k){
 | 
						|
						// make the element...
 | 
						|
						var e = make(k)
 | 
						|
						// disable dir_b...
 | 
						|
						if(use_disabled && k == 'dir_b'){
 | 
						|
							e.addClass('disabled')
 | 
						|
						}
 | 
						|
						if(typeof(cur[k]) == typeof('str')){
 | 
						|
							e.addClass('not-traversable')
 | 
						|
						}
 | 
						|
						return k
 | 
						|
					})
 | 
						|
			},
 | 
						|
			open: function(path){
 | 
						|
				console.log('OPEN:', path)
 | 
						|
			},
 | 
						|
		})
 | 
						|
		.focus()
 | 
						|
 | 
						|
 | 
						|
	// Custom flat list demo...
 | 
						|
	f = browser.Browser($('.container.flat'), {
 | 
						|
			data: [
 | 
						|
				'option 1',
 | 
						|
				'option 2',
 | 
						|
				'option 3',
 | 
						|
				'option 4',
 | 
						|
				'option 5',
 | 
						|
				'option 6',
 | 
						|
				'option 7',
 | 
						|
			],
 | 
						|
 | 
						|
			fullPathEdit: false,
 | 
						|
			traversable: false,
 | 
						|
			flat: true,
 | 
						|
 | 
						|
			list: function(path, make){
 | 
						|
				return this.options.data
 | 
						|
					.map(function(k){
 | 
						|
						// make the element...
 | 
						|
						var e = make(k)
 | 
						|
						// disable dir_b...
 | 
						|
						if(use_disabled && k == 'option 4'){
 | 
						|
							e.addClass('disabled')
 | 
						|
						}
 | 
						|
 | 
						|
						if(k == 'option 3'){
 | 
						|
							e.on('open', function(){ alert('openning: option 3!') })
 | 
						|
						}
 | 
						|
						return k
 | 
						|
					})
 | 
						|
			},
 | 
						|
			open: function(path){
 | 
						|
				console.log('OPEN:', path)
 | 
						|
			},
 | 
						|
		})
 | 
						|
 | 
						|
 | 
						|
	// Default flat list demo...
 | 
						|
	f2 = browser.makeList($('.container.flat2'), {
 | 
						|
			'option 1': function(_, p){ console.log('option:', p) },
 | 
						|
			'option 2': function(_, p){ console.log('option:', p) },
 | 
						|
			'option 3': function(_, p){ console.log('option:', p) },
 | 
						|
			'option 4': function(_, p){ console.log('option:', p) },
 | 
						|
		})
 | 
						|
		// another way to handle the opening of items...
 | 
						|
		.open(function(evt, text){
 | 
						|
				alert('>>> ' + text)
 | 
						|
		})
 | 
						|
})
 | 
						|
 | 
						|
$(function(){
 | 
						|
 | 
						|
	$('.container').first().remove()
 | 
						|
 | 
						|
	$('.container').draggable({ 
 | 
						|
			cancel: ".path .dir, .list div" 
 | 
						|
		})
 | 
						|
})
 | 
						|
 | 
						|
 | 
						|
 | 
						|
var themeToggler = CSSClassToggler('body',
 | 
						|
		[
 | 
						|
			'none', 
 | 
						|
			'light',
 | 
						|
			'dark', 
 | 
						|
		],
 | 
						|
		function(state){
 | 
						|
			$('#theme').text(state)
 | 
						|
		})
 | 
						|
function toggleDisabled(){
 | 
						|
	use_disabled = !use_disabled
 | 
						|
 | 
						|
	use_disabled ? b.disableElements('_b') : b.enableElements('_b')
 | 
						|
	use_disabled ? f.disableElements('4') : f.enableElements('4')
 | 
						|
}
 | 
						|
function toggleFiles(){
 | 
						|
	show_files = !show_files
 | 
						|
	
 | 
						|
	// NOTE: we need to update only because .list(..) does not show
 | 
						|
	//		files at all and we need to re-render them, another way 
 | 
						|
	//		would be render everything but hide and show files via CSS 
 | 
						|
	//		class...
 | 
						|
	b.update()
 | 
						|
}
 | 
						|
 | 
						|
</script>
 | 
						|
 | 
						|
<body>
 | 
						|
 | 
						|
<button onclick="b.pop()"><</button>
 | 
						|
<button onclick="b.push()">></button>
 | 
						|
<button onclick="b.prev()">^</button>
 | 
						|
<button onclick="b.next()">v</button>
 | 
						|
 | 
						|
<br>
 | 
						|
<br>
 | 
						|
 | 
						|
Theme: <button id="theme" onclick="themeToggler()">none</button>
 | 
						|
 | 
						|
<br>
 | 
						|
 | 
						|
Disabled: <button id="theme" onclick="toggleDisabled()">toggle</button>
 | 
						|
 | 
						|
<br>
 | 
						|
 | 
						|
Files: <button id="theme" onclick="toggleFiles()">toggle</button>
 | 
						|
 | 
						|
<br>
 | 
						|
<br>
 | 
						|
Basic key bindings:
 | 
						|
<ul>
 | 
						|
	<li><code>ctrl-a<code> - edit full path </li>
 | 
						|
	<li><code>ctrl-left<code> / <code>ctrl-Backspace<code> - go to root </li>
 | 
						|
</ul>
 | 
						|
 | 
						|
 | 
						|
<div class="container">
 | 
						|
	<div class="browse">
 | 
						|
		<!-- title, optional -->
 | 
						|
		<div class="v-block title">
 | 
						|
			[title]
 | 
						|
		</div>
 | 
						|
 | 
						|
		<!-- current path -->
 | 
						|
		<div class="v-block path">
 | 
						|
			<div class="dir">
 | 
						|
				[dir]
 | 
						|
			</div>
 | 
						|
			<div class="dir">
 | 
						|
				[dir]
 | 
						|
			</div>
 | 
						|
			<div class="dir">
 | 
						|
				[dir]
 | 
						|
			</div>
 | 
						|
		</div>
 | 
						|
 | 
						|
		<!-- path list -->
 | 
						|
		<div class="v-block list">
 | 
						|
			<div>
 | 
						|
				[dir]
 | 
						|
			</div>
 | 
						|
			<div>
 | 
						|
				[dir]
 | 
						|
			</div>
 | 
						|
			<div>
 | 
						|
				[dir]
 | 
						|
			</div>
 | 
						|
		</div>
 | 
						|
 | 
						|
		<!-- info, optional -->
 | 
						|
		<div class="v-block info">
 | 
						|
			[info]
 | 
						|
		</div>
 | 
						|
 | 
						|
		<!-- buttons, optional -->
 | 
						|
		<div class="v-block actions">
 | 
						|
			[actions]
 | 
						|
		</div>
 | 
						|
	</div>
 | 
						|
</div>
 | 
						|
 | 
						|
<div class="container tree">
 | 
						|
</div>
 | 
						|
 | 
						|
<div class="container flat">
 | 
						|
</div>
 | 
						|
 | 
						|
<div class="container flat2">
 | 
						|
</div>
 | 
						|
 | 
						|
</body>
 | 
						|
</html>
 | 
						|
<!-- vim:set ts=4 sw=4 : -->
 |