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