added a demo feature...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-04-02 16:28:53 +03:00
parent 4e1b953398
commit 2738b470ec
5 changed files with 100 additions and 156 deletions

View File

@ -22,7 +22,9 @@ var slideshow = require('features/ui-slideshow')
var exteditor = require('features/external-editor') var exteditor = require('features/external-editor')
var metadata = require('features/metadata') var metadata = require('features/metadata')
var meta = require('features/meta') var meta = require('features/meta')
var experimental = require('features/experimental') var experimental = require('features/experimental')
var demo = require('features/demo')
if(window.nodejs != null){ if(window.nodejs != null){
var filesystem = require('features/filesystem') var filesystem = require('features/filesystem')

87
ui (gen4)/features/demo.js Executable file
View File

@ -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 })

View File

@ -31,6 +31,7 @@ var base = require('features/base')
// ribbon - specific ribbon (gid) // ribbon - specific ribbon (gid)
// Array // Array
// //
// NOTE: of no data is defined this will not have any effect...
function makeTagTogglerAction(tag){ function makeTagTogglerAction(tag){
var t = function(target, action){ var t = function(target, action){
if(target == '?' || target == 'on' || target == 'off'){ if(target == '?' || target == 'on' || target == 'off'){
@ -38,6 +39,11 @@ function makeTagTogglerAction(tag){
action = target action = target
target = x target = x
} }
// special case: no data...
if(this.data == null){
return action == '??' ? ['on', 'off'] : 'off'
}
target = target || 'current' target = target || 'current'
target = target == 'all' target = target == 'all'
|| target == 'loaded' || target == 'loaded'

View File

@ -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 })

View File

@ -42,10 +42,6 @@ var actions = require('lib/actions')
var data = require('data') var data = require('data')
var ribbons = require('ribbons') var ribbons = require('ribbons')
// XXX
var testing = require('testing')
var viewer = require('viewer') var viewer = require('viewer')
//var promise = require('promise') //var promise = require('promise')
@ -306,6 +302,7 @@ $(function(){
// XXX this is not for production... // XXX this is not for production...
'experiments', 'experiments',
'demo',
]) ])
@ -339,11 +336,8 @@ $(function(){
// load some testing data if nothing else loaded... // load some testing data if nothing else loaded...
if(!a.url_history || Object.keys(a.url_history).length == 0){ if(!a.url_history || Object.keys(a.url_history).length == 0){
// NOTE: we can (and do) load this in parts... // NOTE: we can (and do) load this in parts...
a a.loadDemoIndex()
.load({
data: data.Data(testing.mock_data),
images: testing.makeTestImages(),
})
// this is needed when loading legacy sources that do not have tags // this is needed when loading legacy sources that do not have tags
// synced... // synced...
// do not do for actual data... // do not do for actual data...
@ -351,6 +345,7 @@ $(function(){
} }
// XXX calling a.clear() does not display this...
a.setEmptyMsg( a.setEmptyMsg(
'Nothing loaded...', 'Nothing loaded...',
'Press \'O\' to load, \'F1\' for help or \'?\' for keyboard mappings.') 'Press \'O\' to load, \'F1\' for help or \'?\' for keyboard mappings.')
@ -369,7 +364,7 @@ $(function(){
}, },
a)) a))
// drop keys if repeating to fast... // drop keys if repeating too fast...
// NOTE: this is done for smoother animations... // NOTE: this is done for smoother animations...
} else { } else {
$(document) $(document)