2015-12-17 03:34:20 +03:00
|
|
|
/**********************************************************************
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
**********************************************************************/
|
2016-08-21 02:19:24 +03:00
|
|
|
((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define)
|
|
|
|
|
(function(require){ var module={} // make module AMD/node compatible...
|
2016-08-20 22:49:36 +03:00
|
|
|
/*********************************************************************/
|
2015-12-17 03:34:20 +03:00
|
|
|
|
2016-05-08 18:27:59 +03:00
|
|
|
if(typeof(process) != 'undefined'){
|
|
|
|
|
var pathlib = requirejs('path')
|
|
|
|
|
}
|
2015-12-17 03:34:20 +03:00
|
|
|
|
2017-10-04 18:17:01 +03:00
|
|
|
var electron
|
|
|
|
|
try{
|
|
|
|
|
electron = requirejs('electron')
|
|
|
|
|
} catch(e){ }
|
|
|
|
|
|
|
|
|
|
|
2015-12-17 03:34:20 +03:00
|
|
|
var actions = require('lib/actions')
|
|
|
|
|
var features = require('lib/features')
|
2016-04-09 18:39:01 +03:00
|
|
|
var toggler = require('lib/toggler')
|
2015-12-17 03:34:20 +03:00
|
|
|
|
|
|
|
|
var core = require('features/core')
|
|
|
|
|
var base = require('features/base')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************/
|
|
|
|
|
|
2017-10-04 17:07:22 +03:00
|
|
|
var NWHostActions = actions.Actions({
|
2017-10-04 18:20:44 +03:00
|
|
|
// window stuff...
|
2017-10-05 02:01:54 +03:00
|
|
|
// XXX should this be nested in a .window object???
|
2017-10-04 17:07:22 +03:00
|
|
|
get title(){
|
|
|
|
|
return nw.Window.get().title },
|
|
|
|
|
set title(value){
|
|
|
|
|
nw.Window.get().title = value },
|
2017-10-05 02:01:54 +03:00
|
|
|
get size(){
|
|
|
|
|
var win = nw.Window.get()
|
|
|
|
|
return [
|
|
|
|
|
win.width,
|
|
|
|
|
win.height,
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
set size(value){
|
|
|
|
|
var win = nw.Window.get()
|
|
|
|
|
win.width = value[0]
|
|
|
|
|
win.height = value[1]
|
|
|
|
|
},
|
|
|
|
|
get position(){
|
|
|
|
|
var win = nw.Window.get()
|
|
|
|
|
return [
|
|
|
|
|
win.x,
|
|
|
|
|
win.y,
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
set position(value){
|
|
|
|
|
var win = nw.Window.get()
|
|
|
|
|
win.x = value[0]
|
|
|
|
|
win.y = value[1]
|
|
|
|
|
},
|
2017-10-04 17:07:22 +03:00
|
|
|
|
2017-10-05 02:01:54 +03:00
|
|
|
show: ['- Window/',
|
|
|
|
|
function(){
|
|
|
|
|
nw.Window.get().show() }],
|
2017-10-04 17:07:22 +03:00
|
|
|
minimize: ['Window/Minimize',
|
|
|
|
|
function(){
|
|
|
|
|
nw.Window.get().minimize() }],
|
|
|
|
|
toggleFullScreen: ['Window/Full screen mode',
|
|
|
|
|
toggler.CSSClassToggler(
|
|
|
|
|
function(){ return document.body },
|
|
|
|
|
'.full-screen-mode',
|
|
|
|
|
function(action){
|
|
|
|
|
var that = this
|
|
|
|
|
var w = nw.Window.get()
|
|
|
|
|
|
|
|
|
|
// change the state only if the target state is not the same
|
|
|
|
|
// as the current state...
|
|
|
|
|
if((w.isFullscreen ? 'on' : 'off') != action){
|
|
|
|
|
this.ribbons.preventTransitions()
|
|
|
|
|
|
|
|
|
|
// hide the viewer to hide any animation crimes...
|
|
|
|
|
this.dom[0].style.visibility = 'hidden'
|
|
|
|
|
|
|
|
|
|
// XXX async...
|
|
|
|
|
// ...this complicates things as we need to do the next
|
|
|
|
|
// bit AFTER the resize is done...
|
|
|
|
|
w.toggleFullscreen()
|
|
|
|
|
|
|
|
|
|
setTimeout(function(){
|
|
|
|
|
that
|
|
|
|
|
.centerViewer()
|
|
|
|
|
.focusImage()
|
|
|
|
|
.ribbons
|
|
|
|
|
.restoreTransitions()
|
|
|
|
|
|
|
|
|
|
that.dom[0].style.visibility = ''
|
|
|
|
|
}, 100)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NOTE: we delay this to account for window animation...
|
|
|
|
|
setTimeout(function(){
|
|
|
|
|
that.storeWindowGeometry()
|
|
|
|
|
}, 500)
|
|
|
|
|
})],
|
|
|
|
|
|
|
|
|
|
// XXX add ability to use devtools on background page (node context)...
|
|
|
|
|
showDevTools: ['Interface|Development/Show Dev Tools',
|
|
|
|
|
function(){
|
|
|
|
|
nw.Window.get().showDevTools &&
|
|
|
|
|
nw.Window.get().showDevTools()
|
|
|
|
|
}],
|
|
|
|
|
showInFolder: ['File|Image/Show in $folder',
|
|
|
|
|
function(image){
|
|
|
|
|
image = this.images[this.data.getImage(image)]
|
|
|
|
|
|
|
|
|
|
var base = image.base_path || this.location.path
|
|
|
|
|
var filename = image.path
|
|
|
|
|
var path = pathlib.normalize(base + '/' + filename)
|
|
|
|
|
|
|
|
|
|
nw.Shell.showItemInFolder(path)
|
|
|
|
|
}],
|
2017-11-03 03:22:02 +03:00
|
|
|
|
|
|
|
|
toggleSplashScreen: ['Interface/',
|
|
|
|
|
function(){
|
|
|
|
|
}],
|
2017-10-04 17:07:22 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
var NWHost =
|
|
|
|
|
module.NWHost = core.ImageGridFeatures.Feature({
|
|
|
|
|
title: '',
|
|
|
|
|
doc: '',
|
|
|
|
|
|
|
|
|
|
tag: 'ui-nw-host',
|
|
|
|
|
exclusive: 'ui-host',
|
|
|
|
|
depends: [],
|
|
|
|
|
|
|
|
|
|
actions: NWHostActions,
|
|
|
|
|
|
|
|
|
|
isApplicable: function(){ return this.runtime.nw },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
var ElectronHostActions = actions.Actions({
|
2017-10-04 18:20:44 +03:00
|
|
|
// window stuff...
|
2017-10-05 02:01:54 +03:00
|
|
|
// XXX should this be nested in a .window object???
|
|
|
|
|
// XXX should these be props or methods???
|
2017-10-04 17:07:22 +03:00
|
|
|
get title(){
|
2017-10-04 18:17:01 +03:00
|
|
|
return electron.remote.getCurrentWindow().getTitle() },
|
2017-10-04 17:07:22 +03:00
|
|
|
set title(value){
|
2017-10-04 18:17:01 +03:00
|
|
|
electron.remote.getCurrentWindow().setTitle(value) },
|
2017-10-05 02:01:54 +03:00
|
|
|
get size(){
|
|
|
|
|
return electron.remote.getCurrentWindow().getSize() },
|
|
|
|
|
set size(value){
|
2017-11-01 04:53:36 +03:00
|
|
|
value && electron.remote.getCurrentWindow().setSize(value[0], value[1]) },
|
2017-10-05 02:01:54 +03:00
|
|
|
get position(){
|
|
|
|
|
return electron.remote.getCurrentWindow().getPosition() },
|
|
|
|
|
set position(value){
|
2017-11-01 04:53:36 +03:00
|
|
|
value && electron.remote.getCurrentWindow().setPosition(value[0], value[1]) },
|
2017-10-05 02:01:54 +03:00
|
|
|
|
|
|
|
|
show: ['- Window/',
|
|
|
|
|
function(){
|
|
|
|
|
electron.remote.getCurrentWindow().show() }],
|
2017-10-04 17:07:22 +03:00
|
|
|
minimize: ['Window/Minimize',
|
|
|
|
|
function(){
|
2017-10-04 18:17:01 +03:00
|
|
|
electron.remote.getCurrentWindow().minimize() }],
|
2017-10-04 17:07:22 +03:00
|
|
|
// XXX this is almost generic, but it is not usable unless within
|
|
|
|
|
// a user event handler...
|
|
|
|
|
// ...can we use this on electron???
|
2017-10-04 18:17:01 +03:00
|
|
|
// if this fails use:
|
|
|
|
|
// electron.remote.getCurrentWindow().isFullScreen(..)
|
|
|
|
|
// electron.remote.getCurrentWindow().setFullScreen(..)
|
2017-10-04 17:07:22 +03:00
|
|
|
toggleFullScreen: ['Window/Full screen mode',
|
|
|
|
|
toggler.CSSClassToggler(
|
|
|
|
|
function(){ return document.body },
|
|
|
|
|
'.full-screen-mode',
|
|
|
|
|
function(action){
|
|
|
|
|
var that = this
|
2017-10-05 02:01:54 +03:00
|
|
|
var win = electron.remote.getCurrentWindow()
|
2017-10-04 17:07:22 +03:00
|
|
|
|
2017-10-05 02:01:54 +03:00
|
|
|
var state = win.isFullScreen() ? 'on' : 'off'
|
2017-10-04 17:07:22 +03:00
|
|
|
|
|
|
|
|
// change the state only if the target state is not the same
|
|
|
|
|
// as the current state...
|
|
|
|
|
if(state != action){
|
|
|
|
|
this.ribbons.preventTransitions()
|
|
|
|
|
|
|
|
|
|
// hide the viewer to hide any animation crimes...
|
|
|
|
|
this.dom[0].style.visibility = 'hidden'
|
|
|
|
|
|
|
|
|
|
// XXX async...
|
|
|
|
|
// ...this complicates things as we need to do the next
|
|
|
|
|
// bit AFTER the resize is done...
|
2017-10-05 02:01:54 +03:00
|
|
|
win.setFullScreen(action == 'on' ? true : false)
|
2017-10-04 17:07:22 +03:00
|
|
|
|
|
|
|
|
setTimeout(function(){
|
|
|
|
|
that
|
|
|
|
|
.centerViewer()
|
|
|
|
|
.focusImage()
|
|
|
|
|
.ribbons
|
|
|
|
|
.restoreTransitions()
|
|
|
|
|
|
|
|
|
|
that.dom[0].style.visibility = ''
|
|
|
|
|
}, 100)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NOTE: we delay this to account for window animation...
|
|
|
|
|
setTimeout(function(){
|
|
|
|
|
that.storeWindowGeometry()
|
|
|
|
|
}, 500)
|
|
|
|
|
})],
|
2017-10-04 18:20:44 +03:00
|
|
|
|
|
|
|
|
showDevTools: ['Interface|Development/Show Dev Tools',
|
|
|
|
|
function(){
|
|
|
|
|
electron.remote.getCurrentWindow().openDevTools() }],
|
|
|
|
|
// XXX make this portable (osx, linux)...
|
|
|
|
|
showInFolder: ['File|Image/Show in $folder',
|
|
|
|
|
function(image){
|
|
|
|
|
image = this.images[this.data.getImage(image)]
|
|
|
|
|
|
|
|
|
|
var base = image.base_path || this.location.path
|
|
|
|
|
var filename = image.path
|
|
|
|
|
var path = pathlib.normalize(base + '/' + filename)
|
|
|
|
|
|
|
|
|
|
requirejs('child_process')
|
|
|
|
|
// XXX make this portable (osx, linux)...
|
|
|
|
|
.exec('explorer.exe /select,'+JSON.stringify(path.replace(/\//g, '\\')))
|
|
|
|
|
//.exec('open -R '+JSON.stringify(path))
|
|
|
|
|
}],
|
2017-11-03 03:22:02 +03:00
|
|
|
|
|
|
|
|
// XXX make this a real toggler...
|
|
|
|
|
toggleSplashScreen: ['Interface/',
|
|
|
|
|
function(){
|
|
|
|
|
var splash = this.splash = new electron.BrowserWindow({
|
|
|
|
|
// let the window to get ready before we show it to the user...
|
|
|
|
|
//show: false,
|
|
|
|
|
|
|
|
|
|
frame: false,
|
|
|
|
|
center: true,
|
|
|
|
|
//backgroundColor: XXX,
|
|
|
|
|
width: 500,
|
|
|
|
|
height: 500,
|
|
|
|
|
|
|
|
|
|
alwaysOnTop: true,
|
|
|
|
|
|
|
|
|
|
resizable: false,
|
|
|
|
|
movable: false,
|
|
|
|
|
minimizable: false,
|
|
|
|
|
maximizable: false,
|
|
|
|
|
fullscreenable: false,
|
|
|
|
|
|
|
|
|
|
autoHideMenuBar: true,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
splash.setMenu(null)
|
|
|
|
|
|
|
|
|
|
// and load the index.html of the app.
|
|
|
|
|
splash.loadURL(url.format({
|
|
|
|
|
// XXX unify this with index.html
|
|
|
|
|
pathname: path.join(__dirname, 'splash.html'),
|
|
|
|
|
protocol: 'file:',
|
|
|
|
|
slashes: true
|
|
|
|
|
}))
|
|
|
|
|
}],
|
2017-10-04 17:07:22 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
var ElectronHost =
|
|
|
|
|
module.ElectronHost = core.ImageGridFeatures.Feature({
|
|
|
|
|
title: '',
|
|
|
|
|
doc: '',
|
|
|
|
|
|
|
|
|
|
tag: 'ui-electron-host',
|
|
|
|
|
exclusive: 'ui-host',
|
|
|
|
|
depends: [],
|
|
|
|
|
|
|
|
|
|
actions: ElectronHostActions,
|
|
|
|
|
|
|
|
|
|
isApplicable: function(){ return this.runtime.electron },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
|
|
2015-12-17 03:34:20 +03:00
|
|
|
var AppControlActions = actions.Actions({
|
|
|
|
|
config: {
|
2017-01-09 05:11:29 +03:00
|
|
|
//'window-title': 'ImageGrid.Viewer (${VERSION}): ${FILENAME}',
|
|
|
|
|
'window-title': '${FILENAME} - ImageGrid.Viewer (${VERSION})',
|
2016-04-15 02:09:02 +03:00
|
|
|
|
|
|
|
|
'window-delay-initial-display': 200,
|
2017-11-03 03:22:02 +03:00
|
|
|
|
|
|
|
|
'show-splash-screen': 'on',
|
2015-12-17 03:34:20 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// XXX revise these...
|
2016-12-20 06:11:00 +03:00
|
|
|
close: ['File|Window/Close viewer',
|
2015-12-17 03:34:20 +03:00
|
|
|
function(){ window.close() }],
|
2016-12-20 06:11:00 +03:00
|
|
|
storeWindowGeometry: ['- Window/Store window state',
|
2015-12-17 03:34:20 +03:00
|
|
|
function(){
|
|
|
|
|
// store window parameters (size, state)...
|
2017-10-05 02:01:54 +03:00
|
|
|
//var win = nw.Window.get()
|
|
|
|
|
var size = this.size
|
|
|
|
|
var position = this.position
|
2015-12-17 03:34:20 +03:00
|
|
|
|
|
|
|
|
// fullscreen...
|
|
|
|
|
// ...avoid overwriting size...
|
2016-04-09 18:39:01 +03:00
|
|
|
if(this.toggleFullScreen('?') == 'on'){
|
2015-12-17 03:34:20 +03:00
|
|
|
this.config.window = this.config.window || {}
|
|
|
|
|
this.config.window.fullscreen = true
|
2017-10-05 02:01:54 +03:00
|
|
|
//this.config.window.zoom = win.zoomLevel
|
2015-12-17 03:34:20 +03:00
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
this.config.window = {
|
|
|
|
|
size: {
|
2017-10-05 02:01:54 +03:00
|
|
|
width: size[0],
|
|
|
|
|
height: size[1],
|
2015-12-17 03:34:20 +03:00
|
|
|
},
|
2017-10-05 02:01:54 +03:00
|
|
|
// XXX position...
|
2015-12-17 03:34:20 +03:00
|
|
|
fullscreen: false,
|
2017-10-05 02:01:54 +03:00
|
|
|
//zoom: win.zoomLevel,
|
2015-12-17 03:34:20 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}],
|
2016-12-20 06:11:00 +03:00
|
|
|
restoreWindowGeometry: ['- Window/Restore window state',
|
2015-12-17 03:34:20 +03:00
|
|
|
function(){
|
2016-05-08 15:58:22 +03:00
|
|
|
var that = this
|
2015-12-17 03:34:20 +03:00
|
|
|
// or global.window.nwDispatcher.requireNwGui()
|
|
|
|
|
// (see: https://github.com/rogerwang/node-webkit/issues/707)
|
2017-10-05 02:01:54 +03:00
|
|
|
//var win = nw.Window.get()
|
2015-12-17 03:34:20 +03:00
|
|
|
|
|
|
|
|
// XXX move this into .restoreWindowGeometry(..)
|
|
|
|
|
// get window state from config and load it...
|
|
|
|
|
var cfg = this.config.window
|
|
|
|
|
if(cfg != null){
|
|
|
|
|
var W = screen.width
|
|
|
|
|
var H = screen.height
|
|
|
|
|
var w = 800
|
|
|
|
|
var h = 600
|
2017-10-05 02:01:54 +03:00
|
|
|
//var s = cfg.scale
|
2015-12-17 03:34:20 +03:00
|
|
|
|
|
|
|
|
if(cfg.size){
|
2017-10-05 02:01:54 +03:00
|
|
|
//w = win.width = Math.min(cfg.size.width, screen.width)
|
|
|
|
|
//h = win.height = Math.min(cfg.size.height, screen.height)
|
|
|
|
|
w = Math.min(cfg.size.width, screen.width)
|
|
|
|
|
h = Math.min(cfg.size.height, screen.height)
|
|
|
|
|
this.size = [w, h]
|
2015-12-17 03:34:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// place on center of the screen...
|
2017-10-05 02:01:54 +03:00
|
|
|
//var x = win.x = Math.round((W - w)/2)
|
|
|
|
|
//var y = win.y = Math.round((H - h)/2)
|
|
|
|
|
var x = Math.round((W - w)/2)
|
|
|
|
|
var y = Math.round((H - h)/2)
|
|
|
|
|
this.position = [x, y]
|
2015-12-17 03:34:20 +03:00
|
|
|
|
2017-10-05 02:01:54 +03:00
|
|
|
//if(s){
|
|
|
|
|
// win.zoomLevel = s
|
|
|
|
|
//}
|
2015-12-17 03:34:20 +03:00
|
|
|
|
|
|
|
|
//console.log('GEOMETRY:', w, h, x, y)
|
|
|
|
|
|
|
|
|
|
this.centerViewer()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XXX still buggy....
|
|
|
|
|
// restore interface scale...
|
|
|
|
|
this.toggleInterfaceScale(
|
|
|
|
|
this.config['ui-scale-mode']
|
|
|
|
|
|| this.toggleInterfaceScale('??')[0])
|
|
|
|
|
*/
|
2016-04-15 02:09:02 +03:00
|
|
|
|
|
|
|
|
// NOTE: we delay this to enable the browser time to render
|
|
|
|
|
// things before we show them to the user...
|
|
|
|
|
setTimeout(function(){
|
2017-10-05 02:01:54 +03:00
|
|
|
that.show()
|
2016-04-15 02:09:02 +03:00
|
|
|
|
|
|
|
|
// XXX check if we are full screen...
|
2016-05-08 19:03:04 +03:00
|
|
|
if(cfg != null && cfg.fullscreen){
|
2016-05-08 15:58:22 +03:00
|
|
|
that.toggleFullScreen('on')
|
2016-04-15 02:09:02 +03:00
|
|
|
}
|
2017-01-26 07:01:20 +03:00
|
|
|
|
|
|
|
|
// declare we are ready...
|
|
|
|
|
$(function(){ that.declareReady() })
|
|
|
|
|
|
2016-04-15 02:09:02 +03:00
|
|
|
}, this.config['window-delay-initial-display'] || 0)
|
2015-12-17 03:34:20 +03:00
|
|
|
}],
|
2017-11-03 03:22:02 +03:00
|
|
|
|
|
|
|
|
toggleSplashScreenShowing: ['Interface/Splash screen on start',
|
|
|
|
|
core.makeConfigToggler('show-splash-screen', ['on', 'off'])],
|
2015-12-17 03:34:20 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// XXX store/load window state...
|
|
|
|
|
// - size
|
|
|
|
|
// - state (fullscreen/normal)
|
|
|
|
|
var AppControl =
|
|
|
|
|
module.AppControl = core.ImageGridFeatures.Feature({
|
|
|
|
|
title: '',
|
|
|
|
|
doc: '',
|
|
|
|
|
|
2015-12-31 10:37:21 +03:00
|
|
|
tag: 'ui-app-control',
|
2015-12-17 03:34:20 +03:00
|
|
|
depends: [
|
|
|
|
|
'ui',
|
2017-10-04 17:07:22 +03:00
|
|
|
'ui-host',
|
2015-12-17 03:34:20 +03:00
|
|
|
],
|
|
|
|
|
|
|
|
|
|
actions: AppControlActions,
|
|
|
|
|
|
2017-10-06 17:43:02 +03:00
|
|
|
// XXX BUG: when running in electron:
|
|
|
|
|
// - loading this breaks the other buttons (menu, collections, ...)
|
|
|
|
|
// - .toggleFullScreen(..) works in an odd manner -- ok when
|
|
|
|
|
// explicitly called or button pushed but in opposite manner
|
|
|
|
|
// when F11 (FIXED?)
|
|
|
|
|
// - ready protocol breaks -- need to call .ready() to unstall
|
|
|
|
|
// the viewer
|
|
|
|
|
// ...does this all have anything to do with double init???
|
2017-11-01 04:53:36 +03:00
|
|
|
isApplicable: function(){ return this.runtime.desktop },
|
|
|
|
|
//isApplicable: function(){ return this.runtime.desktop && !this.runtime.electron },
|
2015-12-17 03:34:20 +03:00
|
|
|
|
|
|
|
|
// XXX show main window...
|
|
|
|
|
handlers: [
|
2017-01-26 07:01:20 +03:00
|
|
|
['start.pre',
|
|
|
|
|
function(){
|
|
|
|
|
// we are going to declare ready ourselves...
|
2017-10-05 02:01:54 +03:00
|
|
|
this.requestReadyAnnounce() }],
|
2015-12-17 03:34:20 +03:00
|
|
|
['start',
|
|
|
|
|
function(){
|
2017-10-05 02:01:54 +03:00
|
|
|
this.restoreWindowGeometry() }],
|
2015-12-17 03:34:20 +03:00
|
|
|
[[
|
|
|
|
|
'close.pre',
|
|
|
|
|
'toggleFullScreen',
|
|
|
|
|
],
|
|
|
|
|
function(){ this.storeWindowGeometry() }],
|
2017-10-04 17:07:22 +03:00
|
|
|
|
|
|
|
|
// update window title...
|
|
|
|
|
// XXX make this generic...
|
2015-12-17 03:34:20 +03:00
|
|
|
['focusImage',
|
|
|
|
|
function(){
|
|
|
|
|
if(this.images){
|
|
|
|
|
var img = this.images[this.current]
|
2017-10-04 17:07:22 +03:00
|
|
|
this.title = (this.config['window-title']
|
2015-12-17 03:34:20 +03:00
|
|
|
|| 'ImageGrid.Viewer (${VERSION}): ${FILENAME}')
|
|
|
|
|
// XXX get this from the viewer...
|
|
|
|
|
.replace('${VERSION}', this.version || 'gen4')
|
|
|
|
|
.replace('${FILENAME}',
|
2016-04-08 19:28:38 +03:00
|
|
|
img ?
|
|
|
|
|
(img.name || img.path.replace(/\.[\\\/]/, ''))
|
|
|
|
|
: '')
|
2015-12-17 03:34:20 +03:00
|
|
|
.replace('${PATH}',
|
2016-04-08 19:28:38 +03:00
|
|
|
img ?
|
|
|
|
|
(img.base_path || '.')
|
|
|
|
|
+'/'+ img.path.replace(/\.[\\\/]/, '')
|
|
|
|
|
: '')
|
2015-12-17 03:34:20 +03:00
|
|
|
/*
|
|
|
|
|
.replace('${DIR}',
|
|
|
|
|
pathlib.dirname((img.base_path || '.')
|
|
|
|
|
+'/'+ img.path.replace(/\.[\\\/]/, '')))
|
|
|
|
|
*/
|
|
|
|
|
// XXX add ...
|
|
|
|
|
}
|
|
|
|
|
}],
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-05 01:32:47 +03:00
|
|
|
//---------------------------------------------------------------------
|
|
|
|
|
// Fullscreen app control buttons...
|
2016-12-03 00:05:31 +03:00
|
|
|
var AppButtonsActions = actions.Actions({
|
2016-11-08 21:16:33 +03:00
|
|
|
config: {
|
2016-11-15 22:15:14 +03:00
|
|
|
'app-buttons': {
|
2016-11-16 04:57:31 +03:00
|
|
|
// XXX not sure about this...
|
|
|
|
|
'⛭': ['ui-settings allways-shown',
|
|
|
|
|
'browseActions: "Interface/" -- Interface settings...'],
|
2016-11-08 21:16:33 +03:00
|
|
|
'_': ['minimize',
|
|
|
|
|
'minimize -- Minimize'],
|
|
|
|
|
'↙': ['fullscreen allways-shown',
|
|
|
|
|
'toggleFullScreen -- Toggle fullscreen'],
|
|
|
|
|
'×': ['close',
|
|
|
|
|
'close -- Quit'],
|
|
|
|
|
},
|
|
|
|
|
},
|
2016-05-05 01:32:47 +03:00
|
|
|
})
|
|
|
|
|
|
2016-12-03 00:05:31 +03:00
|
|
|
var AppButtons =
|
|
|
|
|
module.AppButtons = core.ImageGridFeatures.Feature({
|
2016-05-05 01:32:47 +03:00
|
|
|
title: '',
|
|
|
|
|
doc: '',
|
|
|
|
|
|
2016-11-15 22:15:14 +03:00
|
|
|
tag: 'ui-app-buttons',
|
2016-05-05 01:32:47 +03:00
|
|
|
depends: [
|
|
|
|
|
'ui-app-control',
|
2016-11-16 16:18:22 +03:00
|
|
|
'ui-buttons',
|
2016-11-09 04:53:42 +03:00
|
|
|
],
|
|
|
|
|
suggested: [
|
|
|
|
|
// needed for reporting info in .makeButtonControls(..)
|
|
|
|
|
'ui-status-bar',
|
2016-05-05 01:32:47 +03:00
|
|
|
],
|
|
|
|
|
|
2016-12-03 00:05:31 +03:00
|
|
|
actions: AppButtonsActions,
|
2016-05-05 01:32:47 +03:00
|
|
|
|
|
|
|
|
handlers: [
|
2016-12-03 00:05:31 +03:00
|
|
|
['start.pre',
|
2016-05-05 01:32:47 +03:00
|
|
|
function(){
|
2016-11-15 22:15:14 +03:00
|
|
|
this.toggleAppButtons('on')
|
2016-12-03 00:05:31 +03:00
|
|
|
}],
|
|
|
|
|
['start toggleFullScreen',
|
|
|
|
|
function(){
|
2016-11-08 19:26:47 +03:00
|
|
|
var fullscreen = this.toggleFullScreen('?')
|
2017-05-16 00:26:37 +03:00
|
|
|
var buttons = this.dom.find('.app-buttons')
|
2016-11-08 19:26:47 +03:00
|
|
|
|
|
|
|
|
// fullscreen button...
|
|
|
|
|
buttons.find('.fullscreen.button')
|
|
|
|
|
.html(fullscreen == 'on' ? '↙' : '↗')
|
|
|
|
|
.attr('info', fullscreen == 'on' ? 'Exit fullscreen' : 'Fullscreen')
|
|
|
|
|
|
|
|
|
|
// XXX should this be done by css???
|
|
|
|
|
if(fullscreen == 'on'){
|
|
|
|
|
buttons.find('.button:not(.allways-shown)').show()
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
buttons.find('.button:not(.allways-shown)').hide()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//this.toggleFullScreenControls(fullScreen)
|
2016-05-05 01:32:47 +03:00
|
|
|
}],
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-12-17 03:34:20 +03:00
|
|
|
/**********************************************************************
|
2016-08-20 22:49:36 +03:00
|
|
|
* vim:set ts=4 sw=4 : */ return module })
|