MDL-59392 calendar: Stop polluting history with useless URLs

This commit is contained in:
Andrew Nicols
2017-09-11 10:00:50 +08:00
parent 6ff225f57e
commit 41fa6a24be
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -1 +1 @@
define(["jquery","core/templates","core/notification","core_calendar/repository","core_calendar/events"],function(a,b,c,d,e){var f={ROOT:"[data-region='calendar']",CALENDAR_NAV_LINK:".calendarwrapper .arrow_link",CALENDAR_MONTH_WRAPPER:".calendarwrapper",LOADING_ICON_CONTAINER:'[data-region="overlay-icon-container"]'},g=function(b){b=a(b),b.on("click",f.CALENDAR_NAV_LINK,function(c){var d=a(b).find(f.CALENDAR_MONTH_WRAPPER).data("courseid"),e=a(c.currentTarget);i(b,e.attr("href"),e.data("time"),d),c.preventDefault()})},h=function(a,e,g){return k(a),d.getCalendarMonthData(e,g).then(function(c){return b.render(a.attr("data-template"),c)}).then(function(c,d){return b.replaceNode(a.find(f.CALENDAR_MONTH_WRAPPER),c,d)}).always(function(){return l(a)}).fail(c.exception)},i=function(b,c,d,f){return h(b,d,f).then(function(){return window.history.pushState({},"",c),arguments}).then(function(){return a("body").trigger(e.monthChanged,[d,f]),arguments})},j=function(a,b){var c=a.find(f.CALENDAR_MONTH_WRAPPER).data("current-time");return b||(b=a.find(f.CALENDAR_MONTH_WRAPPER).data("courseid")),h(a,c,b)},k=function(a){var b=a.find(f.LOADING_ICON_CONTAINER);b.removeClass("hidden")},l=function(a){var b=a.find(f.LOADING_ICON_CONTAINER);b.addClass("hidden")};return{init:function(a){g(a)},reloadCurrentMonth:j,changeMonth:i,refreshMonthContent:h}});
define(["jquery","core/templates","core/notification","core_calendar/repository","core_calendar/events"],function(a,b,c,d,e){var f={ROOT:"[data-region='calendar']",CALENDAR_NAV_LINK:".calendarwrapper .arrow_link",CALENDAR_MONTH_WRAPPER:".calendarwrapper",LOADING_ICON_CONTAINER:'[data-region="overlay-icon-container"]'},g=function(b){b=a(b),b.on("click",f.CALENDAR_NAV_LINK,function(c){var d=a(b).find(f.CALENDAR_MONTH_WRAPPER).data("courseid"),e=a(c.currentTarget);i(b,e.attr("href"),e.data("time"),d),c.preventDefault()})},h=function(a,e,g){return k(a),d.getCalendarMonthData(e,g).then(function(c){return b.render(a.attr("data-template"),c)}).then(function(c,d){return b.replaceNode(a.find(f.CALENDAR_MONTH_WRAPPER),c,d)}).always(function(){return l(a)}).fail(c.exception)},i=function(b,c,d,f){return h(b,d,f).then(function(){return c.length&&"#"!==c&&window.history.pushState({},"",c),arguments}).then(function(){return a("body").trigger(e.monthChanged,[d,f]),arguments})},j=function(a,b){var c=a.find(f.CALENDAR_MONTH_WRAPPER).data("current-time");return b||(b=a.find(f.CALENDAR_MONTH_WRAPPER).data("courseid")),h(a,c,b)},k=function(a){var b=a.find(f.LOADING_ICON_CONTAINER);b.removeClass("hidden")},l=function(a){var b=a.find(f.LOADING_ICON_CONTAINER);b.addClass("hidden")};return{init:function(a){g(a)},reloadCurrentMonth:j,changeMonth:i,refreshMonthContent:h}});
+3 -1
View File
@@ -82,7 +82,9 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito
var changeMonth = function(root, url, time, courseid) {
return refreshMonthContent(root, time, courseid)
.then(function() {
window.history.pushState({}, '', url);
if (url.length && url !== '#') {
window.history.pushState({}, '', url);
}
return arguments;
})
.then(function() {