2015-06-05 20:17:55 +00:00
/ * *
2017-05-19 22:12:53 +00:00
* DO NOT EDIT THIS FILE .
* See the following change record for more information ,
2017-05-23 14:30:14 +00:00
* https : //www.drupal.org/node/2815083
2017-05-19 22:12:53 +00:00
* @ preserve
* * /
2015-06-05 20:17:55 +00:00
2012-10-30 02:15:21 +00:00
( function ( $ , Drupal ) {
2014-01-27 21:41:32 +00:00
Drupal . behaviors . nodePreviewDestroyLinks = {
2017-05-19 22:12:53 +00:00
attach : function attach ( context ) {
2014-10-04 12:49:18 +00:00
function clickPreviewModal ( event ) {
if ( event . button === 0 && ! event . altKey && ! event . ctrlKey && ! event . metaKey && ! event . shiftKey ) {
event . preventDefault ( ) ;
var $previewDialog = $ ( '<div>' + Drupal . theme ( 'nodePreviewModal' ) + '</div>' ) . appendTo ( 'body' ) ;
Drupal . dialog ( $previewDialog , {
title : Drupal . t ( 'Leave preview?' ) ,
2017-05-19 22:12:53 +00:00
buttons : [ {
text : Drupal . t ( 'Cancel' ) ,
click : function click ( ) {
$ ( this ) . dialog ( 'close' ) ;
2014-10-04 12:49:18 +00:00
}
2017-05-19 22:12:53 +00:00
} , {
text : Drupal . t ( 'Leave preview' ) ,
click : function click ( ) {
window . top . location . href = event . target . href ;
}
} ]
2014-10-04 12:49:18 +00:00
} ) . showModal ( ) ;
}
}
2018-01-29 12:46:11 +00:00
var $preview = $ ( context ) . once ( 'node-preview' ) ;
2014-10-04 12:49:18 +00:00
if ( $ ( context ) . find ( '.node-preview-container' ) . length ) {
2018-01-29 12:46:11 +00:00
$preview . on ( 'click.preview' , 'a:not([href^="#"], .node-preview-container a)' , clickPreviewModal ) ;
2014-01-27 21:41:32 +00:00
}
} ,
2017-05-19 22:12:53 +00:00
detach : function detach ( context , settings , trigger ) {
2014-01-27 21:41:32 +00:00
if ( trigger === 'unload' ) {
2014-10-04 12:49:18 +00:00
var $preview = $ ( context ) . find ( '.content' ) . removeOnce ( 'node-preview' ) ;
2014-01-27 21:41:32 +00:00
if ( $preview . length ) {
$preview . off ( 'click.preview' ) ;
}
2012-10-30 02:15:21 +00:00
}
}
2014-01-27 21:41:32 +00:00
} ;
2012-10-30 02:15:21 +00:00
Issue #1510544 by swentel, Bojhan, Gábor Hojtsy, merlinofchaos, Cottser, Wim Leers, plopesc, aspilicious, sannejanssen, larowlan, tim.plunkett, nod_: Fixed Show previews in front-end theme, able to select different view modes.
2014-08-23 19:03:35 +00:00
Drupal . behaviors . nodePreviewSwitchViewMode = {
2017-05-19 22:12:53 +00:00
attach : function attach ( context ) {
Issue #1510544 by swentel, Bojhan, Gábor Hojtsy, merlinofchaos, Cottser, Wim Leers, plopesc, aspilicious, sannejanssen, larowlan, tim.plunkett, nod_: Fixed Show previews in front-end theme, able to select different view modes.
2014-08-23 19:03:35 +00:00
var $autosubmit = $ ( context ) . find ( '[data-drupal-autosubmit]' ) . once ( 'autosubmit' ) ;
if ( $autosubmit . length ) {
2014-10-04 12:49:18 +00:00
$autosubmit . on ( 'formUpdated.preview' , function ( ) {
Issue #1510544 by swentel, Bojhan, Gábor Hojtsy, merlinofchaos, Cottser, Wim Leers, plopesc, aspilicious, sannejanssen, larowlan, tim.plunkett, nod_: Fixed Show previews in front-end theme, able to select different view modes.
2014-08-23 19:03:35 +00:00
$ ( this . form ) . trigger ( 'submit' ) ;
} ) ;
}
}
} ;
2014-10-04 12:49:18 +00:00
Drupal . theme . nodePreviewModal = function ( ) {
2017-05-19 22:12:53 +00:00
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>' ;
2014-10-04 12:49:18 +00:00
} ;
2017-05-19 22:12:53 +00:00
} ) ( jQuery , Drupal ) ;