Mercurial > hg > isophonics-drupal-site
annotate core/modules/contextual/js/toolbar/views/VisualView.js @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 4c8ae668cc8c |
children |
rev | line source |
---|---|
Chris@0 | 1 /** |
Chris@0 | 2 * DO NOT EDIT THIS FILE. |
Chris@0 | 3 * See the following change record for more information, |
Chris@0 | 4 * https://www.drupal.org/node/2815083 |
Chris@0 | 5 * @preserve |
Chris@0 | 6 **/ |
Chris@0 | 7 |
Chris@0 | 8 (function (Drupal, Backbone) { |
Chris@0 | 9 Drupal.contextualToolbar.VisualView = Backbone.View.extend({ |
Chris@0 | 10 events: function events() { |
Chris@0 | 11 var touchEndToClick = function touchEndToClick(event) { |
Chris@0 | 12 event.preventDefault(); |
Chris@0 | 13 event.target.click(); |
Chris@0 | 14 }; |
Chris@0 | 15 |
Chris@0 | 16 return { |
Chris@0 | 17 click: function click() { |
Chris@0 | 18 this.model.set('isViewing', !this.model.get('isViewing')); |
Chris@0 | 19 }, |
Chris@0 | 20 |
Chris@0 | 21 touchend: touchEndToClick |
Chris@0 | 22 }; |
Chris@0 | 23 }, |
Chris@0 | 24 initialize: function initialize() { |
Chris@0 | 25 this.listenTo(this.model, 'change', this.render); |
Chris@0 | 26 this.listenTo(this.model, 'change:isViewing', this.persist); |
Chris@0 | 27 }, |
Chris@0 | 28 render: function render() { |
Chris@0 | 29 this.$el.toggleClass('hidden', !this.model.get('isVisible')); |
Chris@0 | 30 |
Chris@0 | 31 this.$el.find('button').toggleClass('is-active', !this.model.get('isViewing')); |
Chris@0 | 32 |
Chris@0 | 33 return this; |
Chris@0 | 34 }, |
Chris@0 | 35 persist: function persist(model, isViewing) { |
Chris@0 | 36 if (!isViewing) { |
Chris@0 | 37 localStorage.setItem('Drupal.contextualToolbar.isViewing', 'false'); |
Chris@0 | 38 } else { |
Chris@0 | 39 localStorage.removeItem('Drupal.contextualToolbar.isViewing'); |
Chris@0 | 40 } |
Chris@0 | 41 } |
Chris@0 | 42 }); |
Chris@0 | 43 })(Drupal, Backbone); |