From 47befeb3bb450d9075c5dd3f78d8dcd2fcde5aca Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Thu, 16 Nov 2017 13:28:02 +0100 Subject: [PATCH] Fix toggleVisibility for items in Layer Manager. Closes #530 --- src/navigator/view/ItemView.js | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/navigator/view/ItemView.js b/src/navigator/view/ItemView.js index 2cc552040..8fff579c8 100644 --- a/src/navigator/view/ItemView.js +++ b/src/navigator/view/ItemView.js @@ -185,24 +185,26 @@ module.exports = Backbone.View.extend({ * @return void * */ toggleVisibility(e) { - e.stopPropagation(); + e && e.stopPropagation(); const pfx = this.pfx; - - if(!this.$eye) - this.$eye = this.$el.children(`#${pfx}btn-eye`); - - var cCss = _.clone(this.model.get('style')), - hClass = this.pfx + 'hide'; - if(this.isVisible()){ - this.$el.addClass(hClass); - this.$eye.addClass('fa-eye-slash'); - cCss.display = 'none'; - }else{ - this.$el.removeClass(hClass); - this.$eye.removeClass('fa-eye-slash'); - delete cCss.display; + const model = this.model; + const hClass = `${pfx}hide`; + const style = model.getStyle(); + const hideIcon = 'fa-eye-slash'; + const $el = this.$el; + !this.$eye && (this.$eye = $el.children(`#${pfx}btn-eye`)); + + if (this.isVisible()) { + $el.addClass(hClass); + this.$eye.addClass(hideIcon); + style.display = 'none'; + } else { + $el.removeClass(hClass); + this.$eye.removeClass(hideIcon); + delete style.display; } - this.model.set('style', cCss); + + model.setStyle(style); }, /**