Skip to content

Commit ed15297

Browse files
committed
PB-95: Video background for Row
1 parent ff4a985 commit ed15297

File tree

11 files changed

+39
-149
lines changed

11 files changed

+39
-149
lines changed

app/code/Magento/PageBuilder/view/adminhtml/pagebuilder/content_type/row.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<attribute name="parallax_speed" source="data-parallax-speed"/>
5555
<attribute name="background_images" source="data-background-images"/>
5656
<attribute name="background_type" source="data-background-type"/>
57-
<attribute name="video_source" source="data-video-src" converter="Magento_PageBuilder/js/content-type/video/converter/attribute/data-src"/>
57+
<attribute name="video_source" source="data-video-src" converter="Magento_PageBuilder/js/content-type/video/converter/attribute/src"/>
5858
<attribute name="video_loop" source="data-video-loop"/>
5959
<attribute name="video_play_only_visible" source="data-video-play-only-visible"/>
6060
<attribute name="video_lazy_load" source="data-video-lazy-load"/>
@@ -114,7 +114,7 @@
114114
<attribute name="parallax_speed" source="data-parallax-speed"/>
115115
<attribute name="background_images" source="data-background-images"/>
116116
<attribute name="background_type" source="data-background-type"/>
117-
<attribute name="video_source" source="data-video-src" converter="Magento_PageBuilder/js/content-type/video/converter/attribute/data-src"/>
117+
<attribute name="video_source" source="data-video-src" converter="Magento_PageBuilder/js/content-type/video/converter/attribute/src"/>
118118
<attribute name="video_loop" source="data-video-loop"/>
119119
<attribute name="video_play_only_visible" source="data-video-play-only-visible"/>
120120
<attribute name="video_lazy_load" source="data-video-lazy-load"/>
@@ -175,7 +175,7 @@
175175
<attribute name="parallax_speed" source="data-parallax-speed"/>
176176
<attribute name="background_images" source="data-background-images"/>
177177
<attribute name="background_type" source="data-background-type"/>
178-
<attribute name="video_source" source="data-video-src" converter="Magento_PageBuilder/js/content-type/video/converter/attribute/data-src"/>
178+
<attribute name="video_source" source="data-video-src" converter="Magento_PageBuilder/js/content-type/video/converter/attribute/src"/>
179179
<attribute name="video_loop" source="data-video-loop"/>
180180
<attribute name="video_play_only_visible" source="data-video-play-only-visible"/>
181181
<attribute name="video_lazy_load" source="data-video-lazy-load"/>

app/code/Magento/PageBuilder/view/adminhtml/ui_component/pagebuilder_base_form_with_background_video.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,7 @@
8888
<dataType>text</dataType>
8989
<label translate="true">Video URL</label>
9090
<tooltip>
91-
<description translate="true">
92-
<![CDATA[
93-
<p>Supported video sources are:</p>
94-
<p>URL to YouTube or Vimeo video</p>
95-
<p>URL to .mp4, .ogv or .webm video file</p>
96-
]]>
97-
</description>
91+
<description translate="true">Video URLs can include web URLs to files with video extensions (such as https://company/videos/myvideo.mp4) or embed codes from YouTube or Vimeo.</description>
9892
</tooltip>
9993
<imports>
10094
<link name="visible">${$.parentName}.background_type:videoVisible</link>

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/video/converter/attribute/data-src.js

Lines changed: 0 additions & 69 deletions
This file was deleted.

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/video/converter/attribute/src.js

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/js/form/element/validator-rules-mixin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ define([
171171
href.match(/\.(mp4|ogv|webm)(?!\w)/)
172172
);
173173
},
174-
$.mage.__('Please enter a valid video URL.')
174+
$.mage.__('Please enter a valid video URL. Valid URLs have a video file extension (.mp4, .webm, .ogv) or an embed code from YouTube or Vimeo.')//eslint-disable-line max-len
175175
);
176176

177177
validator.addRule(

app/code/Magento/PageBuilder/view/adminhtml/web/template/content-type/row/contained/preview.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
<div class="pagebuilder-content-type type-container pagebuilder-row children-min-height"
1212
attr="data.inner.attributes"
1313
ko-style="data.inner.style"
14-
css="Object.assign(data.inner.css(), {'empty-container': contentType.children().length == 0, 'jarallax': data.inner.attributes()['data-enable-parallax'] == 1})"
14+
css="Object.assign(data.inner.css(), {
15+
'empty-container': contentType.children().length == 0,
16+
'jarallax': data.inner.attributes()['data-enable-parallax'] == 1 || data.inner.attributes()['data-background-type'] == 'video'
17+
})"
1518
event="{ mouseover: onMouseOver, mouseout: onMouseOut }, mouseoverBubble: false"
1619
afterRender="initParallax">
1720
<div if="data.video_overlay.attributes()['data-video-overlay-color']"

app/code/Magento/PageBuilder/view/adminhtml/web/template/content-type/row/full-bleed/preview.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
<div class="pagebuilder-content-type type-container pagebuilder-row children-min-height"
99
attr="data.main.attributes"
1010
ko-style="data.main.style"
11-
css="Object.assign(data.main.css(), {'empty-container': contentType.children().length == 0, 'jarallax': data.main.attributes()['data-enable-parallax'] == 1})"
11+
css="Object.assign(data.main.css(), {
12+
'empty-container': contentType.children().length == 0,
13+
'jarallax': data.main.attributes()['data-enable-parallax'] == 1 || data.main.attributes()['data-background-type'] == 'video'
14+
})"
1215
event="{ mouseover: onMouseOver, mouseout: onMouseOut }, mouseoverBubble: false"
1316
afterRender="initParallax">
1417
<div if="data.video_overlay.attributes()['data-video-overlay-color']"

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/video/converter/attribute/data-src.ts

Lines changed: 0 additions & 56 deletions
This file was deleted.

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/video/converter/attribute/src.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ export default class Src implements ConverterInterface {
1515
* @returns {string | object}
1616
*/
1717
public fromDom(value: string): string | object {
18+
const fileRegExp = new RegExp("^(webm:|mp4:|ogv:)");
19+
if (fileRegExp.test(value)) {
20+
return value.substr(fileRegExp.exec(value)[0].length)
21+
}
22+
1823
return value;
1924
}
2025

@@ -35,11 +40,15 @@ export default class Src implements ConverterInterface {
3540
"(?:youtu\\.be\/|youtube\\.com\/(?:embed\/|v\/|watch\\?v=|watch\\?.+&v=))([\\w-]{11})(?![\\w-])");
3641
const vimeoRegExp = new RegExp("https?:\/\/(?:www\\.|player\\.)?vimeo.com\/(?:channels\/" +
3742
"(?:\\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\\d+)\/video\/|video\/|)(\\d+)(?:$|\/|\\?)");
43+
const fileRegExp = new RegExp("^(?:https:)?\\/\\/.*[\\\\\\/].+\\.(webm|mp4|ogv)(?!\w)");
3844

3945
if (youtubeRegExp.test(value)) {
4046
return "https://www.youtube.com/embed/" + youtubeRegExp.exec(value)[1];
4147
} else if (vimeoRegExp.test(value)) {
4248
return "https://player.vimeo.com/video/" + vimeoRegExp.exec(value)[3] + "?title=0&byline=0&portrait=0";
49+
} else if (fileRegExp.test(value)) {
50+
const result = fileRegExp.exec(value);
51+
return result[1] + ":" + value;
4352
}
4453

4554
return value;

app/code/Magento/PageBuilder/view/base/web/css/source/jarallax/_jarallax.less

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
z-index: 0;
1414
}
1515

16-
.jarallax{
16+
.jarallax {
1717
& > .jarallax-img {
18-
// Support for plugin https://github.com/bfred-it/object-fit-images
1918
font-family: 'object-fit: cover;', sans-serif;
2019
height: 100%;
2120
left: 0;

0 commit comments

Comments
 (0)