From b6817b7e3b1a0f72149b7f366aee7a78f6bee3e8 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 1 Dec 2017 20:59:58 +0300 Subject: [PATCH] added .addToCrop(..)... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/base.js | 64 ++++++++++++++++++++++++++++++-- ui (gen4)/features/core.js | 2 + ui (gen4)/features/ui-ribbons.js | 1 + ui (gen4)/imagegrid/data.js | 10 +++++ 4 files changed, 74 insertions(+), 3 deletions(-) diff --git a/ui (gen4)/features/base.js b/ui (gen4)/features/base.js index 99745b48..e2d86270 100755 --- a/ui (gen4)/features/base.js +++ b/ui (gen4)/features/base.js @@ -1801,11 +1801,69 @@ module.CropActions = actions.Actions({ // XXX do we need this??? // XXX add gids to crop (current by default)... // XXX use this as undo for .removeFromCrop(..) + // ...after we remove images from a crop we lose their containing + // ribbon information and the order might get messed up by + // horizontal shifting if not undone correctly... addToCrop: ['- Crop/', - function(list, index){ - // XXX + core.doc`Add gids to current crop... + + Place images to their positions in order in current ribbon + .addToCrop(images) + .addToCrop(images, 'keep', 'keep') + -> this + + Place images at order into ribbon... + .addToCrop(images, ribbon, order) + -> this + + As above but place images before/after order... + .addToCrop(images, ribbon, order, 'before') + .addToCrop(images, ribbon, order, 'after') + -> this + + Place images at order but do not touch ribbon position... (horizontal) + .addToCrop(images, 'keep', order) + -> this + + As above but place images before/after order... + .addToCrop(images, 'keep', order, 'before') + .addToCrop(images, 'keep', order, 'after') + -> this + + + Place images to ribbon but do not touch order... (vertical) + .addToCrop(images, ribbon, 'keep') + -> this + + + NOTE: this is signature-compatible with .data.placeImage(..) but + different in that it does not require the images to be loaded + in the current crop... + NOTE: this can only add gids to current crop... + `, + function(gids, ribbon, reference, mode){ + if(!this.cropped){ + return + } + + gids = gids instanceof Array ? gids : [gids] + + var r = this.data.ribbons[this.current_ribbon] + var o = this.data.order + + // add gids to current ribbon... + gids.forEach(function(gid){ + var i = o.indexOf(gid) + if(i >= 0){ + r[i] = gid + } + }) + + // place... + ;(ribbon || reference || mode) + && this.data.placeImage(gids, ribbon, reference, mode) }], - // XXX undo... + // XXX undo -- need containing ribbon info per gid to undo correctly... removeFromCrop: ['Crop|Image/Remove from crop', {browseMode: 'uncrop'}, function(gids){ diff --git a/ui (gen4)/features/core.js b/ui (gen4)/features/core.js index 80a02c65..7cb58629 100755 --- a/ui (gen4)/features/core.js +++ b/ui (gen4)/features/core.js @@ -638,6 +638,7 @@ var JournalActions = actions.Actions({ journalable: null, + // XXX should the action have control over what gets journaled and how??? updateJournalableActions: ['System/Update list of journalable actions', function(){ var that = this @@ -726,6 +727,7 @@ var JournalActions = actions.Actions({ // - should the undo action have side-effects on the // journal/rjournal or should we clean them out??? // (currently cleaned) + // XXX should we control what gets pushed to the journal??? undo: ['Edit/Undo', doc`Undo last action from .journal that can be undone diff --git a/ui (gen4)/features/ui-ribbons.js b/ui (gen4)/features/ui-ribbons.js index 7bfbe43d..ee785dab 100755 --- a/ui (gen4)/features/ui-ribbons.js +++ b/ui (gen4)/features/ui-ribbons.js @@ -561,6 +561,7 @@ core.ImageGridFeatures.Feature({ 'collapseGroup', 'crop', 'uncrop', + 'addToCrop', 'removeFromCrop', 'reverseImages', ], diff --git a/ui (gen4)/imagegrid/data.js b/ui (gen4)/imagegrid/data.js index 8968d1df..f65b7f45 100755 --- a/ui (gen4)/imagegrid/data.js +++ b/ui (gen4)/imagegrid/data.js @@ -1585,10 +1585,20 @@ var DataPrototype = { // .placeImage(images, ribbon, order) // -> data // + // As above but add before/after order... + // .placeImage(images, ribbon, order, 'before') + // .placeImage(images, ribbon, order, 'after') + // -> data + // // Place images at order but do not touch ribbon position... (horizontal) // .placeImage(images, 'keep', order) // -> data // + // As above but add before/after order... + // .placeImage(images, 'keep', order, 'before') + // .placeImage(images, 'keep', order, 'after') + // -> data + // // Place images to ribbon but do not touch order... (vertical) // .placeImage(images, ribbon, 'keep') // -> data