MDL-63352 block_timeline: Persist user preference on timeline
[moodle.git] / blocks / timeline / amd / build / view_nav.min.js
1 define(["jquery","core/custom_interaction_events","block_timeline/view","core/ajax","core/notification"],function(a,b,c,d,e){var f={TIMELINE_DAY_FILTER:'[data-region="day-filter"]',TIMELINE_DAY_FILTER_OPTION:"[data-from]",TIMELINE_VIEW_SELECTOR:'[data-region="view-selector"]',DATA_DAYS_OFFSET:"[data-days-offset]",DATA_DAYS_LIMIT:"[data-days-limit]"},g=function(a,b){var c={methodname:"core_user_update_user_preferences",args:{preferences:[{type:a,value:b}]}};d.call([c])[0].fail(e.exception)},h=function(d,e){var h=d.find(f.TIMELINE_DAY_FILTER);b.define(h,[b.events.activate]),h.on(b.events.activate,f.TIMELINE_DAY_FILTER_OPTION,function(b,h){var i=a(b.currentTarget).data("filtername"),j="block_timeline_user_filter_preference";g(j,i);var k=a(b.target).closest(f.TIMELINE_DAY_FILTER_OPTION);if(!k.hasClass("active")){var l=k.attr("data-from"),m=k.attr("data-to"),n=d.find(f.DATA_DAYS_OFFSET);n.attr("data-days-offset",l),void 0!=m?n.attr("data-days-limit",m):n.removeAttr("data-days-limit"),c.reset(e),h.originalEvent.preventDefault()}})},i=function(d,e){var h=d.find(f.TIMELINE_VIEW_SELECTOR);h.on("shown shown.bs.tab",function(){c.shown(e)}),b.define(h,[b.events.activate]),h.on(b.events.activate,"[data-toggle='tab']",function(b){var c=a(b.currentTarget).data("filtername"),d="block_timeline_user_sort_preference";g(d,c)})},j=function(b,c){b=a(b),h(b,c),i(b,c)};return{init:j}});