/********************************************************************** * * * **********************************************************************/ define(function(require){ var module = {} //var DEBUG = DEBUG != null ? DEBUG : true var toggler = require('lib/toggler') var actions = require('lib/actions') var features = require('lib/features') var keyboard = require('lib/keyboard') var data = require('imagegrid/data') var images = require('imagegrid/images') var ribbons = require('imagegrid/ribbons') var core = require('features/core') var base = require('features/base') /*********************************************************************/ var makeStateIndicator = function(type){ return $('
') .addClass('state-indicator-container ' + type || '') } // XXX do we need this??? var makeStateIndicatorItem = function(container, type, text){ var item = $('
') .addClass('item '+ type || '') .attr('text', text) this.ribbons.viewer.find('.state-indicator-container.'+container) .append(item) return item } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // XXX revise how/where info is displayed... var StatusBarActions = actions.Actions({ config: { 'status-bar-mode': 'minimal', 'status-bar-modes': [ 'none', 'minimal', 'full', ], // XXX make different configurations for different modes instead // of hiding some items... (???) 'status-bar-items': [ 'index', 'ribbon', 'gid', 'path', // separates left/right aligned elements... '---', 'mark', 'bookmark', ], // XXX not sure about this... 'status-bar-full-only': [ 'gid', 'path', ], 'status-bar-index': { 'mode': 'normal', // NOTE: this would need to reconstruct the status bar for // changes to take effect, i.e. call .resetStatusBar() // XXX might be a good idea to run an editor on click on // touch devices... 'editable': true, 'live-update-on-edit': false, }, }, __statusbar_elements__: { index: function(item, gid, img){ var that = this gid = gid || this.current // make an element... if(typeof(item) == typeof('str')){ var type = item item = $('') .addClass(type) .append(!(this.config['status-bar-index'] || {})['editable'] ? // not-editable... $('') .addClass('position') .attr('info', 'Image position (click to toggle ribbon/global)') // toggle index state... .click(function(){ that.toggleStatusBarIndexMode() that.updateStatusBar() }) // editable... : $('') .addClass('position editable') .attr('info', 'Image position (click to edit)') .makeEditable() // select image when done... .on('edit-done', function(_, text){ var i = parseInt(text) i = i >= 1 ? i-1 : i == null ? 'current' : i that.focusImage(i, item.hasClass('global') ? 'global' : undefined) }) // update image position... // XXX this appears to be run in the node context... .keyup(function(){ // XXX KeyboardEvent does not appear to have this... //event.stopPropagation() if((that.config['status-bar-index'] || {})['live-update-on-edit']){ var i = parseInt($(this).text()) i = i >= 1 ? i-1 : i == null ? 'current' : i that.focusImage(i, item.hasClass('global') ? 'global' : undefined) } }) .click(function(){ $(this).selectText() }) .blur(function(){ that.updateStatusBar() })) .append($('') .addClass('length') .attr('info', 'Image position (click to toggle ribbon/global)') // toggle index state... .click(function(){ that.toggleStatusBarIndexMode() that.updateStatusBar() })) } else { var type = item.attr('type') } // update... // NOTE: using .toggleStatusBarIndexMode(..) here will fall // into an infinite recursion... var cls = (that.config['status-bar-index'] || {})['mode'] || 'normal' item .addClass(cls) .removeClass(cls != 'normal' ? 'normal' : 'global') // global index... if(cls == 'global'){ item.find('.position:not(:focus)') .text(this.data ? this.data.getImageOrder(gid)+1 : 0) item.find('.length') .text('/'+ (this.data ? this.data.length : 0)) // ribbon index... } else { item.find('.position:not(:focus)') .text(this.data ? this.data.getImageOrder('ribbon', gid)+1 : 0) item.find('.length') .text('/'+ (this.data ? this.data.getImages(gid).len : 0)) } return item }, ribbon: function(item, gid, img){ var that = this // get ribbon number... var n = (this.data && this.data.ribbon_order.length > 0) ? this.data.getRibbonOrder(gid || this.current) : '-' // flag the base ribbon... n += (this.data && this.data.base && this.data.getRibbon(gid) == this.base) ? '*' : '' // make an element... if(typeof(item) == typeof('str')){ item = $('') .addClass('ribbon-number') .attr('info', 'Current ribbon (click to edit)') .makeEditable() .on('edit-done', function(_, text){ that.focusRibbon(text == '*' ? that.base : parseInt(text)) }) .click(function(){ $(this).selectText() }) .blur(function(){ that.updateStatusBar() }) } item.text(n) return item }, // XXX handle path correctly... 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($('