annotate core/modules/node/node.preview.js @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@0 1 /**
Chris@0 2 * DO NOT EDIT THIS FILE.
Chris@0 3 * See the following change record for more information,
Chris@0 4 * https://www.drupal.org/node/2815083
Chris@0 5 * @preserve
Chris@0 6 **/
Chris@0 7
Chris@0 8 (function ($, Drupal) {
Chris@0 9 Drupal.behaviors.nodePreviewDestroyLinks = {
Chris@0 10 attach: function attach(context) {
Chris@0 11 function clickPreviewModal(event) {
Chris@0 12 if (event.button === 0 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
Chris@0 13 event.preventDefault();
Chris@0 14 var $previewDialog = $('<div>' + Drupal.theme('nodePreviewModal') + '</div>').appendTo('body');
Chris@0 15 Drupal.dialog($previewDialog, {
Chris@0 16 title: Drupal.t('Leave preview?'),
Chris@0 17 buttons: [{
Chris@0 18 text: Drupal.t('Cancel'),
Chris@0 19 click: function click() {
Chris@0 20 $(this).dialog('close');
Chris@0 21 }
Chris@0 22 }, {
Chris@0 23 text: Drupal.t('Leave preview'),
Chris@0 24 click: function click() {
Chris@0 25 window.top.location.href = event.target.href;
Chris@0 26 }
Chris@0 27 }]
Chris@0 28 }).showModal();
Chris@0 29 }
Chris@0 30 }
Chris@0 31
Chris@17 32 var $preview = $(context).once('node-preview');
Chris@0 33 if ($(context).find('.node-preview-container').length) {
Chris@17 34 $preview.on('click.preview', 'a:not([href^="#"], .node-preview-container a)', clickPreviewModal);
Chris@0 35 }
Chris@0 36 },
Chris@0 37 detach: function detach(context, settings, trigger) {
Chris@0 38 if (trigger === 'unload') {
Chris@0 39 var $preview = $(context).find('.content').removeOnce('node-preview');
Chris@0 40 if ($preview.length) {
Chris@0 41 $preview.off('click.preview');
Chris@0 42 }
Chris@0 43 }
Chris@0 44 }
Chris@0 45 };
Chris@0 46
Chris@0 47 Drupal.behaviors.nodePreviewSwitchViewMode = {
Chris@0 48 attach: function attach(context) {
Chris@0 49 var $autosubmit = $(context).find('[data-drupal-autosubmit]').once('autosubmit');
Chris@0 50 if ($autosubmit.length) {
Chris@0 51 $autosubmit.on('formUpdated.preview', function () {
Chris@0 52 $(this.form).trigger('submit');
Chris@0 53 });
Chris@0 54 }
Chris@0 55 }
Chris@0 56 };
Chris@0 57
Chris@0 58 Drupal.theme.nodePreviewModal = function () {
Chris@0 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>';
Chris@0 60 };
Chris@0 61 })(jQuery, Drupal);