mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 19:00:09 +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() {
|
// XXX need a uniform way to address images (filename?)
|
||||||
// current state...
|
|
||||||
|
$(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){
|
if($('.current-ribbon').length == 0){
|
||||||
$('.ribbon').first().addClass('current-ribbon')
|
$('.ribbon').first().addClass('current-ribbon')
|
||||||
}
|
}
|
||||||
if($('.current-image').length == 0){
|
if($('.current-image').length == 0){
|
||||||
$('.current-ribbon').children('.image').first().addClass('current-image')
|
$('.current-ribbon').children('.image').first().addClass('current-image')
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// setup event handlers...
|
|
||||||
|
|
||||||
|
function setupKeyboard(){
|
||||||
$(document)
|
$(document)
|
||||||
.keydown(handleKeys)
|
.keydown(handleKeys)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function setupGestures(){
|
||||||
$('.viewer')
|
$('.viewer')
|
||||||
// XXX this is flaky and breaks some of my code...
|
// XXX this is flaky and breaks some of my code...
|
||||||
.swipe({
|
.swipe({
|
||||||
@ -30,25 +68,22 @@ $(document).ready(function() {
|
|||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
*/
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function setupControlElements(){
|
||||||
|
// images...
|
||||||
$(".image").click(handleImageClick)
|
$(".image").click(handleImageClick)
|
||||||
|
|
||||||
// control elements...
|
// buttons...
|
||||||
$('.next-image').click(nextImage)
|
$('.next-image').click(nextImage)
|
||||||
$('.prev-image').click(prevImage)
|
$('.prev-image').click(prevImage)
|
||||||
$('.demote').click(shiftImageUp)
|
$('.demote').click(shiftImageUp)
|
||||||
$('.promote').click(shiftImageDown)
|
$('.promote').click(shiftImageDown)
|
||||||
$('.toggle-wide').click(toggleWideView)
|
$('.toggle-wide').click(toggleWideView)
|
||||||
$('.toggle-single').click(toggleRibbonView)
|
$('.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) {
|
function handleImageClick(e) {
|
||||||
|
|
||||||
var cur = $(this)
|
var cur = $(this)
|
||||||
@ -175,6 +213,9 @@ function handleKeys(event){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************ Modes **/
|
||||||
|
|
||||||
// mode switchers...
|
// mode switchers...
|
||||||
function unsetViewerMode(mode){
|
function unsetViewerMode(mode){
|
||||||
$('.' + mode)
|
$('.' + mode)
|
||||||
@ -196,6 +237,7 @@ function setViewerMode(mode){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ribbon/single view modes...
|
// ribbon/single view modes...
|
||||||
function toggleRibbonView(){
|
function toggleRibbonView(){
|
||||||
if($('.single-image-mode').length > 0){
|
if($('.single-image-mode').length > 0){
|
||||||
@ -221,6 +263,9 @@ function toggleWideView(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************* Navigation **/
|
||||||
|
|
||||||
// basic navigation...
|
// basic navigation...
|
||||||
function firstImage(){
|
function firstImage(){
|
||||||
$('.current-ribbon').children('.image').first().click()
|
$('.current-ribbon').children('.image').first().click()
|
||||||
@ -244,6 +289,9 @@ function focusBelowRibbon(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/********************************************************** Actions **/
|
||||||
// basic actions...
|
// basic actions...
|
||||||
|
|
||||||
// create ribbon above/below helpers...
|
// create ribbon above/below helpers...
|
||||||
@ -290,7 +338,7 @@ function mergeRibbons(direction){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Modifiers...
|
/*************************************************** Editor Actions **/
|
||||||
|
|
||||||
// now the actual modifiers...
|
// now the actual modifiers...
|
||||||
function shiftImage(direction){
|
function shiftImage(direction){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user