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