Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / node / node.preview.es6.js
index abd670acf80c4030a68d732a27ea2d0bf858a906..a2cc63be4d25872203e797b28c3c102e9fdbed84 100644 (file)
@@ -3,7 +3,7 @@
  * Preview behaviors.
  */
 
-(function ($, Drupal) {
+(function($, Drupal) {
   /**
    * Disables all non-relevant links in node previews.
    *
         // Only confirm leaving previews when left-clicking and user is not
         // pressing the ALT, CTRL, META (Command key on the Macintosh keyboard)
         // or SHIFT key.
-        if (event.button === 0 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
+        if (
+          event.button === 0 &&
+          !event.altKey &&
+          !event.ctrlKey &&
+          !event.metaKey &&
+          !event.shiftKey
+        ) {
           event.preventDefault();
-          const $previewDialog = $(`<div>${Drupal.theme('nodePreviewModal')}</div>`).appendTo('body');
+          const $previewDialog = $(
+            `<div>${Drupal.theme('nodePreviewModal')}</div>`,
+          ).appendTo('body');
           Drupal.dialog($previewDialog, {
             title: Drupal.t('Leave preview?'),
             buttons: [
@@ -34,7 +42,8 @@
                 click() {
                   $(this).dialog('close');
                 },
-              }, {
+              },
+              {
                 text: Drupal.t('Leave preview'),
                 click() {
                   window.top.location.href = event.target.href;
         }
       }
 
-      const $preview = $(context).find('.content').once('node-preview');
+      const $preview = $(context).once('node-preview');
       if ($(context).find('.node-preview-container').length) {
-        $preview.on('click.preview', 'a:not([href^=#], #edit-backlink, #toolbar-administration a)', clickPreviewModal);
+        $preview.on(
+          'click.preview',
+          'a:not([href^="#"], .node-preview-container a)',
+          clickPreviewModal,
+        );
       }
     },
     detach(context, settings, trigger) {
       if (trigger === 'unload') {
-        const $preview = $(context).find('.content').removeOnce('node-preview');
+        const $preview = $(context)
+          .find('.content')
+          .removeOnce('node-preview');
         if ($preview.length) {
           $preview.off('click.preview');
         }
    */
   Drupal.behaviors.nodePreviewSwitchViewMode = {
     attach(context) {
-      const $autosubmit = $(context).find('[data-drupal-autosubmit]').once('autosubmit');
+      const $autosubmit = $(context)
+        .find('[data-drupal-autosubmit]')
+        .once('autosubmit');
       if ($autosubmit.length) {
-        $autosubmit.on('formUpdated.preview', function () {
+        $autosubmit.on('formUpdated.preview', function() {
           $(this.form).trigger('submit');
         });
       }
    * @return {string}
    *   Markup for the node preview modal.
    */
-  Drupal.theme.nodePreviewModal = function () {
-    return `<p>${
-      Drupal.t('Leaving the preview will cause unsaved changes to be lost. Are you sure you want to leave the preview?')
-      }</p><small class="description">${
-      Drupal.t('CTRL+Left click will prevent this dialog from showing and proceed to the clicked link.')}</small>`;
+  Drupal.theme.nodePreviewModal = function() {
+    return `<p>${Drupal.t(
+      'Leaving the preview will cause unsaved changes to be lost. Are you sure you want to leave the preview?',
+    )}</p><small class="description">${Drupal.t(
+      'CTRL+Left click will prevent this dialog from showing and proceed to the clicked link.',
+    )}</small>`;
   };
-}(jQuery, Drupal));
+})(jQuery, Drupal);