mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
migrated to nw.js v0.13.x
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
31656e0203
commit
7041714454
@ -11,6 +11,8 @@
|
||||
|
||||
APP_NAME=ImageGrid.Viewer
|
||||
|
||||
NODE_VERSION=v5.10.0
|
||||
|
||||
|
||||
# process LESS files to CSS...
|
||||
%.css: %.less
|
||||
@ -120,6 +122,10 @@ zip: $(APP_ZIP)
|
||||
node-deps:
|
||||
npm install
|
||||
|
||||
sharp: node-deps
|
||||
cd node_modules/sharp/
|
||||
node-gyp --target=$(NODE_VERSION) rebuild
|
||||
|
||||
css: $(CSS_FILES)
|
||||
|
||||
dev: css
|
||||
|
||||
@ -10,6 +10,7 @@ define(function(require){ var module = {}
|
||||
|
||||
var actions = require('lib/actions')
|
||||
var features = require('lib/features')
|
||||
var toggler = require('lib/toggler')
|
||||
|
||||
var core = require('features/core')
|
||||
var base = require('features/base')
|
||||
@ -31,12 +32,11 @@ var AppControlActions = actions.Actions({
|
||||
storeWindowGeometry: ['- Interface/Store window state',
|
||||
function(){
|
||||
// store window parameters (size, state)...
|
||||
var gui = requirejs('nw.gui')
|
||||
var win = gui.Window.get()
|
||||
var win = nw.Window.get()
|
||||
|
||||
// fullscreen...
|
||||
// ...avoid overwriting size...
|
||||
if(win.isFullscreen){
|
||||
if(this.toggleFullScreen('?') == 'on'){
|
||||
this.config.window = this.config.window || {}
|
||||
this.config.window.fullscreen = true
|
||||
this.config.window.zoom = win.zoomLevel
|
||||
@ -56,8 +56,7 @@ var AppControlActions = actions.Actions({
|
||||
function(){
|
||||
// or global.window.nwDispatcher.requireNwGui()
|
||||
// (see: https://github.com/rogerwang/node-webkit/issues/707)
|
||||
var gui = requirejs('nw.gui')
|
||||
var win = gui.Window.get()
|
||||
var win = nw.Window.get()
|
||||
|
||||
// XXX move this into .restoreWindowGeometry(..)
|
||||
// get window state from config and load it...
|
||||
@ -92,7 +91,7 @@ var AppControlActions = actions.Actions({
|
||||
|
||||
// XXX check if we are full screen...
|
||||
if(cfg != null && cfg.fullscreen && !win.isFullscreen){
|
||||
this.toggleFullScreen()
|
||||
this.toggleFullScreen('on')
|
||||
}
|
||||
|
||||
/* XXX still buggy....
|
||||
@ -102,18 +101,27 @@ var AppControlActions = actions.Actions({
|
||||
|| this.toggleInterfaceScale('??')[0])
|
||||
*/
|
||||
}],
|
||||
|
||||
toggleFullScreen: ['Interface/Toggle full screen mode',
|
||||
function(){
|
||||
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.ribbons.viewer[0].style.visibility = 'hidden'
|
||||
|
||||
// XXX where should toggleFullscreenMode(..) be defined...
|
||||
// ...this also toggles a fullscreen css class on body...
|
||||
toggleFullscreenMode()
|
||||
//requirejs('nw.gui').Window.get().toggleFullscreen()
|
||||
// XXX async...
|
||||
// ...this complicates things as we need to do the next
|
||||
// bit AFTER the resize is done...
|
||||
w.toggleFullscreen()
|
||||
|
||||
setTimeout(function(){
|
||||
that
|
||||
@ -123,13 +131,18 @@ var AppControlActions = actions.Actions({
|
||||
.restoreTransitions()
|
||||
|
||||
that.ribbons.viewer[0].style.visibility = ''
|
||||
}, 0)
|
||||
}],
|
||||
}, 100)
|
||||
}
|
||||
|
||||
// NOTE: we delay this to account for window animation...
|
||||
setTimeout(function(){
|
||||
that.storeWindowGeometry()
|
||||
}, 500)
|
||||
})],
|
||||
showDevTools: ['Interface|Development/Show Dev Tools',
|
||||
function(){
|
||||
if(window.showDevTools != null){
|
||||
showDevTools()
|
||||
}
|
||||
nw.Window.get().showDevTools &&
|
||||
nw.Window.get().showDevTools()
|
||||
}],
|
||||
})
|
||||
|
||||
@ -174,8 +187,7 @@ module.AppControl = core.ImageGridFeatures.Feature({
|
||||
function(){ this.storeWindowGeometry() }],
|
||||
['focusImage',
|
||||
function(){
|
||||
var gui = requirejs('nw.gui')
|
||||
var win = gui.Window.get()
|
||||
var win = nw.Window.get()
|
||||
|
||||
if(this.images){
|
||||
var img = this.images[this.current]
|
||||
|
||||
@ -119,7 +119,7 @@ module.CLI = core.ImageGridFeatures.Feature({
|
||||
// ig lf sm lf
|
||||
// ...this will print the list of features before
|
||||
// and after setup...
|
||||
.option('sm, --setup-minimal', 'setup minimap features', function(){
|
||||
.option('sm, --setup-minimal', 'setup minimal features', function(){
|
||||
// load features we might need...
|
||||
// XXX require js loads these at the root...
|
||||
var location = require('features/location')
|
||||
|
||||
@ -51,25 +51,27 @@ var ImageGridFeatures =
|
||||
module.ImageGridFeatures = Object.create(features.FeatureSet)
|
||||
|
||||
|
||||
// setup exit...
|
||||
// nw or node...
|
||||
if(typeof(process) != 'undefined'){
|
||||
|
||||
// NOTE: if this passes it is async while when fails it's sync, this
|
||||
// is why we set .runtime to 'nw' optimistically in advance so
|
||||
// as not to wait if all goes well and set it to 'node' in the
|
||||
// callback that if fails will fail right away...
|
||||
// nw.js 0.13+
|
||||
if(typeof(nw) != 'undefined'){
|
||||
ImageGridFeatures.runtime = 'nw'
|
||||
requirejs(['nw.gui'],
|
||||
// OK: nw.js
|
||||
function(){},
|
||||
// ERR: pure node.js...
|
||||
function(){ ImageGridFeatures.runtime = 'node' })
|
||||
|
||||
// node...
|
||||
} else {
|
||||
ImageGridFeatures.runtime = 'node'
|
||||
}
|
||||
|
||||
// browser...
|
||||
// NOTE: we're avoiding detecting browser specifics for as long as possible,
|
||||
// this will minimize the headaches of supporting several non-standard
|
||||
// versions of code...
|
||||
} else if(typeof(window) != 'undefined'){
|
||||
ImageGridFeatures.runtime = 'browser'
|
||||
|
||||
// unknown...
|
||||
// XXX do we need to detect chrome app???
|
||||
} else {
|
||||
ImageGridFeatures.runtime = 'unknown'
|
||||
}
|
||||
@ -101,8 +103,6 @@ var LifeCycleActions = actions.Actions({
|
||||
|
||||
// nw.js...
|
||||
if(runtime == 'nw'){
|
||||
var gui = requirejs('nw.gui')
|
||||
|
||||
// this handles both reload and close...
|
||||
$(window).on('beforeunload', stop)
|
||||
|
||||
@ -117,7 +117,9 @@ var LifeCycleActions = actions.Actions({
|
||||
// wait till ALL the handlers finish before
|
||||
// exiting...
|
||||
.on('stop.post', function(){
|
||||
w.close(true)
|
||||
// XXX might be broken in nw13 -- test!!!
|
||||
//w.close(true)
|
||||
nw.App.quit()
|
||||
})
|
||||
.stop()
|
||||
|
||||
@ -127,8 +129,7 @@ var LifeCycleActions = actions.Actions({
|
||||
this.close(true)
|
||||
}
|
||||
}
|
||||
gui.Window.get().on('close', this.__nw_stop_handler)
|
||||
|
||||
nw.Window.get().on('close', this.__nw_stop_handler)
|
||||
|
||||
// node.js...
|
||||
} else if(runtime == 'node'){
|
||||
@ -154,8 +155,7 @@ var LifeCycleActions = actions.Actions({
|
||||
|
||||
// nw...
|
||||
if(this.__nw_stop_handler && this.runtime == 'nw'){
|
||||
var gui = requirejs('nw.gui')
|
||||
//gui.Window.get().off('close', this.__nw_stop_handler)
|
||||
//nw.Window.get().off('close', this.__nw_stop_handler)
|
||||
delete this.__nw_stop_handler
|
||||
}
|
||||
|
||||
|
||||
@ -5,9 +5,6 @@
|
||||
**********************************************************************/
|
||||
if(window.nodejs != null){
|
||||
|
||||
// node-webkit specific modules...
|
||||
var gui = require('nw.gui')
|
||||
|
||||
define(function(require){ var module = {}
|
||||
|
||||
var toggler = require('lib/toggler')
|
||||
@ -29,20 +26,20 @@ module.toggleFullscreenMode = toggler.CSSClassToggler(
|
||||
document.body,
|
||||
'.full-screen-mode',
|
||||
function(action){
|
||||
gui.Window.get().toggleFullscreen()
|
||||
nw.Window.get().toggleFullscreen()
|
||||
})
|
||||
|
||||
|
||||
window.showDevTools =
|
||||
module.showDevTools = function(){
|
||||
gui.Window.get().showDevTools()
|
||||
nw.Window.get().showDevTools()
|
||||
}
|
||||
|
||||
|
||||
window.setWindowTitle =
|
||||
module.setWindowTitle = function(text){
|
||||
browser.setWindowTitle(test)
|
||||
gui.Window.get().title = title
|
||||
nw.Window.get().title = title
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user