mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	more refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									96114f4e24
								
							
						
					
					
						commit
						39afc04751
					
				| @ -1,15 +1,53 @@ | ||||
| $(document).ready(function() { | ||||
| 	// current state...
 | ||||
| // XXX need a uniform way to address images (filename?)
 | ||||
| 
 | ||||
| $(document).ready(setup); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /************************************************************ Setup **/ | ||||
| 
 | ||||
| function setup(){ | ||||
| 	// XXX load state...
 | ||||
| 	// initial state (default)...
 | ||||
| 	setDefaultInitialState() | ||||
| 
 | ||||
| 	// setup event handlers...
 | ||||
| 	setupKeyboard() | ||||
| 	setupGestures() | ||||
| 	setupControlElements() | ||||
| 
 | ||||
| 	// load images...
 | ||||
| 	// XXX not allowed...
 | ||||
| 	//$.getJSON('images.js', loadImages})
 | ||||
| 	// XXX STUB
 | ||||
| 	loadImages(image_list) | ||||
| 
 | ||||
| 	// set the default position and init...
 | ||||
| 	$('.current-image').click() | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| function setDefaultInitialState(){ | ||||
| 	if($('.current-ribbon').length == 0){ | ||||
| 		$('.ribbon').first().addClass('current-ribbon') | ||||
| 	} | ||||
| 	if($('.current-image').length == 0){ | ||||
| 		$('.current-ribbon').children('.image').first().addClass('current-image') | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| 	// setup event handlers...
 | ||||
| 
 | ||||
| 
 | ||||
| function setupKeyboard(){ | ||||
| 	$(document) | ||||
| 		.keydown(handleKeys) | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| function setupGestures(){ | ||||
| 	$('.viewer') | ||||
| 		// XXX this is flaky and breaks some of my code...
 | ||||
| 		.swipe({ | ||||
| @ -30,25 +68,22 @@ $(document).ready(function() { | ||||
| 			return false | ||||
| 		}) | ||||
| 		*/ | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| function setupControlElements(){ | ||||
| 	// images...
 | ||||
| 	$(".image").click(handleImageClick) | ||||
| 
 | ||||
| 	// control elements...
 | ||||
| 	// buttons...
 | ||||
| 	$('.next-image').click(nextImage) | ||||
| 	$('.prev-image').click(prevImage) | ||||
| 	$('.demote').click(shiftImageUp) | ||||
| 	$('.promote').click(shiftImageDown) | ||||
| 	$('.toggle-wide').click(toggleWideView) | ||||
| 	$('.toggle-single').click(toggleRibbonView) | ||||
| 
 | ||||
| 	// load images...
 | ||||
| 	// XXX not allowed...
 | ||||
| 	//$.getJSON('images.js', loadImages})
 | ||||
| 	// XXX STUB
 | ||||
| 	loadImages(image_list) | ||||
| 
 | ||||
| 	// set the default position and init...
 | ||||
| 	$('.current-image').click() | ||||
| }); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @ -69,6 +104,9 @@ function loadImages(json){ | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /*************************************************** Event Handlers **/ | ||||
| 
 | ||||
| function handleImageClick(e) { | ||||
| 
 | ||||
| 	var cur = $(this) | ||||
| @ -175,6 +213,9 @@ function handleKeys(event){ | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /************************************************************ Modes **/ | ||||
| 
 | ||||
| // mode switchers...
 | ||||
| function unsetViewerMode(mode){ | ||||
| 	$('.' + mode) | ||||
| @ -196,6 +237,7 @@ function setViewerMode(mode){ | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| // ribbon/single view modes...
 | ||||
| function toggleRibbonView(){ | ||||
| 	if($('.single-image-mode').length > 0){ | ||||
| @ -221,6 +263,9 @@ function toggleWideView(){ | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /******************************************************* Navigation **/ | ||||
| 
 | ||||
| // basic navigation...
 | ||||
| function firstImage(){ | ||||
| 	$('.current-ribbon').children('.image').first().click() | ||||
| @ -244,6 +289,9 @@ function focusBelowRibbon(){ | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /********************************************************** Actions **/ | ||||
| // basic actions...
 | ||||
| 
 | ||||
| // create ribbon above/below helpers...
 | ||||
| @ -290,7 +338,7 @@ function mergeRibbons(direction){ | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| // Modifiers...
 | ||||
| /*************************************************** Editor Actions **/ | ||||
| 
 | ||||
| // now the actual modifiers...
 | ||||
| function shiftImage(direction){ | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user