mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
refactoring to make cli work...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
4bfb3fc03d
commit
8480c0425c
@ -8,6 +8,8 @@ define(function(require){ var module = {}
|
|||||||
|
|
||||||
//var DEBUG = DEBUG != null ? DEBUG : true
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
||||||
|
|
||||||
|
var toggler = require('lib/toggler')
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
@ -36,7 +38,7 @@ module.exitFullscreen = function() {
|
|||||||
|
|
||||||
|
|
||||||
window.toggleFullscreenMode =
|
window.toggleFullscreenMode =
|
||||||
module.toggleFullscreenMode = CSSClassToggler(
|
module.toggleFullscreenMode = toggler.CSSClassToggler(
|
||||||
document.body,
|
document.body,
|
||||||
'.full-screen-mode',
|
'.full-screen-mode',
|
||||||
function(action){
|
function(action){
|
||||||
|
|||||||
@ -168,7 +168,7 @@ module.AppControl = core.ImageGridFeatures.Feature({
|
|||||||
title: '',
|
title: '',
|
||||||
doc: '',
|
doc: '',
|
||||||
|
|
||||||
tag: 'app-control',
|
tag: 'ui-app-control',
|
||||||
depends: [
|
depends: [
|
||||||
'ui',
|
'ui',
|
||||||
],
|
],
|
||||||
@ -179,7 +179,7 @@ module.AppControl = core.ImageGridFeatures.Feature({
|
|||||||
// - chrome app
|
// - chrome app
|
||||||
// - nw
|
// - nw
|
||||||
// - mobile
|
// - mobile
|
||||||
isApplicable: function(){ return window.nodejs != null },
|
isApplicable: function(){ return this.runtime == 'nw' },
|
||||||
|
|
||||||
// XXX show main window...
|
// XXX show main window...
|
||||||
handlers: [
|
handlers: [
|
||||||
|
|||||||
@ -11,6 +11,7 @@ define(function(require){ var module = {}
|
|||||||
|
|
||||||
var actions = require('lib/actions')
|
var actions = require('lib/actions')
|
||||||
var features = require('lib/features')
|
var features = require('lib/features')
|
||||||
|
var toggler = require('lib/toggler')
|
||||||
|
|
||||||
var data = require('data')
|
var data = require('data')
|
||||||
var images = require('images')
|
var images = require('images')
|
||||||
@ -57,7 +58,7 @@ function(direction, dfl_tag){
|
|||||||
var makeConfigToggler =
|
var makeConfigToggler =
|
||||||
module.makeConfigToggler =
|
module.makeConfigToggler =
|
||||||
function(attr, states, callback){
|
function(attr, states, callback){
|
||||||
return Toggler(null,
|
return toggler.Toggler(null,
|
||||||
function(_, action){
|
function(_, action){
|
||||||
var lst = states.constructor === Array ? states : states.call(this)
|
var lst = states.constructor === Array ? states : states.call(this)
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,6 @@ var features = require('lib/features')
|
|||||||
|
|
||||||
var data = require('data')
|
var data = require('data')
|
||||||
var images = require('images')
|
var images = require('images')
|
||||||
var ribbons = require('ribbons')
|
|
||||||
|
|
||||||
var core = require('features/core')
|
var core = require('features/core')
|
||||||
var base = require('features/base')
|
var base = require('features/base')
|
||||||
@ -44,15 +43,31 @@ module.CLI = core.ImageGridFeatures.Feature({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// XXX for some reason this always contains --help in nw...
|
// XXX for some reason this always contains --help in nw...
|
||||||
console.log('>>>>', argv)
|
//console.log('>>>>', argv)
|
||||||
|
|
||||||
|
|
||||||
var cli = requirejs('commander')
|
var cli = requirejs('commander')
|
||||||
|
|
||||||
cli
|
|
||||||
.version('0.0.1')
|
.version('0.0.1')
|
||||||
.usage('COMMAND OPTION ..')
|
.usage('[command] [options] ..')
|
||||||
.command('index PATH', 'build and index of path')
|
.option('--features', 'list loaded features')
|
||||||
|
.command('index [path]', 'build and index of path')
|
||||||
.parse(argv)
|
.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 '))
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|||||||
@ -23,20 +23,20 @@ module.ImageGridFeatures = Object.create(features.FeatureSet)
|
|||||||
|
|
||||||
// setup exit...
|
// setup exit...
|
||||||
if(typeof(process) != 'undefined'){
|
if(typeof(process) != 'undefined'){
|
||||||
// nw.js...
|
|
||||||
try{
|
|
||||||
// this will fail if we're not in nw.js...
|
|
||||||
requirejs('nw.gui')
|
|
||||||
|
|
||||||
ImageGridFeatures.runtime = 'nw'
|
// 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
|
||||||
// pure node.js...
|
// as not to wait if all goes well and set it to 'node' in the
|
||||||
} catch(e) {
|
// callback that if fails will fail right away...
|
||||||
ImageGridFeatures.runtime = 'node'
|
ImageGridFeatures.runtime = 'nw'
|
||||||
}
|
requirejs(['nw.gui'],
|
||||||
|
// OK: nw.js
|
||||||
|
function(){},
|
||||||
|
// ERR: pure node.js...
|
||||||
|
function(){ ImageGridFeatures.runtime = 'node' })
|
||||||
|
|
||||||
// browser...
|
// browser...
|
||||||
} else if(typeof('window') != 'undefined'){
|
} else if(typeof(window) != 'undefined'){
|
||||||
ImageGridFeatures.runtime = 'browser'
|
ImageGridFeatures.runtime = 'browser'
|
||||||
|
|
||||||
// unknown...
|
// unknown...
|
||||||
@ -130,9 +130,11 @@ var LifeCycleActions = actions.Actions({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// node...
|
// node...
|
||||||
|
/* XXX there's no process.off(...)
|
||||||
if(this.__stop_handler && this.runtime == 'node'){
|
if(this.__stop_handler && this.runtime == 'node'){
|
||||||
process.off('exit', this.__stop_handler)
|
process.off('exit', this.__stop_handler)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
delete this.__stop_handler
|
delete this.__stop_handler
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ define(function(require){ var module = {}
|
|||||||
|
|
||||||
// XXX this should not be imported!!!
|
// XXX this should not be imported!!!
|
||||||
// ...something wrong with requirejs(..)
|
// ...something wrong with requirejs(..)
|
||||||
if(window.nodejs != null){
|
if(typeof(process) != 'undefined'){
|
||||||
var fse = requirejs('fs-extra')
|
var fse = requirejs('fs-extra')
|
||||||
var pathlib = requirejs('path')
|
var pathlib = requirejs('path')
|
||||||
var glob = requirejs('glob')
|
var glob = requirejs('glob')
|
||||||
@ -314,7 +314,8 @@ module.FileSystemLoader = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
actions: FileSystemLoaderActions,
|
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,
|
actions: FileSystemWriterActions,
|
||||||
|
|
||||||
isApplicable: function(){ return window.nodejs != null },
|
isApplicable: function(){
|
||||||
|
return this.runtime == 'node' || this.runtime == 'nw' },
|
||||||
|
|
||||||
// monitor changes...
|
// monitor changes...
|
||||||
// XXX should we use .load(..) to trigger changes instead of .loadURLs(..)???
|
// XXX should we use .load(..) to trigger changes instead of .loadURLs(..)???
|
||||||
|
|||||||
@ -295,7 +295,9 @@ module.URLHistoryLocalStorage = core.ImageGridFeatures.Feature({
|
|||||||
'url-history',
|
'url-history',
|
||||||
],
|
],
|
||||||
|
|
||||||
isApplicable: function(){ return localStorage != null },
|
isApplicable: function(){
|
||||||
|
return typeof(localStorage) != 'undefined'
|
||||||
|
&& localStorage != null },
|
||||||
|
|
||||||
actions: URLHistoryLocalStorageActions,
|
actions: URLHistoryLocalStorageActions,
|
||||||
|
|
||||||
|
|||||||
@ -25,10 +25,24 @@ var core = require('features/core')
|
|||||||
// - editor - editing capability
|
// - editor - editing capability
|
||||||
//
|
//
|
||||||
|
|
||||||
core.ImageGridFeatures.Feature('viewer-testing', [
|
core.ImageGridFeatures.Feature('viewer-commandline', [
|
||||||
'lifecycle',
|
'lifecycle',
|
||||||
'base-full',
|
'base-full',
|
||||||
'commandline',
|
'commandline',
|
||||||
|
|
||||||
|
'image-marks',
|
||||||
|
'image-bookmarks',
|
||||||
|
|
||||||
|
'fs-loader',
|
||||||
|
'fs-writer',
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
core.ImageGridFeatures.Feature('viewer-testing', [
|
||||||
|
'viewer-commandline',
|
||||||
|
|
||||||
'ui',
|
'ui',
|
||||||
|
|
||||||
'ui-ribbons-placement',
|
'ui-ribbons-placement',
|
||||||
@ -58,15 +72,11 @@ core.ImageGridFeatures.Feature('viewer-testing', [
|
|||||||
'ui-single-image-view-local-storage',
|
'ui-single-image-view-local-storage',
|
||||||
|
|
||||||
|
|
||||||
'fs-loader',
|
// fs...
|
||||||
'ui-fs-loader',
|
'ui-fs-loader',
|
||||||
'fs-url-history',
|
'fs-url-history',
|
||||||
'ui-fs-url-history',
|
'ui-fs-url-history',
|
||||||
|
'ui-fs-writer',
|
||||||
'fs-writer',
|
|
||||||
'ui-fs-writer',
|
|
||||||
|
|
||||||
'app-control',
|
|
||||||
|
|
||||||
// chrome...
|
// chrome...
|
||||||
'ui-animation',
|
'ui-animation',
|
||||||
@ -97,6 +107,7 @@ core.ImageGridFeatures.Feature('viewer-testing', [
|
|||||||
//'auto-single-image',
|
//'auto-single-image',
|
||||||
//'auto-ribbon',
|
//'auto-ribbon',
|
||||||
|
|
||||||
|
'ui-app-control',
|
||||||
|
|
||||||
// XXX not yet fully tested...
|
// XXX not yet fully tested...
|
||||||
'system-journal',
|
'system-journal',
|
||||||
|
|||||||
@ -8,12 +8,12 @@ define(function(require){ var module = {}
|
|||||||
|
|
||||||
//var DEBUG = DEBUG != null ? DEBUG : true
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
||||||
|
|
||||||
|
var toggler = require('lib/toggler')
|
||||||
var actions = require('lib/actions')
|
var actions = require('lib/actions')
|
||||||
var features = require('lib/features')
|
var features = require('lib/features')
|
||||||
|
|
||||||
var data = require('data')
|
var data = require('data')
|
||||||
var images = require('images')
|
var images = require('images')
|
||||||
var ribbons = require('ribbons')
|
|
||||||
|
|
||||||
var core = require('features/core')
|
var core = require('features/core')
|
||||||
var base = require('features/base')
|
var base = require('features/base')
|
||||||
@ -32,7 +32,7 @@ var base = require('features/base')
|
|||||||
// Array
|
// Array
|
||||||
//
|
//
|
||||||
function makeTagTogglerAction(tag){
|
function makeTagTogglerAction(tag){
|
||||||
var toggler = function(target, action){
|
var t = function(target, action){
|
||||||
if(target == '?' || target == 'on' || target == 'off'){
|
if(target == '?' || target == 'on' || target == 'off'){
|
||||||
var x = action
|
var x = action
|
||||||
action = target
|
action = target
|
||||||
@ -86,16 +86,16 @@ function makeTagTogglerAction(tag){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// cheating a bit...
|
// cheating a bit...
|
||||||
toggler.__proto__ = Toggler.prototype
|
t.__proto__ = toggler.Toggler.prototype
|
||||||
toggler.constructor = Toggler
|
t.constructor = toggler.Toggler
|
||||||
|
|
||||||
return toggler
|
return t
|
||||||
}
|
}
|
||||||
/* XXX this toggler is not fully compatible with the Toggler interface
|
/* XXX this toggler is not fully compatible with the Toggler interface
|
||||||
* thus, we either need to update the Toggler to suppor multiple
|
* thus, we either need to update the Toggler to suppor multiple
|
||||||
* values or keep this...
|
* values or keep this...
|
||||||
function makeTagTogglerAction(tag){
|
function makeTagTogglerAction(tag){
|
||||||
return Toggler(null,
|
return toggler.Toggler(null,
|
||||||
function(target, action){
|
function(target, action){
|
||||||
// get the target...
|
// get the target...
|
||||||
target = target || 'current'
|
target = target || 'current'
|
||||||
|
|||||||
@ -8,6 +8,7 @@ define(function(require){ var module = {}
|
|||||||
|
|
||||||
//var DEBUG = DEBUG != null ? DEBUG : true
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
||||||
|
|
||||||
|
var toggler = require('lib/toggler')
|
||||||
var actions = require('lib/actions')
|
var actions = require('lib/actions')
|
||||||
var features = require('lib/features')
|
var features = require('lib/features')
|
||||||
|
|
||||||
@ -288,7 +289,7 @@ actions.Actions({
|
|||||||
// General UI stuff...
|
// General UI stuff...
|
||||||
// NOTE: this is applicable to all uses...
|
// NOTE: this is applicable to all uses...
|
||||||
toggleTheme: ['Interface/Toggle viewer theme',
|
toggleTheme: ['Interface/Toggle viewer theme',
|
||||||
CSSClassToggler(
|
toggler.CSSClassToggler(
|
||||||
function(){ return this.ribbons.viewer },
|
function(){ return this.ribbons.viewer },
|
||||||
function(){ return this.config.themes },
|
function(){ return this.config.themes },
|
||||||
function(state){ this.config.theme = state }) ],
|
function(state){ this.config.theme = state }) ],
|
||||||
@ -1132,7 +1133,7 @@ var ConfigLocalStorageActions = actions.Actions({
|
|||||||
}],
|
}],
|
||||||
|
|
||||||
toggleAutoStoreConfig: ['File/Store configuration',
|
toggleAutoStoreConfig: ['File/Store configuration',
|
||||||
Toggler(null, function(_, state){
|
toggler.Toggler(null, function(_, state){
|
||||||
if(state == null){
|
if(state == null){
|
||||||
return this.__auto_save_config_timer || 'none'
|
return this.__auto_save_config_timer || 'none'
|
||||||
|
|
||||||
@ -1188,7 +1189,9 @@ module.ConfigLocalStorage = core.ImageGridFeatures.Feature({
|
|||||||
'ui',
|
'ui',
|
||||||
],
|
],
|
||||||
|
|
||||||
isApplicable: function(){ return localStorage != null },
|
isApplicable: function(){
|
||||||
|
return typeof(localStorage) != 'undefined'
|
||||||
|
&& localStorage != null },
|
||||||
|
|
||||||
actions: ConfigLocalStorageActions,
|
actions: ConfigLocalStorageActions,
|
||||||
|
|
||||||
@ -1623,7 +1626,7 @@ var SingleImageActions = actions.Actions({
|
|||||||
|
|
||||||
toggleSingleImage: ['Interface/Toggle single image view',
|
toggleSingleImage: ['Interface/Toggle single image view',
|
||||||
// XXX this is wrong!!!
|
// XXX this is wrong!!!
|
||||||
CSSClassToggler(
|
toggler.CSSClassToggler(
|
||||||
function(){ return this.ribbons.viewer },
|
function(){ return this.ribbons.viewer },
|
||||||
'single-image-mode') ],
|
'single-image-mode') ],
|
||||||
})
|
})
|
||||||
@ -2463,7 +2466,7 @@ module.PassiveBaseRibbonIndicator = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
actions: actions.Actions({
|
actions: actions.Actions({
|
||||||
togglePassiveBaseRibbonIndicator: ['Interface/Toggle passive base ribbon indicator',
|
togglePassiveBaseRibbonIndicator: ['Interface/Toggle passive base ribbon indicator',
|
||||||
CSSClassToggler(
|
toggler.CSSClassToggler(
|
||||||
function(){ return this.ribbons.viewer },
|
function(){ return this.ribbons.viewer },
|
||||||
'show-passive-base-ribbon-indicator',
|
'show-passive-base-ribbon-indicator',
|
||||||
function(state){
|
function(state){
|
||||||
@ -2639,7 +2642,7 @@ module.RibbonsPlacement = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
actions: actions.Actions({
|
actions: actions.Actions({
|
||||||
toggleRibbonsPlacementMode: ['- Interface/',
|
toggleRibbonsPlacementMode: ['- Interface/',
|
||||||
Toggler(null, function(_, state){
|
toggler.Toggler(null, function(_, state){
|
||||||
if(state == null){
|
if(state == null){
|
||||||
return this.config['ui-ribbons-placement-mode']
|
return this.config['ui-ribbons-placement-mode']
|
||||||
}
|
}
|
||||||
@ -2809,7 +2812,7 @@ module.IndirectControl = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
actions: actions.Actions({
|
actions: actions.Actions({
|
||||||
toggleSwipeHandling:['Interface/Toggle indirect control swipe handling',
|
toggleSwipeHandling:['Interface/Toggle indirect control swipe handling',
|
||||||
Toggler(null,
|
toggler.Toggler(null,
|
||||||
function(_, state){
|
function(_, state){
|
||||||
|
|
||||||
if(state == null){
|
if(state == null){
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@ -6,9 +7,6 @@
|
|||||||
|
|
||||||
//var DEBUG = DEBUG != null ? DEBUG : true
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
||||||
|
|
||||||
|
|
||||||
//var ui = require('./ui')
|
|
||||||
|
|
||||||
var requirejs = require('requirejs')
|
var requirejs = require('requirejs')
|
||||||
requirejs.config({
|
requirejs.config({
|
||||||
nodeRequire: require,
|
nodeRequire: require,
|
||||||
@ -18,24 +16,72 @@ requirejs.config({
|
|||||||
//urlArgs: 'bust='+Date.now(),
|
//urlArgs: 'bust='+Date.now(),
|
||||||
})
|
})
|
||||||
|
|
||||||
// XXX load only the actualy used here modules...
|
var _require = require
|
||||||
var actions = requirejs('lib/actions')
|
require = requirejs
|
||||||
var data = requirejs('data')
|
|
||||||
var ribbons = requirejs('ribbons')
|
|
||||||
|
|
||||||
|
|
||||||
// XXX
|
var core = require('features/core')
|
||||||
var testing = requirejs('testing')
|
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)
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -197,7 +197,6 @@ typeof(require) != 'undefined' && require('nw.gui').Window.get().showDevTools()
|
|||||||
|
|
||||||
|
|
||||||
<script src="lib/jli.js"></script>
|
<script src="lib/jli.js"></script>
|
||||||
<script src="lib/toggler.js"></script>
|
|
||||||
|
|
||||||
<script data-main="ui" src="ext-lib/require.js"></script>
|
<script data-main="ui" src="ext-lib/require.js"></script>
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
define(function(require){ var module = {}
|
define(function(require){ var module = {}
|
||||||
|
|
||||||
|
var args2array = require('lib/util').args2array
|
||||||
|
var toggler = require('lib/toggler')
|
||||||
var object = require('lib/object')
|
var object = require('lib/object')
|
||||||
|
|
||||||
|
|
||||||
@ -127,14 +129,6 @@ var object = require('lib/object')
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
// helpers...
|
// helpers...
|
||||||
|
|
||||||
// XXX
|
|
||||||
if(typeof(args2array) != 'function'){
|
|
||||||
function args2array(args){
|
|
||||||
return [].slice.call(args)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
@ -440,7 +434,7 @@ module.MetaActions = {
|
|||||||
|| MetaActions.getHandlers)
|
|| MetaActions.getHandlers)
|
||||||
.call(this, name)
|
.call(this, name)
|
||||||
|
|
||||||
if(handlers.slice(-1)[0] instanceof Toggler){
|
if(handlers.slice(-1)[0] instanceof toggler.Toggler){
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@ define(function(require){ var module = {}
|
|||||||
|
|
||||||
//var DEBUG = DEBUG != null ? DEBUG : true
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
||||||
|
|
||||||
|
args2array = require('lib/util').args2array
|
||||||
actions = require('lib/actions')
|
actions = require('lib/actions')
|
||||||
|
|
||||||
|
|
||||||
@ -328,11 +329,12 @@ module.FeatureSet = {
|
|||||||
var e = that[n]
|
var e = that[n]
|
||||||
|
|
||||||
if(!e){
|
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...
|
// no dependencies...
|
||||||
if(e.depends == null || e.depends.length == 0){
|
} else if(e.depends == null || e.depends.length == 0){
|
||||||
res.push(n)
|
res.push(n)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -349,7 +351,6 @@ module.FeatureSet = {
|
|||||||
res = res.concat(deps)
|
res = res.concat(deps)
|
||||||
res.push(n)
|
res.push(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
lst = res
|
lst = res
|
||||||
depth -= 1
|
depth -= 1
|
||||||
|
|||||||
@ -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<this.length; i++){
|
|
||||||
if(this[i] != other[i]){
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compare two Arrays as sets...
|
|
||||||
//
|
|
||||||
// This will ignore order
|
|
||||||
Array.prototype.setCmp = function(other){
|
|
||||||
return this === other
|
|
||||||
|| this.unique().sort().cmp(other.unique().sort())
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// like .length but for sparse arrays will return the element count...
|
|
||||||
// XXX make this a prop...
|
|
||||||
/*
|
|
||||||
Array.prototype.len = function(){
|
|
||||||
//return this.compact().length
|
|
||||||
return Object.keys(this).length
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
Object.defineProperty(Array.prototype, 'len', {
|
|
||||||
get : function () {
|
|
||||||
return Object.keys(this).length
|
|
||||||
},
|
|
||||||
set : function(val){},
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// convert JS arguments to Array...
|
// convert JS arguments to Array...
|
||||||
function args2array(args){
|
function args2array(args){
|
||||||
//return Array.apply(null, args)
|
//return Array.apply(null, args)
|
||||||
|
|||||||
@ -1,7 +1,11 @@
|
|||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
|
define(function(require){ var module = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
@ -124,7 +128,9 @@
|
|||||||
// later is enough, but as strict mode is not stable enough (sometimes
|
// later is enough, but as strict mode is not stable enough (sometimes
|
||||||
// works and sometimes does not), we can not reliably pass the element
|
// works and sometimes does not), we can not reliably pass the element
|
||||||
// via 'this'.
|
// via 'this'.
|
||||||
function Toggler(elem, state_accessor, states, callback_a, callback_b){
|
var Toggler =
|
||||||
|
module.Toggler =
|
||||||
|
function(elem, state_accessor, states, callback_a, callback_b){
|
||||||
// normalize states...
|
// normalize states...
|
||||||
var states_getter = states
|
var states_getter = states
|
||||||
var state_set = typeof(states) == typeof('str') ? ['none', states] : states
|
var state_set = typeof(states) == typeof('str') ? ['none', states] : states
|
||||||
@ -321,6 +327,8 @@ Toggler.prototype.__proto__ = Function.prototype
|
|||||||
|
|
||||||
// XXX this should be drop-in compatible with createCSSClassToggler(..)
|
// XXX this should be drop-in compatible with createCSSClassToggler(..)
|
||||||
// test and replace...
|
// test and replace...
|
||||||
|
var CSSClassToggler =
|
||||||
|
module.CSSClassToggler =
|
||||||
function CSSClassToggler(elem, classes, callback_a, callback_b){
|
function CSSClassToggler(elem, classes, callback_a, callback_b){
|
||||||
var classes_getter = classes
|
var classes_getter = classes
|
||||||
var classes_set = classes
|
var classes_set = classes
|
||||||
@ -400,3 +408,4 @@ CSSClassToggler.prototype.__proto__ = Toggler.prototype
|
|||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* vim:set ts=4 sw=4 : */
|
* vim:set ts=4 sw=4 : */
|
||||||
|
return module })
|
||||||
|
|||||||
@ -11,6 +11,81 @@ define(function(require){ var module = {}
|
|||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
|
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<this.length; i++){
|
||||||
|
if(this[i] != other[i]){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare two Arrays as sets...
|
||||||
|
//
|
||||||
|
// This will ignore order
|
||||||
|
Array.prototype.setCmp = function(other){
|
||||||
|
return this === other
|
||||||
|
|| this.unique().sort().cmp(other.unique().sort())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// like .length but for sparse arrays will return the element count...
|
||||||
|
// XXX make this a prop...
|
||||||
|
/*
|
||||||
|
Array.prototype.len = function(){
|
||||||
|
//return this.compact().length
|
||||||
|
return Object.keys(this).length
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
Object.defineProperty(Array.prototype, 'len', {
|
||||||
|
get : function () {
|
||||||
|
return Object.keys(this).length
|
||||||
|
},
|
||||||
|
set : function(val){},
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// convert JS arguments to Array...
|
// convert JS arguments to Array...
|
||||||
var args2array =
|
var args2array =
|
||||||
module.args2array =
|
module.args2array =
|
||||||
@ -78,47 +153,48 @@ function(path){
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
// XXX experiment
|
// XXX experiment
|
||||||
jQuery.fn._drag = function(){
|
if(typeof(jQuery) != typeof(undefined)){
|
||||||
var dragging = false
|
jQuery.fn._drag = function(){
|
||||||
var s,
|
var dragging = false
|
||||||
px, py
|
var s,
|
||||||
|
px, py
|
||||||
|
|
||||||
var elem = $(this)
|
var elem = $(this)
|
||||||
.on('mousedown touchstart', function(evt){
|
.on('mousedown touchstart', function(evt){
|
||||||
dragging = true
|
dragging = true
|
||||||
px = evt.clientX
|
px = evt.clientX
|
||||||
px = evt.clientY
|
px = evt.clientY
|
||||||
|
|
||||||
s = elem.rscale()
|
s = elem.rscale()
|
||||||
})
|
})
|
||||||
.on('mousemove touchmove', function(evt){
|
.on('mousemove touchmove', function(evt){
|
||||||
if(!dragging){
|
if(!dragging){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var x = evt.clientX
|
var x = evt.clientX
|
||||||
var dx = px - x
|
var dx = px - x
|
||||||
px = x
|
px = x
|
||||||
|
|
||||||
var y = evt.clientY
|
var y = evt.clientY
|
||||||
var dy = py - y
|
var dy = py - y
|
||||||
py = y
|
py = y
|
||||||
|
|
||||||
elem
|
elem
|
||||||
.velocity('stop')
|
.velocity('stop')
|
||||||
.velocity({
|
.velocity({
|
||||||
translateX: '-=' + (dx / s),
|
translateX: '-=' + (dx / s),
|
||||||
translateY: '-=' + (dy / s),
|
translateY: '-=' + (dy / s),
|
||||||
}, 0)
|
}, 0)
|
||||||
})
|
})
|
||||||
.on('mouseup touchend', function(evt){
|
.on('mouseup touchend', function(evt){
|
||||||
dragging = false
|
dragging = false
|
||||||
elem.velocity('stop')
|
elem.velocity('stop')
|
||||||
})
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* vim:set ts=4 sw=4 : */
|
* vim:set ts=4 sw=4 : */
|
||||||
return module })
|
return module })
|
||||||
|
|||||||
@ -20,8 +20,9 @@ define(function(require){ var module = {}
|
|||||||
|
|
||||||
//var promise = require('promise')
|
//var promise = require('promise')
|
||||||
|
|
||||||
var keyboard = require('../keyboard')
|
var toggler = require('lib/toggler')
|
||||||
var object = require('../object')
|
var keyboard = require('lib/keyboard')
|
||||||
|
var object = require('lib/object')
|
||||||
var widget = require('./widget')
|
var widget = require('./widget')
|
||||||
|
|
||||||
|
|
||||||
@ -1229,7 +1230,7 @@ var BrowserPrototype = {
|
|||||||
// on filter field)...
|
// on filter field)...
|
||||||
// NOTE: this uses .filter(..) for actual filtering...
|
// NOTE: this uses .filter(..) for actual filtering...
|
||||||
// NOTE: on state change this will return this...
|
// NOTE: on state change this will return this...
|
||||||
toggleFilter: CSSClassToggler(
|
toggleFilter: toggler.CSSClassToggler(
|
||||||
function(){ return this.dom },
|
function(){ return this.dom },
|
||||||
'filtering',
|
'filtering',
|
||||||
// do not enter filter mode if filtering is disabled...
|
// do not enter filter mode if filtering is disabled...
|
||||||
|
|||||||
@ -10,10 +10,11 @@ var gui = require('nw.gui')
|
|||||||
|
|
||||||
define(function(require){ var module = {}
|
define(function(require){ var module = {}
|
||||||
|
|
||||||
|
var toggler = require('lib/toggler')
|
||||||
|
|
||||||
var browser = require('browser')
|
var browser = require('browser')
|
||||||
//var DEBUG = DEBUG != null ? DEBUG : true
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
||||||
|
|
||||||
|
|
||||||
var walk = require('lib/widget/browse-walk')
|
var walk = require('lib/widget/browse-walk')
|
||||||
|
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ var walk = require('lib/widget/browse-walk')
|
|||||||
window.listDirBrowser = walk.listDirBrowser
|
window.listDirBrowser = walk.listDirBrowser
|
||||||
|
|
||||||
window.toggleFullscreenMode =
|
window.toggleFullscreenMode =
|
||||||
module.toggleFullscreenMode = CSSClassToggler(
|
module.toggleFullscreenMode = toggler.CSSClassToggler(
|
||||||
document.body,
|
document.body,
|
||||||
'.full-screen-mode',
|
'.full-screen-mode',
|
||||||
function(action){
|
function(action){
|
||||||
|
|||||||
@ -1,30 +1,34 @@
|
|||||||
{
|
{
|
||||||
"name": "ImageGrid.Viewer.g4",
|
"name": "ImageGrid.Viewer.g4",
|
||||||
"main": "index.html",
|
"main": "index.html",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"window": {
|
"window": {
|
||||||
"title": "ImageGrid.Viewer (gen4)",
|
"title": "ImageGrid.Viewer (gen4)",
|
||||||
"position": "center",
|
"position": "center",
|
||||||
"width": 900,
|
"width": 900,
|
||||||
"height": 700,
|
"height": 700,
|
||||||
"min_width": 400,
|
"min_width": 400,
|
||||||
"min_height": 400,
|
"min_height": 400,
|
||||||
"frame": true,
|
"frame": true,
|
||||||
"toolbar": false,
|
"toolbar": false,
|
||||||
"show": false
|
"show": false
|
||||||
},
|
},
|
||||||
"webkit": {
|
"webkit": {
|
||||||
"page-cache": true
|
"page-cache": true
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"commander": "^2.9.0",
|
"commander": "^2.9.0",
|
||||||
"flickrapi": "^0.3.28",
|
"flickrapi": "^0.3.28",
|
||||||
"fs-extra": "*",
|
"fs-extra": "*",
|
||||||
"fs-walk": "0.0.1",
|
"fs-walk": "0.0.1",
|
||||||
"glob": "^4.0.6",
|
"glob": "^4.0.6",
|
||||||
"guarantee-events": "^1.0.0",
|
"guarantee-events": "^1.0.0",
|
||||||
"promise": "^6.0.1",
|
"promise": "^6.0.1",
|
||||||
"requirejs": "*",
|
"requirejs": "*",
|
||||||
"sharp": "^0.12.0"
|
"sharp": "^0.12.0"
|
||||||
}
|
},
|
||||||
|
"preferGlobal": true,
|
||||||
|
"bin": {
|
||||||
|
"ig": "ig.js"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,7 @@ var object = require('lib/object')
|
|||||||
var data = require('data')
|
var data = require('data')
|
||||||
var images = require('images')
|
var images = require('images')
|
||||||
|
|
||||||
|
|
||||||
var IMAGE = '.image:not(.clone)'
|
var IMAGE = '.image:not(.clone)'
|
||||||
var RIBBON = '.ribbon:not(.clone)'
|
var RIBBON = '.ribbon:not(.clone)'
|
||||||
|
|
||||||
|
|||||||
@ -46,9 +46,6 @@ var ribbons = require('ribbons')
|
|||||||
// XXX
|
// XXX
|
||||||
var testing = require('testing')
|
var testing = require('testing')
|
||||||
|
|
||||||
|
|
||||||
var client = require('client')
|
|
||||||
|
|
||||||
var viewer = require('viewer')
|
var viewer = require('viewer')
|
||||||
|
|
||||||
//var promise = require('promise')
|
//var promise = require('promise')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user