diff --git a/core/modules/responsive_preview/css/responsive-preview.icons.css b/core/modules/responsive_preview/css/responsive-preview.icons.css index e616c2c..6ed041e 100644 --- a/core/modules/responsive_preview/css/responsive-preview.icons.css +++ b/core/modules/responsive_preview/css/responsive-preview.icons.css @@ -81,15 +81,15 @@ background-position: left -56px; } .responsive-preview .icon-orientation:before { - background-position: left -68px; + background-position: left -92px; left: 9px; /* LTR */ } .responsive-preview .icon-orientation:hover:before { - background-position: left -80px; + background-position: left -104px; } .responsive-preview .icon-orientation.rotated:before { - background-position: left -92px; + background-position: left -68px; } .responsive-preview .icon-orientation.rotated:hover:before { - background-position: left -104px; + background-position: left -80px; } diff --git a/core/modules/responsive_preview/css/responsive-preview.theme.css b/core/modules/responsive_preview/css/responsive-preview.theme.css index 5b19b83..15291cc 100644 --- a/core/modules/responsive_preview/css/responsive-preview.theme.css +++ b/core/modules/responsive_preview/css/responsive-preview.theme.css @@ -166,7 +166,7 @@ -moz-transition: all 150ms ease-out; -o-transition: all 150ms ease-out; transition: all 150ms ease-out; - top: 1em; + margin-top: 2em; } .responsive-preview .frame-container iframe { box-shadow: diff --git a/core/modules/responsive_preview/images/responsive-preview-icons.png b/core/modules/responsive_preview/images/responsive-preview-icons.png index 6eedbbe..0ce06e7 100644 --- a/core/modules/responsive_preview/images/responsive-preview-icons.png +++ b/core/modules/responsive_preview/images/responsive-preview-icons.png @@ -1,10 +1,11 @@ ‰PNG  - IHDR ‚� BqtEXtSoftwareAdobe ImageReadyqÉe<ìIDATxÚìX½O#Gß]/6„} :HH“*>)]R�:Å] -8EÅ4¤AŠ# -H`Äww—ꄎ€D(�ï/Èu©"‘*MA�"@‰mìØ›ß[æíÍ~z—‹¬(b¤Ñì|üfÞ{óÞofVÝÙÙÉ+ŠòH Ÿ^êõz= -€Ò#™_cccj£Ñ[[[•(Lⱺa¡A<ön+݃ÞÄäµZ-4ˆÇÞo®´°°`„id�|„ü‰(]ý‘ÄãD —ÄÒ‡üƒ±Ðry#ZÊ«XɈ,»F,SCø^³Ù¨y ÿ£N÷†h¶NêÉÉIä l©ÇÇÇ‘¯9êÐÐÐc|l#îïïpÚÓ(^!g÷öö¶m:!?ENÒ1P$E¿âÑJ% ˜‘Ô>èÒÉcfN&¢x­¤]²Ž¾¬¬ã›¯äÐÀ1YÇááá´—xyYiˆ´-”g`ÞÏzGò>‰’�9—NQ¼Üf½¦�H§"rZUU…3ÕE{Æ+űXDN‹¶´¨s»-ž¼dõ´ ä1³°Y[¬ § “É¿³Ò�t -a½C¿• éÈÀÇNÐÜ÷ˆ÷¬ -BÛ,­VîLõååå·§§§‹<¦áJ¸D©ÖÖÖú}ÅÃ*_’ñ4M# YVšŸŸÿÀ´ „†ÔÈÈH ƒŸëº~kZõõm®Z­ª¸ÿd�077÷W¥RÑØßh* &RÚÛÛ ¬·@‹‹‹g4 @£hûluuõ�˜ 6;;ƒnæ EïééùñììÌœ–f„¥bu>·hH ðzŸÊårš½€:ëò6 ÏuMÕnnnZ¥úß¡<ºÜó·Šw†½-«Â¤Š,wóvww·¼±±Ñ ÔÒÒò6ö?òôrJ›››/0ðÓÖÖÖ^Ç�È8??’J¥öuî hFšÙ¥6� ÖÖÖö�Dtt*…B¡!PzÊP±X|BŽ`êD+`6kç±áEˆ²†Aýb;®...>O&“ß›ÐùBžnõ«Ì<ð»2Ib£°ëëëÄ·Ò(ë‰D"Åè›ÑÑÑÀ- Ž0¯näB šåÛP¾GÀjfe||<ÜóÎIY¡|ÏÐÑÑñ¤¨!r Ê�¾G$ÓÛÛ{ £¼ µ†^N€õõõ?OOOÛ¬¿ÎîînÐÒÒÒ)¼@cR‰ÇãU°Rbrrò�'«¨———-¦oÁAA_1¸SÑ\aw�@–fÕ••â¸zÃÈ…:óœÌá� ÒC°+L0¨³³óæ–m ×ÞØ@333=|:P‰0WàV5âq_YÞáÓ¡«««†#å=§Å\:aÀ!€I¬‰‰‰©Þð!å•)¢¯®®þ�‚Úvù°e -m -qnñ5`%o�sâŒR©´ê"Y‡ VòEa%Ë�˜•Y>�|ÔÀAŠ�y Ñî-ï}âjy"ªS{ GÀ¤óþPIõ CXtŒ`…*'AùN×Q]¾i¥©©©AñjË©!´‡âga)ì="'”2jH±øWä3ðcV !?ö�øQ©E <_  ±¾b±xe™\ˆ@¿²<“ŸX²—Ó _P‰Áé ±dÓÕ˜óË¡‘ž¬_‹:½ÕçÅ÷Ï^OpëׂÃMø÷ÂCLxàªÃbý˜ çJÿ0v]{Îq{ÈŒIEND®B`‚ \ No newline at end of file + IHDR ‚� BqtEXtSoftwareAdobe ImageReadyqÉe<ŒIDATxÚìYMvÚ0¶À$ÙÅÙuWn÷¡'ˆ{‚Â È +v!»°KO}¹9Aé œ�¯e;~ +îÈ�á�eI–Ó<^Ó½7±,Íç�FŸÇDÜßß�<Ï»ôÜÛƒ¿ÛíÊd»” ´×jµD‘ö`0Häuri¤ë'Iâ "ÝçYzýMÈ·Û­3ˆtß6WÝÜÜ$® ŠŒˆFž@>â57_Ê=jô !–÷ ßLÄ"ÀÜè¼+aè§KIY÷äS +ªV«Â!÷R]±ÙlÒN­V+‘®X¯×içèè¨DºbµZ¥�ãããBéŠår™vNNN +A¤{Àãþ�ƒþÇ@lMb6›•>„&6úr…×—a#1�NËK§Ó‰ 3iôûý˜f`<„ˤ}{{;̬ ääT* "œâ¼§‚¤¥6@Ž7rkÒ<™Z +×b-�Ò€͵`�CÝæ?ËREHÅ_c·Û u�ñEK—pñ™¢÷Ä÷ ¯lçÖT&Ë’©�ÌABe<Äñ¦z4äŸIò§í� @ã9�ªÐTîÃHóäÄÈÄ-ðÖ$2yKÏZ“Cô&&KË>E*èäžUàdÇ ׯ8<÷©­žc#…•"Má¸'Ÿ)H0ç‹ÄuŸ& +…yK‹§á¼ï Ÿ@Îðþ‘�Ð0ëW˜l2·cÌ)z$­\�˜lèÞ³*ï]°û;§w®r?~e¹ƒdrÏ” °nŠ&±Ò(É·=_påŸhkNa�†Âì–4ÆH([SÈ¡2ëPY£6zcnÁeK<ÅJä’Á&„˜eùÉÒ4¡²°Ð^××(±RäÈJÚ“kc¥Âz/ÃJ<`ÜR“[à›{άdzkXYI ƒêÂû.†&²l WgºÒZ-|%iĬ, ÁÊʰÊg‚|ÿDüó¡TnjX)_P9°’TÀJF��•œê½¡‰+ø 3+ñAgV2�+ÈBú±�,uû²§b[á[WêÖº•–•òSW–z/RŽúÀÝNŠp +x +zÂày“?.*Žõ�²–pt‹~ŠüœÞ®8¸E‰û„ ߌ[Tó W·Ð¦}óÑɨmz’É-Î{òì|æ¿G˜Üâ Ëÿ+´@«×ª[™/”îŠÕÞ׌e{Öw.Kz©}à¤É- %buŽÐ3•¿>�Š(œ¯>]IEND®B`‚ \ No newline at end of file diff --git a/core/modules/responsive_preview/js/responsive-preview.js b/core/modules/responsive_preview/js/responsive-preview.js index 7183298..16b4b64 100644 --- a/core/modules/responsive_preview/js/responsive-preview.js +++ b/core/modules/responsive_preview/js/responsive-preview.js @@ -80,6 +80,18 @@ Drupal.behaviors.responsivePreview = { // Update the viewport width whenever it is resized, but max 4 times/s. .on('resize.responsivePreview', Drupal.debounce(setViewportWidth, 250)); + $(document) + // Respond to viewport offsetting elements like the Toolbar. + .on('drupalViewportOffsetChange.responsivePreview', function (event, offsets) { + envModel.set('offsets', offsets); + }) + .on('keyup.responsivePreview', function (event) { + // Close the preview if the Esc key is pressed. + if (event.keyCode === 27) { + previewModel.set('isActive', false); + } + }); + // Allow other scripts to respond to responsive preview mode changes. tabModel.on('change:isActive', function (model, isActive) { $(document).trigger((isActive) ? 'drupalResponsivePreviewStarted' : 'drupalResponsivePreviewStopped'); @@ -125,7 +137,14 @@ Drupal.responsivePreview.models.EnvironmentModel = Backbone.Model.extend({ // The viewport width, within which the preview will have to fit. viewportWidth: null, // Text direction of the document, affects some positioning. - dir: 'ltr' + dir: 'ltr', + // Viewport offset values. + offsets: { + top: 0, + right: 0, + bottom: 0, + left: 0 + } } }); @@ -391,7 +410,7 @@ Drupal.responsivePreview.views.PreviewView = Backbone.View.extend({ this.model.on('change:isActive change:isRotated change:dimensions change:activeDevice', this.render, this); // Recalculate the size of the preview container when the window resizes. - this.envModel.on('change:viewportWidth', this.render, this); + this.envModel.on('change:viewportWidth change:offsets', this.render, this); }, /** @@ -405,10 +424,10 @@ Drupal.responsivePreview.views.PreviewView = Backbone.View.extend({ this._build(); } - // Early-return if inactive. if (isActive) { // Refresh the preview. this._refresh(); + Drupal.displace(); } // Render the state of the preview. @@ -446,6 +465,7 @@ Drupal.responsivePreview.views.PreviewView = Backbone.View.extend({ * Builds the preview iframe. */ _build: function () { + var offsets = this.envModel.get('offsets'); var $frameContainer = $(Drupal.theme('responsivePreviewFrameContainer')) .find('#responsive-preview-close span') .text(this.strings.close) @@ -469,11 +489,9 @@ Drupal.responsivePreview.views.PreviewView = Backbone.View.extend({ .on('load.responsivePreview', $.proxy(this._refresh, this)) // Add the frame to the preview container. .appendTo($frameContainer); - // Adjust the placement of the preview container and insert it into the DOM. + // Insert the container into the DOM. this.$el - .css({ top: this._getDisplacement('top') }) - // Displace the top of the container. - .attr('data-offset-top', this._getDisplacement('top')) + .css('top', offsets.top) // Apend the frame container. .append($frameContainer) // Append the container to the body to initialize the iframe document. @@ -490,6 +508,7 @@ Drupal.responsivePreview.views.PreviewView = Backbone.View.extend({ var $deviceLink = $(this.model.get('activeDevice')); var $container = this.$el.find('#responsive-preview-frame-container'); var $frame = $container.find('> iframe'); + var offsets = this.envModel.get('offsets'); // Get the static state. var edge = (this.envModel.get('dir') === 'rtl') ? 'right' : 'left'; @@ -525,6 +544,7 @@ Drupal.responsivePreview.views.PreviewView = Backbone.View.extend({ // Resize & reposition the iframe. var position = {}; position[edge] = gutter; // Depends on text direction. + position.top = offsets.top; $frame .css({ width: width,