diff --git a/ui (gen4)/actions.js b/ui (gen4)/actions.js index d748b890..7c82c56d 100755 --- a/ui (gen4)/actions.js +++ b/ui (gen4)/actions.js @@ -15,11 +15,17 @@ console.log('>>> actions') // arguments for actions (a-la jQuery collections): // // Image - current image -// Images - all images +// .next( | 'all') +// .prev(..) // Ribbon - ribbon or ribbon images +// .next(..) +// .prev(..) +// +// Images - all images // Marked - marked images // Bookmarked - bookmarked images // +// // NOTE: these can also beused as a basis for actions... // // @@ -35,12 +41,14 @@ function(context, name, args){ : null var jQuery = typeof(jQuery) != 'undefined' ? jQuery : null + // jQuery event... if(typeof(context) == typeof('str') || (jq_object != null && context instanceof jQuery)){ var c = $(context) .trigger(name, args) + // node event... } else if(EventEmitter != null && context instanceof EventEmitter){ var c = context .emit.apply(context, [name].concat(args)) @@ -129,6 +137,37 @@ function Actions(context, names, actions, mode){ +/*********************************************************************/ +// +// Action variables: +// +// SCREEN_IMAGES +// - screen width in images +// - resolves to number +// +// CURRENT +// - current image +// - resolves to gid +// - support basic math: +/- +// e.g. CURRENT + 1 ~ next image +// +// RIBBON +// - current ribbon +// - resolves to gid +// - support basic math: +/- +// +// BASE +// - base ribbon +// - resolves to gid +// - support basic math: +/- +// +// +// XXX add action variables!!! +var SCREEN_IMAGES = null + + + + /*********************************************************************/ // XXX need a way to define compound actions... @@ -169,12 +208,17 @@ module.BASE_ACTIONS = { // crop... // XXX should this be here on in a crop pligin... cropRibbon: '', - uncropView: '', - uncropAll: '', + cropCurrentRibbonAndAbove: '', + uncropView: 'Uncrop to previous crop', + uncropAll: 'Uncrop to base', + uncropViewAndKeepOrder: + 'Uncrop view to previous crop, keeping current image order', + uncropAllAndKeepOrder: 'Uncrop to base, keeping current image order', openURL: '', //openHistory: '', + saveOrder: '', saveState: '', exportImages: '', @@ -195,14 +239,19 @@ function setupBaseActions(context, actions){ var UI_ACTIONS = module.UI_ACTIONS = { - // basic navigation... - nextImage: 'Focus next image in current ribbon', - nextRibbon: 'Focus next ribbon (down)', - nextScreen: 'Show next screen width of images', + focusImage: '', + focusRibbon: '', - prevImage: 'Focus previous image in current ribbon', - prevRibbon: 'Focus previous ribbon (up)', - prevScreen: 'Show previous screen width of images', + // basic navigation... + nextImage: ['Focus next image in current ribbon', { focusImage: 'next' }], + nextRibbon: ['Focus next ribbon (down)', { focusRibbon: 'next' }], + // XXX actions vars... + nextScreen: ['Show next screen width of images', { focusImage: SCREEN_IMAGES }], + + prevImage: ['Focus previous image in current ribbon', { focusImage: 'prev' }], + prevRibbon: ['Focus previous ribbon (up)', { focusRibbon: 'prev' }], + // XXX actions vars... + prevScreen: ['Show previous screen width of images', { focusImage: -SCREEN_IMAGES }], firstImage: 'Focus first image in ribbon', lastImage: 'Focus last image in ribbon', @@ -238,10 +287,10 @@ module.UI_ACTIONS = { toggleTheme: 'Toggle themes', // dialogs... + // XXX move to specific blocks... openDialog: 'Show open diaolg', historyDialog: 'Show history dialog', cropDialog: 'Show crop dialog', - markDialog: 'Show mark dialog', // panels... togglePanels: '', @@ -290,6 +339,10 @@ module.MARKS_ACTIONS = { invertMarkedRibbon: '', invertMarkedAll: '', + // placing... + placeMarkedAfter: 'Place marked images after current', + placeMarkedBefore: 'Place marked images before current', + shiftMarkedUp: '', shiftMarkedDown: '', shiftMarkedLeft: '', @@ -299,6 +352,9 @@ module.MARKS_ACTIONS = { cropMarkedImages: '', cropMarkedImagesToSingleRibbon: '', + + markDialog: 'Show mark dialog', + placeMarkedDialog: '', } var setupMarksActions = diff --git a/ui (gen4)/data.js b/ui (gen4)/data.js index 3ecfc543..124ba867 100755 --- a/ui (gen4)/data.js +++ b/ui (gen4)/data.js @@ -372,7 +372,7 @@ module.DataPrototype = { if(target in this.ribbons || target.constructor.name == 'Array'){ list = target target = this.current - } else if(target == 'before' || target == 'after'){ + } else if(['before', 'after', 'next', 'prev'].indexOf(target) >= 0){ list = mode mode = target target = this.current @@ -419,10 +419,10 @@ module.DataPrototype = { } // prepare for the search... - if(mode == 'before'){ + if(mode == 'before' || mode == 'prev'){ var step = -1 - } else if(mode == 'after'){ + } else if(mode == 'after' || mode == 'next'){ var step = 1 // strict -- no hit means there is no point in searching... @@ -1470,6 +1470,15 @@ Data.prototype.constructor = Data +/*********************************************************************/ + +// XXX keep this here or move this to a different module??? +module.setupActionHandlers = function(context){ + // XXX +} + + + /********************************************************************** * vim:set ts=4 sw=4 : */ return module }) diff --git a/ui (gen4)/images.js b/ui (gen4)/images.js index 3625eb6a..e91eeec6 100755 --- a/ui (gen4)/images.js +++ b/ui (gen4)/images.js @@ -508,6 +508,15 @@ Images.prototype.constructor = Images +/*********************************************************************/ + +// XXX keep this here or move this to a different module??? +module.setupActionHandlers = function(context){ + // XXX +} + + + /********************************************************************** * vim:set ts=4 sw=4 : */ return module }) diff --git a/ui (gen4)/ribbons.js b/ui (gen4)/ribbons.js index 2ee9af2b..0f5d9ab1 100755 --- a/ui (gen4)/ribbons.js +++ b/ui (gen4)/ribbons.js @@ -1,6 +1,6 @@ /********************************************************************** * -* Minomal UI API... +* Minimal UI API... * * **********************************************************************/ @@ -23,6 +23,39 @@ var IMAGE_UPDATERS = module.IMAGE_UPDATERS = [] +/*********************************************************************/ + +// XXX add inheritance... +var makeObject = +module.makeObject = +function makeObject(name, cls, obj){ + // NOTE: we are using eval here to name the function correctly as + // simply assigning .name does not work... + // XXX think of a cleaner way... + eval(('var O = function ${NAME}(){' + +' if(this.constructor.name != name){' + +' return new (Function.prototype.bind.apply(' + +' ${NAME},' + +' arguments.length == 1 ? [null, arguments[0]]' + +' : [null].concat(Array.apply(null, arguments))))' + +' }' + +'' + +' if(this.__init__ != null){' + +' this.__init__.apply(this, arguments)' + +' }' + +'' + +' return this' + +'}').replace(/\${NAME}/g, name)) + + O.__proto__ = cls == null ? {} : cls + O.prototype = obj == null ? {} : obj + O.prototype.constructor = O + + return O +} + + + /*********************************************************************/ // // This expects the following HTML structure... @@ -1161,6 +1194,23 @@ Ribbons.prototype.constructor = Ribbons +/*********************************************************************/ + +// XXX keep this here or move this to a different module??? +module.setupActionHandlers = function(ribbons, context, actions){ + + context.on('focusImage', function(evt, img){ + ribbons.alignRibbon(ribbons.focusImage(img)) + }) + + + // XXX this does not need focus ribbon handlers as the Data will + // get those, chose an image and trigger the appropriate + // focusImage event... +} + + + /********************************************************************** * vim:set ts=4 sw=4 : */ return module })