Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / toolbar / js / toolbar.es6.js
index 4fdf090fbedb47ef234b6e6f600da09bcc04d99b..4149d27da7c7b2e7c9787cb9128df5315fe9f360 100644 (file)
       // Process the administrative toolbar.
       $(context).find('#toolbar-administration').once('toolbar').each(function () {
         // Establish the toolbar models and views.
-        const model = Drupal.toolbar.models.toolbarModel = new Drupal.toolbar.ToolbarModel({
+        const model = new Drupal.toolbar.ToolbarModel({
           locked: JSON.parse(localStorage.getItem('Drupal.toolbar.trayVerticalLocked')),
           activeTab: document.getElementById(JSON.parse(localStorage.getItem('Drupal.toolbar.activeTabID'))),
           height: $('#toolbar-administration').outerHeight(),
         });
 
+        Drupal.toolbar.models.toolbarModel = model;
+
         // Attach a listener to the configured media query breakpoints.
         // Executes it before Drupal.toolbar.views to avoid extra rendering.
-        for (const label in options.breakpoints) {
-          if (options.breakpoints.hasOwnProperty(label)) {
-            const mq = options.breakpoints[label];
-            const mql = Drupal.toolbar.mql[label] = window.matchMedia(mq);
-            // Curry the model and the label of the media query breakpoint to
-            // the mediaQueryChangeHandler function.
-            mql.addListener(Drupal.toolbar.mediaQueryChangeHandler.bind(null, model, label));
-            // Fire the mediaQueryChangeHandler for each configured breakpoint
-            // so that they process once.
-            Drupal.toolbar.mediaQueryChangeHandler.call(null, model, label, mql);
-          }
-        }
+        Object.keys(options.breakpoints).forEach((label) => {
+          const mq = options.breakpoints[label];
+          const mql = window.matchMedia(mq);
+          Drupal.toolbar.mql[label] = mql;
+          // Curry the model and the label of the media query breakpoint to
+          // the mediaQueryChangeHandler function.
+          mql.addListener(Drupal.toolbar.mediaQueryChangeHandler.bind(null, model, label));
+          // Fire the mediaQueryChangeHandler for each configured breakpoint
+          // so that they process once.
+          Drupal.toolbar.mediaQueryChangeHandler.call(null, model, label, mql);
+        });
 
         Drupal.toolbar.views.toolbarVisualView = new Drupal.toolbar.ToolbarVisualView({
           el: this,
@@ -88,7 +89,8 @@
         model.trigger('change:activeTray', model, model.get('activeTray'));
 
         // Render collapsible menus.
-        const menuModel = Drupal.toolbar.models.menuModel = new Drupal.toolbar.MenuModel();
+        const menuModel = new Drupal.toolbar.MenuModel();
+        Drupal.toolbar.models.menuModel = menuModel;
         Drupal.toolbar.views.menuVisualView = new Drupal.toolbar.MenuVisualView({
           el: $(this).find('.toolbar-menu-administration').get(0),
           model: menuModel,