weekly release 4.0dev
[moodle.git] / mod / forum / amd / build / discussion_nested_v2.min.js
1 function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("mod_forum/discussion_nested_v2",["exports","jquery","core/auto_rows","core/custom_interaction_events","core_form/changechecker","core/notification","core/templates","mod_forum/discussion","mod_forum/inpage_reply","mod_forum/lock_toggle","mod_forum/favourite_toggle","mod_forum/pin_toggle","mod_forum/selectors","mod_forum/subscription_toggle"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=q(b);c=q(c);d=q(d);e=p(e);f=q(f);g=q(g);h=q(h);i=q(i);j=q(j);k=q(k);l=q(l);m=q(m);n=q(n);function o(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;o=function(){return a};return a}function p(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=o();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a){if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;if(f&&(f.get||f.set)){Object.defineProperty(c,e,f)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function q(a){return a&&a.__esModule?a:{default:a}}function r(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);if(b)d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable});c.push.apply(c,d)}return c}function s(a){for(var b=1,c;b<arguments.length;b++){c=null!=arguments[b]?arguments[b]:{};if(b%2){r(Object(c),!0).forEach(function(b){t(a,b,c[b])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(a,Object.getOwnPropertyDescriptors(c))}else{r(Object(c)).forEach(function(b){Object.defineProperty(a,b,Object.getOwnPropertyDescriptor(c,b))})}}return a}function t(a,b,c){if(b in a){Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0})}else{a[b]=c}return a}function u(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function v(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){u(h,d,e,f,g,"next",a)}function g(a){u(h,d,e,f,g,"throw",a)}f(void 0)})}}var w=function(a){return a.closest(m.default.post.post)},x=function(a,b){return a.find("".concat(m.default.post.post,"[data-post-id=").concat(b,"]"))},y=function(a){return a.parents(m.default.post.post)},z=function(a){return a.children().not(m.default.post.repliesContainer).find(m.default.post.forumCoreContent)},A=function(a){return a.children().filter(m.default.post.inpageReplyContainer)},B=function(a){return A(a).find(m.default.post.inpageReplyContent)},C=function(a){return z(a).find(m.default.post.inpageReplyCreateButton)},D=function(a){return a.children(m.default.post.repliesVisibilityToggleContainer)},E=function(a){return a.children(m.default.post.repliesContainer)},F=function(a){return 0<E(a).children().length},G=function(a){return a.find(m.default.post.showReplies)},H=function(a){return a.find(m.default.post.hideReplies)},I=function(a){var b=E(a);return b.is(":visible")},J=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:null,c=E(a),d=D(a),e=G(d),f=H(d);e.addClass("hidden");f.removeClass("hidden");c.slideDown({duration:150,queue:!1,complete:function complete(){if(b){var a=x(c,b);if(a.length){a[0].scrollIntoView()}}}}).css("display","none").fadeIn(150)},K=function(a){var b=E(a),c=D(a),d=G(c),e=H(c);d.removeClass("hidden");e.addClass("hidden");b.slideUp({duration:150,queue:!1}).fadeOut(150)},L=null,N=function(a){return function(){var b=v(regeneratorRuntime.mark(function b(c){var d,h,i,j;return regeneratorRuntime.wrap(function(b){while(1){switch(b.prev=b.next){case 0:d=A(c);h=D(c);i=C(c);if(P(d)){b.next=15;break}b.prev=4;b.next=7;return Q(a,i,c);case 7:j=b.sent;g.default.appendNodeContents(d,j,"");b.next=14;break;case 11:b.prev=11;b.t0=b["catch"](4);f.default.exception(b.t0);case 14:e.watchForm(c[0].querySelector("form"));case 15:i.fadeOut(150,function(){var a=B(c);a.slideDown({duration:150,queue:!1,complete:function complete(){a.find("textarea").focus()}}).css("display","none").fadeIn(150);if(h.length&&F(c)){h.fadeIn(150);K(c)}});case 16:case"end":return b.stop();}}},b,null,[[4,11]])}));return function(){return b.apply(this,arguments)}}()},O=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:null,c=B(a),d=C(a),e=D(a);if(e.length&&F(a)){e.fadeOut(150);if(!I(a)){J(a,b)}}c.slideUp({duration:150,queue:!1,complete:function complete(){d.fadeIn(150)}}).fadeOut(200)},P=function(a){return 0<a.find(m.default.post.inpageReplyContent).length},Q=function(a,b,c){var d=z(c),e=d.find(m.default.post.forumSubject).text(),f=d.find(m.default.post.authorName).text(),h=s({postid:c.data("post-id"),reply_url:b.attr("data-href"),sesskey:M.cfg.sesskey,parentsubject:e,parentauthorname:f,canreplyprivately:b.data("can-reply-privately"),postformat:i.default.CONTENT_FORMATS.MOODLE},a);return g.default.render("mod_forum/inpage_reply_v2",h)},R=function(a){D(a).find(m.default.post.replyCount).each(function(a,b){var c=parseInt(b.innerText,10);b.innerText=c+1})},S=function(a){d.default.define(a,[d.default.events.activate]);c.default.init(a);a.on(d.default.events.activate,m.default.post.inpageReplyCreateButton,function(a,c){c.originalEvent.preventDefault();var d=w((0,b.default)(a.currentTarget));L(d)});a.on(d.default.events.activate,m.default.post.inpageReplyCancelButton,function(a,c){c.originalEvent.preventDefault();var d=w((0,b.default)(a.currentTarget));O(d)});a.on(d.default.events.activate,m.default.post.showReplies,function(a,c){c.originalEvent.preventDefault();var d=w((0,b.default)(a.target));J(d)});a.on(d.default.events.activate,m.default.post.hideReplies,function(a,c){c.originalEvent.preventDefault();var d=w((0,b.default)(a.target));K(d)});a.on(i.default.EVENTS.POST_CREATED,m.default.post.inpageSubmitBtn,function(a,c){var d=(0,b.default)(a.currentTarget),e=w(d),f=y(d);O(e,c);f.each(function(a,c){R((0,b.default)(c))})})},T=function(a,b){L=N(b);S(a);h.default.init(a);i.default.init(a);var c=a.find(m.default.discussion.tools);j.default.init(c,!1);k.default.init(c,!1,function(a,b){var c=b.userstate.favourited?0:1;return a.data("targetstate",c)});l.default.init(c,!1,function(a,b){var c=b.pinned?0:1;return a.data("targetstate",c)});n.default.init(c,!1,function(a,b){var c=b.userstate.subscribed?0:1;a.data("targetstate",c)})};a.init=T});
2 //# sourceMappingURL=discussion_nested_v2.min.js.map