mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-17 08:41:40 +00:00
more work on modulerizing the code... still hate CJS and RequireJS...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
9e630922d2
commit
47dd396ee9
@ -4,6 +4,9 @@
|
|||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
|
define(function(require){ var module = {}
|
||||||
|
console.log('>>> actions')
|
||||||
|
|
||||||
//var DEBUG = DEBUG != null ? DEBUG : true
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
||||||
|
|
||||||
|
|
||||||
@ -24,6 +27,8 @@
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
// NOTE: context is dynamic.
|
// NOTE: context is dynamic.
|
||||||
|
var Action =
|
||||||
|
module.Action =
|
||||||
function Action(context, name, doc, code){
|
function Action(context, name, doc, code){
|
||||||
var action = function(){
|
var action = function(){
|
||||||
var args = args2array(arguments)
|
var args = args2array(arguments)
|
||||||
@ -83,6 +88,8 @@ function Action(context, name, doc, code){
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
// NOTE: context is dynamic.
|
// NOTE: context is dynamic.
|
||||||
|
var Actions =
|
||||||
|
module.Action =
|
||||||
function Actions(context, names, actions){
|
function Actions(context, names, actions){
|
||||||
actions = actions == null ? {} : actions
|
actions = actions == null ? {} : actions
|
||||||
Object.keys(names).forEach(function(e){
|
Object.keys(names).forEach(function(e){
|
||||||
@ -103,7 +110,8 @@ function Actions(context, names, actions){
|
|||||||
// - compound action is like a normal action with a set of other
|
// - compound action is like a normal action with a set of other
|
||||||
// actions chanined to it's main event.
|
// actions chanined to it's main event.
|
||||||
// - actions should accept arguments, both optional and required
|
// - actions should accept arguments, both optional and required
|
||||||
var BASE_ACTIONS = {
|
var BASE_ACTIONS =
|
||||||
|
module.BASE_ACTIONS = {
|
||||||
// basic editing...
|
// basic editing...
|
||||||
shiftImageUp:
|
shiftImageUp:
|
||||||
'Shift image to the ribbon above current, creating one if '
|
'Shift image to the ribbon above current, creating one if '
|
||||||
@ -148,6 +156,8 @@ var BASE_ACTIONS = {
|
|||||||
|
|
||||||
|
|
||||||
// XXX think of a better name...
|
// XXX think of a better name...
|
||||||
|
var setupBaseActions =
|
||||||
|
module.setupBaseActions =
|
||||||
function setupBaseActions(context, actions){
|
function setupBaseActions(context, actions){
|
||||||
return Actions(context, BASE_ACTIONS, actions)
|
return Actions(context, BASE_ACTIONS, actions)
|
||||||
}
|
}
|
||||||
@ -156,7 +166,8 @@ function setupBaseActions(context, actions){
|
|||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
var UI_ACTIONS = {
|
var UI_ACTIONS =
|
||||||
|
module.UI_ACTIONS = {
|
||||||
// basic navigation...
|
// basic navigation...
|
||||||
nextImage: 'Focus next image in current ribbon',
|
nextImage: 'Focus next image in current ribbon',
|
||||||
nextRibbon: 'Focus next ribbon (down)',
|
nextRibbon: 'Focus next ribbon (down)',
|
||||||
@ -223,6 +234,8 @@ var UI_ACTIONS = {
|
|||||||
|
|
||||||
|
|
||||||
// XXX think of a better name...
|
// XXX think of a better name...
|
||||||
|
var setupUIActions =
|
||||||
|
module.setupUIActions =
|
||||||
function setupUIActions(context, actions){
|
function setupUIActions(context, actions){
|
||||||
return Actions(context, UI_ACTIONS, actions)
|
return Actions(context, UI_ACTIONS, actions)
|
||||||
}
|
}
|
||||||
@ -233,7 +246,8 @@ function setupUIActions(context, actions){
|
|||||||
|
|
||||||
// Marks actions...
|
// Marks actions...
|
||||||
// XXX move to marks.js
|
// XXX move to marks.js
|
||||||
var MARKS_ACTIONS = {
|
var MARKS_ACTIONS =
|
||||||
|
module.MARKS_ACTIONS = {
|
||||||
toggleMark: '',
|
toggleMark: '',
|
||||||
toggleMarkBlock: '',
|
toggleMarkBlock: '',
|
||||||
|
|
||||||
@ -253,6 +267,8 @@ var MARKS_ACTIONS = {
|
|||||||
cropMarkedImagesToSingleRibbon: '',
|
cropMarkedImagesToSingleRibbon: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var setupMarksActions =
|
||||||
|
module.setupMarksActions =
|
||||||
function setupMarksActions(context, actions){
|
function setupMarksActions(context, actions){
|
||||||
return Actions(context, MARKS_ACTIONS, actions)
|
return Actions(context, MARKS_ACTIONS, actions)
|
||||||
}
|
}
|
||||||
@ -263,7 +279,8 @@ function setupMarksActions(context, actions){
|
|||||||
|
|
||||||
// Bookmarks actions...
|
// Bookmarks actions...
|
||||||
// XXX move to bookmarks.js
|
// XXX move to bookmarks.js
|
||||||
var BOOKMARKS_ACTIONS = {
|
var BOOKMARKS_ACTIONS =
|
||||||
|
module.BOOKMARKS_ACTIONS = {
|
||||||
toggleBookmark: 'Toggle image bookmark',
|
toggleBookmark: 'Toggle image bookmark',
|
||||||
|
|
||||||
bookmarkMarked: 'Bookmark marked images',
|
bookmarkMarked: 'Bookmark marked images',
|
||||||
@ -277,6 +294,8 @@ var BOOKMARKS_ACTIONS = {
|
|||||||
cropBookmarkedImagesToSingleRibbon: '',
|
cropBookmarkedImagesToSingleRibbon: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var setupBookmarksActions =
|
||||||
|
module.setupBookmarksActions =
|
||||||
function setupBookmarksActions(context, actions){
|
function setupBookmarksActions(context, actions){
|
||||||
return Actions(context, BOOKMARKS_ACTIONS, actions)
|
return Actions(context, BOOKMARKS_ACTIONS, actions)
|
||||||
}
|
}
|
||||||
@ -286,3 +305,4 @@ function setupBookmarksActions(context, actions){
|
|||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* vim:set ts=4 sw=4 : */
|
* vim:set ts=4 sw=4 : */
|
||||||
|
return module })
|
||||||
|
|||||||
@ -49,21 +49,6 @@ module.toggleFullscreenMode = createCSSClassToggler(
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
window.closeWindow =
|
|
||||||
module.closeWindow = function(){
|
|
||||||
window.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
window.showDevTools =
|
|
||||||
module.showDevTools = function(){}
|
|
||||||
|
|
||||||
|
|
||||||
window.reload =
|
|
||||||
module.reload = function(){
|
|
||||||
location.reload()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
window.setWindowTitle =
|
window.setWindowTitle =
|
||||||
module.setWindowTitle = function(text){
|
module.setWindowTitle = function(text){
|
||||||
|
|||||||
@ -12,11 +12,16 @@ console.log('>>> ui')
|
|||||||
|
|
||||||
//var DEBUG = DEBUG != null ? DEBUG : true
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
||||||
|
|
||||||
|
var keyboard = require('lib/keyboard')
|
||||||
|
var doc = keyboard.doc
|
||||||
|
|
||||||
|
// compatibility...
|
||||||
var browser = require('browser')
|
var browser = require('browser')
|
||||||
var nw = require('nw')
|
var nw = require('nw')
|
||||||
|
|
||||||
var keyboard = require('lib/keyboard')
|
// XXX load only the actualy used here modules...
|
||||||
var doc = keyboard.doc
|
var actions = require('actions')
|
||||||
|
var data = require('data')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -31,7 +36,7 @@ window.GLOBAL_KEYBOARD = {
|
|||||||
F4: {
|
F4: {
|
||||||
alt: doc('Close viewer',
|
alt: doc('Close viewer',
|
||||||
function(){
|
function(){
|
||||||
closeWindow()
|
window.close()
|
||||||
return false
|
return false
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -43,13 +48,19 @@ window.GLOBAL_KEYBOARD = {
|
|||||||
reload()
|
reload()
|
||||||
})
|
})
|
||||||
*/
|
*/
|
||||||
reload()
|
location.reload()
|
||||||
return false
|
return false
|
||||||
}),
|
}),
|
||||||
F12: doc('Show devTools',
|
F12: doc('Show devTools',
|
||||||
function(){
|
function(){
|
||||||
showDevTools()
|
if(window.showDevTools != null){
|
||||||
return false
|
showDevTools()
|
||||||
|
return false
|
||||||
|
|
||||||
|
// if no showDevTools defined pass the button further...
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
// NOTE: these are for systems where F** keys are not available
|
// NOTE: these are for systems where F** keys are not available
|
||||||
// or do other stuff...
|
// or do other stuff...
|
||||||
@ -76,7 +87,6 @@ window.GLOBAL_KEYBOARD = {
|
|||||||
F: {
|
F: {
|
||||||
ctrl: 'F11',
|
ctrl: 'F11',
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +95,7 @@ window.GLOBAL_KEYBOARD = {
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
$(function(){
|
$(function(){
|
||||||
|
// setup base keyboard for devel, in case something breaks...
|
||||||
$(document)
|
$(document)
|
||||||
.keydown(
|
.keydown(
|
||||||
keyboard.makeKeyboardHandler(
|
keyboard.makeKeyboardHandler(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user