2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
8 (function ($, Drupal) {
9 Drupal.behaviors.nodePreviewDestroyLinks = {
10 attach: function attach(context) {
11 function clickPreviewModal(event) {
12 if (event.button === 0 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
13 event.preventDefault();
14 var $previewDialog = $('<div>' + Drupal.theme('nodePreviewModal') + '</div>').appendTo('body');
15 Drupal.dialog($previewDialog, {
16 title: Drupal.t('Leave preview?'),
18 text: Drupal.t('Cancel'),
19 click: function click() {
20 $(this).dialog('close');
23 text: Drupal.t('Leave preview'),
24 click: function click() {
25 window.top.location.href = event.target.href;
32 var $preview = $(context).find('.content').once('node-preview');
33 if ($(context).find('.node-preview-container').length) {
34 $preview.on('click.preview', 'a:not([href^=#], #edit-backlink, #toolbar-administration a)', clickPreviewModal);
37 detach: function detach(context, settings, trigger) {
38 if (trigger === 'unload') {
39 var $preview = $(context).find('.content').removeOnce('node-preview');
40 if ($preview.length) {
41 $preview.off('click.preview');
47 Drupal.behaviors.nodePreviewSwitchViewMode = {
48 attach: function attach(context) {
49 var $autosubmit = $(context).find('[data-drupal-autosubmit]').once('autosubmit');
50 if ($autosubmit.length) {
51 $autosubmit.on('formUpdated.preview', function () {
52 $(this.form).trigger('submit');
58 Drupal.theme.nodePreviewModal = function () {
59 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>';