cleanup and tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-05-29 19:50:37 +03:00
parent 11b9351e06
commit 803cbb84a5
7 changed files with 27 additions and 458 deletions

View File

@ -1,347 +0,0 @@
/**********************************************************************
*
*
*
**********************************************************************/
define(function(require){ var module = {}
console.log('>>> actions')
var actions = require('lib/actions')
/*********************************************************************/
//
// Action variables:
//
// SCREEN_IMAGES
// - screen width in images
// - resolves to number
//
// CURRENT
// - current image
// - resolves to gid
// - support basic math: +/-
// e.g. CURRENT + 1 ~ next image
//
// RIBBON
// - current ribbon
// - resolves to gid
// - support basic math: +/-
//
// BASE
// - base ribbon
// - resolves to gid
// - support basic math: +/-
//
//
// XXX add action variables!!!
var SCREEN_IMAGES = null
/*********************************************************************/
//
// Contexts:
// Browser node node-webkit PhoneGap
// UI o x o o
// navigation o o o o
// edit o, x o o, x o, x
//
//
// The basic inheritance tree should be something like this:
//
// .
// Data . UI
// .
// MetaActions .
// ^ .
// | .
// | .
// BaseActions .
// ^ ^ .
// | +------------------ UIActions
// | . ^
// | . | -+
// BaseMarks . | |
// ^ . | | Plugin
// + - - - - -???- - - UIMarks |
// . -+
// .
//
//
// XXX Need a way to combine a set of features into a view, preferably
// in runtime...
// - turn feature on/off at load
// - turn feature on/off in runtime
//
// XXX without multiple inheritance we'll need to either:
//
// - build inheritance chains per task -- i.e. connect blocks in
// a custom way depending on use
// ...this makes it really hard to have two systems configured
// differently in the same runtime...
//
// - build a multiple inheritance system
// ...without the ability to hook into attribute access this is
// not trivial... (feasibility unknown)
//
// - make the UI versions by copying methods from the base and UI
// into a single object, effectively creating two separate chains
// ...auto-creating proxy methods is another way to implement this
// + solves the problem
// - not dynamic -- changes have to be applied to both chains
// rather than to a single relevant object.
//
// - encapsulate and proxy?
//
// - static mixin...
//
//
// XXX actions should be split by feature
// - basic navigation
// - basic editing
// - cropping
// - marking
// - bookmarking
// - tagging
// - image editing
// - url loading
// - url saving
// - fs loading
// - fs saving
// Features can be organized into contexts:
// - browser viewer
// - browser editor
// - app viewer
// - app editor
//
// XXX each plugin must be split into:
// - UI view -- display only
// - UI controls -- edit
// - base actions -- usable without UI
//
// XXX think about life-cycle...
//
//
/*********************************************************************/
var BaseActions =
module.BaseActions = actions.Actions({
// state props...
/*
get current(){
// XXX should this return a gid or a jQuery-like object for
// image-oriented operations???
return this.data.current
},
set current(val){
return this.focusImage(val)
},
*/
// life-cycle / state...
// XXX
// actions...
focusImage: '',
focusRibbon: '',
// basic editing...
shiftImageUp:
'Shift image to the ribbon above current, creating one if '
+'it does not exist',
shiftImageDown:
'Shift image to the ribbon below current, creating one if '
+'it does not exist',
shiftImageUpNewRibbon:
'Create an empty ribbon above and shift the image into it',
shiftImageDownNewRibbon:
'Create an empty ribbon below and shift the image into it',
shiftImageLeft: 'Shift image to the left',
shiftImageRight: 'Shift image to the right',
shiftRibbonUp: 'Move current ribbon one position up',
shiftRibbonDown: 'Move current ribbon one position down',
// XXX
sortImages: '',
reverseImages: '',
setAsBaseRibbon: '',
// image adjustments...
rotateCW: '',
rotateCCW: '',
flipVertical: '',
flipHorizontal: '',
// external editors/viewers...
systemOpen: '',
openWith: '',
// crop...
// XXX should this be here on in a crop pligin...
cropRibbon: '',
cropCurrentRibbonAndAbove: '',
uncropView: 'Uncrop to previous crop',
uncropAll: 'Uncrop to base',
uncropViewAndKeepOrder:
'Uncrop view to previous crop, keeping current image order',
uncropAllAndKeepOrder: 'Uncrop to base, keeping current image order',
openURL: '',
//openHistory: '',
saveOrder: '',
saveState: '',
exportImages: '',
exit: '',
})
/*********************************************************************/
var UIActions =
module.UIActions = {
// basic navigation...
nextImage: ['Focus next image in current ribbon', { focusImage: 'next' }],
nextRibbon: ['Focus next ribbon (down)', { focusRibbon: 'next' }],
// XXX actions vars...
nextScreen: ['Show next screen width of images', { focusImage: SCREEN_IMAGES }],
prevImage: ['Focus previous image in current ribbon', { focusImage: 'prev' }],
prevRibbon: ['Focus previous ribbon (up)', { focusRibbon: 'prev' }],
// XXX actions vars...
prevScreen: ['Show previous screen width of images', { focusImage: -SCREEN_IMAGES }],
firstImage: 'Focus first image in ribbon',
lastImage: 'Focus last image in ribbon',
// zooming...
zoomIn: 'Zoom in',
zoomOut: 'Zoom out',
// NOTE: if this gets a count argument it will fit count images,
// default is one.
fitImage: 'Fit image',
// XXX should these be relative to screen rather than actual image counts?
fitTwo: ['Fit two images', { fitImage: 2, }],
fitThree: ['Fit three images', { fitImage: 3, }],
fitFour: ['Fit four images', { fitImage: 4, }],
fitFive: ['Fit five images', { fitImage: 5, }],
fitSix: ['Fit six images', { fitImage: 6, }],
fitSeven: ['Fit seven images', { fitImage: 7, }],
fitEight: ['Fit eight images', { fitImage: 8, }],
fitNine: ['Fit nine images', { fitImage: 9, }],
fitMax: 'Fit the maximum number of images',
fitSmall: 'Show small image',
fitNormal: 'Show normal image',
fitScreen: 'Fit image to screen',
// modes...
singleImageMode: 'Show single image',
ribbonMode: 'Show ribbon',
toggleTheme: 'Toggle themes',
// dialogs...
// XXX move to specific blocks...
openDialog: 'Show open diaolg',
historyDialog: 'Show history dialog',
cropDialog: 'Show crop dialog',
// panels...
togglePanels: '',
showInfoPanel: '',
showTagsPanel: '',
showSearchPanel: '',
showQuickEditPanel: '',
showStatesPanel: '',
showHistoryPanel: '',
showDirBrowserPanel: '',
showConsolePanel: '',
// developer actions...
showConsole: 'Show application console',
showDevTools: 'Show development tools',
}
/*********************************************************************/
// Marks actions...
// XXX move to marks.js
var MARKS_ACTIONS =
module.MARKS_ACTIONS = {
toggleMark: '',
toggleMarkBlock: '',
nextMarked: '',
prevMarked: '',
nextMarkedInRibbon: '',
prevMarkedInRibbon: '',
markRibbon: '',
unmarkRibbon: '',
markAll: '',
unmarkAll: '',
invertMarkedRibbon: '',
invertMarkedAll: '',
// placing...
placeMarkedAfter: 'Place marked images after current',
placeMarkedBefore: 'Place marked images before current',
shiftMarkedUp: '',
shiftMarkedDown: '',
shiftMarkedLeft: '',
shiftMarkedRight: '',
shiftMarkedUpNewRibbon: '',
shiftMarkedDownNewRibbon: '',
cropMarkedImages: '',
cropMarkedImagesToSingleRibbon: '',
markDialog: 'Show mark dialog',
placeMarkedDialog: '',
}
/*********************************************************************/
// Bookmarks actions...
// XXX move to bookmarks.js
var BOOKMARKS_ACTIONS =
module.BOOKMARKS_ACTIONS = {
toggleBookmark: 'Toggle image bookmark',
nextBookmarked: '',
prevBookmarked: '',
nextBookmarkedInRibbon: '',
prevBookmarkedInRibbon: '',
bookmarkMarked: 'Bookmark marked images',
unbookmarkMarked: 'Remove bookmarks from marked images',
toggleBookmarkMarked: 'Toggle bookmarks on marked images',
clearRibbonBookmarks: 'Remove bookmarks in ribbon',
clearAllBookmarks: 'Clear all bookmarks',
cropBookmarkedImages: '',
cropBookmarkedImagesToSingleRibbon: '',
}
/**********************************************************************
* vim:set ts=4 sw=4 : */
return module })

View File

@ -1,16 +0,0 @@
/**********************************************************************
*
*
*
**********************************************************************/
//var DEBUG = DEBUG != null ? DEBUG : true
/*********************************************************************/
/**********************************************************************
* vim:set ts=4 sw=4 : */

View File

@ -104,11 +104,12 @@ module.CLI = core.ImageGridFeatures.Feature({
var argv = process.argv var argv = process.argv
} }
var package = requirejs('fs-extra').readJSONSync('./package.json')
var cli = requirejs('commander') var cli = requirejs('commander')
cli cli
// XXX get the version from config... // XXX get the version from package.json...
.version('0.0.1') .version(package.version)
//.usage('[command] [options] ..') //.usage('[command] [options] ..')
.option('-v, --verbose', 'verbose mode', function(){ .option('-v, --verbose', 'verbose mode', function(){
@ -191,10 +192,23 @@ module.CLI = core.ImageGridFeatures.Feature({
input: process.stdin, input: process.stdin,
output: process.stdout, output: process.stdout,
ignoreUndefined: true, //ignoreUndefined: true,
}) })
}) })
// XXX this needs both a local/linked nwjs installed and an
// appropriate nw version under it...
// npm install -g nwjs
// npm link nwjs
// nw install 0.14.5-sdk
.option('gui, --gui', 'start ImageGrid.Viewer', function(){
var path = requirejs('path')
requirejs('child_process')
.spawn(requirejs('nwjs'), [
path.dirname(process.argv[1]).replace(/\\/g, '/') + '/'])
})
// XXX the problem with this is that it still tires // XXX the problem with this is that it still tires
// to find and run 'ig-index'... // to find and run 'ig-index'...
/* /*

View File

@ -1,49 +0,0 @@
/**********************************************************************
*
*
*
**********************************************************************/
if(window.nodejs != null){
define(function(require){ var module = {}
var toggler = require('lib/toggler')
var browser = require('browser')
//var DEBUG = DEBUG != null ? DEBUG : true
var walk = require('lib/widget/browse-walk')
/*********************************************************************/
//var data = require('data')
window.listDirBrowser = walk.listDirBrowser
window.toggleFullscreenMode =
module.toggleFullscreenMode = toggler.CSSClassToggler(
document.body,
'.full-screen-mode',
function(action){
nw.Window.get().toggleFullscreen()
})
window.showDevTools =
module.showDevTools = function(){
nw.Window.get().showDevTools()
}
window.setWindowTitle =
module.setWindowTitle = function(text){
browser.setWindowTitle(test)
nw.Window.get().title = title
}
/**********************************************************************
* vim:set ts=4 sw=4 : */
return module })}

View File

@ -1,7 +1,7 @@
{ {
"name": "ImageGrid.Viewer.g4", "name": "ImageGrid.Viewer.g4",
"main": "index.html", "main": "index.html",
"version": "0.0.1", "version": "4.0.0a",
"window": { "window": {
"title": "ImageGrid.Viewer (gen4)", "title": "ImageGrid.Viewer (gen4)",
"position": "center", "position": "center",
@ -33,9 +33,11 @@
}, },
"devDependencies": { "devDependencies": {
"less": "*", "less": "*",
"webdriverio": "^4.0.4" "webdriverio": "^4.0.4",
"nwjs": "*"
}, },
"scripts": { "scripts": {
"build-css": "lessc css/layout.less css/layout.css" "build-css": "lessc css/layout.less css/layout.css",
"start": "nw ."
} }
} }

View File

@ -1,40 +0,0 @@
define(function(require){ var module = {}
/**********************************************************************
*
*
*
**********************************************************************/
//var DEBUG = DEBUG != null ? DEBUG : true
/*********************************************************************/
// proof of run...
console.log('111')
// this is global (F*CK!!)...
GLOBAL = 123
// this is not global...
// XXX did I say I hate this CommonJS dance?
var func =
module.func =
function func(){
console.log('>>> func!')
}
var func =
module._func =
function _func(){
// closure test...
console.log('>>> func!', func)
}
/**********************************************************************
* vim:set ts=4 sw=4 : */
return module })

View File

@ -30,6 +30,11 @@ if(typeof(process) != 'undefined'){
global.requirejs = global.requirejs =
window.requirejs = window.requirejs =
require('requirejs') require('requirejs')
var nodeRequire =
global.nodeRequire =
window.nodeRequire =
require
} }