MDL-66770 mod_forum: rename modern display mode to nested v2
[moodle.git] / mod / forum / amd / build / discussion_nested_v2.min.js
CommitLineData
2602c7bf
RW
1define ("mod_forum/discussion_nested_v2",["exports","jquery","core/auto_rows","core/custom_interaction_events","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){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=n(b);c=n(c);d=n(d);e=n(e);f=n(f);g=n(g);h=n(h);i=n(i);j=n(j);k=n(k);l=n(l);m=n(m);function n(a){return a&&a.__esModule?a:{default:a}}function o(a){for(var b=1;b<arguments.length;b++){var c=null!=arguments[b]?arguments[b]:{},d=Object.keys(c);if("function"==typeof Object.getOwnPropertySymbols){d=d.concat(Object.getOwnPropertySymbols(c).filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable}))}d.forEach(function(b){p(a,b,c[b])})}return a}function p(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 q(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 r(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){q(h,d,e,f,g,"next",a)}function g(a){q(h,d,e,f,g,"throw",a)}f(void 0)})}}var s=function(a){return a.closest(l.default.post.post)},t=function(a,b){return a.find("".concat(l.default.post.post,"[data-post-id=").concat(b,"]"))},u=function(a){return a.parents(l.default.post.post)},v=function(a){return a.children().not(l.default.post.repliesContainer).find(l.default.post.forumCoreContent)},w=function(a){return a.children().filter(l.default.post.inpageReplyContainer)},x=function(a){return w(a).find(l.default.post.inpageReplyContent)},y=function(a){return v(a).find(l.default.post.inpageReplyCreateButton)},z=function(a){return a.children(l.default.post.repliesVisibilityToggleContainer)},A=function(a){return a.children(l.default.post.repliesContainer)},B=function(a){return 0<A(a).children().length},C=function(a){return a.find(l.default.post.showReplies)},D=function(a){return a.find(l.default.post.hideReplies)},E=function(a){var b=A(a);return b.is(":visible")},F=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:null,c=A(a),d=z(a),e=C(d),f=D(d);e.addClass("hidden");f.removeClass("hidden");c.slideDown({duration:150,queue:!1,complete:function complete(){if(b){var a=t(c,b);if(a.length){a[0].scrollIntoView()}}}}).css("display","none").fadeIn(150)},G=function(a){var b=A(a),c=z(a),d=C(c),e=D(c);d.removeClass("hidden");e.addClass("hidden");b.slideUp({duration:150,queue:!1}).fadeOut(150)},H=null,I=function(a){return function(){var b=r(regeneratorRuntime.mark(function b(c){var d,g,h,i;return regeneratorRuntime.wrap(function(b){while(1){switch(b.prev=b.next){case 0:d=w(c);g=z(c);h=y(c);if(K(d)){b.next=14;break}b.prev=4;b.next=7;return L(a,h,c);case 7:i=b.sent;f.default.appendNodeContents(d,i,"");b.next=14;break;case 11:b.prev=11;b.t0=b["catch"](4);e.default.exception(b.t0);case 14:h.fadeOut(150,function(){var a=x(c);a.slideDown({duration:150,queue:!1,complete:function complete(){a.find("textarea").focus()}}).css("display","none").fadeIn(150);if(g.length&&B(c)){g.fadeIn(150);G(c)}});case 15:case"end":return b.stop();}}},b,null,[[4,11]])}));return function(){return b.apply(this,arguments)}}()},J=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:null,c=x(a),d=y(a),e=z(a);if(e.length&&B(a)){e.fadeOut(150);if(!E(a)){F(a,b)}}c.slideUp({duration:150,queue:!1,complete:function complete(){d.fadeIn(150)}}).fadeOut(200)},K=function(a){return 0<a.find(l.default.post.inpageReplyContent).length},L=function(a,b,c){var d=v(c),e=d.find(l.default.post.forumSubject).text(),g=d.find(l.default.post.authorName).text(),i=o({postid:c.data("post-id"),reply_url:b.attr("data-href"),sesskey:M.cfg.sesskey,parentsubject:e,parentauthorname:g,canreplyprivately:b.data("can-reply-privately"),postformat:h.default.CONTENT_FORMATS.MOODLE},a);return f.default.render("mod_forum/inpage_reply_v2",i)},N=function(a){z(a).find(l.default.post.replyCount).each(function(a,b){var c=parseInt(b.innerText,10);b.innerText=c+1})},O=function(a){d.default.define(a,[d.default.events.activate]);c.default.init(a);a.on(d.default.events.activate,l.default.post.inpageReplyCreateButton,function(a,c){c.originalEvent.preventDefault();var d=s((0,b.default)(a.currentTarget));H(d)});a.on(d.default.events.activate,l.default.post.inpageReplyCancelButton,function(a,c){c.originalEvent.preventDefault();var d=s((0,b.default)(a.currentTarget));J(d)});a.on(d.default.events.activate,l.default.post.showReplies,function(a,c){c.originalEvent.preventDefault();var d=s((0,b.default)(a.target));F(d)});a.on(d.default.events.activate,l.default.post.hideReplies,function(a,c){c.originalEvent.preventDefault();var d=s((0,b.default)(a.target));G(d)});a.on(h.default.EVENTS.POST_CREATED,l.default.post.inpageSubmitBtn,function(a,c){var d=(0,b.default)(a.currentTarget),e=s(d),f=u(d);J(e,c);f.each(function(a,c){N((0,b.default)(c))})})},P=function(a,b){H=I(b);O(a);g.default.init(a);h.default.init(a);var c=a.find(l.default.discussion.tools);i.default.init(c,!1);j.default.init(c,!1,function(a,b){var c=b.userstate.favourited?0:1;return a.data("targetstate",c)});k.default.init(c,!1,function(a,b){var c=b.pinned?0:1;return a.data("targetstate",c)});m.default.init(c,!1,function(a,b){var c=b.userstate.subscribed?0:1;a.data("targetstate",c)})};a.init=P});
2//# sourceMappingURL=discussion_nested_v2.min.js.map