diff --git a/ui (gen4)/browser.js b/ui (gen4)/browser.js
index d809d17c..022d9958 100755
--- a/ui (gen4)/browser.js
+++ b/ui (gen4)/browser.js
@@ -8,6 +8,8 @@ define(function(require){ var module = {}
//var DEBUG = DEBUG != null ? DEBUG : true
+var toggler = require('lib/toggler')
+
/*********************************************************************/
@@ -36,7 +38,7 @@ module.exitFullscreen = function() {
window.toggleFullscreenMode =
-module.toggleFullscreenMode = CSSClassToggler(
+module.toggleFullscreenMode = toggler.CSSClassToggler(
document.body,
'.full-screen-mode',
function(action){
diff --git a/ui (gen4)/features/app.js b/ui (gen4)/features/app.js
index 6b064949..69bf4dad 100755
--- a/ui (gen4)/features/app.js
+++ b/ui (gen4)/features/app.js
@@ -168,7 +168,7 @@ module.AppControl = core.ImageGridFeatures.Feature({
title: '',
doc: '',
- tag: 'app-control',
+ tag: 'ui-app-control',
depends: [
'ui',
],
@@ -179,7 +179,7 @@ module.AppControl = core.ImageGridFeatures.Feature({
// - chrome app
// - nw
// - mobile
- isApplicable: function(){ return window.nodejs != null },
+ isApplicable: function(){ return this.runtime == 'nw' },
// XXX show main window...
handlers: [
diff --git a/ui (gen4)/features/base.js b/ui (gen4)/features/base.js
index 01df6602..9433d351 100755
--- a/ui (gen4)/features/base.js
+++ b/ui (gen4)/features/base.js
@@ -11,6 +11,7 @@ define(function(require){ var module = {}
var actions = require('lib/actions')
var features = require('lib/features')
+var toggler = require('lib/toggler')
var data = require('data')
var images = require('images')
@@ -57,7 +58,7 @@ function(direction, dfl_tag){
var makeConfigToggler =
module.makeConfigToggler =
function(attr, states, callback){
- return Toggler(null,
+ return toggler.Toggler(null,
function(_, action){
var lst = states.constructor === Array ? states : states.call(this)
diff --git a/ui (gen4)/features/cli.js b/ui (gen4)/features/cli.js
index b0faf1af..4037ca9c 100755
--- a/ui (gen4)/features/cli.js
+++ b/ui (gen4)/features/cli.js
@@ -13,7 +13,6 @@ var features = require('lib/features')
var data = require('data')
var images = require('images')
-var ribbons = require('ribbons')
var core = require('features/core')
var base = require('features/base')
@@ -44,15 +43,31 @@ module.CLI = core.ImageGridFeatures.Feature({
}
// XXX for some reason this always contains --help in nw...
- console.log('>>>>', argv)
+ //console.log('>>>>', argv)
+
var cli = requirejs('commander')
-
- cli
.version('0.0.1')
- .usage('COMMAND OPTION ..')
- .command('index PATH', 'build and index of path')
+ .usage('[command] [options] ..')
+ .option('--features', 'list loaded features')
+ .command('index [path]', 'build and index of path')
.parse(argv)
+
+
+ // list features...
+ // XXX make this a core action...
+ if(cli.features){
+ this.features.excluded.length > 0
+ && console.warn('Features excluded (%d):\n ',
+ this.features.excluded.length,
+ this.features.excluded.join('\n '))
+ console.log('Features not applicable (%d):\n ',
+ this.features.unapplicable.length,
+ this.features.unapplicable.join('\n '))
+ console.log('Features loaded (%d):\n ',
+ this.features.features.length,
+ this.features.features.join('\n '))
+ }
}]
],
})
diff --git a/ui (gen4)/features/core.js b/ui (gen4)/features/core.js
index 0f43660f..2dd5105a 100755
--- a/ui (gen4)/features/core.js
+++ b/ui (gen4)/features/core.js
@@ -23,20 +23,20 @@ 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'
- }
+ // 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...
+ ImageGridFeatures.runtime = 'nw'
+ requirejs(['nw.gui'],
+ // OK: nw.js
+ function(){},
+ // ERR: pure node.js...
+ function(){ ImageGridFeatures.runtime = 'node' })
// browser...
-} else if(typeof('window') != 'undefined'){
+} else if(typeof(window) != 'undefined'){
ImageGridFeatures.runtime = 'browser'
// unknown...
@@ -130,9 +130,11 @@ var LifeCycleActions = actions.Actions({
}
// node...
+ /* XXX there's no process.off(...)
if(this.__stop_handler && this.runtime == 'node'){
process.off('exit', this.__stop_handler)
}
+ */
delete this.__stop_handler
diff --git a/ui (gen4)/features/filesystem.js b/ui (gen4)/features/filesystem.js
index e42149f4..2dfac8da 100755
--- a/ui (gen4)/features/filesystem.js
+++ b/ui (gen4)/features/filesystem.js
@@ -10,7 +10,7 @@ define(function(require){ var module = {}
// XXX this should not be imported!!!
// ...something wrong with requirejs(..)
-if(window.nodejs != null){
+if(typeof(process) != 'undefined'){
var fse = requirejs('fs-extra')
var pathlib = requirejs('path')
var glob = requirejs('glob')
@@ -314,7 +314,8 @@ module.FileSystemLoader = core.ImageGridFeatures.Feature({
actions: FileSystemLoaderActions,
- isApplicable: function(){ return window.nodejs != null },
+ isApplicable: function(){
+ return this.runtime == 'node' || this.runtime == 'nw' },
})
@@ -746,7 +747,8 @@ module.FileSystemWriter = core.ImageGridFeatures.Feature({
actions: FileSystemWriterActions,
- isApplicable: function(){ return window.nodejs != null },
+ isApplicable: function(){
+ return this.runtime == 'node' || this.runtime == 'nw' },
// monitor changes...
// XXX should we use .load(..) to trigger changes instead of .loadURLs(..)???
diff --git a/ui (gen4)/features/history.js b/ui (gen4)/features/history.js
index 2101675d..3613e156 100755
--- a/ui (gen4)/features/history.js
+++ b/ui (gen4)/features/history.js
@@ -295,7 +295,9 @@ module.URLHistoryLocalStorage = core.ImageGridFeatures.Feature({
'url-history',
],
- isApplicable: function(){ return localStorage != null },
+ isApplicable: function(){
+ return typeof(localStorage) != 'undefined'
+ && localStorage != null },
actions: URLHistoryLocalStorageActions,
diff --git a/ui (gen4)/features/meta.js b/ui (gen4)/features/meta.js
index 4cd72c4a..1b7817c1 100755
--- a/ui (gen4)/features/meta.js
+++ b/ui (gen4)/features/meta.js
@@ -25,10 +25,24 @@ var core = require('features/core')
// - editor - editing capability
//
-core.ImageGridFeatures.Feature('viewer-testing', [
+core.ImageGridFeatures.Feature('viewer-commandline', [
'lifecycle',
'base-full',
'commandline',
+
+ 'image-marks',
+ 'image-bookmarks',
+
+ 'fs-loader',
+ 'fs-writer',
+])
+
+
+
+
+core.ImageGridFeatures.Feature('viewer-testing', [
+ 'viewer-commandline',
+
'ui',
'ui-ribbons-placement',
@@ -58,15 +72,11 @@ core.ImageGridFeatures.Feature('viewer-testing', [
'ui-single-image-view-local-storage',
- 'fs-loader',
- 'ui-fs-loader',
- 'fs-url-history',
- 'ui-fs-url-history',
-
- 'fs-writer',
- 'ui-fs-writer',
-
- 'app-control',
+ // fs...
+ 'ui-fs-loader',
+ 'fs-url-history',
+ 'ui-fs-url-history',
+ 'ui-fs-writer',
// chrome...
'ui-animation',
@@ -97,6 +107,7 @@ core.ImageGridFeatures.Feature('viewer-testing', [
//'auto-single-image',
//'auto-ribbon',
+ 'ui-app-control',
// XXX not yet fully tested...
'system-journal',
diff --git a/ui (gen4)/features/ui-marks.js b/ui (gen4)/features/ui-marks.js
index 1c519d00..b3dc7aad 100755
--- a/ui (gen4)/features/ui-marks.js
+++ b/ui (gen4)/features/ui-marks.js
@@ -8,12 +8,12 @@ define(function(require){ var module = {}
//var DEBUG = DEBUG != null ? DEBUG : true
+var toggler = require('lib/toggler')
var actions = require('lib/actions')
var features = require('lib/features')
var data = require('data')
var images = require('images')
-var ribbons = require('ribbons')
var core = require('features/core')
var base = require('features/base')
@@ -32,7 +32,7 @@ var base = require('features/base')
// Array
//
function makeTagTogglerAction(tag){
- var toggler = function(target, action){
+ var t = function(target, action){
if(target == '?' || target == 'on' || target == 'off'){
var x = action
action = target
@@ -86,16 +86,16 @@ function makeTagTogglerAction(tag){
}
// cheating a bit...
- toggler.__proto__ = Toggler.prototype
- toggler.constructor = Toggler
+ t.__proto__ = toggler.Toggler.prototype
+ t.constructor = toggler.Toggler
- return toggler
+ return t
}
/* XXX this toggler is not fully compatible with the Toggler interface
* thus, we either need to update the Toggler to suppor multiple
* values or keep this...
function makeTagTogglerAction(tag){
- return Toggler(null,
+ return toggler.Toggler(null,
function(target, action){
// get the target...
target = target || 'current'
diff --git a/ui (gen4)/features/ui.js b/ui (gen4)/features/ui.js
index 5acc0a06..985c716d 100755
--- a/ui (gen4)/features/ui.js
+++ b/ui (gen4)/features/ui.js
@@ -8,6 +8,7 @@ define(function(require){ var module = {}
//var DEBUG = DEBUG != null ? DEBUG : true
+var toggler = require('lib/toggler')
var actions = require('lib/actions')
var features = require('lib/features')
@@ -288,7 +289,7 @@ actions.Actions({
// General UI stuff...
// NOTE: this is applicable to all uses...
toggleTheme: ['Interface/Toggle viewer theme',
- CSSClassToggler(
+ toggler.CSSClassToggler(
function(){ return this.ribbons.viewer },
function(){ return this.config.themes },
function(state){ this.config.theme = state }) ],
@@ -1132,7 +1133,7 @@ var ConfigLocalStorageActions = actions.Actions({
}],
toggleAutoStoreConfig: ['File/Store configuration',
- Toggler(null, function(_, state){
+ toggler.Toggler(null, function(_, state){
if(state == null){
return this.__auto_save_config_timer || 'none'
@@ -1188,7 +1189,9 @@ module.ConfigLocalStorage = core.ImageGridFeatures.Feature({
'ui',
],
- isApplicable: function(){ return localStorage != null },
+ isApplicable: function(){
+ return typeof(localStorage) != 'undefined'
+ && localStorage != null },
actions: ConfigLocalStorageActions,
@@ -1623,7 +1626,7 @@ var SingleImageActions = actions.Actions({
toggleSingleImage: ['Interface/Toggle single image view',
// XXX this is wrong!!!
- CSSClassToggler(
+ toggler.CSSClassToggler(
function(){ return this.ribbons.viewer },
'single-image-mode') ],
})
@@ -2463,7 +2466,7 @@ module.PassiveBaseRibbonIndicator = core.ImageGridFeatures.Feature({
actions: actions.Actions({
togglePassiveBaseRibbonIndicator: ['Interface/Toggle passive base ribbon indicator',
- CSSClassToggler(
+ toggler.CSSClassToggler(
function(){ return this.ribbons.viewer },
'show-passive-base-ribbon-indicator',
function(state){
@@ -2639,7 +2642,7 @@ module.RibbonsPlacement = core.ImageGridFeatures.Feature({
actions: actions.Actions({
toggleRibbonsPlacementMode: ['- Interface/',
- Toggler(null, function(_, state){
+ toggler.Toggler(null, function(_, state){
if(state == null){
return this.config['ui-ribbons-placement-mode']
}
@@ -2809,7 +2812,7 @@ module.IndirectControl = core.ImageGridFeatures.Feature({
actions: actions.Actions({
toggleSwipeHandling:['Interface/Toggle indirect control swipe handling',
- Toggler(null,
+ toggler.Toggler(null,
function(_, state){
if(state == null){
diff --git a/ui (gen4)/ig.js b/ui (gen4)/ig.js
index d891e00b..82096c56 100644
--- a/ui (gen4)/ig.js
+++ b/ui (gen4)/ig.js
@@ -1,3 +1,4 @@
+#!/usr/bin/env node
/**********************************************************************
*
*
@@ -6,9 +7,6 @@
//var DEBUG = DEBUG != null ? DEBUG : true
-
-//var ui = require('./ui')
-
var requirejs = require('requirejs')
requirejs.config({
nodeRequire: require,
@@ -18,24 +16,72 @@ requirejs.config({
//urlArgs: 'bust='+Date.now(),
})
-// XXX load only the actualy used here modules...
-var actions = requirejs('lib/actions')
-var data = requirejs('data')
-var ribbons = requirejs('ribbons')
+var _require = require
+require = requirejs
-// XXX
-var testing = requirejs('testing')
+var core = require('features/core')
+var base = require('features/base')
+var location = require('features/location')
+var history = require('features/history')
+var app = require('features/app')
+var marks = require('features/ui-marks')
+var filesystem = require('features/filesystem')
+var cli = require('features/cli')
+var experimental = require('features/experimental')
+
+var meta = require('features/meta')
-var client = requirejs('client')
-var viewer = requirejs('viewer')
+//---------------------------------------------------------------------
+
+// NOTE: this is here to simplify importing...
+var ImageGridFeatures =
+module.ImageGridFeatures =
+ core.ImageGridFeatures
+
/*********************************************************************/
+// XXX stub action set -- this needs to be auto-generated...
+var a = actions.Actions()
+
+// used switch experimental actions on (set to true) or off (unset or false)...
+//a.experimental = true
+
+//a.logger = a.logger || {emit: function(e, v){ console.log(' ', e, v) }}
+
+// setup actions...
+// XXX this will fail because we did not load ui...
+ImageGridFeatures
+ .setup(a, [
+ 'viewer-commandline',
+
+ // XXX this is not for production...
+ 'experiments',
+ ])
+ .start()
+
+
+/*
+// 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)
+
+*/
+
diff --git a/ui (gen4)/index.html b/ui (gen4)/index.html
index 9af173a3..5d9d5f1d 100755
--- a/ui (gen4)/index.html
+++ b/ui (gen4)/index.html
@@ -197,7 +197,6 @@ typeof(require) != 'undefined' && require('nw.gui').Window.get().showDevTools()
-
diff --git a/ui (gen4)/lib/actions.js b/ui (gen4)/lib/actions.js
index 35fcfe07..b67af1d4 100755
--- a/ui (gen4)/lib/actions.js
+++ b/ui (gen4)/lib/actions.js
@@ -8,6 +8,8 @@
define(function(require){ var module = {}
+var args2array = require('lib/util').args2array
+var toggler = require('lib/toggler')
var object = require('lib/object')
@@ -127,14 +129,6 @@ var object = require('lib/object')
/*********************************************************************/
// helpers...
-// XXX
-if(typeof(args2array) != 'function'){
- function args2array(args){
- return [].slice.call(args)
- }
-}
-
-
/*********************************************************************/
@@ -440,7 +434,7 @@ module.MetaActions = {
|| MetaActions.getHandlers)
.call(this, name)
- if(handlers.slice(-1)[0] instanceof Toggler){
+ if(handlers.slice(-1)[0] instanceof toggler.Toggler){
return true
}
diff --git a/ui (gen4)/lib/features.js b/ui (gen4)/lib/features.js
index 34d01e66..d347d11e 100755
--- a/ui (gen4)/lib/features.js
+++ b/ui (gen4)/lib/features.js
@@ -8,6 +8,7 @@ define(function(require){ var module = {}
//var DEBUG = DEBUG != null ? DEBUG : true
+args2array = require('lib/util').args2array
actions = require('lib/actions')
@@ -328,11 +329,12 @@ module.FeatureSet = {
var e = that[n]
if(!e){
- console.warn('%s: feature is not loaded.', n)
- }
+ //console.warn('%s: feature is not loaded.', n)
+ // XXX should we break here???
+ throw (n + ': feature is not loaded.')
// no dependencies...
- if(e.depends == null || e.depends.length == 0){
+ } else if(e.depends == null || e.depends.length == 0){
res.push(n)
} else {
@@ -349,7 +351,6 @@ module.FeatureSet = {
res = res.concat(deps)
res.push(n)
}
-
})
lst = res
depth -= 1
diff --git a/ui (gen4)/lib/jli.js b/ui (gen4)/lib/jli.js
index 74e9c4a9..77728793 100755
--- a/ui (gen4)/lib/jli.js
+++ b/ui (gen4)/lib/jli.js
@@ -1029,80 +1029,6 @@ function sign(x){
}
-String.prototype.capitalize = function(){
- return this[0].toUpperCase() + this.slice(1)
-}
-
-
-// XXX not sure if this has to be a utility or a method...
-Object.get = function(obj, name, dfl){
- var val = obj[name]
- if(val === undefined && dfl != null){
- return dfl
- }
- return val
-}
-
-
-// Compact a sparse array...
-//
-// NOTE: this will not compact in-place.
-Array.prototype.compact = function(){
- return this.filter(function(){ return true })
-}
-
-
-// return an array with duplicate elements removed...
-//
-Array.prototype.unique = function(){
- return this.filter(function(e, i, a){ return a.indexOf(e) == i })
-}
-
-
-// Compare two arrays...
-//
-Array.prototype.cmp = function(other){
- if(this === other){
- return true
- }
- if(this.length != other.length){
- return false
- }
- for(var i=0; i