Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/node/node.preview.js @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children | a9cd425dd02b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 /** | |
2 * DO NOT EDIT THIS FILE. | |
3 * See the following change record for more information, | |
4 * https://www.drupal.org/node/2815083 | |
5 * @preserve | |
6 **/ | |
7 | |
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?'), | |
17 buttons: [{ | |
18 text: Drupal.t('Cancel'), | |
19 click: function click() { | |
20 $(this).dialog('close'); | |
21 } | |
22 }, { | |
23 text: Drupal.t('Leave preview'), | |
24 click: function click() { | |
25 window.top.location.href = event.target.href; | |
26 } | |
27 }] | |
28 }).showModal(); | |
29 } | |
30 } | |
31 | |
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); | |
35 } | |
36 }, | |
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'); | |
42 } | |
43 } | |
44 } | |
45 }; | |
46 | |
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'); | |
53 }); | |
54 } | |
55 } | |
56 }; | |
57 | |
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>'; | |
60 }; | |
61 })(jQuery, Drupal); |