diff --git a/core/modules/responsive_preview/js/responsive-preview.js b/core/modules/responsive_preview/js/responsive-preview.js index bd7d7c5..fb634e6 100644 --- a/core/modules/responsive_preview/js/responsive-preview.js +++ b/core/modules/responsive_preview/js/responsive-preview.js @@ -7,21 +7,20 @@ "use strict"; +var strings = { + close: Drupal.t('Close'), + orientation: Drupal.t('Change orientation'), + portrait: Drupal.t('Portrait'), + landscape: Drupal.t('Landscape') +}; + var options = $.extend({ gutter: 60, // The width of the device border around the iframe. This value is critical // to determine the size and placement of the preview iframe container, // therefore it must be defined here instead of in the CSS file. - bleed: 30, - strings: { - close: Drupal.t('Close'), - orientation: Drupal.t('Change orientation'), - portrait: Drupal.t('Portrait'), - landscape: Drupal.t('Landscape') - } -}, drupalSettings.responsivePreview || {}); - -var currentPath; + bleed: 30 +}, drupalSettings.responsivePreview); /** * Attaches behaviors to the toolbar tab and preview containers. @@ -32,9 +31,6 @@ Drupal.behaviors.responsivePreview = { // elements are found. window and window.parent are equivalent unless the // Drupal page is itself wrapped in an iframe. var $body = $(window.parent.document.body).once('responsive-preview'); - // Store the current path. The drupalSettings.currentPath changes whenever - // an AJAX request is sent, so we save it on the first process of attach. - currentPath = currentPath || drupalSettings.currentPath; if ($body.length) { // If this window is itself in an iframe it must be marked as processed. @@ -59,7 +55,7 @@ Drupal.behaviors.responsivePreview = { gutter: options.gutter, // Preview device frame width. bleed: options.bleed, - strings: options.strings + strings: strings }); // The toolbar tab view. @@ -631,7 +627,7 @@ Drupal.responsivePreview = Drupal.responsivePreview || { $(Drupal.theme('responsivePreviewFrame')) .attr({ 'data-loading': true, - src: drupalSettings.basePath + Drupal.encodePath(currentPath), + src: drupalSettings.basePath + Drupal.encodePath(drupalSettings.currentPath), width: '100%', height: '100%' })