Skip to content

[Owls] Video background for Slide #386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
4231ab7
PB-266: Video background for Slide
eug123 Feb 11, 2020
4355811
PB-265: Video background for Banner
cspruiell Feb 13, 2020
b84757d
PB-266: Video background for Slide
eug123 Feb 13, 2020
1521cca
PB-266: Video background for Slide
eug123 Feb 13, 2020
b368135
Merge remote-tracking branch 'mainline/develop' into PB-266-with-row
eug123 Feb 18, 2020
99b7701
PB-266: Video background for Slide
eug123 Feb 18, 2020
0c4bae0
PB-266: Video background for Slide
eug123 Feb 18, 2020
62a9a46
Merge remote-tracking branch 'origin/develop' into PB-265-video-backg…
cspruiell Feb 18, 2020
46f9d26
PB-370: Introduce upgrade mechanism for Page Builder content
cspruiell Feb 18, 2020
c6a89da
PB-266: Video background for Slide
eug123 Feb 19, 2020
89d3e3f
PB-266: Video background for Slide
eug123 Feb 19, 2020
1bb8617
PB-266: Video background for Slide
eug123 Feb 19, 2020
75a8b38
PB-265: Video background for Banner
cspruiell Feb 19, 2020
50ad98c
PB-265: Video background for Banner
cspruiell Feb 19, 2020
bfcbf42
Merge remote-tracking branch 'origin/develop' into PB-265-video-backg…
cspruiell Feb 19, 2020
180471f
PB-266: Video background for Slide
eug123 Feb 19, 2020
1f1a258
Merge remote-tracking branch 'origin/develop' into PB-265-video-backg…
cspruiell Feb 20, 2020
50861fb
PB-266: Video background for Slide
eug123 Feb 20, 2020
c70a4a4
PB-265: Video background for Banner
cspruiell Feb 20, 2020
ca7ca38
PB-265: Video background for Banner
cspruiell Feb 20, 2020
3223f3b
PB-370: Introduce upgrade mechanism for Page Builder content
cspruiell Feb 20, 2020
f77f769
PB-266: Video background for Slide
eug123 Feb 24, 2020
b586c7a
PB-266: Video background for Slide
eug123 Feb 24, 2020
93c515e
PB-266: Video background for Slide
eug123 Feb 25, 2020
33513e5
Merge remote-tracking branch 'mainline/develop' into PB-266-with-row
eug123 Feb 25, 2020
1d338fd
PB-266: Video background for Slide
eug123 Feb 25, 2020
011c9e5
Merge remote-tracking branch 'origin/develop' into PB-265-video-backg…
cspruiell Feb 25, 2020
51a426e
PB-265: Video background for Banner
cspruiell Feb 25, 2020
f047afc
PB-265: Video background for Banner
omiroshnichenko Feb 25, 2020
f331b38
PB-265: Video background for Banner
omiroshnichenko Feb 25, 2020
718c6c4
Merge branch 'develop' into PB-265-video-background-for-banner
omiroshnichenko Feb 25, 2020
40359e9
PB-265: Video background for Banner
omiroshnichenko Feb 25, 2020
ca9d308
Merge branch 'PB-265-video-background-for-banner' of github.com:magen…
omiroshnichenko Feb 25, 2020
842e0e1
PB-266: Video background for Slide
eug123 Feb 25, 2020
d68faef
PB-266: Video background for Slide
eug123 Feb 25, 2020
5af0fd7
PB-266: Video background for Slide
eug123 Feb 26, 2020
d0d50e1
PB-265: Video background for Banner
omiroshnichenko Feb 26, 2020
b1db099
PB-266: Video background for Slide
eug123 Feb 26, 2020
fa9a098
PB-266: Video background for Slide
eug123 Feb 26, 2020
7045419
PB-266: Video background for Slide
eug123 Feb 26, 2020
d3cf705
Merge remote-tracking branch 'origin/PB-265-video-background-for-bann…
eug123 Feb 26, 2020
04b8bd2
Merge remote-tracking branch 'mainline/develop' into PB-266-with-row
eug123 Feb 26, 2020
45b8f8a
PB-266: Video background for Slide
eug123 Feb 26, 2020
7ed82b8
PB-266: Video background for Slide
eug123 Feb 26, 2020
009f944
PB-266: Video background for Slide
eug123 Feb 27, 2020
944f6da
PB-266: Video background for Slide
dhaecker Feb 27, 2020
d6efc89
PB-265: Video background for Banner
omiroshnichenko Feb 27, 2020
3998387
PB-266: Video background for Slide
eug123 Feb 27, 2020
c9f4f59
PB-266: Video background for Slide
omiroshnichenko Feb 28, 2020
57df0cb
Merge branch 'develop' into PB-265-video-background-for-banner
omiroshnichenko Feb 28, 2020
bfca6a3
PB-266: Video background for Slide
dhaecker Feb 28, 2020
b500c9f
Merge branch 'PB-266-with-row' of github.com:magento-obsessive-owls/m…
dhaecker Feb 28, 2020
e2c30c6
PB-265: Video background for Banner
omiroshnichenko Feb 28, 2020
8739a69
PB-265: Video background for Banner
omiroshnichenko Feb 28, 2020
ad7a553
PB-265: Video background for Banner
omiroshnichenko Feb 28, 2020
068acfd
PB-266: Video background for Slide
eug123 Feb 28, 2020
787cacd
Merge branch 'develop' into PB-265-video-background-for-banner
omiroshnichenko Feb 29, 2020
6409969
PB-266: Video background for Slide
dhaecker Feb 29, 2020
0a2e0ad
PB-266: Video background for Slide
dhaecker Mar 1, 2020
1af3f58
PB-266: Video background for Slide
dhaecker Mar 1, 2020
61bac05
PB-266: Video background for Slide
omiroshnichenko Mar 1, 2020
a4195f2
Merge branch 'PB-265-video-background-for-banner' of github.com:magen…
omiroshnichenko Mar 1, 2020
cf80778
PB-266: Video background for Slide
omiroshnichenko Mar 1, 2020
2b3a5b3
PB-266: Video background for Slide
dhaecker Mar 1, 2020
f732f64
Merge branch 'PB-266-with-row' of github.com:magento-obsessive-owls/m…
dhaecker Mar 1, 2020
3ff476c
PB-265: Video background for Banner
omiroshnichenko Mar 2, 2020
82557e6
Merge branch 'PB-265-video-background-for-banner' of github.com:magen…
omiroshnichenko Mar 2, 2020
d18ffeb
PB-265: Video background for Banner
omiroshnichenko Mar 2, 2020
3ba7fe8
PB-265: Video background for Banner
omiroshnichenko Mar 2, 2020
610851f
PB-265: Video background for Banner
omiroshnichenko Mar 2, 2020
319f844
PB-266: Video background for Slide
omiroshnichenko Mar 2, 2020
2ab25d1
PB-265: Video background for Banner
omiroshnichenko Mar 2, 2020
c1ccc45
PB-265: Video background for Banner
omiroshnichenko Mar 2, 2020
fc11bfb
Merge branch 'develop' into PB-266-with-row
omiroshnichenko Mar 2, 2020
6b96be2
PB-265: Video background for Banner
omiroshnichenko Mar 2, 2020
6cd9f5a
PB-265: Video background for Banner
omiroshnichenko Mar 2, 2020
93fad4f
PB-266: Video background for Slide
eug123 Mar 2, 2020
0baaf06
PB-266: Video background for Slide
eug123 Mar 3, 2020
0b5ec34
PB-265: Video background for Banner
omiroshnichenko Mar 3, 2020
f4788fc
Merge branch 'PB-266-with-row' of github.com:magento-obsessive-owls/m…
omiroshnichenko Mar 3, 2020
b1b4002
PB-265: Video background for Banner
omiroshnichenko Mar 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PB-265: Video background for Banner
- fix video reloading for any changes in content type
  • Loading branch information
omiroshnichenko committed Feb 25, 2020
commit f331b38288032822b22fae495e242ea8a125b7eb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import "jarallaxVideo";
import $ from "jquery";
import $t from "mage/translate";
import events from "Magento_PageBuilder/js/events";
import mageUtils from "mageUtils";
import _ from "underscore";
import "vimeoWrapper";
import ContentTypeConfigInterface from "../../content-type-config.types";
import HideShowOption from "../../content-type-menu/hide-show-option";
import {OptionsInterface} from "../../content-type-menu/option.types";
import ContentTypeInterface from "../../content-type.types";
import {DataObject} from "../../data-store";
import Uploader from "../../uploader";
import delayUntil from "../../utils/delay-until";
import {
Expand All @@ -27,8 +27,7 @@ import {
import nestingLinkDialog from "../../utils/nesting-link-dialog";
import WysiwygFactory from "../../wysiwyg/factory";
import WysiwygInterface from "../../wysiwyg/wysiwyg-interface";
import {ContentTypeMountEventParamsInterface, ContentTypeReadyEventParamsInterface} from "../content-type-events.types";
import ObservableUpdater from "../observable-updater";
import {ContentTypeReadyEventParamsInterface} from "../content-type-events.types";
import BasePreview from "../preview";

/**
Expand Down Expand Up @@ -67,6 +66,18 @@ export default class Preview extends BasePreview {
*/
private handledDoubleClick: boolean = false;

/**
* Properties that cause rebuilding video background
*/
private videoUpdateProperties = [
"background_type",
"video_fallback_image",
"video_lazy_load",
"video_loop",
"video_play_only_visible",
"video_source",
];

/**
* Debounce and defer the init of Jarallax
*
Expand Down Expand Up @@ -110,26 +121,6 @@ export default class Preview extends BasePreview {

}, 50);

/**
* @param {ContentTypeInterface} contentType
* @param {ContentTypeConfigInterface} config
* @param {ObservableUpdater} observableUpdater
*/
constructor(
contentType: ContentTypeInterface,
config: ContentTypeConfigInterface,
observableUpdater: ObservableUpdater,
) {
super(contentType, config, observableUpdater);

this.contentType.dataStore.subscribe(this.buildJarallax);
events.on("banner:mountAfter", (args: ContentTypeReadyEventParamsInterface) => {
if (args.id === this.contentType.id) {
this.buildJarallax();
}
});
}

/**
* Return an array of options
*
Expand Down Expand Up @@ -459,7 +450,11 @@ export default class Preview extends BasePreview {
*/
protected bindEvents() {
super.bindEvents();

events.on("banner:mountAfter", (args: ContentTypeReadyEventParamsInterface) => {
if (args.id === this.contentType.id) {
this.buildJarallax();
}
});
events.on(`${this.config.name}:${this.contentType.id}:updateAfter`, () => {
const dataStore = this.contentType.dataStore.getState();
const imageObject = (dataStore[this.config.additional_data.uploaderConfig.dataScope] as object[])[0] || {};
Expand All @@ -470,6 +465,14 @@ export default class Preview extends BasePreview {
events.trigger(`image:${this.contentType.id}:assignAfter`, imageObject);
nestingLinkDialog(this.contentType.dataStore, this.wysiwyg, "message", "link_url");
});
this.contentType.dataStore.subscribe(function(data: DataObject) {
if (this.isVideoShouldBeUpdated(data)) {
this.buildJarallax();
}
}.bind(this));
events.on(`image:${this.contentType.id}:uploadAfter`, () => {
this.contentType.dataStore.set("background_type", "image");
});
}

/**
Expand All @@ -487,4 +490,25 @@ export default class Preview extends BasePreview {

$(this.textarea).height(scrollHeight);
}

/**
* Adjust textarea's height based on scrollHeight
*
* @return boolean
*/
private isVideoShouldBeUpdated(state: DataObject): boolean {
const previousState = this.contentType.dataStore.previousState;
const diff = mageUtils.compare(previousState, state).changes;

if (diff.length > 0) {
return _.some(diff, (element) => {
if (element.name === "video_fallback_image") {
return (!_.isEmpty(previousState.video_fallback_image) && previousState.video_fallback_image) !==
(!_.isEmpty(state.video_fallback_image) && state.video_fallback_image);
}

return this.videoUpdateProperties.indexOf(element.name) !== -1;
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export interface DataObject<T = any> {
}

export default class DataStore {
public previousState: DataObject = {};
private state: DataObject = {};
private events: JQuery = $({});
private previousState: DataObject = {};

/**
* Retrieve specific data from the data store
Expand Down Expand Up @@ -46,6 +46,7 @@ export default class DataStore {
* @param value
*/
public set(key: string, value: any) {
this.previousState = Object.assign({}, this.state);
set(this.state, key, value);
this.emitState();
}
Expand All @@ -56,6 +57,7 @@ export default class DataStore {
* @param {DataObject} state
*/
public setState(state: DataObject) {
this.previousState = Object.assign({}, this.state);
this.state = state;
this.emitState();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
* See COPYING.txt for license details.
*/

interface CompareObject {
containers: object;
changes: CompareObjectItem[];
equal: boolean;
}

interface CompareObjectItem {
path: string;
name: string;
value: any;
oldValue: any;
}

declare let mageUtils: {
/**
* Generates a unique identifier.
Expand All @@ -18,6 +31,14 @@ declare let mageUtils: {
* @returns {Object|Array} Extended object.
*/
extend(...args: any[]): object;

/**
* Compare two objects
* @param args
*
* @return {CompareObject}.
*/
compare(...args: any[]): CompareObject;
};
declare module "mageUtils" {
export = mageUtils;
Expand Down