some tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-10-10 18:01:55 +03:00
parent 6ed2d1ebd5
commit ed58ff4cc8
3 changed files with 30 additions and 18 deletions

View File

@ -474,10 +474,11 @@ module.ImageMarksUI = core.ImageGridFeatures.Feature({
function(ribbon){ this.reload(true) }],
// XXX is this the right way to go???
['updateImage', function(_, gid, img){
['updateImage', function(_, gid, img, options){
// NOTE: we are not using .toggleMark(..) here as this
// does not need to depend on the 'edit' feature...
this.ribbons
!(options || {}).nochrome
&& this.ribbons
&& this.ribbons
.toggleImageMark(
gid,
@ -592,8 +593,9 @@ module.ImageBookmarksUI = core.ImageGridFeatures.Feature({
handlers: [
// XXX is this the right way to go???
['updateImage', function(_, gid, img){
this.ribbons
['updateImage', function(_, gid, img, options){
!(options || {}).nochrome
&& this.ribbons
&& this.ribbons
.toggleImageMark(
gid,

View File

@ -366,16 +366,16 @@ var MetadataUIActions = actions.Actions({
make.Separator()
make.Spinner() }
// XXX BUG: this when attached is stealing marks from
// the original image in ribbon and sows them in
// the dialog...
// ...need to avoid both!
// the original image in ribbon...
make.dialog.updatePreview = function(){
var preview = this.preview = this.preview || that.ribbons.createImage(image)
return that.ribbons.updateImage(preview, image, preview_size, false,
function([p]){
p.classList.add('clone', 'preview')
p.style.height = preview_size +'px'
p.style.width = preview_size +'px'
return that.ribbons.updateImage(preview, image, preview_size, false, {
nochrome: true,
pre_updaters_callback: function([p]){
p.classList.add('clone', 'preview')
p.style.height = preview_size +'px'
p.style.width = preview_size +'px'
},
}) }
make(['Preview:', this.updatePreview()])

View File

@ -1447,7 +1447,7 @@ var RibbonsPrototype = {
},
// XXX is .__image_updaters the right way to go???
callImageUpdaters: function(gid, image){
callImageUpdaters: function(gid, image, options){
gid = gid == null ? this.elemGID() : gid
image = image == null ? this.getImage() : $(image)
@ -1456,7 +1456,7 @@ var RibbonsPrototype = {
;(this.__image_updaters || [])
.forEach(function(update){
update(gid, image) })
update(gid, image, options) })
return image
},
@ -1492,6 +1492,14 @@ var RibbonsPrototype = {
// .updateImage('*')
// -> image
//
//
// options format:
// {
// nochrome: <bool>,
//
// pre_updaters_callback: <function>,
// }
//
// NOTE: this can update collections of images by passing either a
// list of gids, images or a jQuery collection...
// NOTE: pre_updaters_callback if given is called after image is fully
@ -1520,10 +1528,13 @@ var RibbonsPrototype = {
// XXX add support for basic image templating here...
// ...templates for blank images, text blocks and other stuff,
// this would best be done by simply filling in SVG templates...
updateImage: function(image, gid, size, sync, pre_updaters_callback){
updateImage: function(image, gid, size, sync, options){
var that = this
var imgs = this.viewer.find(IMAGE)
options = options || {}
var pre_updaters_callback = options.pre_updaters_callback
// reduce the length of input image set...
// NOTE: this will make things substantially faster for very large
// input sets...
@ -1534,8 +1545,7 @@ var RibbonsPrototype = {
|| image.indexOf(that.elemGID(img)) >= 0 })
.map(function(_, img){
return that.elemGID(img) })
.toArray()
}
.toArray() }
// normalize...
image = image == '*' ?
imgs
@ -1663,7 +1673,7 @@ var RibbonsPrototype = {
that.correctImageProportionsForRotation(img, W, H)
pre_updaters_callback
&& pre_updaters_callback.call(that, image, data)
that.callImageUpdaters(data.gid, img)
that.callImageUpdaters(data.gid, img, options)
return _img
}))