From 85de35f4e330a52814d8f489e72a6140f2e4e6d5 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 26 Apr 2016 03:43:22 +0300 Subject: [PATCH] fixed a bug with messing up ribbon scale on load... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/meta.js | 1 - ui (gen4)/features/ui-single-image.js | 38 +++++++++++++++++++-------- ui (gen4)/features/ui.js | 2 +- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/ui (gen4)/features/meta.js b/ui (gen4)/features/meta.js index 0cb302c1..e23e7651 100755 --- a/ui (gen4)/features/meta.js +++ b/ui (gen4)/features/meta.js @@ -74,7 +74,6 @@ core.ImageGridFeatures.Feature('viewer-testing', [ 'config-local-storage', 'ui-url-hash', 'url-history', - 'ui-single-image-view-local-storage', 'external-editor', diff --git a/ui (gen4)/features/ui-single-image.js b/ui (gen4)/features/ui-single-image.js index 11376c36..a2e63c39 100755 --- a/ui (gen4)/features/ui-single-image.js +++ b/ui (gen4)/features/ui-single-image.js @@ -231,6 +231,9 @@ module.SingleImageView = core.ImageGridFeatures.Feature({ depends: [ 'ui' ], + suggested: [ + 'ui-single-image-view-local-storage', + ], actions: SingleImageActions, @@ -248,6 +251,13 @@ module.SingleImageView = core.ImageGridFeatures.Feature({ }], ['fitImage.post setScale.post', function(){ + // prevent this from doing anything while no viewer... + if(!this.ribbons + || !this.ribbons.viewer + || this.ribbons.getRibbonSet().length == 0){ + return + } + // singe image mode -- set image proportions... if(this.toggleSingleImage('?') == 'on'){ updateImageProportions.call(this) @@ -325,19 +335,26 @@ module.SingleImageViewLocalStorage = core.ImageGridFeatures.Feature({ handlers:[ // set scale... - ['load', + ['load.pre', function(){ - // prevent this from doing anything while no viewer... - if(!this.ribbons || !this.ribbons.viewer || this.ribbons.viewer.length == 0){ - return - } + // NOTE: at this stage the viewer is not yet ready, and + // we need to save these for when it is, thus avoiding + // stray actions overwriting the config with defaults + // when not finding a value in the viewer... + var rscale = this.config['ribbon-scale'] || this.scale + var iscale = this.config['single-image-scale'] || this.scale - if(this.toggleSingleImage('?') == 'on'){ - this.scale = this.config['single-image-scale'] || this.scale + return function(){ + // prevent this from doing anything while no viewer... + if(!this.ribbons + || !this.ribbons.viewer + || this.ribbons.getRibbonSet().length == 0){ + return + } - } else { - // XXX for some reason this stopped working... - this.scale = this.config['ribbon-scale'] || this.scale + this.scale = this.toggleSingleImage('?') == 'on' ? + iscale + : rscale } }], ], @@ -425,7 +442,6 @@ module.SingleImageAutoHideCursor = core.ImageGridFeatures.Feature({ core.ImageGridFeatures.Feature('ui-single-image', [ 'ui-single-image-view', - 'ui-single-image-view-local-storage', 'ui-single-image-view-autohide-cursor', ]) diff --git a/ui (gen4)/features/ui.js b/ui (gen4)/features/ui.js index 7397cb21..a51351ab 100755 --- a/ui (gen4)/features/ui.js +++ b/ui (gen4)/features/ui.js @@ -959,7 +959,7 @@ module.ConfigLocalStorage = core.ImageGridFeatures.Feature({ }], ['stop.pre', function(){ - this.logger && this.logger.emit('loaded', 'config') + this.logger && this.logger.emit('stored', 'config') this .storeConfig() .toggleAutoStoreConfig('off')