From c4d4e98450b0bac458d0d1e01c765af258ed2ad3 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 12 Sep 2015 04:53:13 +0300 Subject: [PATCH] moved action introspection to actions + some minor tweaks... Signed-off-by: Alex A. Naanou --- ui (gen4)/lib/widget/browse.js | 4 +- ui (gen4)/ui.js | 54 ++---------------------- ui (gen4)/viewer.js | 76 ++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 53 deletions(-) diff --git a/ui (gen4)/lib/widget/browse.js b/ui (gen4)/lib/widget/browse.js index 33cc32e4..8bbc013a 100755 --- a/ui (gen4)/lib/widget/browse.js +++ b/ui (gen4)/lib/widget/browse.js @@ -1863,8 +1863,8 @@ object.makeConstructor('PathList', PathListPrototype) var makePathList = -module.makePathList = function(elem, list){ - return PathList(elem, { data: list }) +module.makePathList = function(elem, list, path){ + return PathList(elem, { data: list, path: path }) } diff --git a/ui (gen4)/ui.js b/ui (gen4)/ui.js index 3cdea63f..b3c35232 100755 --- a/ui (gen4)/ui.js +++ b/ui (gen4)/ui.js @@ -204,10 +204,10 @@ module.GLOBAL_KEYBOARD = { // marking... M: { default: 'toggleMark', + alt: 'browseActions: "/Mark/"', }, A: { - // XXX STUB... - alt: function(){ browseActions() }, + alt: 'browseActions', ctrl: 'toggleMark!: "ribbon" "on"', }, D: { @@ -222,6 +222,7 @@ module.GLOBAL_KEYBOARD = { B: { default: 'toggleBookmark', ctrl: 'toggleTheme!', + alt: 'browseActions: "/Bookmark/"', }, }, } @@ -233,55 +234,6 @@ module.GLOBAL_KEYBOARD = { $(function(){ - window.browse = browse - window.overlay = overlay - - actionCategoryOrder = [ - 'File', - 'Edit', - 'Navigate', - ] - - var makeActionLister = function(list, filter){ - return function(){ - var paths = a.getPath() - var actions = {} - - // pre-order the main categories... - actionCategoryOrder.forEach(function(k){ - actions[k] = null - }) - - // build the action list... - Object.keys(paths).forEach(function(k){ - var n = paths[k][0] - var k = filter ? filter(k) : k - actions[k] = function(){ - return a[n]() - } - }) - - var o = overlay.Overlay($('body'), - list(null, actions) - .open(function(){ o.close() })) - - L = o.client - } - } - - // XXX make this an action... - window.browseActions = makeActionLister(browse.makePathList) - - // XXX make this an action... - window.listActions = makeActionLister(browse.makeList, - // format the doc to: (, ..) - // NOTE: this a bit naive... - function(k){ - var l = k.split(/[\\\/\|]/) - var a = l.pop() - return a +' ('+ l.join(', ') +')' - }) - // XXX window.a = testing.setupActions() .load({ diff --git a/ui (gen4)/viewer.js b/ui (gen4)/viewer.js index 7f634fc2..7a243a96 100755 --- a/ui (gen4)/viewer.js +++ b/ui (gen4)/viewer.js @@ -2210,6 +2210,80 @@ module.GlobalStateIndicator = features.Feature(ImageGridFeatures, { +//--------------------------------------------------------------------- +// XXX revise names... + +// widgets... +var browse = require('lib/widget/browse') +var overlay = require('lib/widget/overlay') + +var makeActionLister = function(list, filter, pre_order){ + pre_order = typeof(filter) == typeof(true) ? filter : pre_order + filter = typeof(filter) == typeof(true) ? null : filter + + return function(path){ + var paths = a.getPath() + var actions = {} + + // pre-order the main categories... + if(pre_order){ + this.config['action-category-order'].forEach(function(k){ + actions[k] = null + }) + } + + // build the action list... + Object.keys(paths).forEach(function(k){ + var n = paths[k][0] + var k = filter ? filter(k, n) : k + actions[k] = function(){ + return a[n]() + } + }) + + var o = overlay.Overlay($('body'), + list(null, actions, path) + .open(function(){ o.close() })) + + return this + } +} + +var ActionTreeActions = actions.Actions({ + browseActions: ['Interface/Browse actions', + makeActionLister(browse.makePathList, true)], + + listActions:['Interface/List actions', + makeActionLister(browse.makeList, + // format the doc to: (, ..) + // NOTE: this a bit naive... + function(k){ + var l = k.split(/[\\\/\|]/) + var a = l.pop() + return a +' ('+ l.join(', ') +')' + })], +}) + +var ActionTree = +module.ActionTree = features.Feature(ImageGridFeatures, { + title: '', + doc: '', + + tag: 'ui-action-tree', + + config: { + 'action-category-order': [ + 'File', + 'Edit', + 'Navigate', + ], + }, + + actions: ActionTreeActions, +}) + + + //--------------------------------------------------------------------- // XXX console / log / status bar // XXX title bar @@ -2560,6 +2634,7 @@ features.Feature(ImageGridFeatures, 'viewer-testing', [ //'ui-current-image-indicator-hide-on-screen-nav', 'ui-image-state-indicator', 'ui-global-state-indicator', + 'ui-action-tree', // experimental and optional features... //'auto-single-image', @@ -2580,6 +2655,7 @@ features.Feature(ImageGridFeatures, 'viewer-minimal', [ 'ui-current-image-indicator', 'ui-current-image-indicator-hide-on-fast-screen-nav', //'ui-current-image-indicator-hide-on-screen-nav', + 'ui-action-tree', ]) features.Feature(ImageGridFeatures, 'viewer', [