From dd8d5c32f6db97ef8c9ff47f7744ebc31ba2929d Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 6 Dec 2014 02:46:43 +0300 Subject: [PATCH] several fixes for features.js and moved app actions to a feature... Signed-off-by: Alex A. Naanou --- ui (gen4)/lib/features.js | 21 ++++++++--- ui (gen4)/ui.js | 3 +- ui (gen4)/viewer.js | 78 ++++++++++++++++++++++++--------------- 3 files changed, 66 insertions(+), 36 deletions(-) diff --git a/ui (gen4)/lib/features.js b/ui (gen4)/lib/features.js index 3925661f..04f531bb 100755 --- a/ui (gen4)/lib/features.js +++ b/ui (gen4)/lib/features.js @@ -164,16 +164,25 @@ Feature.prototype.constructor = Feature var FeatureSet = module.FeatureSet = { buildFeatureList: function(obj, lst){ + lst = lst == null ? Object.keys(this) : lst lst = lst.constructor !== Array ? [lst] : lst var that = this - // sort features via priority... - lst = lst.sort(function(a, b){ - a = that[a] == null ? 0 : that[a].getPriority() - b = that[b] == null ? 0 : that[b].getPriority() - return b - a - }) + // sort features via priority keeping the order as close to + // manual as possible... + var l = lst.length + lst = lst + // remove undefined features... + .filter(function(e){ return that[e] != null }) + // build the sort table: [ , , ] + // NOTE: is element number from the tail... + .map(function(e, i){ return [ -that[e].getPriority(), i, e ] }) + // do the sort... + // XXX for some reason JS compares lists as strings... + .sort(function(a, b){ return a[0] - b[0] || a[1] - b[1] }) + // cleanup... + .map(function(e){ return e[2] }) // sort features via dependencies... var unapplicable = [] diff --git a/ui (gen4)/ui.js b/ui (gen4)/ui.js index 94142f81..9387caa7 100755 --- a/ui (gen4)/ui.js +++ b/ui (gen4)/ui.js @@ -212,15 +212,16 @@ $(function(){ viewer.ImageGridFeatures.setup(a, [ // features... - 'ui-partial-ribbons', 'ui-ribbon-align-to-order', 'ui-single-image-view', 'fs-loader', + 'app-control', // ui elements... 'image-marks', 'image-bookmarks', + 'ui-partial-ribbons', // chrome... 'ui-animation', 'ui-bounds-indicators', diff --git a/ui (gen4)/viewer.js b/ui (gen4)/viewer.js index e7152152..cefb55f7 100755 --- a/ui (gen4)/viewer.js +++ b/ui (gen4)/viewer.js @@ -785,26 +785,6 @@ actions.Actions(Client, { setEmptyMsg: ['Set message to be displayed when nothing is loaded.', function(msg, help){ this.ribbons.setEmptyMsg(msg, help) }], - // App stuff... - // XXX move this to a viewer window action set - // XXX revise these... - close: ['Cloase viewer', - function(){ - // XXX should we do anything else here like auto-save??? - window.close() - }], - toggleFullScreen: ['', - function(){ - // XXX where should toggleFullscreenMode(..) be defined... - toggleFullscreenMode() - }], - showDevTools: ['', - function(){ - if(window.showDevTools != null){ - showDevTools() - } - }], - // align modes... // XXX these should also affect up/down navigation... @@ -1050,7 +1030,6 @@ actions.Actions(Client, { function(target){ return updateImagePosition(this, target) }], shiftImageDown: [ function(target){ return updateImagePosition(this, target) }], - shiftImageLeft: [ function(target){ this.ribbons.placeImage(target, -1) @@ -1077,6 +1056,7 @@ actions.Actions(Client, { } }], + reverseImages: [ reloadAfter() ], reverseRibbons: [ reloadAfter() ], @@ -1142,6 +1122,7 @@ var ImageGridFeatures = module.ImageGridFeatures = Object.create(features.FeatureSet) + //--------------------------------------------------------------------- // NOTE: this is split out to an action so as to enable ui elements to @@ -1262,7 +1243,6 @@ var PartialRibbonsActions = actions.Actions({ // - go to top ribbon // - shift image up // XXX The two should be completely independent.... (???) -// XXX need to test and tweak with actual images... var PartialRibbons = module.PartialRibbons = features.Feature(ImageGridFeatures, { title: 'Partial Ribbons', @@ -1456,6 +1436,7 @@ module.AlignRibbonsToImageOrder = features.Feature(ImageGridFeatures, { doc: '', tag: 'ui-ribbon-align-to-order', + exclusive: ['ui-ribbon-align'], handlers: [ ['focusImage.post', function(){ this.alignByOrder() }] @@ -1463,15 +1444,13 @@ module.AlignRibbonsToImageOrder = features.Feature(ImageGridFeatures, { }) - -//--------------------------------------------------------------------- - var AlignRibbonsToFirstImage = module.AlignRibbonsToFirstImage = features.Feature(ImageGridFeatures, { title: '', doc: '', tag: 'ui-ribbon-align-to-first', + exclusive: ['ui-ribbon-align'], handlers: [ ['focusImage.post', function(){ this.alignByFirst() }], @@ -1819,7 +1798,6 @@ module.CurrentImageIndicator = features.Feature(ImageGridFeatures, { }) -// XXX this depends on CurrentImageIndicator... var CurrentImageIndicatorHideOnFastScreenNav = module.CurrentImageIndicatorHideOnFastScreenNav = features.Feature(ImageGridFeatures, { title: '', @@ -1882,8 +1860,6 @@ module.CurrentImageIndicatorHideOnFastScreenNav = features.Feature(ImageGridFeat ], }) - -// XXX this depends on CurrentImageIndicator... var CurrentImageIndicatorHideOnScreenNav = module.CurrentImageIndicatorHideOnScreenNav = features.Feature(ImageGridFeatures, { title: '', @@ -2171,6 +2147,51 @@ module.ImageBookmarks = features.Feature(ImageGridFeatures, { //--------------------------------------------------------------------- + +var AppControlActions = actions.Actions({ + // XXX revise these... + close: ['Cloase viewer', + function(){ + // XXX should we do anything else here like auto-save??? + window.close() + }], + toggleFullScreen: ['', + function(){ + // XXX where should toggleFullscreenMode(..) be defined... + toggleFullscreenMode() + }], + showDevTools: ['', + function(){ + if(window.showDevTools != null){ + showDevTools() + } + }], +}) + + +// XXX this needs a better .isApplicable(..) +var AppControl = +module.AppControl = features.Feature(ImageGridFeatures, { + title: '', + doc: '', + + tag: 'app-control', + + actions: AppControlActions, + + // XXX test if in: + // - chrome app + // - nw + // - mobile + isApplicable: function(){ + return window.nodejs != null + }, +}) + + + +//--------------------------------------------------------------------- +// XXX at this point this is a stub... var FileSystemLoader = module.FileSystemLoader = features.Feature(ImageGridFeatures, { title: '', @@ -2185,7 +2206,6 @@ module.FileSystemLoader = features.Feature(ImageGridFeatures, { - /********************************************************************** * vim:set ts=4 sw=4 : */ return module })