From 4491c0020007396644c85e29b808a1a25842f3a3 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Tue, 10 Feb 2026 16:56:53 +0500 Subject: [PATCH 1/6] chore: bundling all js files with webpack --- xblocks_contrib/discussion/public/js/discussion_bundle.js | 2 ++ .../discussion/public/js/discussion_bundle.js.LICENSE.txt | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 xblocks_contrib/discussion/public/js/discussion_bundle.js create mode 100644 xblocks_contrib/discussion/public/js/discussion_bundle.js.LICENSE.txt diff --git a/xblocks_contrib/discussion/public/js/discussion_bundle.js b/xblocks_contrib/discussion/public/js/discussion_bundle.js new file mode 100644 index 00000000..6431494c --- /dev/null +++ b/xblocks_contrib/discussion/public/js/discussion_bundle.js @@ -0,0 +1,2 @@ +/*! For license information please see discussion_bundle.js.LICENSE.txt */ +(()=>{var __webpack_modules__={290(e,t){(function(){var e;e=t,function(){function t(e){return e}function n(e){return!1}function i(){}function o(){}i.prototype={chain:function(e,n){var i=this[e];if(!i)throw new Error("unknown hook "+e);this[e]=i===t?n:function(e){return n(i(e))}},set:function(e,t){if(!this[e])throw new Error("unknown hook "+e);this[e]=t},addNoop:function(e){this[e]=t},addFalse:function(e){this[e]=n}},e.HookCollection=i,o.prototype={set:function(e,t){this["s_"+e]=t},get:function(e){return this["s_"+e]}},e.Converter=function(){var e,t,n,r,s=this.hooks=new i;function a(e){return(e=(e=(e=(e=e.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,d)).replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,d)).replace(/\n[ ]{0,3}((<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,d)).replace(/\n\n[ ]{0,3}(-]|-[^>])(?:[^-]|-[^-])*)--)>[ \t]*(?=\n{2,}))/g,d)).replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,d)}function d(e,t){var i=t;return i=(i=i.replace(/^\n+/,"")).replace(/\n+$/g,""),"\n\n~K"+(n.push(i)-1)+"K\n\n"}function l(e,t){var i="
\n";return e=function(e,t){for(var i=(e=(e=e.replace(/^\n+/g,"")).replace(/\n+$/g,"")).split(/\n{2,}/g),o=[],r=/~K(\d+)K/,s=i.length,a=0;a"),d+="

",o.push(d))}if(!t)for(s=o.length,a=0;a[ \t]?.+\n(.+\n)*\n*)+)/gm,function(e,t){var i=t;return i=(i=(i=l(i=(i=(i=i.replace(/^[ \t]*>[ \t]?/gm,"~0")).replace(/~0/g,"")).replace(/^[ \t]+$/gm,""))).replace(/(^|\n)/g,"$1 ")).replace(/(\s*
[^\r]+?<\/pre>)/gm,function(e,t){var n=t;return(n=n.replace(/^ {2}/gm,"~0")).replace(/~0/g,"")}),function(e){return e=e.replace(/(^\n+|\n+$)/g,""),"\n\n~K"+(n.push(e)-1)+"K\n\n"}("
\n"+i+"\n
")})}(e=function(e){return e=(e=(e+="~0").replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(e,t,n){var i=n;return"\n\n"+("
"+v(y(w(t))).replace(/^\n+/g,"").replace(/\n+$/g,"")+"\n
")+"\n\n"+i})).replace(/~0/,"")}(e=m(e=(e=(e=(e=function(e){return e=(e=(e=e.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,function(e,t){return"

"+c(t)+"

\n\n"})).replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(e,t){return"

"+c(t)+"

\n\n"})).replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(e,t,n){var i=t.length;return""+c(n)+"\n\n"})}(e)).replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,i)).replace(/^[ ]{0,2}([ ]?-[ ]?){3,}[ \t]*$/gm,i)).replace(/^[ ]{0,2}([ ]?_[ ]?){3,}[ \t]*$/gm,i))))),t),e}function c(e){return(e=function(e){return e=(e=e.replace(/([\W_]|^)(\*\*|__)(?=\S)([^\r]*?\S[\*_]*)\2([\W_]|$)/g,"$1$3$4")).replace(/([\W_]|^)(\*|_)(?=\S)([^\r\*_]*?\S)\2([\W_]|$)/g,"$1$3$4")}(e=_(e=(e=function(e){return e=(e=e.replace(/(^|\s)(https?|ftp)(:\/\/[-A-Z0-9+&@#\/%?=~_|\[\]\(\)!:,\.;]*[-A-Z0-9+&@#\/%=~_|\[\]])($|\W)/gi,"$1<$2$3>$4")).replace(/<((https?|ftp):[^'">\s]+)>/gi,function(e,t){return''+s.plainLinkText(t)+""})}(e=function(e){return e=(e=(e=e.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,u)).replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,u)).replace(/(\[([^\[\]]+)\])()()()()()/g,u)}(e=function(e){return e=(e=e.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,h)).replace(/(!\[(.*?)\]\s?\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,h)}(e=function(e){return e=(e=e.replace(/\\(\\)/g,$)).replace(/\\([`*_{}\[\]()>#+-.!])/g,$)}(e=function(e){return e=e.replace(/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|-]|-[^>])(?:[^-]|-[^-])*)--)>)/gi,function(e){var t=e.replace(/(.)<\/?code>(?=.)/g,"$1`");return b(t,"!"==e.charAt(1)?"\\`*_/":"\\`*_")})}(e=function(e){return e=e.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(e,t,n,i,o){return t+""+y(i.replace(/^([ \t]*)/g,"").replace(/[ \t]*$/g,"")).replace(/:\/\//g,"~P")+""})}(e))))))).replace(/~P/g,"://")))).replace(/ +\n/g,"
\n")}function u(n,i,o,r,s,a,d,l){null==l&&(l="");var c=i,u=o.replace(/:\/\//g,"~P"),h=r.toLowerCase(),m=s,f=l;if(""==m)if(""==h&&(h=u.toLowerCase().replace(/ ?\n/g," ")),m="#"+h,null!=e.get(h))m=e.get(h),null!=t.get(h)&&(f=t.get(h));else{if(!(c.search(/\(\s*\)$/m)>-1))return c;m=""}var g='"+u+""}function p(e){return e.replace(/>/g,">").replace(/"}function m(e){e+="~0";var t=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;return r?e=e.replace(t,function(e,t,n){var i=t,o=n.search(/[*+-]/g)>-1?"ul":"ol",r=g(i,o);return"<"+o+">"+(r=r.replace(/\s+$/,""))+"\n"}):(t=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g,e=e.replace(t,function(e,t,n,i){var o=t,r=n,s=i.search(/[*+-]/g)>-1?"ul":"ol",a=g(r,s);return o+"<"+s+">\n"+a+"\n"})),e.replace(/~0/,"")}s.addNoop("plainLinkText"),s.addNoop("preConversion"),s.addNoop("postConversion"),this.makeHtml=function(i){if(e)throw new Error("Recursive call to converter.makeHtml");return e=new o,t=new o,n=[],r=0,i=(i=(i=function(e){return e=e.replace(/~E(\d+)E/g,function(e,t){var n=parseInt(t);return String.fromCharCode(n)})}(i=l(i=function(n){return n=n.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*?(?=\s|$)[ \t]*\n?[ \t]*((\n*)["(](.+?)[")][ \t]*)?(?:\n+)/gm,function(n,i,o,r,s,a){return i=i.toLowerCase(),e.set(i,_(o)),s?r:(a&&t.set(i,a.replace(/"/g,""")),"")})}(i=a(i=(i=v(i="\n\n"+(i=(i=(i=(i=(i=s.preConversion(i)).replace(/~/g,"~T")).replace(/\$/g,"~D")).replace(/\r\n/g,"\n")).replace(/\r/g,"\n"))+"\n\n")).replace(/^[ \t]+$/gm,"")))))).replace(/~D/g,"$$")).replace(/~T/g,"~"),i=s.postConversion(i),n=t=e=null,i};var f={ol:"\\d+[.]",ul:"[*+-]"};function g(e,t){r++,e=e.replace(/\n{2,}$/,"\n"),e+="~0";var n=f[t],i=new RegExp("(^[ \\t]*)("+n+")[ \\t]+([^\\r]+?(\\n+))(?=(~0|\\1("+n+")[ \\t]+))","gm"),o=!1;return e=(e=e.replace(i,function(e,t,n,i){var r=i,s=/\n\n$/.test(r),a=s||r.search(/\n{2,}/)>-1;return r=a||o?l(w(r),!0):c(r=(r=m(w(r))).replace(/\n$/,"")),o=s,"
  • "+r+"
  • \n"})).replace(/~0/g,""),r--,e}function y(e){return b(e=(e=(e=e.replace(/&/g,"&")).replace(//g,">"),"*_{}[]\\",!1)}function _(e){return(e=e.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&")).replace(/<(?![a-z\/?\$!])/gi,"<")}function w(e){return(e=e.replace(/^(\t|[ ]{1,4})/gm,"~0")).replace(/~0/g,"")}function v(e){if(!/\t/.test(e))return e;var t,n=[" "," "," "," "],i=0;return e.replace(/[\n\t]/g,function(e,o){return"\n"===e?(i=o+1,e):(t=(o-i)%4,i=o+1,n[t])})}function b(e,t,n){var i="(["+t.replace(/([\[\]\\])/g,"\\$1")+"])";n&&(i="\\\\"+i);var o=new RegExp(i,"g");return e.replace(o,$)}function $(e,t){return"~E"+t.charCodeAt(0)+"E"}}}()}).call(window),window.Markdown=t},786(e,t,n){(function(){!function(){var e,i;function o(e){return e.replace(/<[^>]*>?/gi,d)}e=t,i=n(290).Converter,e.getSanitizingConverter=function(){var e=new i;return e.hooks.chain("postConversion",o),e.hooks.chain("postConversion",l),e};var r=/^(<\/?(b|blockquote|code|del|dd|dl|dt|em|h1|h2|h3|i|kbd|li|ol|p|pre|s|sup|sub|strong|strike|ul)>|<(br|hr)\s?\/?>)$/i,s=/^(]+")?\s?>|<\/a>)$/i,a=/^(]*")?(\stitle="[^"<>]*")?\s?\/?>)$/i;function d(e){return e.match(r)||e.match(s)||e.match(a)?e:""}function l(e){if(""==e)return"";var t,n,i=/<\/?\w+[^>]*(\s|$|>)/g,o=e.toLowerCase().match(i),r=(o||[]).length;if(0==r)return e;for(var s,a=[],d=[],l=!1,c=0;c

  • ".search("<"+t+">")>-1)){if(n=o[c],s=-1,!/^<\//.test(n))for(var u=c+1;u"){s=u;break}-1==s?l=d[c]=!0:a[s]=!0}return l?(c=0,e=e.replace(i,function(e){var t=d[c]?"":e;return c++,t}),e):e}}()}).call(window),window.Markdown.getSanitizingConverter=t.getSanitizingConverter},398(){(function(){var e;e=e||function(e){var t,n=String.prototype.split,i=/()??/.exec("")[1]===e;return t=function(t,o,r){if("[object RegExp]"!==Object.prototype.toString.call(o))return n.call(t,o,r);var s,a,d,l,c=[],u=(o.ignoreCase?"i":"")+(o.multiline?"m":"")+(o.extended?"x":"")+(o.sticky?"y":""),p=0;for(o=new RegExp(o.source,u+"g"),t+="",i||(s=new RegExp("^"+o.source+"$(?!\\s)",u)),r=r===e?-1>>>0:r>>>0;(a=o.exec(t))&&!((d=a.index+a[0].length)>p&&(c.push(t.slice(p,a.index)),!i&&a.length>1&&a[0].replace(s,function(){for(var t=1;t1&&a.index=r));)o.lastIndex===a.index&&o.lastIndex++;return p===t.length?!l&&o.test("")||c.push(""):c.push(t.slice(p)),c.length>r?c.slice(0,r):c},String.prototype.split=function(e,n){return t(this,e,n)},t}(),window._split=e}).call(window)},514(){(function(){(function(){"use strict";var e={}.hasOwnProperty;function t(t,n){for(var i in n)e.call(n,i)&&(t[i]=n[i]);function o(){this.constructor=t}return o.prototype=n.prototype,t.prototype=new o,t.__super__=n.prototype,t}var n=[].indexOf||function(e){for(var t=0,n=this.length;t=0||DiscussionUtil.isPrivilegedUser(t.id)&&e.length>0)},e.prototype.incrementVote=function(e){var t;return(t=_.clone(this.get("votes"))).up_count+=e,this.set("votes",t)},e.prototype.vote=function(){return this.incrementVote(1)},e.prototype.unvote=function(){return this.incrementVote(-1)},e}(),this.Thread=function(e){function n(){return n.__super__.constructor.apply(this,arguments)}return t(n,e),n.prototype.urlMappers={retrieve:function(){return DiscussionUtil.urlFor("retrieve_single_thread",this.get("commentable_id"),this.id)},reply:function(){return DiscussionUtil.urlFor("create_comment",this.id)},unvote:function(){return DiscussionUtil.urlFor("undo_vote_for_"+this.get("type"),this.id)},upvote:function(){return DiscussionUtil.urlFor("upvote_"+this.get("type"),this.id)},downvote:function(){return DiscussionUtil.urlFor("downvote_"+this.get("type"),this.id)},close:function(){return DiscussionUtil.urlFor("openclose_thread",this.id)},update:function(){return DiscussionUtil.urlFor("update_thread",this.id)},_delete:function(){return DiscussionUtil.urlFor("delete_thread",this.id)},follow:function(){return DiscussionUtil.urlFor("follow_thread",this.id)},unfollow:function(){return DiscussionUtil.urlFor("unfollow_thread",this.id)},flagAbuse:function(){return DiscussionUtil.urlFor("flagAbuse_"+this.get("type"),this.id)},unFlagAbuse:function(){return DiscussionUtil.urlFor("unFlagAbuse_"+this.get("type"),this.id)},pinThread:function(){return DiscussionUtil.urlFor("pin_thread",this.id)},unPinThread:function(){return DiscussionUtil.urlFor("un_pin_thread",this.id)}},n.prototype.initialize=function(){return this.set("thread",this),n.__super__.initialize.call(this)},n.prototype.comment=function(){return this.set("comments_count",parseInt(this.get("comments_count"))+1)},n.prototype.follow=function(){return this.set("subscribed",!0)},n.prototype.unfollow=function(){return this.set("subscribed",!1)},n.prototype.display_body=function(){return this.has("highlighted_body")?String(this.get("highlighted_body")).replace(//g,"").replace(/<\/highlight>/g,""):this.get("body")},n.prototype.display_title=function(){return this.has("highlighted_title")?String(this.get("highlighted_title")).replace(//g,"").replace(/<\/highlight>/g,""):this.get("title")},n.prototype.toJSON=function(){var e;return e=_.clone(this.attributes),_.extend(e,{title:this.display_title(),body:this.display_body()})},n.prototype.created_at_date=function(){return new Date(this.get("created_at"))},n.prototype.created_at_time=function(){return new Date(this.get("created_at")).getTime()},n.prototype.hasResponses=function(){return this.get("comments_count")>0},n}(this.Content),this.Comment=function(e){function n(){var e=this;return this.canBeEndorsed=function(){return n.prototype.canBeEndorsed.apply(e,arguments)},n.__super__.constructor.apply(this,arguments)}return t(n,e),n.prototype.urlMappers={reply:function(){return DiscussionUtil.urlFor("create_sub_comment",this.id)},unvote:function(){return DiscussionUtil.urlFor("undo_vote_for_"+this.get("type"),this.id)},upvote:function(){return DiscussionUtil.urlFor("upvote_"+this.get("type"),this.id)},downvote:function(){return DiscussionUtil.urlFor("downvote_"+this.get("type"),this.id)},endorse:function(){return DiscussionUtil.urlFor("endorse_comment",this.id)},update:function(){return DiscussionUtil.urlFor("update_comment",this.id)},_delete:function(){return DiscussionUtil.urlFor("delete_comment",this.id)},flagAbuse:function(){return DiscussionUtil.urlFor("flagAbuse_"+this.get("type"),this.id)},unFlagAbuse:function(){return DiscussionUtil.urlFor("unFlagAbuse_"+this.get("type"),this.id)}},n.prototype.getCommentsCount=function(){var e;return e=0,this.get("comments").each(function(t){return e+=t.getCommentsCount()+1}),e},n.prototype.canBeEndorsed=function(){var e;return(e=window.user.get("id"))&&(DiscussionUtil.isPrivilegedUser(e)||"question"===this.get("thread").get("thread_type")&&this.get("thread").get("user_id")===e)},n}(this.Content),this.Comments=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return t(e,Backbone.Collection),e.prototype.model=Comment,e.prototype.initialize=function(){var e=this;return this.bind("add",function(t){t.collection=e})},e.prototype.find=function(e){return _.first(this.where({id:e}))},e}())}).call(window)}).call(window)},779(){(function(){(function(){"use strict";var e={}.hasOwnProperty;"undefined"!=typeof Backbone&&null!==Backbone&&(this.Discussion=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return function(t,n){for(var i in n)e.call(n,i)&&(t[i]=n[i]);function o(){this.constructor=t}o.prototype=n.prototype,t.prototype=new o,t.__super__=n.prototype}(t,Backbone.Collection),t.prototype.model=Thread,t.prototype.initialize=function(e,t){var n=this;return t||(t={}),this.pages=t.pages||1,this.current_page=1,this.sort_preference=t.sort,this.is_commentable_divided=t.is_commentable_divided,this.bind("add",function(e){e.discussion=n}),this.setSortComparator(this.sort_preference),this.on("thread:remove",function(e){n.remove(e)})},t.prototype.find=function(e){return _.first(this.where({id:e}))},t.prototype.hasMorePages=function(){return this.current_pagei?-1:i>n?1:e.created_at_time()>t.created_at_time()?-1:1},t.prototype.pinnedThreadsSortComparatorWithDate=function(e,t){var n,i,o;return i=new Date(e.get("last_activity_at")).getTime(),e.get("pinned")?(o=new Date,n=new Date(o.getTime()+864e5+i)):n=i,t?n:-n},t}())}).call(window)}).call(window)},189(){(function(){var e;"undefined"==typeof MathJax&&(window.MathJax={menuSettings:{CHTMLpreview:!1}},(e=document.createElement("script")).onload=function(){"use strict";var e,t=window.MathJax;t.Hub.Config({tex2jax:{inlineMath:[["\\(","\\)"],["[mathjaxinline]","[/mathjaxinline]"]],displayMath:[["\\[","\\]"],["[mathjax]","[/mathjax]"]]}}),t.Hub.processSectionDelay=0,t.Hub.signal.Interest(function(t){"End Math"===t[0]&&e()}),e=function(){$(".MathJax_Display").each(function(){this.setAttribute("tabindex","0"),this.setAttribute("aria-live","off"),this.removeAttribute("role"),this.removeAttribute("aria-readonly")})}},window.MathJax={menuSettings:{collapsible:!0,autocollapse:!1,explorer:!0}},e.src="https://cdn.jsdelivr.net/npm/mathjax@2.7.5/MathJax.js?config=TeX-MML-AM_HTMLorMML",document.body.appendChild(e))}).call(window)},376(){(function(){(function(){"use strict";var e={}.hasOwnProperty;"undefined"!=typeof Backbone&&null!==Backbone&&(this.DiscussionCourseSettings=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return function(t,n){for(var i in n)e.call(n,i)&&(t[i]=n[i]);function o(){this.constructor=t}o.prototype=n.prototype,t.prototype=new o,t.__super__=n.prototype}(t,Backbone.Model),t}())}).call(this)}).call(window)},840(){(function(){(function(){"use strict";var e={}.hasOwnProperty;"undefined"!=typeof Backbone&&null!==Backbone&&(this.DiscussionUser=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return function(t,n){for(var i in n)e.call(n,i)&&(t[i]=n[i]);function o(){this.constructor=t}o.prototype=n.prototype,t.prototype=new o,t.__super__=n.prototype}(t,Backbone.Model),t.prototype.following=function(e){return _.include(this.get("subscribed_thread_ids"),e.id)},t.prototype.voted=function(e){return _.include(this.get("upvoted_ids"),e.id)},t.prototype.vote=function(e){return this.get("upvoted_ids").push(e.id),e.vote()},t.prototype.unvote=function(e){return this.set("upvoted_ids",_.without(this.get("upvoted_ids"),e.id)),e.unvote()},t}())}).call(this)}).call(window)},970(){(function(){(function(){"use strict";this.DiscussionUtil=function(){function e(){}e.wmdEditors={},e.leftKey=37,e.rightKey=39,e.getTemplate=function(e){return $("script#"+e).html()},e.setUser=function(e){this.user=e},e.getUser=function(){return this.user},e.loadRoles=function(e){this.roleIds=e},e.isStaff=function(e){var t;return _.isUndefined(e)&&(e=this.user?this.user.id:void 0),_.isUndefined(this.roleIds)&&(this.roleIds={}),t=_.union(this.roleIds.Moderator,this.roleIds.Administrator),_.include(t,parseInt(e))},e.isTA=function(e){var t;return _.isUndefined(e)&&(e=this.user?this.user.id:void 0),t=_.union(this.roleIds["Community TA"]),_.include(t,parseInt(e))},e.isGroupTA=function(e){var t,n=e;return _.isUndefined(e)&&(n=this.user?this.user.id:void 0),t=_.union(this.roleIds["Group Moderator"]),_.include(t,parseInt(n,10))},e.isPrivilegedUser=function(e){return this.isStaff(e)||this.isTA(e)},e.bulkUpdateContentInfo=function(e){var t,n,i;for(t in i=[],e)e.hasOwnProperty(t)&&(n=e[t],i.push(Content.getContent(t).updateInfo(n)));return i},e.generateDiscussionLink=function(e,t,n){return $("").addClass("discussion-link").attr("href","#").addClass(e).text(t).click(function(){return n(this)})},e.urlFor=function(e,t,n,i){return{follow_discussion:"/courses/"+$$course_id+"/discussion/"+t+"/follow",unfollow_discussion:"/courses/"+$$course_id+"/discussion/"+t+"/unfollow",create_thread:"/courses/"+$$course_id+"/discussion/"+t+"/threads/create",update_thread:"/courses/"+$$course_id+"/discussion/threads/"+t+"/update",create_comment:"/courses/"+$$course_id+"/discussion/threads/"+t+"/reply",delete_thread:"/courses/"+$$course_id+"/discussion/threads/"+t+"/delete",flagAbuse_thread:"/courses/"+$$course_id+"/discussion/threads/"+t+"/flagAbuse",unFlagAbuse_thread:"/courses/"+$$course_id+"/discussion/threads/"+t+"/unFlagAbuse",flagAbuse_comment:"/courses/"+$$course_id+"/discussion/comments/"+t+"/flagAbuse",unFlagAbuse_comment:"/courses/"+$$course_id+"/discussion/comments/"+t+"/unFlagAbuse",upvote_thread:"/courses/"+$$course_id+"/discussion/threads/"+t+"/upvote",downvote_thread:"/courses/"+$$course_id+"/discussion/threads/"+t+"/downvote",pin_thread:"/courses/"+$$course_id+"/discussion/threads/"+t+"/pin",un_pin_thread:"/courses/"+$$course_id+"/discussion/threads/"+t+"/unpin",undo_vote_for_thread:"/courses/"+$$course_id+"/discussion/threads/"+t+"/unvote",follow_thread:"/courses/"+$$course_id+"/discussion/threads/"+t+"/follow",unfollow_thread:"/courses/"+$$course_id+"/discussion/threads/"+t+"/unfollow",update_comment:"/courses/"+$$course_id+"/discussion/comments/"+t+"/update",endorse_comment:"/courses/"+$$course_id+"/discussion/comments/"+t+"/endorse",create_sub_comment:"/courses/"+$$course_id+"/discussion/comments/"+t+"/reply",delete_comment:"/courses/"+$$course_id+"/discussion/comments/"+t+"/delete",upvote_comment:"/courses/"+$$course_id+"/discussion/comments/"+t+"/upvote",downvote_comment:"/courses/"+$$course_id+"/discussion/comments/"+t+"/downvote",undo_vote_for_comment:"/courses/"+$$course_id+"/discussion/comments/"+t+"/unvote",upload:"/courses/"+$$course_id+"/discussion/upload",users:"/courses/"+$$course_id+"/discussion/users",search:"/courses/"+$$course_id+"/discussion/forum/search",retrieve_discussion:"/courses/"+$$course_id+"/discussion/forum/"+t+"/inline",retrieve_single_thread:"/courses/"+$$course_id+"/discussion/forum/"+t+"/threads/"+n,openclose_thread:"/courses/"+$$course_id+"/discussion/threads/"+t+"/close",user_profile:"/courses/"+$$course_id+"/discussion/forum/users/"+t,followed_threads:"/courses/"+$$course_id+"/discussion/forum/users/"+t+"/followed",threads:"/courses/"+$$course_id+"/discussion/forum",enable_notifications:"/notification_prefs/enable/",disable_notifications:"/notification_prefs/disable/",notifications_status:"/notification_prefs/status/"}[e]},e.ignoreEnterKey=function(e){if(13===e.which)return e.preventDefault()},e.activateOnSpace=function(e,t){if(32===e.which)return e.preventDefault(),t(e)},e.makeFocusTrap=function(e){return e.keydown(function(e){if(9===e.which)return e.preventDefault()})},e.showLoadingIndicator=function(e,t){var n=edx.HtmlUtils.joinHtml(edx.HtmlUtils.HTML("
    "),edx.HtmlUtils.HTML(""),gettext("Loading content"),edx.HtmlUtils.HTML("
    ")),i=$(n.toString());e.after(i),this.$_loading=i,t&&(this.makeFocusTrap(this.$_loading),this.$_loading.focus())},e.hideLoadingIndicator=function(){return this.$_loading.remove()},e.discussionAlert=function(e,t){var n,i,o=$("#alert-popup").html()||"";0===$("#discussion-alert").length&&(n=$(edx.HtmlUtils.template(o)({}).toString()),this.makeFocusTrap(n.find("button")),(i=$("
    ").css("display","none")).leanModal({closeButton:"#discussion-alert .dismiss",overlay:1,top:200}),$("body").append(n).append(i)),$("#discussion-alert header h2").text(e),$("#discussion-alert p").text(t),$("#discussion-alert-trigger").click(),$("#discussion-alert button").focus()},e.safeAjax=function(e){var t,n,i=this;return(t=e.$elem)&&t.prop("disabled")?((n=$.Deferred()).reject(),n.promise()):(e.url=URI(e.url).addSearch({ajax:1}),e.error||(e.error=function(){i.discussionAlert(gettext("Error"),gettext("Your request could not be processed. Refresh the page and try again."))}),t&&t.prop("disabled",!0),e.$loading&&(e.loadingCallback?e.loadingCallback.apply(e.$loading):i.showLoadingIndicator(e.$loading,e.takeFocus)),$.ajax(e).always(function(){if(t&&t.prop("disabled",!1),e.$loading)return e.loadedCallback?e.loadedCallback.apply(e.$loading):i.hideLoadingIndicator()}))},e.updateWithUndo=function(e,t,n,i,o){var r,s=this;return i&&(n.error=function(){return s.discussionAlert(gettext("Error"),i)}),r=_.pick(e.attributes,_.keys(t)),e.set(t),"function"==typeof o&&o(),this.safeAjax(n).fail(function(){return e.set(r)})},e.bindLocalEvents=function(e,t){var n,i,o,r,s,a;for(i in a=[],t)t.hasOwnProperty(i)&&(o=t[i],n=(s=i.split(" "))[0],r=s[1],a.push(e(r).unbind(n)[n](o)));return a},e.formErrorHandler=function(e){return function(t){var n,i,o,r;if(n=function(e,t){return edx.HtmlUtils.joinHtml(edx.HtmlUtils.HTML("
  • "),edx.HtmlUtils.template($("#new-post-alert-template").html())({message:e,alertId:t}),edx.HtmlUtils.HTML("
  • "))},e.empty().show(),400===t.status){if((i=JSON.parse(t.responseText)).errors)for(o=0;o"),edx.HtmlUtils.ensureHtml(e))).find("code").each(function(e,t){return a[e]=$(t).html(),$(t).text(e)}),l=(l=s.html()).replace(/\\\$/g,i);;)if(n.test(l))l=l.replace(n,function(e,t,n,i){return d+=t+r("$"+n+"$","inline"),i});else{if(!t.test(l)){d+=l;break}l=l.replace(t,function(e,t,n,i){return d+=t+r("$$"+n+"$$","display"),i})}return l=(l=(l=(l=(l=(l=d).replace(new RegExp(i,"g"),"\\$")).replace(/\\\\\\\\/g,o)).replace(/\\begin\{([a-z]*\*?)\}([\s\S]*?)\\end\{\1\}/gim,function(e,t,n){return r("\\begin{"+t+"}"+n+"\\end{"+t+"}")})).replace(new RegExp(o,"g"),"\\\\\\\\")).replace(new RegExp("{javascript:(.+?)}","g"),"{}"),(s=edx.HtmlUtils.setHtml($("
    "),edx.HtmlUtils.HTML(l))).find("code").each(function(e,t){edx.HtmlUtils.setHtml($(t),edx.HtmlUtils.HTML(r(a[e],"code")))}),edx.HtmlUtils.HTML(s.html())},e.unescapeHighlightTag=function(e){return edx.HtmlUtils.HTML(e.toString().replace(/\<\;highlight\>\;/g,"").replace(/\<\;\/highlight\>\;/g,""))},e.stripHighlight=function(e){return e.replace(/\&(amp\;)?lt\;highlight\&(amp\;)?gt\;/g,"").replace(/\&(amp\;)?lt\;\/highlight\&(amp\;)?gt\;/g,"")},e.stripLatexHighlight=function(e){return this.processEachMathAndCode(e,this.stripHighlight)},e.markdownWithHighlight=function(e){var t;e=e.replace(/^\>\;/gm,">"),t=Markdown.getMathCompatibleConverter();var n=edx.HtmlUtils.HTML(t.makeHtml(e));return this.unescapeHighlightTag(this.stripLatexHighlight(n))},e.abbreviateString=function(e,t){if(e.length"),o,edx.HtmlUtils.HTML("
    ")).toString())).find("img:not(:first)")).length>0&&edx.HtmlUtils.append(n,edx.HtmlUtils.interpolateHtml(edx.HtmlUtils.HTML("

    {text}

    "),{text:gettext("Some images in this post have been omitted")}));var r=edx.HtmlUtils.interpolateHtml(edx.HtmlUtils.HTML("{text}"),{text:gettext("image omitted")});return i.after(edx.HtmlUtils.ensureHtml(r).toString()).remove(),n.html()},e.getPaginationParams=function(e,t,n){var i,o,r;return o=Math.max(e-2,1),i=Math.min(e+2,t),r=function(e){return{number:e,url:n(e)}},{page:e,lowPages:_.range(o,e).map(r),highPages:_.range(e+1,i+1).map(r),previous:e>1?r(e-1):null,next:e2,rightdots:i1?r(1):null,last:i0,a&&d&&(s=i.index(t),r=o===this.leftKey?s-1:s+1,r=Math.max(Math.min(r,i.length-1),0),n=$(i[r]),this.moveSelectionToNextItem(t,n))},e.moveSelectionToNextItem=function(e,t){e.attr("aria-selected","false"),e.attr("tabindex","-1"),t.attr("aria-selected","true"),t.attr("tabindex","0"),t.focus()},e}.call(this)}).call(window)}).call(window)},760(){(function(){(function(){"use strict";var e={}.hasOwnProperty,t=function(t,n){for(var i in n)e.call(n,i)&&(t[i]=n[i]);function o(){this.constructor=t}return o.prototype=n.prototype,t.prototype=new o,t.__super__=n.prototype,t};"undefined"!=typeof Backbone&&null!==Backbone&&(this.DiscussionContentView=function(e){function n(){var e=this;return this.setWmdContent=function(){return n.prototype.setWmdContent.apply(e,arguments)},this.getWmdContent=function(){return n.prototype.getWmdContent.apply(e,arguments)},this.getWmdEditor=function(){return n.prototype.getWmdEditor.apply(e,arguments)},this.makeWmdEditor=function(){return n.prototype.makeWmdEditor.apply(e,arguments)},n.__super__.constructor.apply(this,arguments)}return t(n,e),n.prototype.events={"click .discussion-flag-abuse":"toggleFlagAbuse","keydown .discussion-flag-abuse":function(e){return DiscussionUtil.activateOnSpace(e,this.toggleFlagAbuse)}},n.prototype.attrRenderer={ability:function(e){var t,n,i,o;for(t in o=[],i=this.abilityRenderer)i.hasOwnProperty(t)&&(n=i[t],e[t]?o.push(n.enable.apply(this)):o.push(n.disable.apply(this)));return o}},n.prototype.abilityRenderer={editable:{enable:function(){return this.$(".action-edit").closest(".actions-item").removeClass("is-hidden")},disable:function(){return this.$(".action-edit").closest(".actions-item").addClass("is-hidden")}},can_delete:{enable:function(){return this.$(".action-delete").closest(".actions-item").removeClass("is-hidden")},disable:function(){return this.$(".action-delete").closest(".actions-item").addClass("is-hidden")}},can_openclose:{enable:function(){var e=this;return _.each([".action-close",".action-pin"],function(t){return e.$(t).closest(".actions-item").removeClass("is-hidden")})},disable:function(){var e=this;return _.each([".action-close",".action-pin"],function(t){return e.$(t).closest(".actions-item").addClass("is-hidden")})}},can_report:{enable:function(){return this.$(".action-report").closest(".actions-item").removeClass("is-hidden")},disable:function(){return this.$(".action-report").closest(".actions-item").addClass("is-hidden")}},can_vote:{enable:function(){this.$(".action-vote").closest(".actions-item").removeClass("is-disabled")},disable:function(){this.$(".action-vote").closest(".actions-item").addClass("is-disabled")}}},n.prototype.renderPartialAttrs=function(){var e,t,n,i;for(e in i=[],n=this.model.changedAttributes())n.hasOwnProperty(e)&&(t=n[e],this.attrRenderer[e]?i.push(this.attrRenderer[e].apply(this,[t])):i.push(void 0));return i},n.prototype.renderAttrs=function(){var e,t,n,i;for(e in i=[],n=this.model.attributes)n.hasOwnProperty(e)&&(t=n[e],this.attrRenderer[e]?i.push(this.attrRenderer[e].apply(this,[t])):i.push(void 0));return i},n.prototype.makeWmdEditor=function(e){return this.$el.find(".wmd-panel").length?null:DiscussionUtil.makeWmdEditor(this.$el,$.proxy(this.$,this),e)},n.prototype.getWmdEditor=function(e){return DiscussionUtil.getWmdEditor(this.$el,$.proxy(this.$,this),e)},n.prototype.getWmdContent=function(e){return DiscussionUtil.getWmdContent(this.$el,$.proxy(this.$,this),e)},n.prototype.setWmdContent=function(e,t){return DiscussionUtil.setWmdContent(this.$el,$.proxy(this.$,this),e,t)},n.prototype.initialize=function(){var e=this;return this.model.bind("change",this.renderPartialAttrs,this),this.listenTo(this.model,"change:endorsed",function(){e.model instanceof Comment&&e.trigger("comment:endorse")})},n}(Backbone.View),this.DiscussionContentShowView=function(e){function n(){var e=this;return this.toggleClose=function(){return n.prototype.toggleClose.apply(e,arguments)},this.toggleReport=function(){return n.prototype.toggleReport.apply(e,arguments)},this.togglePin=function(){return n.prototype.togglePin.apply(e,arguments)},this.toggleVote=function(){return n.prototype.toggleVote.apply(e,arguments)},this.toggleEndorse=function(){return n.prototype.toggleEndorse.apply(e,arguments)},this.toggleFollow=function(){return n.prototype.toggleFollow.apply(e,arguments)},this.handleSecondaryActionBlur=function(){return n.prototype.handleSecondaryActionBlur.apply(e,arguments)},this.handleSecondaryActionEscape=function(){return n.prototype.handleSecondaryActionEscape.apply(e,arguments)},this.toggleSecondaryActions=function(){return n.prototype.toggleSecondaryActions.apply(e,arguments)},this.updateButtonState=function(){return n.prototype.updateButtonState.apply(e,arguments)},n.__super__.constructor.apply(this,arguments)}return t(n,e),n.prototype.events=_.reduce([[".action-follow","toggleFollow"],[".action-answer","toggleEndorse"],[".action-endorse","toggleEndorse"],[".action-vote","toggleVote"],[".action-more","toggleSecondaryActions"],[".action-pin","togglePin"],[".action-edit","edit"],[".action-delete","_delete"],[".action-report","toggleReport"],[".action-close","toggleClose"]],function(e,t){var n,i;return i=t[0],n=t[1],e["click "+i]=function(e){return this[n](e)},e["keydown "+i]=function(e){return DiscussionUtil.activateOnSpace(e,this[n])},e},{}),n.prototype.updateButtonState=function(e,t){var n;return(n=this.$(e)).toggleClass("is-checked",t),n.attr("aria-checked",t)},n.prototype.attrRenderer=$.extend({},DiscussionContentView.prototype.attrRenderer,{subscribed:function(e){return this.updateButtonState(".action-follow",e)},endorsed:function(e){var t,n;return n="question"===this.model.get("thread").get("thread_type")?".action-answer":".action-endorse",this.updateButtonState(n,e),(t=this.$(n)).closest(".actions-item").toggleClass("is-hidden",!this.model.canBeEndorsed()),t.toggleClass("is-checked",e)},votes:function(e){var t,n,i,o,r;i=".action-vote",this.updateButtonState(i,window.user.voted(this.model)),t=this.$el.find(i),n=e.up_count,r=ngettext("there is currently {numVotes} vote","there are currently {numVotes} votes",n),t.find(".js-sr-vote-count").empty().text(edx.StringUtils.interpolate(r,{numVotes:n})),o=edx.StringUtils.interpolate(ngettext("{numVotes} Vote","{numVotes} Votes",n),{numVotes:n}),t.find(".vote-count").empty().text(o),this.$el.find(".display-vote .vote-count").empty().text(o)},pinned:function(e){return this.updateButtonState(".action-pin",e),this.$(".post-label-pinned").toggleClass("is-hidden",!e)},abuse_flaggers:function(){var e;return e=this.model.isFlagged(),this.updateButtonState(".action-report",e),this.$(".post-label-reported").toggleClass("is-hidden",!e)},closed:function(e){return this.updateButtonState(".action-close",e),this.$(".post-label-closed").toggleClass("is-hidden",!e),this.$(".display-vote").toggle(e)}}),n.prototype.toggleSecondaryActions=function(e){return e.preventDefault(),e.stopPropagation(),this.secondaryActionsExpanded=!this.secondaryActionsExpanded,this.$(".action-more").toggleClass("is-expanded",this.secondaryActionsExpanded),this.$(".actions-dropdown").toggleClass("is-expanded",this.secondaryActionsExpanded).attr("aria-expanded",this.secondaryActionsExpanded),this.secondaryActionsExpanded?("keydown"===e.type&&this.$(".action-list-item:first").focus(),$("body").on("click",this.toggleSecondaryActions),$("body").on("keydown",this.handleSecondaryActionEscape),this.$(".action-list-item").on("blur",this.handleSecondaryActionBlur)):($("body").off("click",this.toggleSecondaryActions),$("body").off("keydown",this.handleSecondaryActionEscape),this.$(".action-list-item").off("blur",this.handleSecondaryActionBlur))},n.prototype.handleSecondaryActionEscape=function(e){27===e.keyCode&&(this.toggleSecondaryActions(e),this.$(".action-more").focus())},n.prototype.handleSecondaryActionBlur=function(e){var t=this;return setTimeout(function(){t.secondaryActionsExpanded&&0===t.$(".actions-dropdown :focus").length&&t.toggleSecondaryActions(e)},10)},n.prototype.toggleFollow=function(e){var t,n,i;return e.preventDefault(),t=!this.model.get("subscribed"),i=this.model.urlFor(t?"follow":"unfollow"),n=t?gettext("You could not be subscribed to this post. Refresh the page and try again."):gettext("You could not be unsubscribed from this post. Refresh the page and try again."),DiscussionUtil.updateWithUndo(this.model,{subscribed:t},{url:i,type:"POST",$elem:$(e.currentTarget)},n)},n.prototype.toggleEndorse=function(e){var t,n,i,o,r=this;return e.preventDefault(),t=!this.model.get("endorsed"),o=this.model.urlFor("endorse"),i={endorsed:t,endorsement:t?{username:DiscussionUtil.getUser().get("username"),user_id:DiscussionUtil.getUser().id,time:(new Date).toISOString()}:null},n="question"===this.model.get("thread").get("thread_type")?t?gettext("This response could not be marked as an answer. Refresh the page and try again."):gettext("This response could not be unmarked as an answer. Refresh the page and try again."):t?gettext("This response could not be marked as endorsed. Refresh the page and try again."):gettext("This response could not be unendorsed. Refresh the page and try again."),DiscussionUtil.updateWithUndo(this.model,i,{url:o,type:"POST",data:{endorsed:t},$elem:$(e.currentTarget)},n,function(){return r.trigger("comment:endorse")}).always(this.trigger("comment:endorse"))},n.prototype.toggleVote=function(e){var t,n,i,o,r=this;if(e.preventDefault(),o=DiscussionUtil.getUser(),t=!o.voted(this.model),i=this.model.urlFor(t?"upvote":"unvote"),n={upvoted_ids:(t?_.union:_.difference)(o.get("upvoted_ids"),[this.model.id])},!$(e.target.closest(".actions-item")).hasClass("is-disabled"))return DiscussionUtil.updateWithUndo(o,n,{url:i,type:"POST",$elem:$(e.currentTarget)},gettext("This vote could not be processed. Refresh the page and try again.")).done(function(){return t?r.model.vote():r.model.unvote()})},n.prototype.togglePin=function(e){var t,n,i;return e.preventDefault(),t=!this.model.get("pinned"),i=this.model.urlFor(t?"pinThread":"unPinThread"),n=t?gettext("This post could not be pinned. Refresh the page and try again."):gettext("This post could not be unpinned. Refresh the page and try again."),DiscussionUtil.updateWithUndo(this.model,{pinned:t},{url:i,type:"POST",$elem:$(e.currentTarget)},n)},n.prototype.toggleReport=function(e){var t,n,i,o;return e.preventDefault(),this.model.isFlagged()?(t=!1,n=gettext("This post could not be flagged for abuse. Refresh the page and try again.")):(t=!0,n=gettext("This post could not be unflagged for abuse. Refresh the page and try again.")),o=this.model.urlFor(t?"flagAbuse":"unFlagAbuse"),i={abuse_flaggers:(t?_.union:_.difference)(this.model.get("abuse_flaggers"),[DiscussionUtil.getUser().id])},DiscussionUtil.updateWithUndo(this.model,i,{url:o,type:"POST",$elem:$(e.currentTarget)},n)},n.prototype.toggleClose=function(e){var t,n,i;return e.preventDefault(),n=(t=!this.model.get("closed"))?gettext("This post could not be closed. Refresh the page and try again."):gettext("This post could not be reopened. Refresh the page and try again."),i={closed:t},DiscussionUtil.updateWithUndo(this.model,i,{url:this.model.urlFor("close"),type:"POST",data:i,$elem:$(e.currentTarget)},n)},n.prototype.getAuthorDisplay=function(){return _.template($("#post-user-display-template").html())({username:this.model.get("username")||null,user_url:this.model.get("user_url"),is_community_ta:this.model.get("community_ta_authored"),is_staff:this.model.get("staff_authored")})},n.prototype.getEndorserDisplay=function(){var e;return(e=this.model.get("endorsement"))&&e.username?_.template($("#post-user-display-template").html())({username:e.username,user_url:DiscussionUtil.urlFor("user_profile",e.user_id),is_community_ta:DiscussionUtil.isTA(e.user_id)||DiscussionUtil.isGroupTA(e.user_id),is_staff:DiscussionUtil.isStaff(e.user_id)}):null},n}.call(this,this.DiscussionContentView))}).call(window)}).call(window)},368(){(function(){(function(){"use strict";this.DiscussionInlineView=Backbone.View.extend({events:{"click .discussion-show":"toggleDiscussion","keydown .discussion-show":function(e){return DiscussionUtil.activateOnSpace(e,this.toggleDiscussion)},"click .new-post-btn":"toggleNewPost","click .all-posts-btn":"navigateToAllPosts",keydown:"handleKeydown","keydown .new-post-btn":function(e){return DiscussionUtil.activateOnSpace(e,this.toggleNewPost)}},page_re:/\?discussion_page=(\d+)/,initialize:function(e){var t;this.$el=e.el,this.readOnly=e.readOnly,this.toggleDiscussionBtn=this.$(".discussion-show"),this.listenTo(this.model,"change",this.render),this.escKey=27,void 0!==e.startHeader?this.startHeader=e.startHeader:this.startHeader=4,t=this.page_re.exec(window.location.href),this.page=t?parseInt(t[1],10):1,this.defaultSortKey="activity",this.defaultSortOrder="desc",this.toggleDiscussion()},loadDiscussions:function(e,t){var n=this.$el.data("discussion-id"),i=DiscussionUtil.urlFor("retrieve_discussion",n)+"?page="+this.page+"&sort_key="+this.defaultSortKey+"&sort_order="+this.defaultSortOrder,o=this;DiscussionUtil.safeAjax({$elem:this.$el,$loading:this.$el,takeFocus:!1,url:i,type:"GET",dataType:"json",success:function(e,t){o.renderDiscussion(o.$el,e,t,n)},error:t})},renderDiscussion:function(e,t,n,i){var o,r=new DiscussionUser(t.user_info);e.focus(),window.user=r,DiscussionUtil.setUser(r),Content.loadContentInfos(t.annotated_content_info),DiscussionUtil.loadRoles(t.roles),this.courseSettings=new DiscussionCourseSettings(t.course_settings),this.is_commentable_divided=t.is_commentable_divided,this.discussion=new Discussion(void 0,{pages:t.num_pages}),this.discussion.reset(t.discussion_data,{silent:!1}),o=edx.HtmlUtils.template($("#inline-discussion-template").html())({threads:t.discussion_data,read_only:this.readOnly,discussionId:i}),this.$("section.discussion").length?(edx.HtmlUtils.setHtml(this.$el,o),this.$("section.discussion").replaceWith(edx.HtmlUtils.ensureHtml(o).toString())):edx.HtmlUtils.append(this.$el,o),this.threadListView=new DiscussionThreadListView({el:this.$(".inline-threads"),collection:this.discussion,courseSettings:this.courseSettings}),this.threadListView.render(),this.threadListView.on("thread:selected",_.bind(this.navigateToThread,this)),DiscussionUtil.bulkUpdateContentInfo(window.$$annotated_content_info),this.newPostForm=this.$el.find(".new-post-article"),this.newPostView=new NewPostView({el:this.newPostForm,collection:this.discussion,course_settings:this.courseSettings,topicId:i,startHeader:this.startHeader,is_commentable_divided:t.is_commentable_divided,user_group_id:t.user_group_id}),this.newPostView.render(),this.listenTo(this.newPostView,"newPost:createPost",this.onNewPostCreated),this.listenTo(this.newPostView,"newPost:cancel",this.hideNewPost),this.discussion.on("add",this.addThread),this.retrieved=!0,this.showed=!0,this.isWaitingOnNewPost&&this.newPostForm.removeClass("is-hidden").focus(),this.$(".inline-thread").addClass("is-hidden")},navigateToThread:function(e){var t=this.discussion.get(e);this.threadView=new DiscussionThreadView({el:this.$(".forum-content"),model:t,mode:"inline",startHeader:this.startHeader,courseSettings:this.courseSettings,is_commentable_divided:this.is_commentable_divided}),this.threadView.render(),this.listenTo(this.threadView.showView,"thread:_delete",this.navigateToAllPosts),this.$(".forum-nav-thread[data-id='"+e+"']").removeClass("never-read"),this.threadListView.$el.addClass("is-hidden"),this.$(".inline-thread").removeClass("is-hidden")},navigateToAllPosts:function(){this.$(".inline-thread").addClass("is-hidden"),this.threadView&&(this.threadView.$el.empty().off(),this.threadView.stopListening(),this.threadView=null),this.threadListView.$el.removeClass("is-hidden"),this.threadListView.$(".is-active").focus()},hideDiscussion:function(){this.$("section.discussion").addClass("is-hidden"),this.toggleDiscussionBtn.removeClass("shown"),this.toggleDiscussionBtn.find(".button-text").text(gettext("Show Discussion")),this.showed=!1},toggleDiscussion:function(){var e=this;this.showed?this.hideDiscussion():(this.toggleDiscussionBtn.addClass("shown"),this.toggleDiscussionBtn.find(".button-text").text(gettext("Hide Discussion")),this.retrieved?(this.$("section.discussion").removeClass("is-hidden"),this.showed=!0):this.loadDiscussions(this.$el,function(t){403===t.status&&t.responseText?(DiscussionUtil.discussionAlert(gettext("Warning"),t.responseText),e.$el.text(t.responseText),e.showed=!0):(e.hideDiscussion(),DiscussionUtil.discussionAlert(gettext("Error"),gettext("This discussion could not be loaded. Refresh the page and try again.")))}))},toggleNewPost:function(e){if(e.preventDefault(),!this.newPostForm)return this.toggleDiscussion(),void(this.isWaitingOnNewPost=!0);this.showed&&(this.$("section.discussion").find(".inline-discussion-thread-container").addClass("is-hidden"),this.$("section.discussion").find(".add_post_btn_container").addClass("is-hidden"),this.newPostForm.removeClass("is-hidden")),this.newPostView.$el.removeClass("is-hidden"),this.toggleDiscussionBtn.addClass("shown"),this.toggleDiscussionBtn.find(".button-text").text(gettext("Hide Discussion")),this.showed=!0},onNewPostCreated:function(){this.navigateToAllPosts(),this.hideNewPost()},hideNewPost:function(){this.$("section.discussion").find(".inline-discussion-thread-container").removeClass("is-hidden"),this.$("section.discussion").find(".add_post_btn_container").removeClass("is-hidden").focus(),this.newPostForm.addClass("is-hidden")},handleKeydown:function(e){e.keyCode===this.escKey&&this.$("section.discussion").find(".cancel").trigger("click")}})}).call(window)}).call(window)},156(){(function(){(function(){"use strict";Backbone&&(this.DiscussionThreadEditView=Backbone.View.extend({tagName:"form",events:{submit:"updateHandler","click .post-cancel":"cancelHandler","keypress input:not(.wmd-input)":function(e){return DiscussionUtil.ignoreEnterKey(e)}},attributes:{class:"discussion-post edit-post-form"},initialize:function(e){return this.container=e.container||$(".thread-content-wrapper"),this.mode=e.mode||"inline",this.startHeader=e.startHeader,this.course_settings=e.course_settings,this.threadType=this.model.get("thread_type"),this.topicId=this.model.get("commentable_id"),this.context=e.context||"course",_.bindAll(this,"updateHandler","cancelHandler"),this},render:function(){var e,t=_.uniqueId("form-"),n=edx.HtmlUtils.template($("#thread-type-template").html()),i=$(n({form_id:t}).toString()),o=edx.HtmlUtils.template($("#thread-edit-template").html());return e=$.extend({mode:this.mode,startHeader:this.startHeader},this.model.attributes),edx.HtmlUtils.setHtml(this.$el,o(e)),this.container.append(this.$el),this.$submitBtn=this.$(".post-update"),this.addField(i),this.$("#"+t+"-post-type-"+this.threadType).attr("checked",!0),this.isTabMode()&&(this.topicView=new DiscussionTopicMenuView({topicId:this.topicId,course_settings:this.course_settings}),this.addField(this.topicView.render())),DiscussionUtil.makeWmdEditor(this.$el,$.proxy(this.$,this),"edit-post-body"),this},addField:function(e){return this.$(".forum-edit-post-form-wrapper").append(e),this},isTabMode:function(){return"tab"===this.mode},save:function(){var e=this.$(".edit-post-title").val(),t=this.$(".input-radio:checked").val(),n=this.$(".edit-post-body textarea").val(),i={title:e,thread_type:t,body:n};return this.topicView&&(i.commentable_id=this.topicView.getCurrentTopicId()),DiscussionUtil.safeAjax({$elem:this.$submitBtn,$loading:this.$submitBtn,url:DiscussionUtil.urlFor("update_thread",this.model.id),type:"POST",dataType:"json",data:i,error:DiscussionUtil.formErrorHandler(this.$(".post-errors")),success:function(){this.$(".edit-post-title").val("").attr("prev-text",""),this.$(".edit-post-body textarea").val("").attr("prev-text",""),this.$(".wmd-preview p").html(""),this.topicView&&(i.courseware_title=this.topicView.getFullTopicName()),this.model.set(i).unset("abbreviatedBody"),this.trigger("thread:updated"),this.threadType!==t&&(this.model.set("thread_type",t),this.model.trigger("thread:thread_type_updated"),this.trigger("comment:endorse"))}.bind(this)})},updateHandler:function(e){return e.preventDefault(),this.trigger("thread:update",e),this.save(),this},cancelHandler:function(e){return e.preventDefault(),this.trigger("thread:cancel_edit",e),this.remove(),this}}))}).call(window)}).call(window)},556(){(function(){(function(){"use strict";var e={}.hasOwnProperty;"undefined"!=typeof Backbone&&null!==Backbone&&(this.DiscussionThreadListView=function(t){function n(){var e=this;return this.updateEmailNotifications=function(){return n.prototype.updateEmailNotifications.apply(e,arguments)},this.retrieveFollowed=function(){return n.prototype.retrieveFollowed.apply(e,arguments)},this.chooseGroup=function(){return n.prototype.chooseGroup.apply(e,arguments)},this.chooseFilter=function(){return n.prototype.chooseFilter.apply(e,arguments)},this.threadRemoved=function(){return n.prototype.threadRemoved.apply(e,arguments)},this.threadSelected=function(){return n.prototype.threadSelected.apply(e,arguments)},this.renderThread=function(){return n.prototype.renderThread.apply(e,arguments)},this.loadMorePages=function(){return n.prototype.loadMorePages.apply(e,arguments)},this.showMetadataAccordingToSort=function(){return n.prototype.showMetadataAccordingToSort.apply(e,arguments)},this.renderThreads=function(){return n.prototype.renderThreads.apply(e,arguments)},this.addAndSelectThread=function(){return n.prototype.addAndSelectThread.apply(e,arguments)},this.reloadDisplayedCollection=function(){return n.prototype.reloadDisplayedCollection.apply(e,arguments)},this.clearSearchAlerts=function(){return n.prototype.clearSearchAlerts.apply(e,arguments)},this.removeSearchAlert=function(){return n.prototype.removeSearchAlert.apply(e,arguments)},this.addSearchAlert=function(){return n.prototype.addSearchAlert.apply(e,arguments)},this.performSearch=function(){return n.prototype.performSearch.apply(e,arguments)},n.__super__.constructor.apply(this,arguments)}return function(t,n){for(var i in n)e.call(n,i)&&(t[i]=n[i]);function o(){this.constructor=t}o.prototype=n.prototype,t.prototype=new o,t.__super__=n.prototype}(n,t),n.prototype.events={"keypress .forum-nav-browse-filter-input":function(e){return DiscussionUtil.ignoreEnterKey(e)},"change .forum-nav-sort-control":"sortThreads","click .forum-nav-thread-link":"threadSelected","click .forum-nav-load-more-link":"loadMorePages","change .forum-nav-filter-main-control":"chooseFilter","change .forum-nav-filter-cohort-control":"chooseGroup"},n.prototype.initialize=function(e){var t=this;this.courseSettings=e.courseSettings,this.supportsActiveThread=e.supportsActiveThread,this.hideReadState=e.hideReadState||!1,this.displayedCollection=new Discussion(this.collection.models,{pages:this.collection.pages}),this.collection.on("change",this.reloadDisplayedCollection),this.discussionIds=this.$el.data("discussion-id")||"",this.collection.on("reset",function(e){return t.displayedCollection.current_page=e.current_page,t.displayedCollection.pages=e.pages,t.displayedCollection.reset(e.models)}),this.collection.on("add",this.addAndSelectThread),this.collection.on("thread:remove",this.threadRemoved),this.sidebar_padding=10,this.boardName=null,this.current_search="",this.mode=e.mode||"commentables",this.showThreadPreview=!0,this.searchAlertCollection=new Backbone.Collection([],{model:Backbone.Model}),this.searchAlertCollection.on("add",function(e){var n;return n=edx.HtmlUtils.template($("#search-alert-template").html())({messageHtml:e.attributes.message,cid:e.cid,css_class:e.attributes.css_class}),edx.HtmlUtils.append(t.$(".search-alerts"),n),t.$("#search-alert-"+e.cid+" .dismiss").bind("click",e,function(e){return t.removeSearchAlert(e.data.cid)})}),this.searchAlertCollection.on("remove",function(e){return t.$("#search-alert-"+e.cid).remove()}),this.searchAlertCollection.on("reset",function(){return t.$(".search-alerts").empty()}),this.template=edx.HtmlUtils.template($("#thread-list-template").html()),this.threadListItemTemplate=edx.HtmlUtils.template($("#thread-list-item-template").html())},n.prototype.addSearchAlert=function(e,t){var n=new Backbone.Model({message:e,css_class:t||""});return this.searchAlertCollection.add(n),n},n.prototype.removeSearchAlert=function(e){return this.searchAlertCollection.remove(e)},n.prototype.clearSearchAlerts=function(){return this.searchAlertCollection.reset()},n.prototype.reloadDisplayedCollection=function(e){var t,n,i,o;this.clearSearchAlerts(),o=e.get("id"),n=this.renderThread(e),t=0!==(i=this.$(".forum-nav-thread[data-id="+o+"]")).has(".forum-nav-thread-link.is-active").length,i.replaceWith(n),this.showMetadataAccordingToSort(),this.supportsActiveThread&&t&&this.setActiveThread(o)},n.prototype.addAndSelectThread=function(e){var t=e.get("commentable_id"),n=this;return this.retrieveDiscussion(t,function(){return n.trigger("thread:created",e.get("id"))})},n.prototype.ignoreClick=function(e){return e.stopPropagation()},n.prototype.render=function(){var e=this;return this.timer=0,this.$el.empty(),edx.HtmlUtils.append(this.$el,this.template({isDiscussionDivisionEnabled:this.courseSettings.get("is_discussion_division_enabled"),isPrivilegedUser:DiscussionUtil.isPrivilegedUser()})),this.hideReadState&&this.$(".forum-nav-filter-main").addClass("is-hidden"),this.$(".forum-nav-sort-control option").removeProp("selected"),this.$(".forum-nav-sort-control option[value="+this.collection.sort_preference+"]").prop("selected",!0),this.displayedCollection.on("reset",this.renderThreads),this.displayedCollection.on("thread:remove",this.renderThreads),this.displayedCollection.on("change:commentable_id",function(){"commentables"===e.mode&&e.retrieveDiscussions(e.discussionIds.split(","))}),this.renderThreads(),this},n.prototype.renderThreads=function(){var e,t,n,i;for(this.$(".forum-nav-thread-list").empty(),n=0,i=this.displayedCollection.models.length;n1;return t||n},n.prototype.renderThread=function(e){var t=e.get("comments_count"),n=e.get("unread_comments_count"),i=!e.get("read")&&n===t,o=this.containsMarkup(e.get("body"))?"":e.get("body"),r=_.extend({neverRead:i,threadUrl:e.urlFor("retrieve"),threadPreview:o,showThreadPreview:this.showThreadPreview,hideReadState:this.hideReadState},e.toJSON()),s=$(this.threadListItemTemplate(r).toString()),a=s.find(".thread-preview-body").text();return a=(new DOMParser).parseFromString(a,"text/html").documentElement.textContent,s.find(".thread-preview-body").text(a),s},n.prototype.threadSelected=function(e){var t;return t=$(e.target).closest(".forum-nav-thread").attr("data-id"),this.supportsActiveThread&&this.setActiveThread(t),this.trigger("thread:selected",t),!1},n.prototype.threadRemoved=function(e){this.trigger("thread:removed",e)},n.prototype.setActiveThread=function(e){var t;this.$(".forum-nav-thread-link").find(".sr").remove(),this.$(".forum-nav-thread[data-id!='"+e+"'] .forum-nav-thread-link").removeClass("is-active"),t=edx.HtmlUtils.joinHtml(edx.HtmlUtils.HTML(''),edx.HtmlUtils.ensureHtml(gettext("Current conversation")),edx.HtmlUtils.HTML("")).toString(),this.$(".forum-nav-thread[data-id='"+e+"'] .forum-nav-thread-link").addClass("is-active").find(".forum-nav-thread-wrapper-1").prepend(t)},n.prototype.selectTopic=function(e){var t,n;return(n=e.closest(".forum-nav-browse-menu-item")).hasClass("forum-nav-browse-menu-all")?(this.discussionIds="",this.$(".forum-nav-filter-cohort").show(),this.retrieveAllThreads()):n.hasClass("forum-nav-browse-menu-following")?(this.retrieveFollowed(),this.$(".forum-nav-filter-cohort").hide()):(t=n.find(".forum-nav-browse-menu-item").andSelf().filter("[data-discussion-id]").map(function(e,t){return $(t).data("discussion-id")}).get(),this.retrieveDiscussions(t),this.$(".forum-nav-filter-cohort").toggle(!0===n.data("divided")))},n.prototype.chooseFilter=function(){return this.filter=$(".forum-nav-filter-main-control :selected").val(),this.clearSearchAlerts(),this.retrieveFirstPage()},n.prototype.chooseGroup=function(){return this.group_id=this.$(".forum-nav-filter-cohort-control :selected").val(),this.retrieveFirstPage()},n.prototype.retrieveDiscussion=function(e,t){var n=DiscussionUtil.urlFor("retrieve_discussion",e),i=this;return DiscussionUtil.safeAjax({url:n,type:"GET",success:function(e){i.collection.current_page=e.page,i.collection.pages=e.num_pages,i.collection.reset(e.discussion_data),Content.loadContentInfos(e.annotated_content_info),i.displayedCollection.reset(i.collection.models),t&&t()}})},n.prototype.retrieveDiscussions=function(e){return this.discussionIds=e.join(","),this.mode="commentables",this.retrieveFirstPage()},n.prototype.retrieveAllThreads=function(){return this.mode="all",this.retrieveFirstPage()},n.prototype.retrieveFirstPage=function(e){return this.collection.current_page=0,this.$(".forum-nav-thread-list").empty(),this.collection.models=[],this.loadMorePages(e)},n.prototype.sortThreads=function(e){return this.displayedCollection.setSortComparator(this.$(".forum-nav-sort-control").val()),this.retrieveFirstPage(e)},n.prototype.performSearch=function(e){this.trigger("search:initiated"),this.searchFor(e.val(),e)},n.prototype.searchFor=function(e,t){var n=DiscussionUtil.urlFor("search"),i=this;return this.clearSearchAlerts(),this.clearFilters(),this.mode="search",this.current_search=e,DiscussionUtil.safeAjax({$elem:t,data:{text:e},url:n,type:"GET",dataType:"json",$loading:$,loadingCallback:function(){var e=i.$(".forum-nav-thread-list");e.empty(),edx.HtmlUtils.append(e,edx.HtmlUtils.joinHtml(edx.HtmlUtils.HTML("
  • "),i.getLoadingContent(gettext("Loading posts list")),edx.HtmlUtils.HTML("
  • ")))},loadedCallback:function(){return i.$(".forum-nav-thread-list .forum-nav-load-more").remove()},success:function(t,n){var o,r;return"success"===n&&(i.collection.reset(t.discussion_data),i.clearSearchAlerts(),Content.loadContentInfos(t.annotated_content_info),i.collection.current_page=t.page,i.collection.pages=t.num_pages,_.isNull(t.corrected_text)?0===t.discussion_data.length&&(i.addSearchAlert(gettext("No posts matched your query.")),i.displayedCollection.models=[]):(r=_.escape(gettext("No results found for {original_query}. Showing results for {suggested_query}.")),o=edx.HtmlUtils.interpolateHtml(r,{original_query:edx.HtmlUtils.joinHtml(edx.HtmlUtils.HTML(""),e,edx.HtmlUtils.HTML("")),suggested_query:edx.HtmlUtils.joinHtml(edx.HtmlUtils.HTML(""),t.corrected_text,edx.HtmlUtils.HTML(""))}),i.addSearchAlert(o)),0!==i.collection.models.length&&i.displayedCollection.reset(i.collection.models),e)?i.searchForUser(e):t}})},n.prototype.searchForUser=function(e){var t=this;return DiscussionUtil.safeAjax({data:{username:e},url:DiscussionUtil.urlFor("users"),type:"GET",dataType:"json",error:function(){},success:function(e){var n,i;e.users.length>0&&(i=edx.HtmlUtils.joinHtml(edx.HtmlUtils.interpolateHtml(edx.HtmlUtils.HTML('
    '),{url:DiscussionUtil.urlFor("user_profile",e.users[0].id)}),e.users[0].username,edx.HtmlUtils.HTML("")),n=edx.HtmlUtils.interpolateHtml(gettext("Show posts by {username}."),{username:i}),t.addSearchAlert(n,"search-by-user"))}})},n.prototype.clearFilters=function(){return this.$(".forum-nav-filter-main-control").val("all"),this.$(".forum-nav-filter-cohort-control").val("all")},n.prototype.retrieveFollowed=function(){return this.mode="followed",this.retrieveFirstPage()},n.prototype.updateEmailNotifications=function(){var e,t,n;e=$("input.email-setting"),n=(t=e.prop("checked"))?"enable_notifications":"disable_notifications",DiscussionUtil.safeAjax({url:DiscussionUtil.urlFor(n),type:"POST",error:function(){e.prop("checked",!t)}})},n}.call(this,Backbone.View))}).call(window)}).call(window)},669(){(function(){(function(){"use strict";var e={}.hasOwnProperty;"undefined"!=typeof Backbone&&null!==Backbone&&(this.DiscussionThreadProfileView=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return function(t,n){for(var i in n)e.call(n,i)&&(t[i]=n[i]);function o(){this.constructor=t}o.prototype=n.prototype,t.prototype=new o,t.__super__=n.prototype}(t,Backbone.View),t.prototype.render=function(){var e;return this.convertMath(),this.abbreviateBody(),e=$.extend(this.model.toJSON(),{permalink:this.model.urlFor("retrieve")}),this.model.get("anonymous")||(e=$.extend(e,{user:{username:this.model.username,user_url:this.model.user_url}})),edx.HtmlUtils.setHtml(this.$el,edx.HtmlUtils.template($("#profile-thread-template").html())(e)),this.$("span.timeago").timeago(),DiscussionUtil.typesetMathJax(this.$(".post-body")),this},t.prototype.convertMath=function(){var e=DiscussionUtil.markdownWithHighlight(this.model.get("body"));this.model.set("markdownBody",e)},t.prototype.abbreviateBody=function(){var e;e=DiscussionUtil.abbreviateHTML(this.model.get("markdownBody"),140),this.model.set("abbreviatedBody",e)},t}())}).call(window)}).call(window)},935(){(function(){(function(){"use strict";var e={}.hasOwnProperty;"undefined"!=typeof Backbone&&null!==Backbone&&(this.DiscussionThreadShowView=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return function(t,n){for(var i in n)e.call(n,i)&&(t[i]=n[i]);function o(){this.constructor=t}o.prototype=n.prototype,t.prototype=new o,t.__super__=n.prototype}(t,DiscussionContentShowView),t.prototype.initialize=function(e){var n;if(t.__super__.initialize.call(this),this.mode=e.mode||"inline",this.startHeader=e.startHeader,this.is_commentable_divided=e.is_commentable_divided,"tab"!==(n=this.mode)&&"inline"!==n)throw new Error("invalid mode: "+this.mode)},t.prototype.renderTemplate=function(){var e=$.extend({mode:this.mode,startHeader:this.startHeader,flagged:this.model.isFlagged(),is_commentable_divided:this.is_commentable_divided,author_display:this.getAuthorDisplay(),cid:this.model.cid,readOnly:$(".discussion-module").data("read-only")},this.model.attributes);return edx.HtmlUtils.template($("#thread-show-template").html())(e)},t.prototype.render=function(){return edx.HtmlUtils.setHtml(this.$el,this.renderTemplate()),this.delegateEvents(),this.renderAttrs(),this.$("span.timeago").timeago(),this.convertMath(),this},t.prototype.convertMath=function(){DiscussionUtil.convertMath(this.$(".post-body")),DiscussionUtil.typesetMathJax(this.$(".post-body"))},t.prototype.edit=function(e){return this.trigger("thread:edit",e)},t.prototype._delete=function(e){return this.trigger("thread:_delete",e)},t}())}).call(window)}).call(window)},411(){(function(){(function(){"use strict";var e={}.hasOwnProperty;"undefined"!=typeof Backbone&&null!==Backbone&&(this.DiscussionThreadView=function(){function t(){var e=this;return this._delete=function(){return t.prototype._delete.apply(e,arguments)},this.closeEditView=function(){return t.prototype.closeEditView.apply(e,arguments)},this.edit=function(){return t.prototype.edit.apply(e,arguments)},this.endorseThread=function(){return t.prototype.endorseThread.apply(e,arguments)},this.addComment=function(){return t.prototype.addComment.apply(e,arguments)},this.renderAddResponseButton=function(){return t.prototype.renderAddResponseButton.apply(e,arguments)},this.renderResponseToList=function(){return t.prototype.renderResponseToList.apply(e,arguments)},this.renderResponseCountAndPagination=function(){return t.prototype.renderResponseCountAndPagination.apply(e,arguments)},t.__super__.constructor.apply(this,arguments)}return function(t,n){for(var i in n)e.call(n,i)&&(t[i]=n[i]);function o(){this.constructor=t}o.prototype=n.prototype,t.prototype=new o,t.__super__=n.prototype}(t,DiscussionContentView),t.prototype.events={"click .discussion-submit-post":"submitComment","click .add-response-btn":"scrollToAddResponse","keydown .wmd-button":function(e){return DiscussionUtil.handleKeypressInToolbar(e)}},t.prototype.$=function(e){return this.$el.find(e)},t.prototype.isQuestion=function(){return"question"===this.model.get("thread_type")},t.prototype.initialize=function(e){var n,i=this;if(t.__super__.initialize.call(this),this.mode=e.mode||"inline",this.context=e.context||"course",this.options=_.extend({},e),this.startHeader=e.startHeader,"tab"!==(n=this.mode)&&"inline"!==n)throw new Error("invalid mode: "+this.mode);this.readOnly=$(".discussion-module").data("read-only"),this.model.collection.on("reset",function(e){var t;t=i.model.get("id"),e.get(t)&&(i.model=e.get(t))}),this.is_commentable_divided=e.is_commentable_divided,this.createShowView(),this.responses=new Comments,this.loadedResponses=!1,this.isQuestion()&&(this.markedAnswers=new Comments)},t.prototype.rerender=function(){return this.showView&&this.showView.undelegateEvents(),this.undelegateEvents(),this.$el.empty(),this.initialize({mode:this.mode,model:this.model,el:this.el,courseSettings:this.options.courseSettings,topicId:this.topicId}),this.render()},t.prototype.renderTemplate=function(){var e,t;return this.template=_.template($("#thread-template").html()),(e=$("#discussion-container")).length||(e=$(".discussion-module")),t=_.extend(this.model.toJSON(),{readOnly:this.readOnly,startHeader:this.startHeader+1,can_create_comment:e.data("user-create-comment")}),this.template(t)},t.prototype.render=function(){var e=this,t=$(this.renderTemplate());this.$el.empty(),this.$el.append(t),this.delegateEvents(),this.renderShowView(),this.renderAttrs(),this.$("span.timeago").timeago(),this.makeWmdEditor("reply-body"),this.renderAddResponseButton(),this.responses.on("add",function(t){return e.renderResponseToList(t,".js-response-list",{})}),this.isQuestion()&&this.markedAnswers.on("add",function(t){return e.renderResponseToList(t,".js-marked-answer-list",{collapseComments:!0})}),this.loadInitialResponses()},t.prototype.attrRenderer=$.extend({},DiscussionContentView.prototype.attrRenderer,{closed:function(e){return this.$(".discussion-reply-new").toggle(!e),this.$(".comment-form").closest("li").toggle(!e),this.$(".action-vote").toggle(!e),this.$(".display-vote").toggle(e),this.renderAddResponseButton()}}),t.prototype.cleanup=function(){if(this.responsesRequest&&this.responsesRequest.abort)return this.responsesRequest.abort()},t.prototype.loadResponses=function(e,t,n){var i=this;this.responsesRequest=DiscussionUtil.safeAjax({url:DiscussionUtil.urlFor("retrieve_single_thread",this.model.get("commentable_id"),this.model.id),data:{resp_skip:this.responses.size(),resp_limit:e||void 0},$elem:t,$loading:t,takeFocus:!1,complete:function(){i.responsesRequest=null},success:function(e){Content.loadContentInfos(e.annotated_content_info),i.isQuestion()&&i.markedAnswers.add(e.content.endorsed_responses),i.responses.add(i.isQuestion()?e.content.non_endorsed_responses:e.content.children),i.renderResponseCountAndPagination(i.isQuestion()?e.content.non_endorsed_resp_total:e.content.resp_total),i.trigger("thread:responses:rendered"),i.loadedResponses=!0},error:function(e,t){"abort"!==t&&(404===e.status?DiscussionUtil.discussionAlert(gettext("Error"),gettext("The post you selected has been deleted.")):n?DiscussionUtil.discussionAlert(gettext("Error"),gettext("Responses could not be loaded. Refresh the page and try again.")):DiscussionUtil.discussionAlert(gettext("Error"),gettext("Additional responses could not be loaded. Refresh the page and try again.")))}})},t.prototype.loadInitialResponses=function(){return this.loadResponses(25,this.$el.find(".js-response-list"),!0)},t.prototype.renderResponseCountAndPagination=function(e){var t,n,i,o,r,s,a,d=this;if(this.isQuestion()&&0!==this.markedAnswers.length?(i=ngettext("{numResponses} other response","{numResponses} other responses",e),0===e&&this.$el.find(".response-count").hide()):i=ngettext("{numResponses} response","{numResponses} responses",e),this.$el.find(".response-count").text(edx.StringUtils.interpolate(i,{numResponses:e},!0)),(r=this.$el.find(".response-pagination")).empty(),e>0){if(a=0===(s=e-this.responses.size())?gettext("Showing all responses"):edx.StringUtils.interpolate(ngettext("Showing first response","Showing first {numResponses} responses",this.responses.size()),{numResponses:this.responses.size()},!0),r.append($("").addClass("response-display-count").text(a)),s>0)return s<100?(o=null,t=gettext("Load all responses")):(o=100,t=edx.StringUtils.interpolate(gettext("Load next {numResponses} responses"),{numResponses:o},!0)),(n=$("