MDL-67654 mod_forum: formchangechecker for discussion inline replies.
[moodle.git] / mod / forum / amd / build / discussion_nested_v2.min.js
... / ...
CommitLineData
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);var t="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function n(a){return a&&a.__esModule?a:{default:a}}function o(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 p(a){for(var b=1,c;b<arguments.length;b++){c=null!=arguments[b]?arguments[b]:{};if(b%2){o(Object(c),!0).forEach(function(b){q(a,b,c[b])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(a,Object.getOwnPropertyDescriptors(c))}else{o(Object(c)).forEach(function(b){Object.defineProperty(a,b,Object.getOwnPropertyDescriptor(c,b))})}}return a}function q(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 r(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 s(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){r(h,d,e,f,g,"next",a)}function g(a){r(h,d,e,f,g,"throw",a)}f(void 0)})}}var u=function(a){return a.closest(l.default.post.post)},v=function(a,b){return a.find("".concat(l.default.post.post,"[data-post-id=").concat(b,"]"))},w=function(a){return a.parents(l.default.post.post)},x=function(a){return a.children().not(l.default.post.repliesContainer).find(l.default.post.forumCoreContent)},y=function(a){return a.children().filter(l.default.post.inpageReplyContainer)},z=function(a){return y(a).find(l.default.post.inpageReplyContent)},A=function(a){return x(a).find(l.default.post.inpageReplyCreateButton)},B=function(a){return a.children(l.default.post.repliesVisibilityToggleContainer)},C=function(a){return a.children(l.default.post.repliesContainer)},D=function(a){return 0<C(a).children().length},E=function(a){return a.find(l.default.post.showReplies)},F=function(a){return a.find(l.default.post.hideReplies)},G=function(a){var b=C(a);return b.is(":visible")},H=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:null,c=C(a),d=B(a),e=E(d),f=F(d);e.addClass("hidden");f.removeClass("hidden");c.slideDown({duration:150,queue:!1,complete:function complete(){if(b){var a=v(c,b);if(a.length){a[0].scrollIntoView()}}}}).css("display","none").fadeIn(150)},I=function(a){var b=C(a),c=B(a),d=E(c),e=F(c);d.removeClass("hidden");e.addClass("hidden");b.slideUp({duration:150,queue:!1}).fadeOut(150)},J=null,K=function(a){return function(){var b=s(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=y(c);g=B(c);h=A(c);if(N(d)){b.next=15;break}b.prev=4;b.next=7;return O(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:("function"==typeof t.define&&t.define.amd?new Promise(function(a,b){t.require(["core/yui"],a,b)}):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&t.require&&"component"===t.require.loader?Promise.resolve(require(("core/yui"))):Promise.resolve(t["core/yui"])).then(function(a){return new Promise(function(b){a.use("moodle-core-formchangechecker",function(a){b(a)})})}).then(function(a){M.core_formchangechecker.init({formid:a.one(c[0].querySelector("form")).generateID()});return a}).catch();case 15:h.fadeOut(150,function(){var a=z(c);a.slideDown({duration:150,queue:!1,complete:function complete(){a.find("textarea").focus()}}).css("display","none").fadeIn(150);if(g.length&&D(c)){g.fadeIn(150);I(c)}});case 16:case"end":return b.stop();}}},b,null,[[4,11]])}));return function(){return b.apply(this,arguments)}}()},L=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:null,c=z(a),d=A(a),e=B(a);if(e.length&&D(a)){e.fadeOut(150);if(!G(a)){H(a,b)}}c.slideUp({duration:150,queue:!1,complete:function complete(){d.fadeIn(150)}}).fadeOut(200)},N=function(a){return 0<a.find(l.default.post.inpageReplyContent).length},O=function(a,b,c){var d=x(c),e=d.find(l.default.post.forumSubject).text(),g=d.find(l.default.post.authorName).text(),i=p({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)},P=function(a){B(a).find(l.default.post.replyCount).each(function(a,b){var c=parseInt(b.innerText,10);b.innerText=c+1})},Q=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=u((0,b.default)(a.currentTarget));J(d)});a.on(d.default.events.activate,l.default.post.inpageReplyCancelButton,function(a,c){c.originalEvent.preventDefault();var d=u((0,b.default)(a.currentTarget));L(d)});a.on(d.default.events.activate,l.default.post.showReplies,function(a,c){c.originalEvent.preventDefault();var d=u((0,b.default)(a.target));H(d)});a.on(d.default.events.activate,l.default.post.hideReplies,function(a,c){c.originalEvent.preventDefault();var d=u((0,b.default)(a.target));I(d)});a.on(h.default.EVENTS.POST_CREATED,l.default.post.inpageSubmitBtn,function(a,c){var d=(0,b.default)(a.currentTarget),e=u(d),f=w(d);L(e,c);f.each(function(a,c){P((0,b.default)(c))})})},R=function(a,b){J=K(b);Q(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=R});
2//# sourceMappingURL=discussion_nested_v2.min.js.map