ef027a50e9246f9612d6047463467f7d94f5322b
[moodle.git] / mod / forum / report / summary / amd / build / filters.min.js
1 define ("forumreport_summary/filters",["exports","jquery","core/popper","core/custom_interaction_events","forumreport_summary/selectors","core/yui","core/ajax","core/key_codes"],function(a,b,c,d,e,f,g,h){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=i(b);c=i(c);d=i(d);e=i(e);f=i(f);g=i(g);h=i(h);function i(a){return a&&a.__esModule?a:{default:a}}var j=function(a){var i=(0,b.default)(a);(0,b.default)(document).ready(function(){(0,b.default)(".loading-icon").hide();(0,b.default)("#summaryreport").removeClass("hidden")});var j=function(a){var c=(0,b.default)("#filtersform").attr("action");if(a){a.preventDefault();var d=a.target.search.substr(1);c+="&"+d}(0,b.default)("#filtersform").attr("action",c);(0,b.default)("#filtersform").submit()};(0,b.default)(".resettable").on("click","a",function(a){j(a)});(0,b.default)("thead").on("click","a",function(a){j(a)});(0,b.default)(".pagination").on("click","a",function(a){j(a)});var k=function(a){f.default.use("moodle-core-formchangechecker",function(){M.core_formchangechecker.reset_form_dirty_state()});(0,b.default)(a).addClass("hidden");j(!1)},l=function(a){var b=document.querySelector(a),d=document.querySelector(e.default.filters.date.calendar);d.style.removeProperty("z-index");new c.default(b,d,{placement:"bottom"})},m=function(a,b){b.classList.add("hidden");b.setAttribute("data-openfilter","false");a.classList.add("btn-primary");a.classList.remove("btn-outline-primary");a.setAttribute("aria-expanded",!1)};i.on(d.default.events.activate,e.default.filters.group.selectall,function(){var b=a.querySelectorAll(e.default.filters.group.checkbox+":not(:checked)");b.forEach(function(a){a.checked=!0})});i.on(d.default.events.activate,e.default.filters.group.clear,function(){var b=a.querySelectorAll(e.default.filters.group.checkbox+":checked");b.forEach(function(a){a.checked=!1})});i.on(d.default.events.activate,e.default.filters.group.trigger,function(){var b=a.querySelector(e.default.filters.group.trigger),d=a.querySelector(e.default.filters.group.popover);new c.default(b,d,{placement:"bottom"});d.classList.remove("hidden");d.setAttribute("data-openfilter","true");b.classList.add("btn-outline-primary");b.classList.remove("btn-primary");b.setAttribute("aria-expanded",!0);var f=function(a){if(a.target.id!==b.id&&d!==a.target.closest("[data-openfilter=\"true\"]")&&("undefined"==typeof a.keyCode||a.keyCode===h.default.enter||a.keyCode===h.default.space)){m(b,d);document.removeEventListener("click",f);document.removeEventListener("keyup",f);document.removeEventListener("keyup",g)}};document.addEventListener("click",f);document.addEventListener("keyup",f);var g=function(a){if(a.keyCode===h.default.escape){m(b,d);document.removeEventListener("keyup",g);document.removeEventListener("click",f)}};document.addEventListener("keyup",g)});i.on(d.default.events.activate,e.default.filters.group.save,function(){var b=a.querySelectorAll(e.default.filters.group.checkbox);b.forEach(function(a){var b=document.forms.filtersform,c=a.getAttribute("data-saveid");b.querySelector("#".concat(c)).checked=a.checked});k("#filter-groups-popover")});i.on(d.default.events.activate,e.default.filters.date.trigger,function(){var b=a.querySelector(e.default.filters.date.trigger),d=a.querySelector(e.default.filters.date.popover);new c.default(b,d,{placement:"bottom"});d.classList.remove("hidden");d.setAttribute("data-openfilter","true");d.querySelector("[name=\"filterdatefrompopover[enabled]\"]").focus();b.classList.add("btn-outline-primary");b.classList.remove("btn-primary");b.setAttribute("aria-expanded",!0);var f=function(a){if(a.target.id!==b.id&&d!==a.target.closest("[data-openfilter=\"true\"]")&&("undefined"==typeof a.keyCode||a.keyCode===h.default.enter||a.keyCode===h.default.space)){m(b,d);document.removeEventListener("click",f);document.removeEventListener("keyup",f);document.removeEventListener("keyup",g)}};document.addEventListener("click",f);document.addEventListener("keyup",f);var g=function(a){if(a.keyCode===h.default.escape){m(b,d);document.removeEventListener("keyup",g);document.removeEventListener("click",f)}};document.addEventListener("keyup",g)});i.on(d.default.events.activate,e.default.filters.date.save,function(){var b=document.forms.filtersform,c=a.querySelector(e.default.filters.date.popover),d=c.querySelector("[name=\"filterdatefrompopover[enabled]\"]").checked?1:0,f=c.querySelector("[name=\"filterdatetopopover[enabled]\"]").checked?1:0;if(!d&&!f){b.elements["datefrom[timestamp]"].value=0;b.elements["datefrom[enabled]"].value=d;b.elements["dateto[timestamp]"].value=0;b.elements["dateto[enabled]"].value=f;k("#filter-dates-popover")}else{var h={data:[]};if(d){h.data.push({key:"from",year:c.querySelector("[name=\"filterdatefrompopover[year]\"]").value,month:c.querySelector("[name=\"filterdatefrompopover[month]\"]").value,day:c.querySelector("[name=\"filterdatefrompopover[day]\"]").value,hour:0,minute:0})}if(f){h.data.push({key:"to",year:c.querySelector("[name=\"filterdatetopopover[year]\"]").value,month:c.querySelector("[name=\"filterdatetopopover[month]\"]").value,day:c.querySelector("[name=\"filterdatetopopover[day]\"]").value,hour:23,minute:59})}g.default.call([{methodname:"core_calendar_get_timestamps",args:h}])[0].done(function(a){var c=0,e=0;a.timestamps.forEach(function(a){if("from"===a.key){c=a.timestamp}else if("to"===a.key){e=a.timestamp}});if(0<e&&c>e){var g=document.getElementById("dates-filter-warning");g.classList.remove("hidden");g.classList.add("d-block")}else{b.elements["datefrom[timestamp]"].value=c;b.elements["datefrom[enabled]"].value=d;b.elements["dateto[timestamp]"].value=e;b.elements["dateto[enabled]"].value=f;k("#filter-dates-popover")}})}});i.on(d.default.events.activate,e.default.filters.date.calendariconfrom,function(){l(e.default.filters.date.calendariconfrom)});i.on(d.default.events.activate,e.default.filters.date.calendariconto,function(){l(e.default.filters.date.calendariconto)})};a.init=j});
2 //# sourceMappingURL=filters.min.js.map