.pubsub.subscribe({ topic : 'tmg.cmp.onConsentReady', func : function(){ function truncate(string, maxLength) { if (string.length <= maxLength) return string; return string.slice(0, maxLength - 2).replace(/[^\w\s]?\s[^\s]*$/, '') + '...'; } // ------------------------------------------------------------------------ // // RecommendedList widget function RecommendedList(element) { this.element = element; } RecommendedList.selector = { ROOT: '#li-recommendation-widget', WIDGETNAME: 'li-recommendation-widget' }; RecommendedList.prototype.init = function () { if (this.element) { liftigniter('register', { max: 5, widget: RecommendedList.selector.WIDGETNAME, callback: this.onRequestSuccess.bind(this) }); } }; RecommendedList.prototype.onRequestSuccess = function (response) { var data = response; data.widgetTitle = this.element.dataset.title || ''; data.items.forEach(function (item) { item.truncatedTitle = truncate(item.title, 100); }); this.render(data); liftigniter('track', { elements: this.element.querySelectorAll('.recommended-articles__item'), name: RecommendedList.selector.WIDGETNAME, source: 'LI', opts: {}, _debug : false }); }; RecommendedList.prototype.render = function (data) { var template = '