Chris@0: /** Chris@0: * DO NOT EDIT THIS FILE. Chris@0: * See the following change record for more information, Chris@0: * https://www.drupal.org/node/2815083 Chris@0: * @preserve Chris@0: **/ Chris@0: Chris@0: (function ($, Drupal) { Chris@0: Drupal.behaviors.nodePreviewDestroyLinks = { Chris@0: attach: function attach(context) { Chris@0: function clickPreviewModal(event) { Chris@0: if (event.button === 0 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) { Chris@0: event.preventDefault(); Chris@0: var $previewDialog = $('
' + Drupal.theme('nodePreviewModal') + '
').appendTo('body'); Chris@0: Drupal.dialog($previewDialog, { Chris@0: title: Drupal.t('Leave preview?'), Chris@0: buttons: [{ Chris@0: text: Drupal.t('Cancel'), Chris@0: click: function click() { Chris@0: $(this).dialog('close'); Chris@0: } Chris@0: }, { Chris@0: text: Drupal.t('Leave preview'), Chris@0: click: function click() { Chris@0: window.top.location.href = event.target.href; Chris@0: } Chris@0: }] Chris@0: }).showModal(); Chris@0: } Chris@0: } Chris@0: Chris@17: var $preview = $(context).once('node-preview'); Chris@0: if ($(context).find('.node-preview-container').length) { Chris@17: $preview.on('click.preview', 'a:not([href^="#"], .node-preview-container a)', clickPreviewModal); Chris@0: } Chris@0: }, Chris@0: detach: function detach(context, settings, trigger) { Chris@0: if (trigger === 'unload') { Chris@0: var $preview = $(context).find('.content').removeOnce('node-preview'); Chris@0: if ($preview.length) { Chris@0: $preview.off('click.preview'); Chris@0: } Chris@0: } Chris@0: } Chris@0: }; Chris@0: Chris@0: Drupal.behaviors.nodePreviewSwitchViewMode = { Chris@0: attach: function attach(context) { Chris@0: var $autosubmit = $(context).find('[data-drupal-autosubmit]').once('autosubmit'); Chris@0: if ($autosubmit.length) { Chris@0: $autosubmit.on('formUpdated.preview', function () { Chris@0: $(this.form).trigger('submit'); Chris@0: }); Chris@0: } Chris@0: } Chris@0: }; Chris@0: Chris@0: Drupal.theme.nodePreviewModal = function () { Chris@0: return '

' + Drupal.t('Leaving the preview will cause unsaved changes to be lost. Are you sure you want to leave the preview?') + '

' + Drupal.t('CTRL+Left click will prevent this dialog from showing and proceed to the clicked link.') + ''; Chris@0: }; Chris@0: })(jQuery, Drupal);