mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
some refactoring + tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
f6790eb500
commit
e957b10437
@ -231,6 +231,9 @@ var FeatureSet =
|
||||
module.FeatureSet = {
|
||||
__feature__: Feature,
|
||||
|
||||
// if true, .setup(..) will report things it's doing...
|
||||
__verbose__: null,
|
||||
|
||||
// Build feature list...
|
||||
//
|
||||
// Build a list of all registered features
|
||||
@ -541,13 +544,13 @@ module.FeatureSet = {
|
||||
}
|
||||
|
||||
// report excluded features...
|
||||
if(features.excluded.length > 0){
|
||||
if(this.__verbose__ && features.excluded.length > 0){
|
||||
console.warn('Excluded features due to exclusivity conflict:',
|
||||
features.excluded.join(', '))
|
||||
}
|
||||
|
||||
// report unapplicable features...
|
||||
if(features.unapplicable.length > 0){
|
||||
if(this.__verbose__ && features.unapplicable.length > 0){
|
||||
console.log('Features not applicable in current context:',
|
||||
features.unapplicable.join(', '))
|
||||
}
|
||||
@ -558,11 +561,14 @@ module.FeatureSet = {
|
||||
lst.forEach(function(n){
|
||||
// setup...
|
||||
if(that[n] != null){
|
||||
console.log('Setting up feature:', n)
|
||||
this.__verbose__ && console.log('Setting up feature:', n)
|
||||
setup.call(that[n], obj)
|
||||
}
|
||||
})
|
||||
|
||||
// XXX should we extend this if it already was in the object???
|
||||
obj.features = features
|
||||
|
||||
return obj
|
||||
},
|
||||
remove: function(obj, lst){
|
||||
|
||||
@ -261,7 +261,9 @@ module.GLOBAL_KEYBOARD = {
|
||||
$(function(){
|
||||
|
||||
// list all loaded modules...
|
||||
console.log('MODULES:', requirejs.s.contexts._.defined)
|
||||
var m = requirejs.s.contexts._.defined
|
||||
m = Object.keys(m).filter(function(e){ return m[e] != null })
|
||||
console.log('Modules (%d):', m.length, m)
|
||||
|
||||
// XXX stub action set -- this needs to be auto-generated...
|
||||
window.a = actions.Actions()
|
||||
@ -279,8 +281,20 @@ $(function(){
|
||||
])
|
||||
|
||||
|
||||
a.logger = a.logger || {emit: function(e, v){ console.log(' ', e, v) }}
|
||||
// report stuff...
|
||||
// XXX we also have .conflicts and .missing
|
||||
a.features.excluded.length > 0
|
||||
&& console.warn('Features excluded (%d):',
|
||||
a.features.excluded.length,
|
||||
a.features.excluded)
|
||||
console.log('Features not applicable (%d):',
|
||||
a.features.unapplicable.length,
|
||||
a.features.unapplicable)
|
||||
console.log('Features loaded (%d):',
|
||||
a.features.features.length,
|
||||
a.features.features)
|
||||
|
||||
a.logger = a.logger || {emit: function(e, v){ console.log(' ', e, v) }}
|
||||
|
||||
|
||||
// setup the viewer...
|
||||
|
||||
@ -153,16 +153,14 @@ module.ImageGridFeatures = Object.create(features.FeatureSet)
|
||||
// XXX should this be a generic library thing???
|
||||
// XXX should his have state???
|
||||
// ...if so, should this be a toggler???
|
||||
// XXX also need ability to unbind...
|
||||
var LifeCycleActions = actions.Actions({
|
||||
// XXX avoid binding multiple times per object...
|
||||
start: ['- System/',
|
||||
function(){
|
||||
var that = this
|
||||
this.logger && this.logger.emit('start')
|
||||
|
||||
// XXX HACK: need to check if actual events are bound...
|
||||
// XXX also need ability to unbind...
|
||||
// NOTE: jQuery currently provides no way to check if an event
|
||||
// is bound so we'll need to keep track manually...
|
||||
if(this.__stop_handler == null){
|
||||
var stop = this.__stop_handler = function(){ that.stop() }
|
||||
|
||||
@ -186,7 +184,7 @@ var LifeCycleActions = actions.Actions({
|
||||
// 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...
|
||||
gui.Window.get().on('close', function(){
|
||||
this.__nw_stop_handler = function(){
|
||||
var w = this
|
||||
try{
|
||||
that
|
||||
@ -202,7 +200,8 @@ var LifeCycleActions = actions.Actions({
|
||||
} catch(e){
|
||||
this.close(true)
|
||||
}
|
||||
})
|
||||
}
|
||||
gui.Window.get().on('close', this.__nw_stop_handler)
|
||||
|
||||
|
||||
// pure node.js...
|
||||
@ -224,13 +223,27 @@ var LifeCycleActions = actions.Actions({
|
||||
}
|
||||
|
||||
}],
|
||||
// unbind events...
|
||||
stop: ['- System/',
|
||||
function(){
|
||||
// unbind events...
|
||||
if(this.runtime == 'browser' || this.runtime == 'nw'){
|
||||
// browser & nw...
|
||||
if(this.__stop_handler
|
||||
&& (this.runtime == 'browser' || this.runtime == 'nw')){
|
||||
$(window).off('beforeunload', this.__stop_handler)
|
||||
}
|
||||
|
||||
// nw...
|
||||
if(this.__nw_stop_handler && this.runtime == 'nw'){
|
||||
var gui = requirejs('nw.gui')
|
||||
gui.Window.get().off('close', this.__nw_stop_handler)
|
||||
delete this.__nw_stop_handler
|
||||
}
|
||||
|
||||
// node...
|
||||
if(this.__stop_handler && this.runtime == 'node'){
|
||||
process.off('exit', this.__stop_handler)
|
||||
}
|
||||
|
||||
delete this.__stop_handler
|
||||
|
||||
this.logger && this.logger.emit('stop')
|
||||
@ -1570,7 +1583,10 @@ module.Viewer = ImageGridFeatures.Feature({
|
||||
|
||||
tag: 'ui',
|
||||
|
||||
depends: ['base'],
|
||||
depends: [
|
||||
'lifecycle',
|
||||
'base',
|
||||
],
|
||||
|
||||
actions: ViewerActions,
|
||||
|
||||
@ -3890,6 +3906,9 @@ module.AppControl = ImageGridFeatures.Feature({
|
||||
doc: '',
|
||||
|
||||
tag: 'app-control',
|
||||
depends: [
|
||||
'ui',
|
||||
],
|
||||
|
||||
actions: AppControlActions,
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user