/********************************************************************** * * * **********************************************************************/ 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 data = require('data') var images = require('images') var ribbons = require('ribbons') var core = require('features/core') var base = require('features/base') /*********************************************************************/ // XXX add setup / teardown... // XXX might be a good idea to merge this with single image mode... 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 Add status messages and log... var ImageStateIndicatorActions = actions.Actions({ config: { // XXX might be a good idea to add custom components API... 'global-state-indicator-elements': [ // XXX should index be here or to the right??? 'index', //'path', 'gid', // separates left/right aligned elements... '---', 'mark', 'bookmark', ], 'global-state-indicator-elements-full-only': [ 'gid', ], 'global-state-indicator-modes': [ 'none', 'minimal', 'full', ], 'global-state-indicator-mode': null, }, // 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) index: function(action, container, elem, gid){ var that = this // construct... if(action == 'make'){ return $('').addClass(elem) // XXX might be a good idea to make this an input... .append($('') .addClass('position') .click(function(){ // XXX enter edit mode -> select contents... // XXX might be a good idea to live select // the indexed image... (???) //$(this) // .prop('contenteditable', true) // XXX })) .append($('') .addClass('length') // toggle index state... .click(function(){ $(this).parent() .toggleClass('global') that.updateStateIndicators() })) // 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() } }, // XXX handle path correctly... gid: function(action, container, elem, gid){ // construct... if(action == 'make'){ return $('') .addClass(elem + ' expanding-text ') .append($('')) .append($('