2014-07-21 16:38:06 +04:00
|
|
|
/**********************************************************************
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
2015-09-08 01:01:06 +03:00
|
|
|
|
2014-07-25 18:34:53 +04:00
|
|
|
window.nodejs = (typeof(process) === 'object' && process.features.uv)
|
|
|
|
|
? {
|
|
|
|
|
require: window.require,
|
|
|
|
|
}
|
|
|
|
|
: null
|
2014-07-21 16:38:06 +04:00
|
|
|
|
|
|
|
|
|
2014-12-28 03:47:44 +03:00
|
|
|
// XXX for some reason requirejs does not fall back to node's require...
|
|
|
|
|
if(nodejs){
|
|
|
|
|
var requirejs = require('requirejs')
|
|
|
|
|
|
|
|
|
|
requirejs.config({
|
|
|
|
|
nodeRequire: require,
|
|
|
|
|
//baseUrl: __dirname,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-07-21 16:38:06 +04:00
|
|
|
define(function(require){ var module = {}
|
|
|
|
|
console.log('>>> ui')
|
|
|
|
|
|
|
|
|
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
|
|
|
|
|
2014-07-21 18:21:36 +04:00
|
|
|
var keyboard = require('lib/keyboard')
|
|
|
|
|
var doc = keyboard.doc
|
|
|
|
|
|
|
|
|
|
// compatibility...
|
2014-07-21 16:38:06 +04:00
|
|
|
var browser = require('browser')
|
|
|
|
|
var nw = require('nw')
|
|
|
|
|
|
2014-07-21 18:21:36 +04:00
|
|
|
// XXX load only the actualy used here modules...
|
|
|
|
|
var actions = require('actions')
|
|
|
|
|
var data = require('data')
|
2014-07-21 18:33:31 +04:00
|
|
|
var ribbons = require('ribbons')
|
2014-07-21 16:38:06 +04:00
|
|
|
|
|
|
|
|
|
2014-08-15 06:03:36 +04:00
|
|
|
// XXX
|
|
|
|
|
var testing = require('testing')
|
|
|
|
|
|
|
|
|
|
|
2014-09-02 02:55:03 +04:00
|
|
|
var client = require('client')
|
|
|
|
|
|
2014-10-11 06:33:49 +04:00
|
|
|
var viewer = require('viewer')
|
|
|
|
|
|
2014-12-28 03:47:44 +03:00
|
|
|
//var promise = require('promise')
|
|
|
|
|
|
2014-09-02 02:55:03 +04:00
|
|
|
|
2015-09-05 16:07:35 +03:00
|
|
|
// widgets...
|
|
|
|
|
var browse = require('lib/widget/browse')
|
2015-09-08 01:01:06 +03:00
|
|
|
var overlay = require('lib/widget/overlay')
|
2015-09-05 16:07:35 +03:00
|
|
|
|
|
|
|
|
|
2014-07-21 16:38:06 +04:00
|
|
|
|
|
|
|
|
/*********************************************************************/
|
|
|
|
|
|
2014-07-21 18:33:31 +04:00
|
|
|
// XXX add this to the global doc...
|
2014-07-22 17:09:25 +04:00
|
|
|
module.GLOBAL_KEYBOARD = {
|
2014-07-21 16:38:06 +04:00
|
|
|
'Global bindings': {
|
|
|
|
|
doc: 'NOTE: binding priority is the same as the order of sections '+
|
|
|
|
|
'on this page.',
|
|
|
|
|
pattern: '*',
|
|
|
|
|
|
|
|
|
|
F4: {
|
2014-10-22 01:05:59 +04:00
|
|
|
alt: 'close',
|
|
|
|
|
/*
|
2014-07-21 16:38:06 +04:00
|
|
|
alt: doc('Close viewer',
|
|
|
|
|
function(){
|
2014-07-21 18:21:36 +04:00
|
|
|
window.close()
|
2014-07-21 16:38:06 +04:00
|
|
|
return false
|
|
|
|
|
}),
|
2014-10-22 01:05:59 +04:00
|
|
|
*/
|
2014-07-21 16:38:06 +04:00
|
|
|
},
|
2015-04-25 20:17:21 +03:00
|
|
|
Q: {
|
|
|
|
|
meta: 'close',
|
|
|
|
|
},
|
2014-07-21 16:38:06 +04:00
|
|
|
F5: doc('Full reload viewer',
|
|
|
|
|
function(){
|
|
|
|
|
/*
|
|
|
|
|
killAllWorkers()
|
|
|
|
|
.done(function(){
|
|
|
|
|
reload()
|
|
|
|
|
})
|
|
|
|
|
*/
|
2014-07-21 18:21:36 +04:00
|
|
|
location.reload()
|
2014-07-21 16:38:06 +04:00
|
|
|
return false
|
|
|
|
|
}),
|
2014-10-22 01:05:59 +04:00
|
|
|
F12: 'showDevTools',
|
2014-07-21 16:38:06 +04:00
|
|
|
// NOTE: these are for systems where F** keys are not available
|
|
|
|
|
// or do other stuff...
|
|
|
|
|
R: {
|
2014-10-24 04:51:35 +04:00
|
|
|
default: 'rotateCW',
|
|
|
|
|
shift: 'reverseImages',
|
2014-10-22 01:05:59 +04:00
|
|
|
ctrl: 'reload!',
|
2014-07-21 16:38:06 +04:00
|
|
|
'ctrl+shift': 'F5',
|
|
|
|
|
},
|
2014-10-24 04:51:35 +04:00
|
|
|
L: 'rotateCCW',
|
|
|
|
|
H: 'flipHorizontal',
|
|
|
|
|
V: 'flipVertical',
|
2014-07-21 16:38:06 +04:00
|
|
|
P: {
|
|
|
|
|
'ctrl+shift': 'F12',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// NOTE: this is handled by the wrapper at this point, so we do
|
|
|
|
|
// not have to do anything here...
|
2014-10-22 01:23:56 +04:00
|
|
|
F11: 'toggleFullScreen',
|
2014-07-21 16:38:06 +04:00
|
|
|
F: {
|
|
|
|
|
ctrl: 'F11',
|
2015-04-25 20:17:21 +03:00
|
|
|
meta: 'F11',
|
2014-07-21 16:38:06 +04:00
|
|
|
},
|
2014-10-12 03:14:29 +04:00
|
|
|
|
|
|
|
|
// XXX testing...
|
2014-10-22 13:11:26 +04:00
|
|
|
|
2014-11-06 03:56:54 +03:00
|
|
|
Enter: 'toggleSingleImage',
|
|
|
|
|
|
2014-10-21 21:17:44 +04:00
|
|
|
Home: {
|
|
|
|
|
default: 'firstImage',
|
2014-10-22 13:11:26 +04:00
|
|
|
ctrl: 'firstGlobalImage',
|
|
|
|
|
shift: 'firstRibbon',
|
2014-10-21 21:17:44 +04:00
|
|
|
},
|
|
|
|
|
End: {
|
|
|
|
|
default: 'lastImage',
|
2014-10-22 13:11:26 +04:00
|
|
|
ctrl: 'lastGlobalImage',
|
|
|
|
|
shift: 'lastRibbon',
|
2014-10-21 21:17:44 +04:00
|
|
|
},
|
2014-10-13 00:18:26 +04:00
|
|
|
Left: {
|
2014-10-20 06:52:13 +04:00
|
|
|
default: 'prevImage',
|
|
|
|
|
alt: 'shiftImageLeft!',
|
|
|
|
|
ctrl: 'prevScreen',
|
2015-04-25 20:17:21 +03:00
|
|
|
// XXX need to prevent default on mac + browser...
|
|
|
|
|
meta: 'prevScreen',
|
2014-10-13 00:18:26 +04:00
|
|
|
},
|
2014-10-21 21:17:44 +04:00
|
|
|
PgUp: 'prevScreen',
|
|
|
|
|
PgDown: 'nextScreen',
|
2014-10-13 00:18:26 +04:00
|
|
|
Right: {
|
2014-10-20 06:52:13 +04:00
|
|
|
default: 'nextImage',
|
|
|
|
|
alt: 'shiftImageRight!',
|
|
|
|
|
ctrl: 'nextScreen',
|
2015-04-25 20:17:21 +03:00
|
|
|
// XXX need to prevent default on mac + browser...
|
|
|
|
|
meta: 'nextScreen',
|
2014-10-13 00:18:26 +04:00
|
|
|
},
|
2014-10-20 06:52:13 +04:00
|
|
|
'(': 'prevImageInOrder',
|
|
|
|
|
')': 'nextImageInOrder',
|
2014-11-19 19:30:38 +03:00
|
|
|
',': 'prevMarked',
|
|
|
|
|
'.': 'nextMarked',
|
2014-11-21 23:53:55 +03:00
|
|
|
'[': 'prevBookmarked',
|
|
|
|
|
']': 'nextBookmarked',
|
2014-10-12 03:14:29 +04:00
|
|
|
Up: {
|
2014-10-20 06:52:13 +04:00
|
|
|
default: 'prevRibbon',
|
|
|
|
|
shift: 'shiftImageUp',
|
2015-01-07 17:44:24 +03:00
|
|
|
'alt+shift': 'travelImageUp',
|
2014-10-20 06:52:13 +04:00
|
|
|
'ctrl+shift': 'shiftImageUpNewRibbon',
|
2014-10-12 03:14:29 +04:00
|
|
|
},
|
|
|
|
|
Down: {
|
2014-10-20 06:52:13 +04:00
|
|
|
default: 'nextRibbon',
|
|
|
|
|
shift: 'shiftImageDown',
|
2015-01-07 17:44:24 +03:00
|
|
|
'alt+shift': 'travelImageDown',
|
2014-10-20 06:52:13 +04:00
|
|
|
'ctrl+shift': 'shiftImageDownNewRibbon',
|
2014-10-13 00:18:26 +04:00
|
|
|
},
|
2014-10-20 16:38:26 +04:00
|
|
|
|
2014-10-20 06:52:13 +04:00
|
|
|
'#0': 'fitMax',
|
2014-10-18 17:32:41 +04:00
|
|
|
'#1': {
|
2014-10-20 06:52:13 +04:00
|
|
|
default: 'fitImage',
|
2014-11-05 03:26:29 +03:00
|
|
|
shift: 'fitRibbon',
|
2014-10-20 06:52:13 +04:00
|
|
|
ctrl: 'fitOrig!',
|
2014-10-18 17:32:41 +04:00
|
|
|
},
|
2014-11-05 16:19:37 +03:00
|
|
|
'#2': 'fitImage: 2',
|
2014-11-05 01:09:06 +03:00
|
|
|
'#3': {
|
2014-11-05 16:19:37 +03:00
|
|
|
default: 'fitImage: 3',
|
2014-11-05 16:24:36 +03:00
|
|
|
shift: 'fitRibbon: 3.5',
|
2014-11-05 01:09:06 +03:00
|
|
|
},
|
2014-11-05 16:24:36 +03:00
|
|
|
'#4': 'fitImage: 4',
|
2014-11-05 01:09:06 +03:00
|
|
|
'#5': {
|
2014-11-05 16:24:36 +03:00
|
|
|
default: 'fitImage: 5',
|
|
|
|
|
shift: 'fitRibbon: 5.5',
|
2014-11-05 01:09:06 +03:00
|
|
|
},
|
2014-11-05 16:24:36 +03:00
|
|
|
'#6': 'fitImage: 6',
|
|
|
|
|
'#7': 'fitImage: 7',
|
|
|
|
|
'#8':'fitImage: 8',
|
|
|
|
|
'#9': 'fitImage: 9',
|
2014-10-13 00:18:26 +04:00
|
|
|
|
2014-10-20 06:52:13 +04:00
|
|
|
'+': 'zoomIn',
|
2014-10-18 17:32:41 +04:00
|
|
|
'=': '+',
|
2014-10-20 06:52:13 +04:00
|
|
|
'-': 'zoomOut',
|
2014-10-22 05:49:11 +04:00
|
|
|
|
|
|
|
|
F2: {
|
|
|
|
|
default: 'cropRibbon',
|
|
|
|
|
shift: 'cropRibbonAndAbove',
|
2014-11-21 23:53:55 +03:00
|
|
|
ctrl: 'cropMarked',
|
|
|
|
|
alt: 'cropBookmarked',
|
2014-10-22 05:49:11 +04:00
|
|
|
},
|
|
|
|
|
Esc: {
|
|
|
|
|
default: 'uncrop',
|
|
|
|
|
ctrl: 'uncropAll',
|
|
|
|
|
},
|
2014-11-19 22:26:59 +03:00
|
|
|
|
|
|
|
|
// marking...
|
2014-11-20 21:45:06 +03:00
|
|
|
M: {
|
|
|
|
|
default: 'toggleMark',
|
|
|
|
|
},
|
2014-11-19 22:26:59 +03:00
|
|
|
A: {
|
2015-09-08 01:01:06 +03:00
|
|
|
// XXX STUB...
|
|
|
|
|
alt: function(){ browseActions() },
|
2014-11-19 22:26:59 +03:00
|
|
|
ctrl: 'toggleMark!: "ribbon" "on"',
|
|
|
|
|
},
|
|
|
|
|
D: {
|
|
|
|
|
ctrl: 'toggleMark!: "ribbon" "off"',
|
|
|
|
|
},
|
|
|
|
|
I: {
|
|
|
|
|
ctrl: 'toggleMark!: "ribbon"',
|
2015-04-25 20:17:21 +03:00
|
|
|
|
|
|
|
|
'meta+alt': 'showDevTools',
|
2014-11-19 22:26:59 +03:00
|
|
|
},
|
2014-10-18 17:32:41 +04:00
|
|
|
|
2014-11-20 21:45:06 +03:00
|
|
|
B: {
|
|
|
|
|
default: 'toggleBookmark',
|
2014-11-21 17:11:13 +03:00
|
|
|
ctrl: 'toggleTheme!',
|
2014-11-20 21:45:06 +03:00
|
|
|
},
|
2014-07-21 16:38:06 +04:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-20 06:52:13 +04:00
|
|
|
|
2014-07-21 16:38:06 +04:00
|
|
|
/*********************************************************************/
|
|
|
|
|
|
|
|
|
|
$(function(){
|
2014-10-20 06:52:13 +04:00
|
|
|
|
2015-09-08 01:01:06 +03:00
|
|
|
window.browse = browse
|
|
|
|
|
window.overlay = overlay
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.browseActions = function(){
|
|
|
|
|
var paths = a.getPath()
|
|
|
|
|
var actions = {}
|
|
|
|
|
|
|
|
|
|
Object.keys(paths).forEach(function(k){
|
|
|
|
|
var n = paths[k][0]
|
|
|
|
|
actions[k] = function(){
|
|
|
|
|
return a[n].apply(a)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
var b = browse.makePathList(null, actions)
|
|
|
|
|
var o = overlay.Overlay($('body'), b.dom)
|
|
|
|
|
|
|
|
|
|
b.open(function(){ o.close() })
|
|
|
|
|
|
|
|
|
|
b.focus()
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-09 19:39:57 +03:00
|
|
|
// XXX
|
2014-10-20 06:52:13 +04:00
|
|
|
window.a = testing.setupActions()
|
2014-11-21 23:53:55 +03:00
|
|
|
.load({
|
|
|
|
|
viewer: $('.viewer')
|
|
|
|
|
})
|
|
|
|
|
|
2014-12-08 13:04:09 +03:00
|
|
|
// used switch experimental actions on (set to true) or off (unset or false)...
|
|
|
|
|
//a.experimental = true
|
2014-11-21 23:53:55 +03:00
|
|
|
|
2014-11-26 04:15:02 +03:00
|
|
|
// XXX for some reason this is not visible when loading...
|
2014-11-21 23:53:55 +03:00
|
|
|
a.setEmptyMsg('Loading...')
|
|
|
|
|
|
2014-12-05 00:10:01 +03:00
|
|
|
viewer.ImageGridFeatures.setup(a, [
|
2014-12-09 16:34:14 +03:00
|
|
|
'viewer-testing',
|
2014-10-20 06:52:13 +04:00
|
|
|
|
2014-12-08 13:04:09 +03:00
|
|
|
// XXX this is not for production...
|
|
|
|
|
'experiments',
|
|
|
|
|
])
|
|
|
|
|
|
2014-10-20 06:52:13 +04:00
|
|
|
// this publishes all the actions...
|
|
|
|
|
//module.GLOBAL_KEYBOARD.__proto__ = a
|
|
|
|
|
|
2014-11-08 16:18:20 +03:00
|
|
|
// load some testing data...
|
2014-11-21 23:53:55 +03:00
|
|
|
// NOTE: we can load this in parts...
|
2014-12-08 13:04:09 +03:00
|
|
|
a
|
|
|
|
|
.load({
|
|
|
|
|
//viewer: $('.viewer'),
|
|
|
|
|
data: data.Data(testing.mock_data),
|
|
|
|
|
images: testing.makeTestImages(),
|
|
|
|
|
})
|
|
|
|
|
// this is needed when loading legacy sources that do not have tags
|
|
|
|
|
// synced...
|
|
|
|
|
// do not do for actual data...
|
|
|
|
|
//.syncTags()
|
|
|
|
|
|
2014-11-08 16:18:20 +03:00
|
|
|
|
2014-11-21 23:53:55 +03:00
|
|
|
a.setEmptyMsg(
|
|
|
|
|
'Nothing loaded...',
|
|
|
|
|
'Press \'O\' to load, \'F1\' for help or \'?\' for keyboard mappings.')
|
|
|
|
|
|
|
|
|
|
|
2014-07-21 18:21:36 +04:00
|
|
|
// setup base keyboard for devel, in case something breaks...
|
2014-07-21 16:38:06 +04:00
|
|
|
$(document)
|
|
|
|
|
.keydown(
|
|
|
|
|
keyboard.makeKeyboardHandler(
|
2014-07-22 17:09:25 +04:00
|
|
|
module.GLOBAL_KEYBOARD,
|
2014-07-21 16:38:06 +04:00
|
|
|
function(k){
|
|
|
|
|
window.DEBUG && console.log(k)
|
2014-10-20 06:52:13 +04:00
|
|
|
},
|
|
|
|
|
a))
|
2014-07-21 16:38:06 +04:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
|
* vim:set ts=4 sw=4 : */
|
|
|
|
|
return module })
|