@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.
@@ -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) {
@@ -716,6 +832,9 @@ function composeResourceUrl(options, params) {
716
832
  var serverKey = options && ((_options$config3 = options.config) === null || _options$config3 === void 0 ? void 0 : _options$config3.cmsKey);
717
833
  return '/pwa/getResource' + '?v=' + schemaVersion + '&serverKey=' + serverKey + '&hardwareKey=' + hardwareKey + '&layoutId=' + params.layoutId + '&regionId=' + params.regionId + '&mediaId=' + params.mediaId;
718
834
  }
835
+ function composeVideoUrl(params) {
836
+ return '/xmds.php?file=' + params.uri;
837
+ }
719
838
  function composeBgUrlByPlatform(platform, params) {
720
839
  var bgImageUrl = params.layoutBackgroundDownloadUrl.replace(":id", params.layout.id) + '?preview=1&width=' + params.layout.sWidth + '&height=' + params.layout.sHeight + '&dynamic&proportional=0';
721
840
  if (platform === 'chromeOS') {
@@ -741,11 +860,22 @@ function getIndexByLayoutId(layoutsInput, layoutId) {
741
860
  index: 0
742
861
  };
743
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
+ }
744
873
 
745
874
  var initialRegion = {
746
875
  layout: initialLayout,
747
876
  id: '',
748
877
  regionId: '',
878
+ uniqueId: '',
749
879
  xml: null,
750
880
  mediaObjects: [],
751
881
  mediaObjectsActions: [],
@@ -770,6 +900,7 @@ var initialRegion = {
770
900
  index: -1,
771
901
  prepareRegion: function prepareRegion() {},
772
902
  playNextMedia: function playNextMedia() {},
903
+ playPreviousMedia: function playPreviousMedia() {},
773
904
  transitionNodes: function transitionNodes() {},
774
905
  finished: function finished() {},
775
906
  run: function run() {},
@@ -1289,6 +1420,9 @@ function Media(region, mediaId, xml, options, xlr) {
1289
1420
  tmpUrl = composeResourceUrlByPlatform(xlr.config, resourceUrlParams);
1290
1421
  } else if (xlr.config.platform === 'chromeOS') {
1291
1422
  tmpUrl = composeResourceUrl(xlr.config, resourceUrlParams);
1423
+ if (self.mediaType === 'video') {
1424
+ tmpUrl = composeVideoUrl(resourceUrlParams);
1425
+ }
1292
1426
  }
1293
1427
  self.url = tmpUrl;
1294
1428
  // Loop if media has loop, or if region has loop and a single media
@@ -1600,7 +1734,7 @@ function Region(layout, xml, regionId, options, xlr) {
1600
1734
  var emitter = createNanoEvents();
1601
1735
  var regionObject = _objectSpread2(_objectSpread2({}, initialRegion), props);
1602
1736
  regionObject.prepareRegion = function () {
1603
- 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;
1604
1738
  var self = regionObject;
1605
1739
  var layout = self.layout,
1606
1740
  options = self.options;
@@ -1608,8 +1742,9 @@ function Region(layout, xml, regionId, options, xlr) {
1608
1742
  self.ending = false;
1609
1743
  self.ended = false;
1610
1744
  self.id = props.regionId;
1745
+ self.uniqueId = "".concat(nextId(self.options));
1611
1746
  self.options = _objectSpread2(_objectSpread2({}, platform), props.options);
1612
- self.containerName = "R-".concat(self.id, "-").concat(nextId(self.options));
1747
+ self.containerName = "R-".concat(self.id, "-").concat(self.uniqueId);
1613
1748
  self.xml = props.xml;
1614
1749
  self.mediaObjects = [];
1615
1750
  self.sWidth = self.xml && Number((_self$xml = self.xml) === null || _self$xml === void 0 ? void 0 : _self$xml.getAttribute('width')) * layout.scaleFactor;
@@ -1648,6 +1783,20 @@ function Region(layout, xml, regionId, options, xlr) {
1648
1783
  mediaObj.index = indx;
1649
1784
  self.mediaObjects.push(mediaObj);
1650
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
+ });
1651
1800
  self.prepareMediaObjects();
1652
1801
  };
1653
1802
  regionObject.finished = function () {
@@ -1805,6 +1954,18 @@ function Region(layout, xml, regionId, options, xlr) {
1805
1954
  console.debug('region::playNextMedia', self);
1806
1955
  self.transitionNodes(self.oldMedia, self.curMedia);
1807
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
+ };
1808
1969
  regionObject.end = function () {
1809
1970
  var self = regionObject;
1810
1971
  self.ending = true;
@@ -1845,6 +2006,251 @@ function Region(layout, xml, regionId, options, xlr) {
1845
2006
  return regionObject;
1846
2007
  }
1847
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
+
1848
2254
  var playAgainClickHandle = function playAgainClickHandle(ev) {
1849
2255
  ev.preventDefault();
1850
2256
  history.go(0);
@@ -2056,7 +2462,7 @@ function Layout(data, options, xlr, layout) {
2056
2462
  layoutObject.parseXlf();
2057
2463
  };
2058
2464
  layoutObject.parseXlf = function () {
2059
- 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;
2060
2466
  var layout = this;
2061
2467
  var options = layout.options;
2062
2468
  layout.done = false;
@@ -2074,7 +2480,9 @@ function Layout(data, options, xlr, layout) {
2074
2480
  $screen && $screen.appendChild($layout);
2075
2481
  if ($layout) {
2076
2482
  $layout.style.display = 'none';
2077
- $layout.style.outline = 'red solid thin';
2483
+ if (xlr.config.platform === 'CMS') {
2484
+ $layout.style.outline = 'red solid thin';
2485
+ }
2078
2486
  }
2079
2487
  layout.layoutNode = props.data;
2080
2488
  /* Calculate the screen size */
@@ -2124,13 +2532,26 @@ function Layout(data, options, xlr, layout) {
2124
2532
  if ($layout && xlr.currentLayoutId !== undefined && xlr.currentLayoutId !== layout.id) {
2125
2533
  $layout.style.display = 'none';
2126
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
+ });
2127
2547
  // Create regions
2128
- var layoutRegions = Array.from((layout === null || layout === void 0 || (_layout$layoutNode6 = layout.layoutNode) === null || _layout$layoutNode6 === void 0 ? void 0 : _layout$layoutNode6.getElementsByTagName('region')) || []);
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')) || []);
2129
2549
  Array.from(layoutRegions).forEach(function (regionXml, indx) {
2130
2550
  var regionObj = Region(layout, regionXml, (regionXml === null || regionXml === void 0 ? void 0 : regionXml.getAttribute('id')) || '', options, xlr);
2131
2551
  regionObj.index = indx;
2132
2552
  layout.regions.push(regionObj);
2133
2553
  });
2554
+ layout.actionController.initTouchActions();
2134
2555
  };
2135
2556
  layoutObject.regionExpired = function () {
2136
2557
  var self = layoutObject;