-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e96563
commit 90da470
Showing
7 changed files
with
115 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/bundle/Resources/public/js/scripts/admin.location.preview.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
(function (global, doc) { | ||
const previewNode = doc.querySelector('.ibexa-location-preview'); | ||
const previewSiteaccessDropdownInput = previewNode.querySelector('.ibexa-location-preview__siteaccess .ibexa-dropdown .ibexa-dropdown__source .ibexa-input'); | ||
const previewIframeWrapperNode = previewNode.querySelector('.ibexa-location-preview__iframe-wrapper'); | ||
const previewIframe = previewIframeWrapperNode.querySelector('.ibexa-location-preview__iframe'); | ||
const handleSiteaccessChange = (event) => { | ||
previewIframe.src = event.target.value; | ||
} | ||
const resizeIframe = () => { | ||
const currentPreviewWidth = previewIframeWrapperNode.offsetWidth; | ||
const currentIframeWidth = previewIframe.offsetWidth; | ||
const scaleValue = currentPreviewWidth / currentIframeWidth; | ||
|
||
previewIframe.style.scale = scaleValue; | ||
|
||
const newPreviewNodeHeight = previewIframe.getBoundingClientRect().height; | ||
|
||
previewIframeWrapperNode.style.height = `${newPreviewNodeHeight}px`; | ||
} | ||
const blockEventsInsideIframe = () => { | ||
const documentHTML = previewIframe.contentWindow.document.documentElement; | ||
|
||
documentHTML.style.pointerEvents = 'none'; | ||
} | ||
const handleIframeLoad = () => { | ||
blockEventsInsideIframe(); | ||
} | ||
const resizeObserver = new ResizeObserver(() => { | ||
resizeIframe(); | ||
}); | ||
|
||
resizeObserver.observe(previewIframeWrapperNode); | ||
previewIframe.addEventListener('load', handleIframeLoad, false); | ||
previewSiteaccessDropdownInput.addEventListener('change', handleSiteaccessChange, false); | ||
})(window, window.document); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.ibexa-location-preview { | ||
&__siteaccess { | ||
display: inline-block; | ||
} | ||
&__iframe { | ||
width: 1920px; | ||
aspect-ratio: 16/9; | ||
transform-origin: left top; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,3 +126,4 @@ | |
@import 'double-input-range'; | ||
@import 'switcher'; | ||
@import 'user-name'; | ||
@import 'location-preview'; |
66 changes: 66 additions & 0 deletions
66
src/bundle/Resources/views/themes/admin/content/tab/preview.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{% set version_no = content.versionInfo.versionNo %} | ||
{% set current_language = app.request.get('languageCode') ?: content.prioritizedFieldLanguageCode %} | ||
{% set siteaccess = 'site' %} | ||
|
||
<div class="ibexa-location-preview"> | ||
<div class="ibexa-location-preview__siteaccess"> | ||
{% set value = '' %} | ||
{% set choices = [ | ||
{ | ||
value: path( | ||
'ibexa.version.preview', | ||
{ | ||
'contentId': content.id, | ||
'versionNo': version_no, | ||
'language': current_language, | ||
'siteAccessName': 'site', | ||
}, | ||
), | ||
label: 'Site', | ||
}, | ||
{ | ||
value: path( | ||
'ibexa.version.preview', | ||
{ | ||
'contentId': content.id, | ||
'versionNo': version_no, | ||
'language': current_language, | ||
'siteAccessName': 'corporate', | ||
}, | ||
), | ||
label: 'Corporate', | ||
}, | ||
] %} | ||
{% set source %} | ||
<select class="form-control ibexa-input"> | ||
{% for choice in choices %} | ||
{% if loop.first %} | ||
{% set value = choice.value %} | ||
{% endif %} | ||
<option value="{{ choice.value }}"> | ||
{{ choice.label }} | ||
</option> | ||
{% endfor %} | ||
</select> | ||
{% endset %} | ||
|
||
{% include '@ibexadesign/ui/component/dropdown/dropdown.html.twig' with { | ||
source: source, | ||
choices: choices, | ||
value: value, | ||
} %} | ||
</div> | ||
<div class="ibexa-location-preview__iframe-wrapper"> | ||
<iframe | ||
class="ibexa-location-preview__iframe" | ||
src="{{ url('ibexa.version.preview', { | ||
'contentId': content.id, | ||
'versionNo': version_no, | ||
'language': current_language, | ||
'siteAccessName': siteaccess, | ||
})}}" | ||
frameborder="0" | ||
> | ||
</iframe> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters