Skip to content

Commit 485181b

Browse files
authored
Merge pull request #1112 from ticketmaster-api-staging/promise-polyfill
empty-month-tab-fix
2 parents a03928a + dfba002 commit 485181b

9 files changed

Lines changed: 95 additions & 83 deletions

File tree

products-and-docs/widgets/calendar/1.0.0/lib/main-widget-config.js

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

products-and-docs/widgets/calendar/1.0.0/lib/main-widget-config.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

products-and-docs/widgets/calendar/1.0.0/lib/main-widget.js

Lines changed: 40 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

products-and-docs/widgets/calendar/1.0.0/lib/main-widget.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

products-and-docs/widgets/calendar/1.0.0/src/main-widget.es6

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
var _Promise = typeof Promise === 'undefined'
2+
? require('es6-promise').Promise
3+
: Promise
4+
15
class TicketmasterCalendarWidget {
26

37
set config(attrs) { this.widgetConfig = this.loadConfig(attrs); }
@@ -173,7 +177,12 @@ class TicketmasterCalendarWidget {
173177
constructor(root) {
174178
if(!root) return;
175179
this.widgetRoot = root;
176-
180+
var scriptPromise = document.createElement("script");
181+
scriptPromise.setAttribute('src', 'https://unpkg.com/es6-promise@3.2.1/dist/es6-promise.min.js');
182+
var scriptFetch = document.createElement("script");
183+
scriptFetch.setAttribute('src', 'https://unpkg.com/whatwg-fetch@1.0.0/fetch.js');
184+
// window.Promise || this.widgetRoot.appendChild(scriptPromise);
185+
// window.fetch || this.widgetRoot.appendChild(scriptFetch);
177186
this.tabsRootContainer = document.createElement("div");
178187
this.tabsRootContainer.classList.add("tabs");
179188
this.tabsRootContainer.innerHTML = '<span class="tb active">Day</span><span class="tb">Week</span><span class="tb">Month</span><span class="tb">Year</span>';
@@ -2318,8 +2327,8 @@ class MonthScheduler {
23182327

23192328
if (calendarWidgetRoot.getAttribute("w-period") != 'week') {
23202329
if (calendarWidgetRoot.getAttribute("w-period").length != 7) {
2321-
firstDay = new Date(date.getFullYear(), date.getMonth() + 1, 1);
2322-
lastDay = new Date(date.getFullYear(), date.getMonth() + 2, 0);
2330+
firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
2331+
lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 1);
23232332
}
23242333
else {
23252334
firstDay = new Date(calendarWidgetRoot.getAttribute("w-period").substr(0, 4), calendarWidgetRoot.getAttribute("w-period").substr(5, 7), 0);
@@ -2536,11 +2545,12 @@ class MonthScheduler {
25362545
if (events.page.totalElements != 0) {
25372546

25382547
let currentMonth = calendarWidgetRoot.getAttribute('w-period').substr(5, 2);
2539-
if (currentMonth == '') {
2540-
currentMonth = new Date().getMonth() + 1;
2541-
if (parseInt(currentMonth) <= 9) currentMonth = '0' + currentMonth;
2542-
}
2543-
2548+
let currentMonthDef = new Date(calendarWidgetRoot.getAttribute('w-period')).getMonth() + 1;
2549+
if (currentMonthDef <= 9) currentMonthDef = '0' + currentMonthDef;
2550+
if (currentMonth == '') {
2551+
currentMonth = new Date().getMonth() + 1;
2552+
if (parseInt(currentMonth) <= 9) currentMonth = '0' + currentMonth;
2553+
}
25442554
events._embedded.events.forEach(function (item) {
25452555
if (item.hasOwnProperty('_embedded') && item._embedded.hasOwnProperty('venues')) {
25462556
if (item._embedded.venues[0].hasOwnProperty('name')) {
@@ -2570,7 +2580,7 @@ class MonthScheduler {
25702580
}
25712581
});
25722582

2573-
if (currentMonth == item.dates.start.localDate.substr(5, 2)) {
2583+
if (currentMonth == item.dates.start.localDate.substr(5, 2) || currentMonthDef == item.dates.start.localDate.substr(5, 2)) {
25742584

25752585
monthEvents.push({
25762586
'name': item.name,

products-and-docs/widgets/countdown/1.0.0/lib/main-widget-config.js

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

products-and-docs/widgets/countdown/1.0.0/lib/main-widget-config.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

products-and-docs/widgets/countdown/1.0.0/lib/main-widget.js

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

products-and-docs/widgets/countdown/1.0.0/lib/main-widget.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)