Mercurial > hg > isophonics-drupal-site
view core/modules/contextual/js/toolbar/views/VisualView.js @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 4c8ae668cc8c |
children |
line wrap: on
line source
/** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ (function (Drupal, Backbone) { Drupal.contextualToolbar.VisualView = Backbone.View.extend({ events: function events() { var touchEndToClick = function touchEndToClick(event) { event.preventDefault(); event.target.click(); }; return { click: function click() { this.model.set('isViewing', !this.model.get('isViewing')); }, touchend: touchEndToClick }; }, initialize: function initialize() { this.listenTo(this.model, 'change', this.render); this.listenTo(this.model, 'change:isViewing', this.persist); }, render: function render() { this.$el.toggleClass('hidden', !this.model.get('isVisible')); this.$el.find('button').toggleClass('is-active', !this.model.get('isViewing')); return this; }, persist: function persist(model, isViewing) { if (!isViewing) { localStorage.setItem('Drupal.contextualToolbar.isViewing', 'false'); } else { localStorage.removeItem('Drupal.contextualToolbar.isViewing'); } } }); })(Drupal, Backbone);