Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / contextual / js / toolbar / views / VisualView.es6.js
index 56bae27859f48557636437bbc3c01300cf35bc3d..d168d5414ca1e786089b752782f2439890ecafcb 100644 (file)
@@ -3,78 +3,79 @@
  * A Backbone View that provides the visual view of the edit mode toggle.
  */
 
-(function (Drupal, Backbone) {
-  Drupal.contextualToolbar.VisualView = Backbone.View.extend(/** @lends Drupal.contextualToolbar.VisualView# */{
+(function(Drupal, Backbone) {
+  Drupal.contextualToolbar.VisualView = Backbone.View.extend(
+    /** @lends Drupal.contextualToolbar.VisualView# */ {
+      /**
+       * Events for the Backbone view.
+       *
+       * @return {object}
+       *   A mapping of events to be used in the view.
+       */
+      events() {
+        // Prevents delay and simulated mouse events.
+        const touchEndToClick = function(event) {
+          event.preventDefault();
+          event.target.click();
+        };
 
-    /**
-     * Events for the Backbone view.
-     *
-     * @return {object}
-     *   A mapping of events to be used in the view.
-     */
-    events() {
-      // Prevents delay and simulated mouse events.
-      const touchEndToClick = function (event) {
-        event.preventDefault();
-        event.target.click();
-      };
+        return {
+          click() {
+            this.model.set('isViewing', !this.model.get('isViewing'));
+          },
+          touchend: touchEndToClick,
+        };
+      },
 
-      return {
-        click() {
-          this.model.set('isViewing', !this.model.get('isViewing'));
-        },
-        touchend: touchEndToClick,
-      };
-    },
+      /**
+       * Renders the visual view of the edit mode toggle.
+       *
+       * Listens to mouse & touch and handles edit mode toggle interactions.
+       *
+       * @constructs
+       *
+       * @augments Backbone.View
+       */
+      initialize() {
+        this.listenTo(this.model, 'change', this.render);
+        this.listenTo(this.model, 'change:isViewing', this.persist);
+      },
 
-    /**
-     * Renders the visual view of the edit mode toggle.
-     *
-     * Listens to mouse & touch and handles edit mode toggle interactions.
-     *
-     * @constructs
-     *
-     * @augments Backbone.View
-     */
-    initialize() {
-      this.listenTo(this.model, 'change', this.render);
-      this.listenTo(this.model, 'change:isViewing', this.persist);
-    },
+      /**
+       * @inheritdoc
+       *
+       * @return {Drupal.contextualToolbar.VisualView}
+       *   The current contextual toolbar visual view.
+       */
+      render() {
+        // Render the visibility.
+        this.$el.toggleClass('hidden', !this.model.get('isVisible'));
+        // Render the state.
+        this.$el
+          .find('button')
+          .toggleClass('is-active', !this.model.get('isViewing'));
 
-    /**
-     * @inheritdoc
-     *
-     * @return {Drupal.contextualToolbar.VisualView}
-     *   The current contextual toolbar visual view.
-     */
-    render() {
-      // Render the visibility.
-      this.$el.toggleClass('hidden', !this.model.get('isVisible'));
-      // Render the state.
-      this.$el.find('button').toggleClass('is-active', !this.model.get('isViewing'));
+        return this;
+      },
 
-      return this;
+      /**
+       * Model change handler; persists the isViewing value to localStorage.
+       *
+       * `isViewing === true` is the default, so only stores in localStorage when
+       * it's not the default value (i.e. false).
+       *
+       * @param {Drupal.contextualToolbar.StateModel} model
+       *   A {@link Drupal.contextualToolbar.StateModel} model.
+       * @param {bool} isViewing
+       *   The value of the isViewing attribute in the model.
+       */
+      persist(model, isViewing) {
+        if (!isViewing) {
+          localStorage.setItem('Drupal.contextualToolbar.isViewing', 'false');
+        } else {
+          localStorage.removeItem('Drupal.contextualToolbar.isViewing');
+        }
+      },
     },
-
-    /**
-     * Model change handler; persists the isViewing value to localStorage.
-     *
-     * `isViewing === true` is the default, so only stores in localStorage when
-     * it's not the default value (i.e. false).
-     *
-     * @param {Drupal.contextualToolbar.StateModel} model
-     *   A {@link Drupal.contextualToolbar.StateModel} model.
-     * @param {bool} isViewing
-     *   The value of the isViewing attribute in the model.
-     */
-    persist(model, isViewing) {
-      if (!isViewing) {
-        localStorage.setItem('Drupal.contextualToolbar.isViewing', 'false');
-      }
-      else {
-        localStorage.removeItem('Drupal.contextualToolbar.isViewing');
-      }
-    },
-
-  });
-}(Drupal, Backbone));
+  );
+})(Drupal, Backbone);