From 2738b470ec1d8dc4bad69b0eba828a4a98e122a5 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 2 Apr 2016 16:28:53 +0300 Subject: [PATCH] added a demo feature... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/all.js | 2 + ui (gen4)/features/demo.js | 87 ++++++++++++++++++++ ui (gen4)/features/ui-marks.js | 6 ++ ui (gen4)/testing.js | 146 --------------------------------- ui (gen4)/ui.js | 15 ++-- 5 files changed, 100 insertions(+), 156 deletions(-) create mode 100755 ui (gen4)/features/demo.js delete mode 100755 ui (gen4)/testing.js diff --git a/ui (gen4)/features/all.js b/ui (gen4)/features/all.js index 12e6de76..69e67139 100755 --- a/ui (gen4)/features/all.js +++ b/ui (gen4)/features/all.js @@ -22,7 +22,9 @@ var slideshow = require('features/ui-slideshow') var exteditor = require('features/external-editor') var metadata = require('features/metadata') var meta = require('features/meta') + var experimental = require('features/experimental') +var demo = require('features/demo') if(window.nodejs != null){ var filesystem = require('features/filesystem') diff --git a/ui (gen4)/features/demo.js b/ui (gen4)/features/demo.js new file mode 100755 index 00000000..a877c18c --- /dev/null +++ b/ui (gen4)/features/demo.js @@ -0,0 +1,87 @@ +/********************************************************************** +* +* +* +**********************************************************************/ + +define(function(require){ var module = {} + +//var DEBUG = DEBUG != null ? DEBUG : true + +var actions = require('lib/actions') +var features = require('lib/features') +var toggler = require('lib/toggler') + +var data = require('data') +var images = require('images') + +var core = require('features/core') + + + +/*********************************************************************/ + +var demo_data = +module.demo_data = { + varsion: '3.0', + + current: '3', + base: 'r0', + + order: [], + + ribbon_order: ['r0', 'r1'], + ribbons: { + r1: ['1', '2', '3'], + r0: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', + 'y', 'z'] + }, + + tags: { + selected: ['b', 'z'], + bookmark: ['1', 'c', 'z'], + }, + + // NOTE: group gids do not have to be present in .order, they will + // get added on .collapseGroup(..)... + groups: { + g0: ['a', 'b', 'c'], + g1: ['l', 'y'], + }, +} +Object.keys(demo_data.ribbons).forEach(function(k){ + demo_data.order = demo_data.order.concat(demo_data.ribbons[k]) +}) + + + +/*********************************************************************/ + +var Demo = +module.Demo = core.ImageGridFeatures.Feature({ + title: '', + doc: '', + + tag: 'demo', + depends: [ + 'base', + ], + + actions: actions.Actions({ + loadDemoIndex: ['File/Load demo data', + function(){ + this.load({ + data: data.Data(demo_data), + images: images.Images(data), + }) + }], + }) +}) + + + + +/********************************************************************** +* vim:set ts=4 sw=4 : */ +return module }) diff --git a/ui (gen4)/features/ui-marks.js b/ui (gen4)/features/ui-marks.js index 706b0eb8..004d3ab8 100755 --- a/ui (gen4)/features/ui-marks.js +++ b/ui (gen4)/features/ui-marks.js @@ -31,6 +31,7 @@ var base = require('features/base') // ribbon - specific ribbon (gid) // Array // +// NOTE: of no data is defined this will not have any effect... function makeTagTogglerAction(tag){ var t = function(target, action){ if(target == '?' || target == 'on' || target == 'off'){ @@ -38,6 +39,11 @@ function makeTagTogglerAction(tag){ action = target target = x } + // special case: no data... + if(this.data == null){ + return action == '??' ? ['on', 'off'] : 'off' + } + target = target || 'current' target = target == 'all' || target == 'loaded' diff --git a/ui (gen4)/testing.js b/ui (gen4)/testing.js deleted file mode 100755 index 858ef4d1..00000000 --- a/ui (gen4)/testing.js +++ /dev/null @@ -1,146 +0,0 @@ -/********************************************************************** -* -* -* -**********************************************************************/ - -if(typeof(process) != 'undefined'){ - var glob = require('glob') -} - - -//var DEBUG = DEBUG != null ? DEBUG : true -// -define(function(require){ var module = {} - - -var data = -module.data = - require('data') - -var images = -module.images = - require('images') - -var ribbons = -module.ribbons = - require('ribbons') - -var v = -module.v = - require('viewer') - - - -/*********************************************************************/ - - -var mock_data = -module.mock_data = { - varsion: '3.0', - - current: '3', - base: 'r0', - - order: [], - - ribbon_order: ['r0', 'r1'], - ribbons: { - r1: ['1', '2', '3'], - r0: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', - 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', - 'y', 'z'] - }, - - tags: { - selected: ['b', 'z'], - bookmark: ['1', 'c', 'z'], - }, - - // NOTE: group gids do not have to be present in .order, they will - // get added on .collapseGroup(..)... - groups: { - g0: ['a', 'b', 'c'], - g1: ['l', 'y'], - }, -} -Object.keys(mock_data.ribbons).forEach(function(k){ - mock_data.order = mock_data.order.concat(mock_data.ribbons[k]) -}) - -var test_data = -module.test_data = - data.Data.fromJSON(mock_data) - - -var makeTestRibbons = -module.makeTestRibbons = function(viewer, images){ - viewer = viewer == null ? $('.viewer') : viewer - return ribbons.Ribbons(viewer, images) -} - -var makeTestImages = -module.makeTestImages = function(data){ - return images.Images(data) -} - - -var loadTestRibbons = -module.loadTestRibbons = function(ribbons, data, images, viewer){ - images = images == null ? makeTestImages() : images - ribbons = ribbons == null ? makeTestRibbons(viewer, images) : ribbons - data = data == null ? module.mock_data : data - return ribbons.updateData(data) -} - - -var setupActions = -module.setupActions = function(viewer){ - viewer = viewer == null ? $('.viewer') : viewer - //r = r == null ? makeTestRibbons(viewer, images) : r - - var vv = Object.create(v.Client) - - // XXX need to automate this... - vv.config = Object.create(vv.config || {}) - - return vv -} - - -/*********************************************************************/ -// node.js specific stuff... -if(typeof(glob) != 'undefined'){ - - window.load2014 = function(){ - return a.loadImages('l:/media/img/my/2014/') - //return glob('l:/media/img/my/2014/*jpg') - // .on('end', function(l){ window.a.loadURLs(l) }) - } - - - window.loadInsta = function(){ - return a.loadImages('l:/mnt/Dropbox/Instagram/fav/ALL/') - //return glob('l:/mnt/Dropbox/Instagram/fav/ALL/*+(jpg|png)') - // .on('end', function(l){ window.a.loadURLs(l) }) - } - - - window.loadMBFWR1 = function(logger){ - a.loadIndex('L:/mnt/hdd15 (photo)/NTFS2/media/img/my/work/20151022 - MBFWR (1),/preview (RAW)/', logger) - } - - - /* - window.loadSaved = function(){ - a.data.loadJSON(require('fs').readFileSync('insta.json', 'utf-8')) - } - */ - -} - - - -/********************************************************************** -* vim:set ts=4 sw=4 : */ -return module }) diff --git a/ui (gen4)/ui.js b/ui (gen4)/ui.js index 12598446..a88c571d 100755 --- a/ui (gen4)/ui.js +++ b/ui (gen4)/ui.js @@ -42,10 +42,6 @@ var actions = require('lib/actions') var data = require('data') var ribbons = require('ribbons') - -// XXX -var testing = require('testing') - var viewer = require('viewer') //var promise = require('promise') @@ -306,6 +302,7 @@ $(function(){ // XXX this is not for production... 'experiments', + 'demo', ]) @@ -339,11 +336,8 @@ $(function(){ // load some testing data if nothing else loaded... if(!a.url_history || Object.keys(a.url_history).length == 0){ // NOTE: we can (and do) load this in parts... - a - .load({ - data: data.Data(testing.mock_data), - images: testing.makeTestImages(), - }) + a.loadDemoIndex() + // this is needed when loading legacy sources that do not have tags // synced... // do not do for actual data... @@ -351,6 +345,7 @@ $(function(){ } + // XXX calling a.clear() does not display this... a.setEmptyMsg( 'Nothing loaded...', 'Press \'O\' to load, \'F1\' for help or \'?\' for keyboard mappings.') @@ -369,7 +364,7 @@ $(function(){ }, a)) - // drop keys if repeating to fast... + // drop keys if repeating too fast... // NOTE: this is done for smoother animations... } else { $(document)