jQuery(document).ready(function(a){function b(){a('.ms-choice span:contains("Do not show")').each(function(){a(this).html(a(this).html().split("Do not show").join("")),","==a(this).html().trim().slice(-1)&&a(this).html(a(this).html().trim().slice(0,-1)),a(this).text().trim().length||a(this).text("Comments not displaying")})}function c(){var b=f.find('input[value="upload"]');b.prop("checked")||f.find("#customize-control-avatar").hide(),a(f).on("click","input",d)}function d(){"upload"===a(this).val()?f.find("#customize-control-avatar").show():f.find("#customize-control-avatar").hide()}a("#comment-display-control").multipleSelect({selectAll:!1}),a.each(a(".ms-drop.bottom").find("li"),function(){"none"==a(this).find("input").val()&&a(this).hide()}),b(),a(".ms-drop.bottom").find("li").bind("click",b);var e=a("html",window.parent.document),f=e.find("#accordion-section-ct_author_avatar");c()}),function(a){"use strict";function b(b,c){var d=this,e=b.attr("name")||c.name||"";b.parent().hide();var f=b.css("width");b.parent().show(),"0px"==f&&(f=b.outerWidth()+20),this.$el=b.hide(),this.options=c,this.$parent=a("
"),this.$choice=a('"),this.$drop=a(''),this.$el.after(this.$parent),this.$parent.append(this.$choice),this.$parent.append(this.$drop),this.$el.prop("disabled")&&this.$choice.addClass("disabled"),this.$parent.css("width",c.width||f),this.options.keepOpen||a("body").click(function(b){a(b.target)[0]!==d.$choice[0]&&a(b.target).parents(".ms-choice")[0]!==d.$choice[0]&&(a(b.target)[0]!==d.$drop[0]&&a(b.target).parents(".ms-drop")[0]===d.$drop[0]||!d.options.isOpen||d.close())}),this.selectAllName='name="selectAll'+e+'"',this.selectGroupName='name="selectGroup'+e+'"',this.selectItemName='name="selectItem'+e+'"'}b.prototype={constructor:b,init:function(){var b=this,c=[];this.options.filter&&c.push('','',"
"),c.push(""),this.options.selectAll&&!this.options.single&&c.push('- ',"","
"),a.each(this.$el.children(),function(a,d){c.push(b.optionToHtml(a,d))}),c.push('- '+this.options.noMatchesFound+"
"),c.push("
"),this.$drop.html(c.join("")),this.$drop.find("ul").css("max-height",this.options.maxHeight+"px"),this.$drop.find(".multiple").css("width",this.options.multipleWidth+"px"),this.$searchInput=this.$drop.find(".ms-search input"),this.$selectAll=this.$drop.find("input["+this.selectAllName+"]"),this.$selectGroups=this.$drop.find("input["+this.selectGroupName+"]"),this.$selectItems=this.$drop.find("input["+this.selectItemName+"]:enabled"),this.$disableItems=this.$drop.find("input["+this.selectItemName+"]:disabled"),this.$noResults=this.$drop.find(".ms-no-results"),this.events(),this.updateSelectAll(!0),this.update(!0),this.options.isOpen&&this.open()},optionToHtml:function(b,c,d,e){var f,g=this,h=a(c),i=[],j=this.options.multiple,k=["class","title"],l=a.map(k,function(a){var b="class"===a&&j,c=h.attr(a)||"";return b||c?" "+a+'="'+(b?"multiple"+(c?" ":""):"")+c+'"':""}).join(""),m=this.options.single?"radio":"checkbox";if(h.is("option")){var n=h.val(),o=g.options.textTemplate(h),p=void 0!=g.$el.attr("multiple")?h.prop("selected"):"selected"==h.attr("selected"),q=this.options.styler(n)?' style="'+this.options.styler(n)+'"':"";f=e||h.prop("disabled"),this.options.blockSeparator>""&&this.options.blockSeparator==h.val()?i.push("",'",""):i.push("","","")}else if(!d&&h.is("optgroup")){var r="group_"+b,s=h.attr("label");f=h.prop("disabled"),i.push('','",""),a.each(h.children(),function(a,b){i.push(g.optionToHtml(a,b,r,f))})}return i.join("")},events:function(){function b(a){a.preventDefault(),c[c.options.isOpen?"close":"open"]()}var c=this,d=this.$el.parent().closest("label")[0]||a("label[for="+this.$el.attr("id")+"]")[0];d&&a(d).off("click").on("click",function(a){"label"===a.target.nodeName.toLowerCase()&&a.target===this&&(b(a),c.options.filter&&c.options.isOpen||c.focus(),a.stopPropagation())}),this.$choice.off("click").on("click",b).off("focus").on("focus",this.options.onFocus).off("blur").on("blur",this.options.onBlur),this.$parent.off("keydown").on("keydown",function(a){switch(a.which){case 27:c.close(),c.$choice.focus()}}),this.$searchInput.off("keydown").on("keydown",function(a){9===a.keyCode&&a.shiftKey&&c.close()}).off("keyup").on("keyup",function(a){return c.options.filterAcceptOnEnter&&(13===a.which||32==a.which)&&c.$searchInput.val()?(c.$selectAll.click(),c.close(),void c.focus()):void c.filter()}),this.$selectAll.off("click").on("click",function(){var b=a(this).prop("checked"),d=c.$selectItems.filter(":visible");d.length===c.$selectItems.length?c[b?"checkAll":"uncheckAll"]():(c.$selectGroups.prop("checked",b),d.prop("checked",b),c.options[b?"onCheckAll":"onUncheckAll"](),c.update())}),this.$selectGroups.off("click").on("click",function(){var b=a(this).parent().attr("data-group"),d=c.$selectItems.filter(":visible"),e=d.filter('[data-group="'+b+'"]'),f=e.length!==e.filter(":checked").length;e.prop("checked",f),c.updateSelectAll(),c.update(),c.options.onOptgroupClick({label:a(this).parent().text(),checked:f,children:e.get()})}),this.$selectItems.off("click").on("click",function(){c.updateSelectAll(),c.update(),c.updateOptGroupSelect(),c.options.onClick({label:a(this).parent().text(),value:a(this).val(),checked:a(this).prop("checked")}),c.options.single&&c.options.isOpen&&!c.options.keepOpen&&c.close()})},open:function(){if(!this.$choice.hasClass("disabled")){if(this.options.isOpen=!0,this.$choice.find(">div").addClass("open"),this.$drop.show(),this.$selectAll.parent().show(),this.$noResults.hide(),0===this.$el.children().length&&(this.$selectAll.parent().hide(),this.$noResults.show()),this.options.container){var b=this.$drop.offset();this.$drop.appendTo(a(this.options.container)),this.$drop.offset({top:b.top,left:b.left})}this.options.filter&&(this.$searchInput.val(""),this.$searchInput.focus(),this.filter()),this.options.onOpen()}},close:function(){this.options.isOpen=!1,this.$choice.find(">div").removeClass("open"),this.$drop.hide(),this.options.container&&(this.$parent.append(this.$drop),this.$drop.css({top:"auto",left:"auto"})),this.options.onClose()},update:function(b){var c=this.getSelects(),d=this.$choice.find(">span");0===c.length?d.addClass("placeholder").html(this.options.placeholder):d.removeClass("placeholder").html(this.options.countSelected&&c.lengththis.options.minumimCountSelected?this.options.etcaetera?(this.options.displayValues?c:this.getSelects("text").slice(0,this.options.minumimCountSelected)).join(this.options.delimiter)+"...":this.options.countSelected.replace("#",c.length).replace("%",this.$selectItems.length+this.$disableItems.length):(this.options.displayValues?c:this.getSelects("text")).join(this.options.delimiter)),this.$el.val(this.getSelects()),this.$drop.find("li").removeClass("selected"),this.$drop.find("input["+this.selectItemName+"]:checked").each(function(){a(this).parents("li").first().addClass("selected")}),b||this.$el.trigger("change")},updateSelectAll:function(a){var b=this.$selectItems;a||(b=b.filter(":visible")),this.$selectAll.prop("checked",b.length&&b.length===b.filter(":checked").length),this.$selectAll.prop("checked")&&this.options.onCheckAll()},updateOptGroupSelect:function(){var b=this.$selectItems.filter(":visible");a.each(this.$selectGroups,function(c,d){var e=a(d).parent().attr("data-group"),f=b.filter('[data-group="'+e+'"]');a(d).prop("checked",f.length&&f.length===f.filter(":checked").length)})},getSelects:function(b){var c=this,d=[],e=[];return this.$drop.find("input["+this.selectItemName+"]:checked").each(function(){d.push(a(this).parents("li").first().text()),e.push(a(this).val())}),"text"===b&&this.$selectGroups.length&&(d=[],this.$selectGroups.each(function(){var b=[],e=a.trim(a(this).parent().text()),f=a(this).parent().data("group"),g=c.$drop.find("["+c.selectItemName+'][data-group="'+f+'"]'),h=g.filter(":checked");if(0!==h.length){if(b.push("["),b.push(e),g.length>h.length){var i=[];h.each(function(){i.push(a(this).parent().text())}),b.push(": "+i.join(", "))}b.push("]"),d.push(b.join(""))}})),"text"===b?d:e},setSelects:function(b){var c=this;this.$selectItems.prop("checked",!1),a.each(b,function(a,b){c.$selectItems.filter('[value="'+b+'"]').prop("checked",!0)}),this.$selectAll.prop("checked",this.$selectItems.length===this.$selectItems.filter(":checked").length),this.update()},enable:function(){this.$choice.removeClass("disabled")},disable:function(){this.$choice.addClass("disabled")},checkAll:function(){this.$selectItems.prop("checked",!0),this.$selectGroups.prop("checked",!0),this.$selectAll.prop("checked",!0),this.update(),this.options.onCheckAll()},uncheckAll:function(){this.$selectItems.prop("checked",!1),this.$selectGroups.prop("checked",!1),this.$selectAll.prop("checked",!1),this.update(),this.options.onUncheckAll()},focus:function(){this.$choice.focus(),this.options.onFocus()},blur:function(){this.$choice.blur(),this.options.onBlur()},refresh:function(){this.init()},filter:function(){var b=this,c=a.trim(this.$searchInput.val()).toLowerCase();0===c.length?(this.$selectItems.parent().show(),this.$disableItems.parent().show(),this.$selectGroups.parent().show()):(this.$selectItems.each(function(){var b=a(this).parent();b[b.text().toLowerCase().indexOf(c)<0?"hide":"show"]()}),this.$disableItems.parent().hide(),this.$selectGroups.each(function(){var c=a(this).parent(),d=c.attr("data-group"),e=b.$selectItems.filter(":visible");c[0===e.filter('[data-group="'+d+'"]').length?"hide":"show"]()}),this.$selectItems.filter(":visible").length?(this.$selectAll.parent().show(),this.$noResults.hide()):(this.$selectAll.parent().hide(),this.$noResults.show())),this.updateOptGroupSelect(),this.updateSelectAll()}},a.fn.multipleSelect=function(){var c,d=arguments[0],e=arguments,f=["getSelects","setSelects","enable","disable","checkAll","uncheckAll","focus","blur","refresh"];return this.each(function(){var g=a(this),h=g.data("multipleSelect"),i=a.extend({},a.fn.multipleSelect.defaults,g.data(),"object"==typeof d&&d);if(h||(h=new b(g,i),g.data("multipleSelect",h)),"string"==typeof d){if(a.inArray(d,f)<0)throw"Unknown method: "+d;c=h[d](e[1])}else h.init(),e[1]&&(c=h[e[1]].apply(h,[].slice.call(e,2)))}),c?c:this},a.fn.multipleSelect.defaults={name:"",isOpen:!1,placeholder:"",selectAll:!0,selectAllText:"Select all",selectAllDelimiter:["[","]"],allSelected:"All selected",minumimCountSelected:3,countSelected:"# of % selected",noMatchesFound:"No matches found",multiple:!1,multipleWidth:80,single:!1,filter:!1,width:void 0,maxHeight:250,container:null,position:"bottom",keepOpen:!1,blockSeparator:"",displayValues:!1,delimiter:", ",styler:function(){return!1},textTemplate:function(a){return a.text()},onOpen:function(){return!1},onClose:function(){return!1},onCheckAll:function(){return!1},onUncheckAll:function(){return!1},onFocus:function(){return!1},onBlur:function(){return!1},onOptgroupClick:function(){return!1},onClick:function(){return!1}}}(jQuery);