Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / views_ui / js / ajax.es6.js
index ab2ed062466a493f3ce36516142b819e7c838316..90856f212ad427458cf67d251c361eadd9f04dbd 100644 (file)
@@ -3,7 +3,7 @@
  * Handles AJAX submission and response in Views UI.
  */
 
-(function ($, Drupal, drupalSettings) {
+(function($, Drupal, drupalSettings) {
   /**
    * Ajax command for highlighting elements.
    *
    * @param {number} [status]
    *   The HTTP status code.
    */
-  Drupal.AjaxCommands.prototype.viewsHighlight = function (ajax, response, status) {
+  Drupal.AjaxCommands.prototype.viewsHighlight = function(
+    ajax,
+    response,
+    status,
+  ) {
     $('.hilited').removeClass('hilited');
     $(response.selector).addClass('hilited');
   };
    * @param {string} [status]
    *   The XHR status code?
    */
-  Drupal.AjaxCommands.prototype.viewsSetForm = function (ajax, response, status) {
+  Drupal.AjaxCommands.prototype.viewsSetForm = function(
+    ajax,
+    response,
+    status,
+  ) {
     const $form = $('.js-views-ui-dialog form');
     // Identify the button that was clicked so that .ajaxSubmit() can use it.
     // We need to do this for both .click() and .mousedown() since JavaScript
     // code might trigger either behavior.
-    const $submitButtons = $form.find('input[type=submit].js-form-submit, button.js-form-submit').once('views-ajax-submit');
-    $submitButtons.on('click mousedown', function () {
+    const $submitButtons = $form
+      .find('input[type=submit].js-form-submit, button.js-form-submit')
+      .once('views-ajax-submit');
+    $submitButtons.on('click mousedown', function() {
       this.form.clk = this;
     });
-    $form.once('views-ajax-submit').each(function () {
+    $form.once('views-ajax-submit').each(function() {
       const $form = $(this);
       const elementSettings = {
         url: response.url,
    * @param {number} [status]
    *   The HTTP status code.
    */
-  Drupal.AjaxCommands.prototype.viewsShowButtons = function (ajax, response, status) {
+  Drupal.AjaxCommands.prototype.viewsShowButtons = function(
+    ajax,
+    response,
+    status,
+  ) {
     $('div.views-edit-view div.form-actions').removeClass('js-hide');
     if (response.changed) {
       $('div.views-edit-view div.view-changed.messages').removeClass('js-hide');
    * @param {number} [status]
    *   The HTTP status code.
    */
-  Drupal.AjaxCommands.prototype.viewsTriggerPreview = function (ajax, response, status) {
+  Drupal.AjaxCommands.prototype.viewsTriggerPreview = function(
+    ajax,
+    response,
+    status,
+  ) {
     if ($('input#edit-displays-live-preview').is(':checked')) {
       $('#preview-submit').trigger('click');
     }
    * @param {number} [status]
    *   The HTTP status code.
    */
-  Drupal.AjaxCommands.prototype.viewsReplaceTitle = function (ajax, response, status) {
+  Drupal.AjaxCommands.prototype.viewsReplaceTitle = function(
+    ajax,
+    response,
+    status,
+  ) {
     const doc = document;
     // For the <title> element, make a best-effort attempt to replace the page
     // title and leave the site name alone. If the theme doesn't use the site
     const oldTitle = doc.title;
     // Escape the site name, in case it has special characters in it, so we can
     // use it in our regex.
-    const escapedSiteName = response.siteName.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
+    const escapedSiteName = response.siteName.replace(
+      /[-[\]{}()*+?.,\\^$|#\s]/g,
+      '\\$&',
+    );
     const re = new RegExp(`.+ (.) ${escapedSiteName}`);
-    doc.title = oldTitle.replace(re, `${response.title} $1 ${response.siteName}`);
+    doc.title = oldTitle.replace(
+      re,
+      `${response.title} $1 ${response.siteName}`,
+    );
 
     $('h1.page-title').text(response.title);
   };
    * @return {Array}
    *   An array of messages. Always empty array, to get rid of the messages.
    */
-  Drupal.theme.tableDragChangedWarning = function () {
+  Drupal.theme.tableDragChangedWarning = function() {
     return [];
   };
 
    */
   Drupal.behaviors.livePreview = {
     attach(context) {
-      $('input#edit-displays-live-preview', context).once('views-ajax').on('click', function () {
-        if ($(this).is(':checked')) {
-          $('#preview-submit').trigger('click');
-        }
-      });
+      $('input#edit-displays-live-preview', context)
+        .once('views-ajax')
+        .on('click', function() {
+          if ($(this).is(':checked')) {
+            $('#preview-submit').trigger('click');
+          }
+        });
     },
   };
 
    */
   Drupal.behaviors.syncPreviewDisplay = {
     attach(context) {
-      $('#views-tabset a').once('views-ajax').on('click', function () {
-        const href = $(this).attr('href');
-        // Cut of #views-tabset.
-        const displayId = href.substr(11);
-        // Set the form element.
-        $('#views-live-preview #preview-display-id').val(displayId);
-      });
+      $('#views-tabset a')
+        .once('views-ajax')
+        .on('click', function() {
+          const href = $(this).attr('href');
+          // Cut of #views-tabset.
+          const displayId = href.substr(11);
+          // Set the form element.
+          $('#views-live-preview #preview-display-id').val(displayId);
+        });
     },
   };
 
         progress: { type: 'fullscreen' },
       };
       // Bind AJAX behaviors to all items showing the class.
-      $('a.views-ajax-link', context).once('views-ajax').each(function () {
-        const elementSettings = baseElementSettings;
-        elementSettings.base = $(this).attr('id');
-        elementSettings.element = this;
-        // Set the URL to go to the anchor.
-        if ($(this).attr('href')) {
-          elementSettings.url = $(this).attr('href');
-        }
-        Drupal.ajax(elementSettings);
-      });
+      $('a.views-ajax-link', context)
+        .once('views-ajax')
+        .each(function() {
+          const elementSettings = baseElementSettings;
+          elementSettings.base = $(this).attr('id');
+          elementSettings.element = this;
+          // Set the URL to go to the anchor.
+          if ($(this).attr('href')) {
+            elementSettings.url = $(this).attr('href');
+          }
+          Drupal.ajax(elementSettings);
+        });
 
       $('div#views-live-preview a')
-        .once('views-ajax').each(function () {
+        .once('views-ajax')
+        .each(function() {
           // We don't bind to links without a URL.
           if (!$(this).attr('href')) {
             return true;
           const elementSettings = baseElementSettings;
           // Set the URL to go to the anchor.
           elementSettings.url = $(this).attr('href');
-          if (Drupal.Views.getPath(elementSettings.url).substring(0, 21) !== 'admin/structure/views') {
+          if (
+            Drupal.Views.getPath(elementSettings.url).substring(0, 21) !==
+            'admin/structure/views'
+          ) {
             return true;
           }
 
       // @todo Revisit this after fixing Views UI to display a Preview outside
       //   of the main Edit form.
       $('div#views-live-preview input[type=submit]')
-        .once('views-ajax').each(function (event) {
-          $(this).on('click', function () {
+        .once('views-ajax')
+        .each(function(event) {
+          $(this).on('click', function() {
             this.form.clk = this;
             return true;
           });
           const elementSettings = baseElementSettings;
           // Set the URL to go to the anchor.
           elementSettings.url = $(this.form).attr('action');
-          if (Drupal.Views.getPath(elementSettings.url).substring(0, 21) !== 'admin/structure/views') {
+          if (
+            Drupal.Views.getPath(elementSettings.url).substring(0, 21) !==
+            'admin/structure/views'
+          ) {
             return true;
           }
 
         });
     },
   };
-}(jQuery, Drupal, drupalSettings));
+})(jQuery, Drupal, drupalSettings);