mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-27 05:21:58 +00:00
reworked platform detection and some tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
4f12f725fb
commit
6b16845856
@ -21,6 +21,30 @@ var ImageGridFeatures =
|
|||||||
module.ImageGridFeatures = Object.create(features.FeatureSet)
|
module.ImageGridFeatures = Object.create(features.FeatureSet)
|
||||||
|
|
||||||
|
|
||||||
|
// setup exit...
|
||||||
|
if(typeof(process) != 'undefined'){
|
||||||
|
// nw.js...
|
||||||
|
try{
|
||||||
|
// this will fail if we're not in nw.js...
|
||||||
|
requirejs('nw.gui')
|
||||||
|
|
||||||
|
ImageGridFeatures.runtime = 'nw'
|
||||||
|
|
||||||
|
// pure node.js...
|
||||||
|
} catch(e) {
|
||||||
|
ImageGridFeatures.runtime = 'node'
|
||||||
|
}
|
||||||
|
|
||||||
|
// browser...
|
||||||
|
} else if(typeof('window') != 'undefined'){
|
||||||
|
ImageGridFeatures.runtime = 'browser'
|
||||||
|
|
||||||
|
// unknown...
|
||||||
|
} else {
|
||||||
|
ImageGridFeatures.runtime = 'unknown'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
@ -42,60 +66,52 @@ var LifeCycleActions = actions.Actions({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup exit...
|
// set the runtime...
|
||||||
if(typeof(process) != 'undefined'){
|
var runtime = this.runtime = ImageGridFeatures.runtime
|
||||||
// nw.js...
|
|
||||||
try{
|
|
||||||
this.runtime = 'nw'
|
|
||||||
|
|
||||||
// this will fail if we're not in nw.js...
|
// nw.js...
|
||||||
var gui = requirejs('nw.gui')
|
if(runtime == 'nw'){
|
||||||
|
var gui = requirejs('nw.gui')
|
||||||
// this handles both reload and close...
|
|
||||||
$(window).on('beforeunload', stop)
|
|
||||||
|
|
||||||
// NOTE: we are using both events as some of them do not
|
|
||||||
// get triggered in specific conditions and some do,
|
|
||||||
// for example, this gets triggered when the window's
|
|
||||||
// 'X' is clicked while does not on reload...
|
|
||||||
this.__nw_stop_handler = function(){
|
|
||||||
var w = this
|
|
||||||
try{
|
|
||||||
that
|
|
||||||
// wait till ALL the handlers finish before
|
|
||||||
// exiting...
|
|
||||||
.on('stop.post', function(){
|
|
||||||
w.close(true)
|
|
||||||
})
|
|
||||||
.stop()
|
|
||||||
|
|
||||||
// in case something breaks exit...
|
|
||||||
// XXX not sure if this is correct...
|
|
||||||
} catch(e){
|
|
||||||
this.close(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gui.Window.get().on('close', this.__nw_stop_handler)
|
|
||||||
|
|
||||||
|
|
||||||
// pure node.js...
|
|
||||||
} catch(e) {
|
|
||||||
this.runtime = 'node'
|
|
||||||
|
|
||||||
process.on('exit', stop)
|
|
||||||
}
|
|
||||||
|
|
||||||
// browser...
|
|
||||||
} else if(typeof('window') != 'undefined'){
|
|
||||||
this.runtime = 'browser'
|
|
||||||
|
|
||||||
|
// this handles both reload and close...
|
||||||
$(window).on('beforeunload', stop)
|
$(window).on('beforeunload', stop)
|
||||||
|
|
||||||
// unknown...
|
// NOTE: we are using both events as some of them do not
|
||||||
} else {
|
// get triggered in specific conditions and some do,
|
||||||
this.runtime = 'unknown'
|
// for example, this gets triggered when the window's
|
||||||
}
|
// 'X' is clicked while does not on reload...
|
||||||
|
this.__nw_stop_handler = function(){
|
||||||
|
var w = this
|
||||||
|
try{
|
||||||
|
that
|
||||||
|
// wait till ALL the handlers finish before
|
||||||
|
// exiting...
|
||||||
|
.on('stop.post', function(){
|
||||||
|
w.close(true)
|
||||||
|
})
|
||||||
|
.stop()
|
||||||
|
|
||||||
|
// in case something breaks exit...
|
||||||
|
// XXX not sure if this is correct...
|
||||||
|
} catch(e){
|
||||||
|
this.close(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gui.Window.get().on('close', this.__nw_stop_handler)
|
||||||
|
|
||||||
|
|
||||||
|
// node.js...
|
||||||
|
} else if(runtime == 'node'){
|
||||||
|
process.on('exit', stop)
|
||||||
|
|
||||||
|
// browser...
|
||||||
|
} else if(runtime == 'browser'){
|
||||||
|
$(window).on('beforeunload', stop)
|
||||||
|
|
||||||
|
// other...
|
||||||
|
} else {
|
||||||
|
// XXX
|
||||||
|
}
|
||||||
}],
|
}],
|
||||||
// unbind events...
|
// unbind events...
|
||||||
stop: ['- System/',
|
stop: ['- System/',
|
||||||
|
|||||||
@ -2781,7 +2781,6 @@ module.DirectControlGSAP = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
// XXX make this browser specific... (???)
|
// XXX make this browser specific... (???)
|
||||||
@ -2793,7 +2792,7 @@ module.URLHash = core.ImageGridFeatures.Feature({
|
|||||||
tag: 'ui-url-hash',
|
tag: 'ui-url-hash',
|
||||||
depends: ['ui'],
|
depends: ['ui'],
|
||||||
|
|
||||||
//isApplicable: function(){},
|
isApplicable: function(){ return this.runtime == 'browser' },
|
||||||
|
|
||||||
handlers: [
|
handlers: [
|
||||||
['focusImage',
|
['focusImage',
|
||||||
|
|||||||
@ -432,6 +432,7 @@ module.FeatureSet = {
|
|||||||
// clasify features...
|
// clasify features...
|
||||||
var unapplicable = []
|
var unapplicable = []
|
||||||
var conflicts = {}
|
var conflicts = {}
|
||||||
|
var that = this
|
||||||
lst = lst.filter(function(n, i){
|
lst = lst.filter(function(n, i){
|
||||||
var e = that[n]
|
var e = that[n]
|
||||||
if(e == null){
|
if(e == null){
|
||||||
@ -439,7 +440,7 @@ module.FeatureSet = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check applicability...
|
// check applicability...
|
||||||
if(!e.isApplicable(obj)){
|
if(!e.isApplicable.call(that, obj)){
|
||||||
unapplicable.push(n)
|
unapplicable.push(n)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user