Source: components/uibuilder.js

  1. define('application/components/uibuilder', [
  2. 'rofl/widgets/component',
  3. 'rofl/lib/utils',
  4. 'rofl/lib/l10n',
  5. 'application/widgets/uibuilder/hero',
  6. 'application/widgets/uibuilder/carousel',
  7. 'application/widgets/uibuilder/filter',
  8. 'application/widgets/uibuilder/herocarousel',
  9. 'application/widgets/uibuilder/heroslider',
  10. 'application/widgets/clock',
  11. 'rofl/widgets/verticallist',
  12. 'antie/widgets/horizontallist',
  13. 'rofl/events/keyevent',
  14. 'antie/runtimecontext',
  15. 'rofl/widgets/label',
  16. 'rofl/widgets/container',
  17. 'application/formatters/vodasset',
  18. 'application/formatters/homeepgasset',
  19. 'application/formatters/heroslider',
  20. 'application/formatters/sports',
  21. 'application/formatters/editorials',
  22. 'application/formatters/bookmarkasset',
  23. 'rofl/analytics/web/google',
  24. 'application/managers/halo'
  25. ], function (
  26. Component,
  27. Utils,
  28. L10N,
  29. Hero,
  30. Carousel,
  31. Filter,
  32. HeroCarousel,
  33. HeroSlider,
  34. Clock,
  35. VerticalList,
  36. HorizontalList,
  37. KeyEvent,
  38. RuntimeContext,
  39. Label,
  40. Container,
  41. VodFormatter,
  42. EpgFormatter,
  43. HeroSliderFormatter,
  44. SportsFormatter,
  45. EditorialFormatter,
  46. BookmarkFormatter,
  47. GoogleAnalytics,
  48. HaloManager
  49. ) {
  50. 'use strict';
  51. var application = RuntimeContext.getCurrentApplication(),
  52. l10n = L10N.getInstance(),
  53. GA = GoogleAnalytics.getInstance(),
  54. UPDATE_CAROUSEL_INTERVAL_TIME = 120000, // 2 minutes.
  55. PROGRESS_INTERVAL_TIME = 5000,
  56. UIBuilderComponent,
  57. WIDGET_TYPES = {
  58. EDITORIAL_BLOCK: 'editorial',
  59. HERO: 'hero',
  60. HERO_SLIDER: 'heroSlider',
  61. CAROUSEL: 'carousel',
  62. FILTERED_RESULT: 'filteredResult'
  63. },
  64. layout = application.getLayout(),
  65. VOD_CAROUSEL_PARAMS = {
  66. formatter: VodFormatter,
  67. layout: layout.asset.vod,
  68. numberOfVisibleItemsOnScreen: 8,
  69. watchAll: {
  70. classNames: []
  71. }
  72. },
  73. EPG_CAROUSEL_PARAMS = {
  74. formatter: EpgFormatter,
  75. layout: layout.asset.epg,
  76. numberOfVisibleItemsOnScreen: 4,
  77. watchAll: {
  78. classNames: ['landscape-watchall']
  79. }
  80. },
  81. BOOKMARK_CAROUSEL_PARAMS = {
  82. formatter: BookmarkFormatter,
  83. layout: layout.asset.epg,
  84. numberOfVisibleItemsOnScreen: 4,
  85. watchAll: {
  86. classNames: ['landscape-watchall']
  87. }
  88. },
  89. VOD_GRID = {
  90. grid: {
  91. columns: 8,
  92. width: layout.requiredScreenSize.width,
  93. height: layout.watchall.gridHeight,
  94. alignPoint: 0,
  95. culling: true,
  96. continuousListener: true,
  97. navigateNext: true,
  98. animOptions: {
  99. easing: 'easeInOut',
  100. fps: 60,
  101. duration: 200,
  102. skipAnim: false
  103. }
  104. },
  105. asset: {
  106. width: layout.asset.vod.width,
  107. height: layout.asset.vod.height,
  108. formatter: VodFormatter
  109. }
  110. },
  111. EPG_GRID = {
  112. grid: {
  113. columns: 4,
  114. width: layout.requiredScreenSize.width,
  115. height: layout.watchall.gridHeight,
  116. alignPoint: 0,
  117. culling: true,
  118. continuousListener: true,
  119. navigateNext: true,
  120. animOptions: {
  121. easing: 'easeInOut',
  122. fps: 60,
  123. duration: 200,
  124. skipAnim: false
  125. }
  126. },
  127. asset: {
  128. width: layout.asset.epg.width,
  129. height: layout.asset.epg.height,
  130. formatter: EpgFormatter
  131. }
  132. },
  133. BOOKMARK_GRID = {
  134. grid: {
  135. columns: 4,
  136. width: layout.requiredScreenSize.width,
  137. height: layout.watchall.gridHeight,
  138. alignPoint: 0,
  139. culling: true,
  140. continuousListener: true,
  141. navigateNext: true,
  142. animOptions: {
  143. easing: 'easeInOut',
  144. fps: 60,
  145. duration: 200,
  146. skipAnim: false
  147. }
  148. },
  149. asset: {
  150. width: layout.asset.epg.width,
  151. height: layout.asset.epg.height,
  152. formatter: BookmarkFormatter
  153. }
  154. },
  155. WIDGETS_PARAMS = {
  156. home: {
  157. hero: {
  158. id: 'hero',
  159. formatter: HeroSliderFormatter,
  160. numberOfVisibleItemsOnScreen: 4,
  161. layout: layout.home.slider
  162. },
  163. carousels: {
  164. vod: VOD_CAROUSEL_PARAMS,
  165. epg: EPG_CAROUSEL_PARAMS,
  166. bookmark: BOOKMARK_CAROUSEL_PARAMS
  167. },
  168. grid: {
  169. vod: VOD_GRID,
  170. epg: EPG_GRID,
  171. bookmark: BOOKMARK_GRID
  172. }
  173. },
  174. movies: {
  175. hero: {
  176. id: 'hero',
  177. formatter: HeroSliderFormatter,
  178. numberOfVisibleItemsOnScreen: 4,
  179. layout: layout.home.slider
  180. },
  181. carousels: {
  182. vod: VOD_CAROUSEL_PARAMS
  183. },
  184. grid: {
  185. vod: VOD_GRID
  186. }
  187. },
  188. series: {
  189. hero: {
  190. id: 'hero',
  191. formatter: HeroSliderFormatter,
  192. numberOfVisibleItemsOnScreen: 4,
  193. layout: layout.home.slider
  194. },
  195. carousels: {
  196. vod: VOD_CAROUSEL_PARAMS
  197. },
  198. grid: {
  199. vod: VOD_GRID
  200. }
  201. },
  202. sports: {
  203. editorialBlocks: {
  204. id: 'hero',
  205. formatter: EditorialFormatter,
  206. numberOfVisibleItemsOnScreen: 4,
  207. layout: layout.home.slider
  208. },
  209. carousels: {
  210. epg: EPG_CAROUSEL_PARAMS
  211. },
  212. grid: {
  213. epg: EPG_GRID
  214. }
  215. }
  216. };
  217. UIBuilderComponent = Component.extend({
  218. /**
  219. * Initialises the component.
  220. */
  221. init: function init () {
  222. init.base.call(this, this.pageId);
  223. this.addClass('page');
  224. this._buildFiltersContainer();
  225. this._buildGenreFilters();
  226. this._build();
  227. this._onKeyDownBound = Utils.bind(this._onKeyDown, this);
  228. this._onToplistFocusBound = Utils.bind(this._onToplistFocus, this);
  229. this._activeFilters = {};
  230. this._onSelectedItemChangeBound = Utils.bind(this._onSelectedItemChange, this);
  231. this._onSelectBound = Utils.bind(this._onSelect, this);
  232. this._unlockAssetsBound = Utils.bind(this._unlockAssets, this);
  233. this._lockAssetsBound = Utils.bind(this._lockAssets, this);
  234. },
  235. /**
  236. * Builds the page layout.
  237. *
  238. * @private
  239. */
  240. _build: function () {
  241. this._list = this.appendChildWidget(new VerticalList());
  242. this._topList = this._list.appendChildWidget(new HorizontalList());
  243. this._widgetList = this._list.appendChildWidget(new VerticalList());
  244. this._widgetList.addClass('widget-list');
  245. },
  246. /**
  247. * Builds the filters container.
  248. *
  249. * @private
  250. */
  251. _buildFiltersContainer: function () {
  252. var filtersContainer = this._filterscontainer = new HorizontalList();
  253. filtersContainer.addClass('filters-container');
  254. filtersContainer.addClass('filters');
  255. },
  256. /**
  257. * Builds genre filters.
  258. *
  259. * @private
  260. */
  261. _buildGenreFilters: function () {
  262. var genreFiltersButton = this._genrefilter = new Filter({
  263. text: l10n.get('genre.all'),
  264. id: 'filter-genre-btn',
  265. isDropDown: true,
  266. classList: 'icon-button',
  267. type: 'genre'
  268. }),
  269. commonFiltersButton = this._commonfilter = new Filter({
  270. text: l10n.get('filter.filter'),
  271. id: 'filter-filter-btn',
  272. isDropDown: true,
  273. classList: 'icon-button',
  274. type: 'filter'
  275. }),
  276. sortingFiltersButton = this._sortfilter = new Filter({
  277. text: l10n.get('sort.all'),
  278. id: 'filter-sort-btn',
  279. isDropDown: true,
  280. classList: 'icon-button',
  281. type: 'sort'
  282. });
  283. this._filterscontainer.appendChildWidget(genreFiltersButton);
  284. this._filterscontainer.appendChildWidget(commonFiltersButton);
  285. this._filterscontainer.appendChildWidget(sortingFiltersButton);
  286. },
  287. /**
  288. * Builds the title.
  289. *
  290. * @param {Object} params - Title params.
  291. * @param {Object} params.label.text - Label text.
  292. * @param {Array} params.label.classNames - Label class names..
  293. * @private
  294. */
  295. _buildTitle: function (params) {
  296. var titleParams = params || {},
  297. title = this._title = new Label(titleParams.label),
  298. branding = this._branding = new Container();
  299. branding.addClass('page-branding');
  300. branding.addClass('page-title');
  301. branding.appendChildWidget(title);
  302. this._header.appendChildWidget(branding);
  303. },
  304. /**
  305. * BeforeRender event.
  306. */
  307. onBeforeRender: function () {
  308. this.addEventListener('keydown', this._onKeyDownBound);
  309. this._topList.addEventListener('keydown', this._onKeyDownBound);
  310. this._topList.addEventListener('focus', this._onToplistFocusBound);
  311. this.addEventListener('selecteditemchange', this._onSelectedItemChangeBound);
  312. this.addEventListener('select', this._onSelectBound);
  313. application.addEventListener('$unlocked', this._unlockAssetsBound);
  314. application.addEventListener('$locked', this._lockAssetsBound);
  315. HaloManager.getInstance()
  316. .getServiceMessage()
  317. .then(function (r) {
  318. if (r) {
  319. application.route('service');
  320. }
  321. });
  322. },
  323. /**
  324. * BeforeHide event.
  325. */
  326. onBeforeHide: function () {
  327. this.removeEventListener('keydown', this._onKeyDownBound);
  328. this._topList.removeEventListener('keydown', this._onKeyDownBound);
  329. this._topList.removeEventListener('focus', this._onToplistFocusBound);
  330. this.removeEventListener('selecteditemchange', this._onSelectedItemChangeBound);
  331. this.removeEventListener('select', this._onSelectBound);
  332. application.removeEventListener('$unlocked', this._unlockAssetsBound);
  333. application.removeEventListener('$locked', this._lockAssetsBound);
  334. this._clearProgressInterval();
  335. this._clearUpdateCarouselsInterval();
  336. this._grid = null;
  337. },
  338. /**
  339. * AddFilterWidget to the page layout event.
  340. */
  341. _addFilterWidget: function () {
  342. this._topList.appendChildWidget(this._filterscontainer);
  343. },
  344. /**
  345. * Builds the clock.
  346. *
  347. * @private
  348. */
  349. _buildClock: function () {
  350. var clock = this._clock = new Clock();
  351. clock.addClass('header-clock');
  352. this._topList.appendChildWidget(clock);
  353. },
  354. /**
  355. * Toplist focus event.
  356. *
  357. * @param {Object} e - The event data.
  358. * @private
  359. */
  360. _onToplistFocus: function (e) {
  361. if (e.target === this._hero) {
  362. if (!this._hero.isVisible()) {
  363. this._hero.show();
  364. e.index = 0;
  365. e.item = e.target;
  366. this._scroll(e, true, true);
  367. this._widgetList.setActiveChildIndex(0);
  368. if (this._grid) {
  369. this._grid.alignToFirstItem();
  370. }
  371. }
  372. if (this._grid && this._grid.getActiveChildIndex() > 0) {
  373. this._grid.alignToFirstItem();
  374. }
  375. }
  376. },
  377. /**
  378. * KeyDown event.
  379. *
  380. * @param {Object} e - The event data.
  381. * @private
  382. */
  383. _onKeyDown: function (e) {
  384. var filtersContainerItem;
  385. switch (e.keyCode) {
  386. case KeyEvent.VK_BACK:
  387. this._onBack();
  388. break;
  389. case KeyEvent.VK_LEFT:
  390. e.preventDefault();
  391. e.stopPropagation();
  392. application.focusMenu('main');
  393. break;
  394. case KeyEvent.VK_RIGHT:
  395. e.preventDefault();
  396. e.stopPropagation();
  397. break;
  398. case KeyEvent.VK_DOWN:
  399. if (this._filterscontainer && this._filterscontainer.isFocussed()) {
  400. if (this.heroFound) {
  401. this._hero.focusAction(this._hero.getButtonCount() - 1);
  402. if (!this._hero.isVisible()) {
  403. this._widgetList.focus();
  404. if (this._grid) {
  405. this._grid.alignToActiveIndex();
  406. }
  407. }
  408. e.preventDefault();
  409. e.stopPropagation();
  410. } else if (this._grid) {
  411. this._widgetList.focus();
  412. this._grid.alignToActiveIndex();
  413. }
  414. }
  415. break;
  416. case KeyEvent.VK_UP:
  417. if (this.heroFound && this._hero.isFocussed()) {
  418. this._hero.setButtonActiveChildIndex(this._hero.getButtonCount() - 1);
  419. filtersContainerItem = this._filterscontainer && this._filterscontainer.getChildWidgetByIndex(0);
  420. if (filtersContainerItem) {
  421. filtersContainerItem.focus();
  422. }
  423. e.preventDefault();
  424. e.stopPropagation();
  425. }
  426. break;
  427. }
  428. },
  429. /**
  430. * Builds the widgets and appends them to the component.
  431. *
  432. * @param {Array} widgets - The widgets.
  433. */
  434. buildWidgets: function (widgets) {
  435. this.heroFound = false;
  436. Utils.each(widgets, function (widget) {
  437. this.buildWidget(widget);
  438. }, this);
  439. if (!this.heroFound) {
  440. this.addClass('no-hero-item');
  441. this._list.getChildWidgetByIndex(0).focus();
  442. } else {
  443. if (this.hasClass('no-hero-item')) {
  444. this.removeClass('no-hero-item');
  445. }
  446. }
  447. },
  448. /**
  449. * Builds the individual widget.
  450. *
  451. * @param {Object} widget - The widget. See WIDGET_TYPES for available widgets.
  452. */
  453. buildWidget: function (widget) {
  454. var list = this._widgetList,
  455. widgetsParams = WIDGETS_PARAMS[this.pageId],
  456. editorialBlocks,
  457. sliderItems,
  458. carouselsWidgetParams,
  459. widgetLayout;
  460. switch (widget.getWidgetType()) {
  461. case WIDGET_TYPES.HERO:
  462. if (widget._item && widget.hasRights() && !this.heroFound) {
  463. if (!widget._item.isLocked()) {
  464. this._hero = new Hero(widget, widgetsParams.hero);
  465. this._topList.insertChildWidget(0, this._hero);
  466. this.heroFound = true;
  467. }
  468. }
  469. break;
  470. case WIDGET_TYPES.CAROUSEL:
  471. if (widget.getItems().length) {
  472. widgetLayout = widget.getLayout();
  473. carouselsWidgetParams = this._getWidgetParams(widgetLayout);
  474. list.appendChildWidget(new Carousel(widget, carouselsWidgetParams));
  475. }
  476. break;
  477. case WIDGET_TYPES.EDITORIAL_BLOCK:
  478. editorialBlocks = widget.getEditorialBlocks({hasContent: true});
  479. if (editorialBlocks.length) {
  480. this._hero = list
  481. .appendChildWidget(new HeroSlider(editorialBlocks, widgetsParams.editorialBlocks));
  482. this.heroFound = true;
  483. }
  484. break;
  485. case WIDGET_TYPES.HERO_SLIDER:
  486. sliderItems = widget.getItems();
  487. this._hero = list.appendChildWidget(new HeroSlider(sliderItems, widgetsParams.hero));
  488. this.heroFound = true;
  489. break;
  490. // No default.
  491. }
  492. },
  493. /**
  494. * Returns the widgets params for the type of layout.
  495. *
  496. * @param {string} widgetLayout - The type of layout of the widget.
  497. * @returns {Object} - The widget's params.
  498. */
  499. _getWidgetParams: function (widgetLayout) {
  500. var widgetsParams = WIDGETS_PARAMS[this.pageId];
  501. switch (widgetLayout) {
  502. case 'EPG_LARGE':
  503. return widgetsParams.carousels.epg;
  504. case 'VOD_SMALL':
  505. return widgetsParams.carousels.vod;
  506. case 'BOOKMARK_LARGE_HORIZONTAL':
  507. return widgetsParams.carousels.bookmark;
  508. default:
  509. return widgetsParams.carousels.vod || widgetsParams.carousels.epg;
  510. }
  511. },
  512. /**
  513. * Aligns the carousels to force them to render items.
  514. */
  515. alignCarousels: function () {
  516. Utils.each(this._widgetList.getChildWidgets(), function (widget) {
  517. if (widget && widget instanceof Carousel) {
  518. widget.alignToIndex(0);
  519. }
  520. });
  521. },
  522. alignCarouselsToLastIndex: function () {
  523. Utils.each(this._widgetList.getChildWidgets(), function (widget) {
  524. if (widget && widget instanceof Carousel) {
  525. widget.alignToLastIndex();
  526. }
  527. });
  528. },
  529. /**
  530. * Removes all the widgets.
  531. */
  532. removeAll: function () {
  533. this._hero = null;
  534. this._list.removeChildWidgets();
  535. this._widgetList.removeChildWidgets();
  536. this._topList.removeChildWidgets();
  537. this._list.appendChildWidget(this._topList);
  538. this._list.appendChildWidget(this._widgetList);
  539. },
  540. /**
  541. * Returns true if the component has a hero element attached.
  542. *
  543. * @returns {boolean} - True if the component has a hero element attached.
  544. */
  545. hasHeroElement: function () {
  546. return this._hero !== null;
  547. },
  548. /**
  549. * Shows the Hero widget.
  550. */
  551. showHero: function () {
  552. var self = this;
  553. if (this.hasHeroElement()) {
  554. if (!this._hero.isVisible() || this._isHidingHero) {
  555. this._isShowingHero = true;
  556. this._hero.show({
  557. duration: 500,
  558. onComplete: function () {
  559. self._isShowingHero = false;
  560. }
  561. });
  562. }
  563. }
  564. },
  565. /**
  566. * Hides the Hero widget.
  567. *
  568. * @param {boolean} skipAnimation - Whether to skip animation.
  569. */
  570. hideHero: function (skipAnimation) {
  571. var self = this;
  572. if (this.hasHeroElement()) {
  573. if (this._hero.isVisible() || this._isShowingHero) {
  574. if (skipAnimation) {
  575. this._hero.hide({skipAnim: true});
  576. } else {
  577. this._isHidingHero = true;
  578. this._hero.hide({
  579. duration: 300,
  580. onComplete: function () {
  581. self._isHidingHero = false;
  582. }
  583. });
  584. }
  585. }
  586. }
  587. },
  588. /**
  589. * Routes to watch all module.
  590. *
  591. * @param {Promise} watchAllItem - The watchall item.
  592. */
  593. goToWatchAll: function (watchAllItem) {
  594. var widgetsParams = WIDGETS_PARAMS[this.pageId],
  595. watchAllEndpoint = watchAllItem.getWatchAll(),
  596. gridParams;
  597. if (watchAllItem.isEpgLayout()) {
  598. gridParams = widgetsParams.grid.epg;
  599. } else if (watchAllItem.isBookmarkLayout()) {
  600. gridParams = widgetsParams.grid.bookmark;
  601. } else {
  602. gridParams = widgetsParams.grid.vod;
  603. }
  604. application.route('watchall', {
  605. watchAll: watchAllEndpoint,
  606. gridParams: gridParams
  607. });
  608. },
  609. /**
  610. * Unlock the assets.
  611. *
  612. * @private
  613. */
  614. _unlockAssets: function () {
  615. var rows = this._widgetList.getChildWidgets(),
  616. assets;
  617. this._assetsUnlocked = true;
  618. Utils.each(rows, function (row) {
  619. if (row.getCarousel) {
  620. assets = row.getCarousel().getChildWidgets();
  621. Utils.each(assets, function (asset) {
  622. if (asset.hasClass('asset')) {
  623. asset.unlock();
  624. }
  625. });
  626. }
  627. });
  628. if (this._grid) {
  629. Utils.each(this._grid.getList().getChildWidgets(), function (row) {
  630. Utils.each(row.getChildWidgets(), function (asset) {
  631. if (asset.hasClass('asset')) {
  632. asset.unlock();
  633. }
  634. });
  635. });
  636. }
  637. },
  638. /**
  639. * Lock the assets.
  640. *
  641. * @private
  642. */
  643. _lockAssets: function () {
  644. var rows = this._widgetList.getChildWidgets(),
  645. assets;
  646. this._assetsUnlocked = false;
  647. Utils.each(rows, function (row) {
  648. if (row.getCarousel) {
  649. assets = row.getCarousel().getChildWidgets();
  650. Utils.each(assets, function (asset) {
  651. if (asset.hasClass('asset')) {
  652. asset.lock();
  653. }
  654. });
  655. }
  656. });
  657. if (this._grid) {
  658. Utils.each(this._grid.getList().getChildWidgets(), function (row) {
  659. Utils.each(row.getChildWidgets(), function (asset) {
  660. if (asset.hasClass('asset')) {
  661. asset.lock();
  662. }
  663. });
  664. });
  665. }
  666. },
  667. /**
  668. * Routes to the details page of the content.
  669. *
  670. * @param {Object} routeParams - The route params.
  671. */
  672. _routeToDetails: function (routeParams) {
  673. application.route('details', {
  674. data: routeParams.data,
  675. callback: Utils.bind(this.focus, this)
  676. });
  677. },
  678. /**
  679. *
  680. * @param {Object} routeParams - The player's route params.
  681. * @param {string} playerRoute - The player to be used (liveplayer, vodplayer, catchupplayer...).
  682. * @private
  683. */
  684. _routeToPlayer: function (routeParams, playerRoute) {
  685. application.route(playerRoute || 'player', routeParams);
  686. GA.onEvent('player', 'started', {eventLabel: this.pageId});
  687. },
  688. /**
  689. * Back event.
  690. *
  691. * @private
  692. */
  693. _onBack: function () {
  694. this.parentWidget.back();
  695. application.focusMenu('main');
  696. },
  697. /**
  698. * Starts the progressbars update interval.
  699. */
  700. _updateProgressbars: function () {
  701. var now = application.getDate(),
  702. rows = this._widgetList.getChildWidgets(),
  703. rowItems,
  704. currentProgramFinished,
  705. dataItem,
  706. hasProgressbar,
  707. updateableCarousel;
  708. if (this._progressInterval) {
  709. this._clearProgressInterval();
  710. Utils.each(rows, Utils.bind(function (row) {
  711. updateableCarousel = row.getCarousel && !row.hasClass('hero') &&
  712. this._isUpdateableCarousel(row.getCarouselLayout());
  713. if (updateableCarousel) {
  714. rowItems = row.getCarousel().getChildWidgets();
  715. Utils.each(rowItems, Utils.bind(function (rowItem) {
  716. if (rowItem.hasClass('asset')) {
  717. hasProgressbar = rowItem.updateProgressBar();
  718. dataItem = rowItem.getDataItem();
  719. currentProgramFinished = now >= dataItem.endTime;
  720. // A program has finished in the row, add it to the update list.
  721. if (currentProgramFinished && hasProgressbar) {
  722. if (!this._updateRowsList) {
  723. this._updateRowsList = [];
  724. }
  725. if (!Utils.contains(this._updateRowsList, row)) {
  726. this._updateRowsList.push(row);
  727. }
  728. }
  729. }
  730. }, this));
  731. }
  732. }, this));
  733. }
  734. if (!this._updateCarouselsInterval) {
  735. this._updateCarouselsInterval = setInterval(Utils.bind(this._updateCarousels, this), UPDATE_CAROUSEL_INTERVAL_TIME);
  736. }
  737. this._progressInterval = setInterval(Utils.bind(this._updateProgressbars, this), PROGRESS_INTERVAL_TIME);
  738. },
  739. /**
  740. * Clears any progress interval update.
  741. *
  742. * @private
  743. */
  744. _clearProgressInterval: function () {
  745. clearInterval(this._progressInterval);
  746. this._progressInterval = null;
  747. },
  748. /**
  749. * Clears any progress interval update.
  750. *
  751. * @private
  752. */
  753. _clearUpdateCarouselsInterval: function () {
  754. clearInterval(this._updateCarouselsInterval);
  755. this._updateCarouselsInterval = null;
  756. },
  757. /**
  758. * Checks carousels with EPG layout that can be updated with new data.
  759. * i.e. live carousels in home or sports page.
  760. *
  761. * @param {string} carouselLayout - The carousel layout.
  762. * @returns {boolean} - True if the carousel can be updated.
  763. **/
  764. _isUpdateableCarousel: function (carouselLayout) {
  765. switch (carouselLayout) {
  766. case 'EPG_SPORT':
  767. // Falls through.
  768. case 'EPG_LARGE':
  769. return true;
  770. default:
  771. return false;
  772. }
  773. },
  774. /**
  775. * Updates the carousels found on the update list.
  776. *
  777. * @private
  778. */
  779. _updateCarousels: function () {
  780. if (this._updateRowsList && this._updateRowsList.length) {
  781. this._clearProgressInterval();
  782. Utils.each(this._updateRowsList, Utils.bind(function (row) {
  783. row.updateCarousel();
  784. this._updateProgressbars();
  785. }, this));
  786. this._updateRowsList.length = 0;
  787. }
  788. }
  789. });
  790. UIBuilderComponent.WIDGET_TYPES = WIDGET_TYPES;
  791. return UIBuilderComponent;
  792. });