Chris@0: /** Chris@0: * DO NOT EDIT THIS FILE. Chris@0: * See the following change record for more information, Chris@0: * https://www.drupal.org/node/2815083 Chris@0: * @preserve Chris@0: **/ Chris@0: Chris@0: (function (Drupal, Backbone) { Chris@0: Drupal.contextualToolbar.VisualView = Backbone.View.extend({ Chris@0: events: function events() { Chris@0: var touchEndToClick = function touchEndToClick(event) { Chris@0: event.preventDefault(); Chris@0: event.target.click(); Chris@0: }; Chris@0: Chris@0: return { Chris@0: click: function click() { Chris@0: this.model.set('isViewing', !this.model.get('isViewing')); Chris@0: }, Chris@0: Chris@0: touchend: touchEndToClick Chris@0: }; Chris@0: }, Chris@0: initialize: function initialize() { Chris@0: this.listenTo(this.model, 'change', this.render); Chris@0: this.listenTo(this.model, 'change:isViewing', this.persist); Chris@0: }, Chris@0: render: function render() { Chris@0: this.$el.toggleClass('hidden', !this.model.get('isVisible')); Chris@0: Chris@0: this.$el.find('button').toggleClass('is-active', !this.model.get('isViewing')); Chris@0: Chris@0: return this; Chris@0: }, Chris@0: persist: function persist(model, isViewing) { Chris@0: if (!isViewing) { Chris@0: localStorage.setItem('Drupal.contextualToolbar.isViewing', 'false'); Chris@0: } else { Chris@0: localStorage.removeItem('Drupal.contextualToolbar.isViewing'); Chris@0: } Chris@0: } Chris@0: }); Chris@0: })(Drupal, Backbone);