From 4c87161b29f51b9a0483ae4d44cc652517deff97 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 18 Feb 2016 04:16:55 +0300 Subject: [PATCH] refactored the status bar... Signed-off-by: Alex A. Naanou --- ui (gen4)/css/layout.css | 2 +- ui (gen4)/css/layout.less | 2 +- ui (gen4)/data.js | 1 + ui (gen4)/features/meta.js | 3 +- ui (gen4)/features/ui-status.js | 625 ++++++++++++-------------------- ui (gen4)/ui.js | 2 +- 6 files changed, 242 insertions(+), 393 deletions(-) diff --git a/ui (gen4)/css/layout.css b/ui (gen4)/css/layout.css index 5eecc65c..014995a1 100644 --- a/ui (gen4)/css/layout.css +++ b/ui (gen4)/css/layout.css @@ -1173,7 +1173,7 @@ stretching in width... */ -ms-user-select: auto; user-select: auto; } -.overlay-info .float-right { +.overlay-info .spacer ~ * { float: right; } .overlay-info .secondary { diff --git a/ui (gen4)/css/layout.less b/ui (gen4)/css/layout.less index dd277245..13388f7c 100755 --- a/ui (gen4)/css/layout.less +++ b/ui (gen4)/css/layout.less @@ -1034,7 +1034,7 @@ stretching in width... */ .overlay-info:hover { .user-select(auto); } -.overlay-info .float-right { +.overlay-info .spacer~* { float: right; } .overlay-info .secondary { diff --git a/ui (gen4)/data.js b/ui (gen4)/data.js index ef13c567..81aceeb1 100755 --- a/ui (gen4)/data.js +++ b/ui (gen4)/data.js @@ -2740,6 +2740,7 @@ var DataWithTagsPrototype = { getTags: function(gids){ gids = arguments.length > 1 ? [].slice.call(arguments) : gids gids = gids == null || gids == 'current' ? this.getImage() : gids + gids = gids == null ? [] : gids gids = gids.constructor !== Array ? [gids] : gids if(this.tags == null){ diff --git a/ui (gen4)/features/meta.js b/ui (gen4)/features/meta.js index bc34310e..67773129 100755 --- a/ui (gen4)/features/meta.js +++ b/ui (gen4)/features/meta.js @@ -103,8 +103,7 @@ core.ImageGridFeatures.Feature('viewer-testing', [ //'ui-current-image-indicator-hide-on-screen-nav', //'ui-base-ribbon-indicator', 'ui-passive-base-ribbon-indicator', - 'ui-image-state-indicator', - 'ui-global-state-indicator', + 'ui-status-bar', 'ui-url-history', 'ui-browse-actions', diff --git a/ui (gen4)/features/ui-status.js b/ui (gen4)/features/ui-status.js index 400aa6bc..5c349980 100755 --- a/ui (gen4)/features/ui-status.js +++ b/ui (gen4)/features/ui-status.js @@ -85,17 +85,18 @@ var makeStateIndicatorItem = function(container, type, text){ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// XXX Add status messages and log... -var ImageStateIndicatorActions = actions.Actions({ +var StatusBarActions = actions.Actions({ config: { - // XXX might be a good idea to add custom components API... - 'global-state-indicator-elements': [ - // Q: should index be here or to the right??? + 'status-bar-mode': 'minimal', + 'status-bar-modes': [ + 'none', + 'minimal', + 'full' + ], + 'status-bar-items': [ 'index', - //'path', 'gid', - // XXX is this the right place for this??? - 'info', + //'path', // separates left/right aligned elements... '---', @@ -104,52 +105,26 @@ var ImageStateIndicatorActions = actions.Actions({ 'bookmark', ], - 'global-state-indicator-elements-full-only': [ + // XXX not sure about this... + 'status-bar-full-only': [ 'gid', + 'path', ], - - 'global-state-indicator-modes': [ - 'none', - 'minimal', - 'full', - ], - 'global-state-indicator-mode': null, }, - // Status indicator handlers... - // - // Format: - // { - // : , - // : | , - // ... - // } - // - // Supported actions: - // - make - // - update - // - remove - // - // NOTE: built-in handlers can be overloaded by user. - // NOTE: alias loops are ignored. - // - // XXX make this visible to the user??? - // XXX is this too complex??? - __state_indicator_elements__: { - // XXX make position editable... - // - edit position on click - // - goto position on enter/blur (blur with value) - // - cancel on esc/blur (blur with no value) - // - treat index depending on mode (global/ribbon) - // XXX might be a good idea to auto-reset global index to ribbon... - index: function(action, container, elem, gid){ + __statusbar_elements__: { + index: function(item, gid, img){ var that = this - // construct... - if(action == 'make'){ - return $('').addClass(elem) - // XXX might be a good idea to make this an input... + gid = gid || this.current + + // make an element... + if(typeof(item) == typeof('str')){ + var type = item + item = $('') + .addClass(type) .append($('') .addClass('position') + .attr('info', 'Image position (click to edit image position)') .click(function(){ // XXX enter edit mode -> select contents... // XXX might be a good idea to live select @@ -157,314 +132,269 @@ var ImageStateIndicatorActions = actions.Actions({ //$(this) // .prop('contenteditable', true) // XXX - }) - // XXX STUB... - .on('mouseover', function(){ - that.showInfo('Image position (click to edit image position)') - }) - // XXX STUB... - .on('mouseout', function(){ - that.hideInfo() })) .append($('') .addClass('length') + .attr('info', 'Image position (click to toggle ribbon/global)') // toggle index state... .click(function(){ $(this).parent() .toggleClass('global') - that.updateStateIndicators() - }) - // XXX STUB... - .on('mouseover', function(){ - that.showInfo('Image position (click to toggle ribbon/global)') - }) - // XXX STUB... - .on('mouseout', function(){ - that.hideInfo() + that.updateStatusBar() })) - // update... - } else if(action == 'update'){ - gid = gid || this.current - - var c = container.find('.'+elem) - - // global index... - if(c.hasClass('global')){ - c.find('.position') - .text(this.data.getImageOrder(gid)+1) - c.find('.length') - .text('/'+ this.data.length) - - // ribbon index... - } else { - c.find('.position') - .text(this.data.getImageOrder('ribbon', gid)+1) - c.find('.length') - .text('/'+ this.data.getImages(gid).len) - } - - // remove... - } else if(action == 'remove'){ - container.find('.'+elem).remove() + } else { + var type = item.attr('type') } + + // update... + // global index... + if(item.hasClass('global')){ + item.find('.position') + .text(this.data.getImageOrder(gid)+1) + item.find('.length') + .text('/'+ this.data.length) + + // ribbon index... + } else { + item.find('.position') + .text(this.data.getImageOrder('ribbon', gid)+1) + item.find('.length') + .text('/'+ this.data.getImages(gid).len) + } + + return item }, // XXX handle path correctly... - gid: function(action, container, elem, gid){ - // construct... - if(action == 'make'){ - return $('') - .addClass(elem + ' expanding-text ') + gid: function(item, gid, img){ + var that = this + gid = gid || this.current + img = img || (this.images && gid in this.images && this.images[gid]) + + // make an element... + if(typeof(item) == typeof('str')){ + var type = item + item = $('') + .addClass(type + ' expanding-text ') + .attr('info', type == 'gid' ? 'Image GID' + : type == 'path'? 'Image filename/path' + : '') .append($('')) .append($('