diff --git a/core/modules/node/node.preview.js b/core/modules/node/node.preview.js
index a9b093b..f864179 100644
--- a/core/modules/node/node.preview.js
+++ b/core/modules/node/node.preview.js
@@ -1,43 +1,50 @@
+/**
+ * @file
+ * Defines Javascript behaviors for node previews.
+ */
+
(function ($, Drupal) {
- "use strict";
- /**
- * Provide a confirmation for all links (except local fragment identifiers
- * such as href="#frag") in node previews to warn users before leaving the page.
- */
- Drupal.behaviors.nodePreviewDestroyLinks = {
- attach: function (context) {
- $('a:not([href^=#])', context).on('click.preview', function (event) {
- // Only confirm exiting 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) {
- event.preventDefault();
- event.stopPropagation();
- var previewElementId = 'node-preview-dialog';
- // Create the preview dialog element.
- var previewElement = $('
' +
- '
Are you sure you want to exit the preview? If you navigate away ' +
- 'without saving, your changes will be lost.
').appendTo('body');
- var dialogOptions = {
- title: 'Exit preview?',
- buttons: {
- Cancel: function() {
- $(this).dialog('close');
- },
- 'Exit preview': function() {
- window.top.location.href = event.target.href;
- }
+
+"use strict";
+
+/**
+ * Provides a modal confirmation before leaving node previews.
+ */
+Drupal.behaviors.nodePreviewDestroyLinks = {
+ attach: function (context) {
+ // Display a modal confirmation for all links within preview, except
+ // for local fragment identifiers such as href="#frag".
+ $('a:not([href^=#])', context).on('click.preview', function (event) {
+ // 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) {
+ event.preventDefault();
+ event.stopPropagation();
+ var previewElementId = 'node-preview-dialog';
+ // Create the preview dialog element.
+ $('' + Drupal.t('Are you sure you want to leave the preview? If you navigate away without saving, your changes will be lost.') + '
').appendTo('body');
+ var dialogOptions = {
+ title: Drupal.t('Leave preview?'),
+ buttons: {
+ Cancel: function() {
+ $(this).dialog('close');
+ },
+ 'Leave preview': function() {
+ window.top.location.href = event.target.href;
}
- };
- var previewDialog = Drupal.dialog('#' + previewElementId, dialogOptions);
- previewDialog.showModal();
- }
- });
- },
- detach: function (context, settings, trigger) {
- if (trigger === 'unload') {
- $('a:not([href^=#])', context).off('click.preview');
+ }
+ };
+ var previewDialog = Drupal.dialog('#' + previewElementId, dialogOptions);
+ previewDialog.showModal();
}
+ });
+ },
+ detach: function (context, settings, trigger) {
+ if (trigger === 'unload') {
+ $('a:not([href^=#])', context).off('click.preview');
}
- };
+ }
+};
+
})(jQuery, Drupal);