"),{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("
")))},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=$("