@xibosignage/xibo-layout-renderer 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/Modules/ActionController/ActionController.d.ts +32 -0
- package/dist/src/Modules/ActionController/index.d.ts +1 -0
- package/dist/src/Modules/Generators/Generators.d.ts +3 -0
- package/dist/src/Types/Layout/Layout.types.d.ts +7 -2
- package/dist/src/Types/Region/Region.types.d.ts +3 -1
- package/dist/styles.css +108 -0
- package/dist/xibo-layout-renderer.cjs.js +419 -6
- package/dist/xibo-layout-renderer.cjs.js.map +1 -1
- package/dist/xibo-layout-renderer.d.ts +40 -3
- package/dist/xibo-layout-renderer.esm.js +419 -6
- package/dist/xibo-layout-renderer.esm.js.map +1 -1
- package/dist/xibo-layout-renderer.js +419 -6
- package/dist/xibo-layout-renderer.min.js +1 -1
- package/dist/xibo-layout-renderer.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
function _callSuper(t, o, e) {
|
|
6
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
7
|
+
}
|
|
8
|
+
function _construct(t, e, r) {
|
|
9
|
+
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
10
|
+
var o = [null];
|
|
11
|
+
o.push.apply(o, e);
|
|
12
|
+
var p = new (t.bind.apply(t, o))();
|
|
13
|
+
return r && _setPrototypeOf(p, r.prototype), p;
|
|
14
|
+
}
|
|
15
|
+
function _isNativeReflectConstruct() {
|
|
16
|
+
try {
|
|
17
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
18
|
+
} catch (t) {}
|
|
19
|
+
return (_isNativeReflectConstruct = function () {
|
|
20
|
+
return !!t;
|
|
21
|
+
})();
|
|
22
|
+
}
|
|
5
23
|
function ownKeys(e, r) {
|
|
6
24
|
var t = Object.keys(e);
|
|
7
25
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -368,6 +386,27 @@ function _asyncToGenerator(fn) {
|
|
|
368
386
|
});
|
|
369
387
|
};
|
|
370
388
|
}
|
|
389
|
+
function _classCallCheck(instance, Constructor) {
|
|
390
|
+
if (!(instance instanceof Constructor)) {
|
|
391
|
+
throw new TypeError("Cannot call a class as a function");
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
function _defineProperties(target, props) {
|
|
395
|
+
for (var i = 0; i < props.length; i++) {
|
|
396
|
+
var descriptor = props[i];
|
|
397
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
398
|
+
descriptor.configurable = true;
|
|
399
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
400
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
404
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
405
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
406
|
+
writable: false
|
|
407
|
+
});
|
|
408
|
+
return Constructor;
|
|
409
|
+
}
|
|
371
410
|
function _defineProperty(obj, key, value) {
|
|
372
411
|
key = _toPropertyKey(key);
|
|
373
412
|
if (key in obj) {
|
|
@@ -382,6 +421,82 @@ function _defineProperty(obj, key, value) {
|
|
|
382
421
|
}
|
|
383
422
|
return obj;
|
|
384
423
|
}
|
|
424
|
+
function _inherits(subClass, superClass) {
|
|
425
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
426
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
427
|
+
}
|
|
428
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
429
|
+
constructor: {
|
|
430
|
+
value: subClass,
|
|
431
|
+
writable: true,
|
|
432
|
+
configurable: true
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
Object.defineProperty(subClass, "prototype", {
|
|
436
|
+
writable: false
|
|
437
|
+
});
|
|
438
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
439
|
+
}
|
|
440
|
+
function _getPrototypeOf(o) {
|
|
441
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
442
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
443
|
+
};
|
|
444
|
+
return _getPrototypeOf(o);
|
|
445
|
+
}
|
|
446
|
+
function _setPrototypeOf(o, p) {
|
|
447
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
448
|
+
o.__proto__ = p;
|
|
449
|
+
return o;
|
|
450
|
+
};
|
|
451
|
+
return _setPrototypeOf(o, p);
|
|
452
|
+
}
|
|
453
|
+
function _isNativeFunction(fn) {
|
|
454
|
+
try {
|
|
455
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
456
|
+
} catch (e) {
|
|
457
|
+
return typeof fn === "function";
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
function _wrapNativeSuper(Class) {
|
|
461
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
462
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
463
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
464
|
+
if (typeof Class !== "function") {
|
|
465
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
466
|
+
}
|
|
467
|
+
if (typeof _cache !== "undefined") {
|
|
468
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
469
|
+
_cache.set(Class, Wrapper);
|
|
470
|
+
}
|
|
471
|
+
function Wrapper() {
|
|
472
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
473
|
+
}
|
|
474
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
475
|
+
constructor: {
|
|
476
|
+
value: Wrapper,
|
|
477
|
+
enumerable: false,
|
|
478
|
+
writable: true,
|
|
479
|
+
configurable: true
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
483
|
+
};
|
|
484
|
+
return _wrapNativeSuper(Class);
|
|
485
|
+
}
|
|
486
|
+
function _assertThisInitialized(self) {
|
|
487
|
+
if (self === void 0) {
|
|
488
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
489
|
+
}
|
|
490
|
+
return self;
|
|
491
|
+
}
|
|
492
|
+
function _possibleConstructorReturn(self, call) {
|
|
493
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
494
|
+
return call;
|
|
495
|
+
} else if (call !== void 0) {
|
|
496
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
497
|
+
}
|
|
498
|
+
return _assertThisInitialized(self);
|
|
499
|
+
}
|
|
385
500
|
function _toConsumableArray(arr) {
|
|
386
501
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
387
502
|
}
|
|
@@ -524,7 +639,7 @@ var initialLayout = {
|
|
|
524
639
|
regionMaxZIndex: 0,
|
|
525
640
|
ready: false,
|
|
526
641
|
regionObjects: [],
|
|
527
|
-
drawer:
|
|
642
|
+
drawer: null,
|
|
528
643
|
allExpired: false,
|
|
529
644
|
regions: [],
|
|
530
645
|
actions: [],
|
|
@@ -548,7 +663,8 @@ var initialLayout = {
|
|
|
548
663
|
return Promise.resolve();
|
|
549
664
|
},
|
|
550
665
|
emitter: {},
|
|
551
|
-
index: -1
|
|
666
|
+
index: -1,
|
|
667
|
+
actionController: undefined
|
|
552
668
|
};
|
|
553
669
|
|
|
554
670
|
function nextId(options) {
|
|
@@ -744,11 +860,22 @@ function getIndexByLayoutId(layoutsInput, layoutId) {
|
|
|
744
860
|
index: 0
|
|
745
861
|
};
|
|
746
862
|
}
|
|
863
|
+
function getAllAttributes(elem) {
|
|
864
|
+
if (!elem || elem === null) {
|
|
865
|
+
return {};
|
|
866
|
+
}
|
|
867
|
+
return elem.getAttributeNames().reduce(function (obj, name) {
|
|
868
|
+
return _objectSpread2(_objectSpread2({}, obj), {}, _defineProperty({}, name, {
|
|
869
|
+
value: elem.getAttribute(name)
|
|
870
|
+
}));
|
|
871
|
+
}, {});
|
|
872
|
+
}
|
|
747
873
|
|
|
748
874
|
var initialRegion = {
|
|
749
875
|
layout: initialLayout,
|
|
750
876
|
id: '',
|
|
751
877
|
regionId: '',
|
|
878
|
+
uniqueId: '',
|
|
752
879
|
xml: null,
|
|
753
880
|
mediaObjects: [],
|
|
754
881
|
mediaObjectsActions: [],
|
|
@@ -773,6 +900,7 @@ var initialRegion = {
|
|
|
773
900
|
index: -1,
|
|
774
901
|
prepareRegion: function prepareRegion() {},
|
|
775
902
|
playNextMedia: function playNextMedia() {},
|
|
903
|
+
playPreviousMedia: function playPreviousMedia() {},
|
|
776
904
|
transitionNodes: function transitionNodes() {},
|
|
777
905
|
finished: function finished() {},
|
|
778
906
|
run: function run() {},
|
|
@@ -1606,7 +1734,7 @@ function Region(layout, xml, regionId, options, xlr) {
|
|
|
1606
1734
|
var emitter = createNanoEvents();
|
|
1607
1735
|
var regionObject = _objectSpread2(_objectSpread2({}, initialRegion), props);
|
|
1608
1736
|
regionObject.prepareRegion = function () {
|
|
1609
|
-
var _self$xml, _self$xml2, _self$xml3, _self$xml4, _self$xml5, _self$xml6;
|
|
1737
|
+
var _self$xml, _self$xml2, _self$xml3, _self$xml4, _self$xml5, _self$xml6, _self$layout$actionCo;
|
|
1610
1738
|
var self = regionObject;
|
|
1611
1739
|
var layout = self.layout,
|
|
1612
1740
|
options = self.options;
|
|
@@ -1614,8 +1742,9 @@ function Region(layout, xml, regionId, options, xlr) {
|
|
|
1614
1742
|
self.ending = false;
|
|
1615
1743
|
self.ended = false;
|
|
1616
1744
|
self.id = props.regionId;
|
|
1745
|
+
self.uniqueId = "".concat(nextId(self.options));
|
|
1617
1746
|
self.options = _objectSpread2(_objectSpread2({}, platform), props.options);
|
|
1618
|
-
self.containerName = "R-".concat(self.id, "-").concat(
|
|
1747
|
+
self.containerName = "R-".concat(self.id, "-").concat(self.uniqueId);
|
|
1619
1748
|
self.xml = props.xml;
|
|
1620
1749
|
self.mediaObjects = [];
|
|
1621
1750
|
self.sWidth = self.xml && Number((_self$xml = self.xml) === null || _self$xml === void 0 ? void 0 : _self$xml.getAttribute('width')) * layout.scaleFactor;
|
|
@@ -1654,6 +1783,20 @@ function Region(layout, xml, regionId, options, xlr) {
|
|
|
1654
1783
|
mediaObj.index = indx;
|
|
1655
1784
|
self.mediaObjects.push(mediaObj);
|
|
1656
1785
|
});
|
|
1786
|
+
// Add media to region for targetted actions
|
|
1787
|
+
(_self$layout$actionCo = self.layout.actionController) === null || _self$layout$actionCo === void 0 || _self$layout$actionCo.actions.forEach(function (action) {
|
|
1788
|
+
var attributes = getAllAttributes(action.xml);
|
|
1789
|
+
if (attributes.target.value === 'region' && attributes.actionType.value === 'navWidget' && attributes.targetId.value == self.id) {
|
|
1790
|
+
var _self$layout$drawer;
|
|
1791
|
+
var drawerMediaItems = Array.from(((_self$layout$drawer = self.layout.drawer) === null || _self$layout$drawer === void 0 ? void 0 : _self$layout$drawer.getElementsByTagName('media')) || []);
|
|
1792
|
+
drawerMediaItems.forEach(function (drawerMedia) {
|
|
1793
|
+
if (drawerMedia.id === attributes.widgetId.value) {
|
|
1794
|
+
// Add drawer media to the region
|
|
1795
|
+
self.mediaObjectsActions.push(Media(self, (drawerMedia === null || drawerMedia === void 0 ? void 0 : drawerMedia.getAttribute('id')) || '', drawerMedia, options, xlr));
|
|
1796
|
+
}
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
});
|
|
1657
1800
|
self.prepareMediaObjects();
|
|
1658
1801
|
};
|
|
1659
1802
|
regionObject.finished = function () {
|
|
@@ -1811,6 +1954,18 @@ function Region(layout, xml, regionId, options, xlr) {
|
|
|
1811
1954
|
console.debug('region::playNextMedia', self);
|
|
1812
1955
|
self.transitionNodes(self.oldMedia, self.curMedia);
|
|
1813
1956
|
};
|
|
1957
|
+
regionObject.playPreviousMedia = function () {
|
|
1958
|
+
var self = regionObject;
|
|
1959
|
+
self.currentMediaIndex = self.currentMediaIndex - 1;
|
|
1960
|
+
if (self.currentMediaIndex < 0 || self.ended) {
|
|
1961
|
+
self.currentMediaIndex = 0;
|
|
1962
|
+
return;
|
|
1963
|
+
}
|
|
1964
|
+
self.prepareMediaObjects();
|
|
1965
|
+
console.debug('region::playPreviousMedia', self);
|
|
1966
|
+
/* Do the transition */
|
|
1967
|
+
self.transitionNodes(self.oldMedia, self.curMedia);
|
|
1968
|
+
};
|
|
1814
1969
|
regionObject.end = function () {
|
|
1815
1970
|
var self = regionObject;
|
|
1816
1971
|
self.ending = true;
|
|
@@ -1851,6 +2006,251 @@ function Region(layout, xml, regionId, options, xlr) {
|
|
|
1851
2006
|
return regionObject;
|
|
1852
2007
|
}
|
|
1853
2008
|
|
|
2009
|
+
var Action = /*#__PURE__*/_createClass(function Action(id, xml) {
|
|
2010
|
+
_classCallCheck(this, Action);
|
|
2011
|
+
_defineProperty(this, "id", void 0);
|
|
2012
|
+
_defineProperty(this, "xml", void 0);
|
|
2013
|
+
this.id = id;
|
|
2014
|
+
this.xml = xml;
|
|
2015
|
+
});
|
|
2016
|
+
var ActionsWrapper = /*#__PURE__*/function (_HTMLDivElement) {
|
|
2017
|
+
function ActionsWrapper() {
|
|
2018
|
+
var _this;
|
|
2019
|
+
_classCallCheck(this, ActionsWrapper);
|
|
2020
|
+
_this = _callSuper(this, ActionsWrapper);
|
|
2021
|
+
_this.classList.add('action-controller', 'noselect');
|
|
2022
|
+
return _this;
|
|
2023
|
+
}
|
|
2024
|
+
_inherits(ActionsWrapper, _HTMLDivElement);
|
|
2025
|
+
return _createClass(ActionsWrapper);
|
|
2026
|
+
}( /*#__PURE__*/_wrapNativeSuper(HTMLDivElement));
|
|
2027
|
+
customElements.define('action-controller', ActionsWrapper, {
|
|
2028
|
+
"extends": 'div'
|
|
2029
|
+
});
|
|
2030
|
+
var ActionController = /*#__PURE__*/function () {
|
|
2031
|
+
function ActionController(parent, actions, options) {
|
|
2032
|
+
_classCallCheck(this, ActionController);
|
|
2033
|
+
_defineProperty(this, "parent", void 0);
|
|
2034
|
+
_defineProperty(this, "actions", void 0);
|
|
2035
|
+
_defineProperty(this, "options", void 0);
|
|
2036
|
+
_defineProperty(this, "$actionController", void 0);
|
|
2037
|
+
_defineProperty(this, "$actionListContainer", void 0);
|
|
2038
|
+
_defineProperty(this, "translations", {});
|
|
2039
|
+
this.parent = parent;
|
|
2040
|
+
this.actions = actions;
|
|
2041
|
+
this.options = options;
|
|
2042
|
+
this.$actionController = document.createElement('div', {
|
|
2043
|
+
is: 'action-controller'
|
|
2044
|
+
});
|
|
2045
|
+
this.$actionListContainer = null;
|
|
2046
|
+
this.init();
|
|
2047
|
+
}
|
|
2048
|
+
return _createClass(ActionController, [{
|
|
2049
|
+
key: "init",
|
|
2050
|
+
value: function init() {
|
|
2051
|
+
var self = this;
|
|
2052
|
+
var previewTranslations = {};
|
|
2053
|
+
// get preview translations
|
|
2054
|
+
if ('previewTranslations' in window) {
|
|
2055
|
+
previewTranslations = window['previewTranslations'];
|
|
2056
|
+
self.translations = previewTranslations;
|
|
2057
|
+
}
|
|
2058
|
+
var $container = document.getElementById(this.parent.containerName);
|
|
2059
|
+
var $actionTitle = document.createElement('div');
|
|
2060
|
+
var $actionsContainer = document.createElement('div');
|
|
2061
|
+
$actionTitle.classList.add('action-controller-title');
|
|
2062
|
+
$actionTitle.innerHTML = "\n <button class=\"toggle\"></button>\n <span class=\"title\">".concat(previewTranslations.actionControllerTitle, "</span>\n ");
|
|
2063
|
+
$actionsContainer.classList.add('actions-container');
|
|
2064
|
+
if ($container) {
|
|
2065
|
+
$container.insertBefore(this.$actionController, $container.firstElementChild);
|
|
2066
|
+
this.$actionController.appendChild($actionTitle);
|
|
2067
|
+
this.$actionController.appendChild($actionsContainer);
|
|
2068
|
+
// Loop through actions
|
|
2069
|
+
Array.from(this.actions).forEach(function (newAction) {
|
|
2070
|
+
// Create new action object
|
|
2071
|
+
var $newAction = document.createElement('div');
|
|
2072
|
+
// Copy element attributes
|
|
2073
|
+
var attributes = getAllAttributes(newAction.xml);
|
|
2074
|
+
Array.from(Object.keys(attributes)).forEach(function (attribKey) {
|
|
2075
|
+
$newAction.setAttribute("data-".concat(attribKey), attributes[attribKey].value);
|
|
2076
|
+
$newAction.setAttribute(attribKey, attributes[attribKey].value);
|
|
2077
|
+
});
|
|
2078
|
+
// Build html for the new action
|
|
2079
|
+
var html = '';
|
|
2080
|
+
// Add action type
|
|
2081
|
+
html += '<span class="action-row-title">' + previewTranslations[$newAction.getAttribute('actiontype') || ''];
|
|
2082
|
+
if ($newAction.getAttribute('actiontype') == 'navWidget') {
|
|
2083
|
+
html += ' <span title="' + previewTranslations.widgetId + '">[' + $newAction.getAttribute('widgetid') + ']</span>';
|
|
2084
|
+
} else if ($newAction.getAttribute('actiontype') == 'navLayout') {
|
|
2085
|
+
html += ' <span title="' + previewTranslations.layoutCode + '">[' + $newAction.getAttribute('layoutcode') + ']</span>';
|
|
2086
|
+
}
|
|
2087
|
+
html += '</span>';
|
|
2088
|
+
// Add target
|
|
2089
|
+
html += '<span class="action-row-target" title="' + previewTranslations.target + '">' + $newAction.getAttribute('target');
|
|
2090
|
+
if ($newAction.getAttribute('targetid') != '') {
|
|
2091
|
+
html += '(' + $newAction.getAttribute('targetid') + $newAction.getAttribute('layoutcode') + ')';
|
|
2092
|
+
}
|
|
2093
|
+
html += '</span>';
|
|
2094
|
+
// Add HTML string to the action
|
|
2095
|
+
$newAction.innerHTML = html;
|
|
2096
|
+
// Append new action to the controller
|
|
2097
|
+
$newAction.classList.add('action');
|
|
2098
|
+
$newAction.setAttribute('originalid', newAction.id);
|
|
2099
|
+
$newAction.setAttribute('id', 'A-' + newAction.id + '-' + nextId(self.options));
|
|
2100
|
+
$actionsContainer.insertBefore($newAction, $actionsContainer.lastElementChild);
|
|
2101
|
+
});
|
|
2102
|
+
//
|
|
2103
|
+
// Enable dragging
|
|
2104
|
+
// const $draggableContainer = new Moveable($container, {
|
|
2105
|
+
// target: this.$actionController,
|
|
2106
|
+
// draggable: true,
|
|
2107
|
+
// });
|
|
2108
|
+
// Toggle actions visibility
|
|
2109
|
+
var $actionsToggler = this.$actionController.querySelector('.toggle');
|
|
2110
|
+
if ($actionsToggler) {
|
|
2111
|
+
$actionsToggler.onclick = function () {
|
|
2112
|
+
self.$actionController.classList.toggle('d-none');
|
|
2113
|
+
};
|
|
2114
|
+
}
|
|
2115
|
+
var $webhookActions = this.$actionController.querySelectorAll('.action[triggertype="webhook"]');
|
|
2116
|
+
// Display according to the number of clickable actions
|
|
2117
|
+
this.$actionController.style.setProperty('display', $webhookActions.length === 0 ? 'none' : 'flex');
|
|
2118
|
+
// Handle webhook action trigger click
|
|
2119
|
+
if ($webhookActions.length > 0) {
|
|
2120
|
+
$webhookActions.forEach(function ($webhookAction) {
|
|
2121
|
+
$webhookAction.onclick = function (event) {
|
|
2122
|
+
event.stopPropagation();
|
|
2123
|
+
self.runAction($webhookAction.dataset, self.options);
|
|
2124
|
+
};
|
|
2125
|
+
$webhookAction.classList.add('clickable');
|
|
2126
|
+
});
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
}, {
|
|
2131
|
+
key: "openLayoutInNewTab",
|
|
2132
|
+
value: function openLayoutInNewTab(layoutCode, options) {
|
|
2133
|
+
if (confirm(this.translations.navigateToLayout.replace('[layoutTag]', layoutCode))) {
|
|
2134
|
+
var url = options.layoutPreviewUrl.replace('[layoutCode]', layoutCode) + '?findByCode=1';
|
|
2135
|
+
window.open(url, '_blank');
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
/** Change media in region (next/previous) */
|
|
2139
|
+
}, {
|
|
2140
|
+
key: "nextMediaInRegion",
|
|
2141
|
+
value: function nextMediaInRegion(regionId, actionType) {
|
|
2142
|
+
// Find target region
|
|
2143
|
+
this.parent.regions.forEach(function (regionObj) {
|
|
2144
|
+
if (regionObj.id === regionId) {
|
|
2145
|
+
if (actionType === 'next') {
|
|
2146
|
+
regionObj.playNextMedia();
|
|
2147
|
+
} else {
|
|
2148
|
+
regionObj.playPreviousMedia();
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
});
|
|
2152
|
+
}
|
|
2153
|
+
}, {
|
|
2154
|
+
key: "loadMediaInRegion",
|
|
2155
|
+
value: function loadMediaInRegion(regionId, widgetId) {
|
|
2156
|
+
var _targetRegion, _targetRegion2, _targetRegion3;
|
|
2157
|
+
var self = this;
|
|
2158
|
+
// Find target region
|
|
2159
|
+
var targetRegion;
|
|
2160
|
+
self.parent.regions.forEach(function (regionObj) {
|
|
2161
|
+
if (regionObj.id === regionId) {
|
|
2162
|
+
targetRegion = regionObj;
|
|
2163
|
+
}
|
|
2164
|
+
});
|
|
2165
|
+
// Find media in actions
|
|
2166
|
+
var targetMedia;
|
|
2167
|
+
if (targetRegion) {
|
|
2168
|
+
targetRegion.mediaObjectsActions.forEach(function (media) {
|
|
2169
|
+
if (media.id === widgetId) {
|
|
2170
|
+
targetMedia = media;
|
|
2171
|
+
}
|
|
2172
|
+
});
|
|
2173
|
+
}
|
|
2174
|
+
// Mark media as temporary (removed after region stop playing or loops)
|
|
2175
|
+
if (targetMedia) {
|
|
2176
|
+
targetMedia.singlePlay = true;
|
|
2177
|
+
}
|
|
2178
|
+
// If region is empty, remove the background color and empty message
|
|
2179
|
+
if (((_targetRegion = targetRegion) === null || _targetRegion === void 0 ? void 0 : _targetRegion.mediaObjects.length) === 0) {
|
|
2180
|
+
targetRegion.complete = false;
|
|
2181
|
+
}
|
|
2182
|
+
// Create media in region and play it next
|
|
2183
|
+
(_targetRegion2 = targetRegion) === null || _targetRegion2 === void 0 || _targetRegion2.mediaObjects.splice(targetRegion.currentMediaIndex + 1, 0, targetMedia);
|
|
2184
|
+
(_targetRegion3 = targetRegion) === null || _targetRegion3 === void 0 || _targetRegion3.playNextMedia();
|
|
2185
|
+
}
|
|
2186
|
+
/** Run action based on action data */
|
|
2187
|
+
}, {
|
|
2188
|
+
key: "runAction",
|
|
2189
|
+
value: function runAction(actionData, options) {
|
|
2190
|
+
if (actionData.actiontype == 'navLayout') {
|
|
2191
|
+
// Open layout preview in a new tab
|
|
2192
|
+
this.openLayoutInNewTab(actionData.layoutcode, options);
|
|
2193
|
+
} else if ((actionData.actiontype == 'previous' || actionData.actiontype == 'next') && actionData.target == 'region') {
|
|
2194
|
+
this.nextMediaInRegion(actionData.targetid, actionData.actiontype);
|
|
2195
|
+
} else if (actionData.actiontype == 'navWidget' && actionData.target == 'region') {
|
|
2196
|
+
this.loadMediaInRegion(actionData.targetid, actionData.widgetid);
|
|
2197
|
+
} else {
|
|
2198
|
+
// TODO Handle other action types ( later? )
|
|
2199
|
+
console.log(actionData.actiontype + ' > ' + actionData.target + '[' + actionData.targetid + ']');
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
}, {
|
|
2203
|
+
key: "initTouchActions",
|
|
2204
|
+
value: function initTouchActions() {
|
|
2205
|
+
var self = this;
|
|
2206
|
+
this.$actionController.querySelectorAll('.action[triggerType="touch"]').forEach(function ($el) {
|
|
2207
|
+
var dataset = $el.dataset;
|
|
2208
|
+
// Find source object
|
|
2209
|
+
var $sourceObj;
|
|
2210
|
+
if (dataset.source === 'layout') {
|
|
2211
|
+
$sourceObj = document.getElementById(self.parent.containerName);
|
|
2212
|
+
} else {
|
|
2213
|
+
var regionObjects = Array.from(self.parent.regions);
|
|
2214
|
+
// Loop through layout regions
|
|
2215
|
+
for (var _i = 0, _regionObjects = regionObjects; _i < _regionObjects.length; _i++) {
|
|
2216
|
+
var regionObj = _regionObjects[_i];
|
|
2217
|
+
if (dataset.source === 'region') {
|
|
2218
|
+
// Try to find the region
|
|
2219
|
+
if (regionObj.id === dataset.sourceid) {
|
|
2220
|
+
$sourceObj = document.getElementById(regionObj.containerName);
|
|
2221
|
+
break;
|
|
2222
|
+
}
|
|
2223
|
+
} else if (dataset.source === 'widget') {
|
|
2224
|
+
// Try to find widget/media
|
|
2225
|
+
var mediaObjects = Array.from(regionObj.mediaObjects);
|
|
2226
|
+
for (var _i2 = 0, _mediaObjects = mediaObjects; _i2 < _mediaObjects.length; _i2++) {
|
|
2227
|
+
var mediaObject = _mediaObjects[_i2];
|
|
2228
|
+
if (mediaObject.id === dataset.sourceid) {
|
|
2229
|
+
$sourceObj = document.getElementById(mediaObject.containerName);
|
|
2230
|
+
break;
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
// Break loop if we already have a $sourceObj
|
|
2235
|
+
if ($sourceObj != undefined) {
|
|
2236
|
+
break;
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
// Handle source click
|
|
2241
|
+
// FIXME: We need to handle the case where a drawer widget has an action and it has been loaded to the preview
|
|
2242
|
+
if ($sourceObj != undefined) {
|
|
2243
|
+
$sourceObj.onclick = function (ev) {
|
|
2244
|
+
ev.stopPropagation();
|
|
2245
|
+
self.runAction(dataset, self.options);
|
|
2246
|
+
};
|
|
2247
|
+
$sourceObj.classList.add('clickable');
|
|
2248
|
+
}
|
|
2249
|
+
});
|
|
2250
|
+
}
|
|
2251
|
+
}]);
|
|
2252
|
+
}();
|
|
2253
|
+
|
|
1854
2254
|
var playAgainClickHandle = function playAgainClickHandle(ev) {
|
|
1855
2255
|
ev.preventDefault();
|
|
1856
2256
|
history.go(0);
|
|
@@ -2062,7 +2462,7 @@ function Layout(data, options, xlr, layout) {
|
|
|
2062
2462
|
layoutObject.parseXlf();
|
|
2063
2463
|
};
|
|
2064
2464
|
layoutObject.parseXlf = function () {
|
|
2065
|
-
var _layout$layoutNode, _layout$layoutNode2, _layout$layoutNode3, _layout$layoutNode4, _layout$layoutNode5, _layout$layoutNode6;
|
|
2465
|
+
var _layout$layoutNode, _layout$layoutNode2, _layout$layoutNode3, _layout$layoutNode4, _layout$layoutNode5, _layout$layoutNode6, _layout$layoutNode7, _layout$layoutNode8;
|
|
2066
2466
|
var layout = this;
|
|
2067
2467
|
var options = layout.options;
|
|
2068
2468
|
layout.done = false;
|
|
@@ -2132,13 +2532,26 @@ function Layout(data, options, xlr, layout) {
|
|
|
2132
2532
|
if ($layout && xlr.currentLayoutId !== undefined && xlr.currentLayoutId !== layout.id) {
|
|
2133
2533
|
$layout.style.display = 'none';
|
|
2134
2534
|
}
|
|
2535
|
+
// Create actions
|
|
2536
|
+
var layoutActions = Array.from((layout === null || layout === void 0 || (_layout$layoutNode6 = layout.layoutNode) === null || _layout$layoutNode6 === void 0 ? void 0 : _layout$layoutNode6.getElementsByTagName('action')) || []);
|
|
2537
|
+
Array.from(layoutActions).forEach(function (actionXml, indx) {
|
|
2538
|
+
layout.actions.push(new Action((actionXml === null || actionXml === void 0 ? void 0 : actionXml.getAttribute('id')) || '', actionXml));
|
|
2539
|
+
});
|
|
2540
|
+
// Create interactive actions
|
|
2541
|
+
layout.actionController = new ActionController(layout, layout.actions, options);
|
|
2542
|
+
// Create drawer
|
|
2543
|
+
var layoutDrawers = Array.from((layout === null || layout === void 0 || (_layout$layoutNode7 = layout.layoutNode) === null || _layout$layoutNode7 === void 0 ? void 0 : _layout$layoutNode7.getElementsByTagName('drawer')) || []);
|
|
2544
|
+
Array.from(layoutDrawers).forEach(function (layoutDrawerXml) {
|
|
2545
|
+
layout.drawer = layoutDrawerXml;
|
|
2546
|
+
});
|
|
2135
2547
|
// Create regions
|
|
2136
|
-
var layoutRegions = Array.from((layout === null || layout === void 0 || (_layout$
|
|
2548
|
+
var layoutRegions = Array.from((layout === null || layout === void 0 || (_layout$layoutNode8 = layout.layoutNode) === null || _layout$layoutNode8 === void 0 ? void 0 : _layout$layoutNode8.getElementsByTagName('region')) || []);
|
|
2137
2549
|
Array.from(layoutRegions).forEach(function (regionXml, indx) {
|
|
2138
2550
|
var regionObj = Region(layout, regionXml, (regionXml === null || regionXml === void 0 ? void 0 : regionXml.getAttribute('id')) || '', options, xlr);
|
|
2139
2551
|
regionObj.index = indx;
|
|
2140
2552
|
layout.regions.push(regionObj);
|
|
2141
2553
|
});
|
|
2554
|
+
layout.actionController.initTouchActions();
|
|
2142
2555
|
};
|
|
2143
2556
|
layoutObject.regionExpired = function () {
|
|
2144
2557
|
var self = layoutObject;
|