if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");!function(l){l.widget("psc.blogcomment",{options:{apictrlr:null,authorId:null,authorName:null,omob:"#ffe08030",omof:"#501208",bgc:"#fff",fgc:"#000",lang:"fr-FR",allowCoc:!0},editable:!1,editting:!1,hideBtn:null,delBtn:null,cmtInput:null,cmtBtn:null,ctlBtn:null,collapsed:!1,subCmts:null,_create:function(){var e=this;this.element.addClass("blogcomment");var t=new Date(this.element.data("date")),o=this.element.data("username");this.editable=this.element.data("allow-edit"),this.element.prepend('
'+o+'
'+t.toLocaleDateString(this.options.lang)+" "+t.toLocaleTimeString(this.options.lang)+"
"),this.element.on("mouseenter",this.onMouseEnter),this.element.on("mouseleave",this.onMouseLeave),this.ctlBtn=l('').on("click",function(t){e.toggleCollapse(e,t)}).appendTo(e.element)},toggleCollapse:function(t,e){t.collapsed=!t.collapsed,t.collapsed?(l(t.ctlBtn).removeClass("glyphicon-collapse-down"),l(t.ctlBtn).addClass("glyphicon-collapse-up")):(l(t.ctlBtn).removeClass("glyphicon-collapse-up"),l(t.ctlBtn).addClass("glyphicon-collapse-down")),t.editable&&t.toggleEdit(t,e),t.options.allowCoc&&t.toggleComment(t,e)},toggleEdit:function(e,t){e.delBtn?(e.delBtn.remove(),e.delBtn=null):(e.delBtn=l(''),e.delBtn.on("click",function(t){e.doDeleteComment(e,t)}).appendTo(e.element))},toggleComment:function(e,t){e.cmtBtn?(e.cmtInput.remove(),e.cmtBtn.remove(),e.cmtBtn=null):(e.subCmts||(e.subCmts=l(e.element).children("div.subcomments"),0==e.subCmts.length&&(e.subCmts=l("
").addClass("subcomments"),e.subCmts.appendTo(e.element))),e.cmtInput=l(''),e.cmtInput.appendTo(e.element),e.cmtBtn=l(''),e.cmtBtn.on("click",function(t){e.doCoC(e,t)}).appendTo(e.element))},onMouseEnter:function(){l(this).animate({backgroundColor:l.psc.blogcomment.prototype.options.omob,color:l.psc.blogcomment.prototype.options.omof},400)},onMouseLeave:function(){l(this).animate({backgroundColor:l.psc.blogcomment.prototype.options.bgc,color:l.psc.blogcomment.prototype.options.fgc},400)},doDeleteComment:function(e,t){var o=l(e.element).data("id"),n=e.options.apictrlr;l.ajax({async:!0,cache:!1,type:"POST",method:"DELETE",error:function(t,e){l('span.field-validation-valid[data-valmsg-for="Content"]').html("Une erreur est survenue : "+t.status+"
").focus()},success:function(t){e.element.remove()},url:n+"/"+o})},doCoC:function(n,t){var e=l("#cmtBtn").data("receiverid"),o={Content:n.cmtInput.val(),PostId:e,ParentId:l(n.element).data("id"),AuthorId:n.options.authorId};l.ajax({async:!0,cache:!1,type:"POST",method:"POST",contentType:"application/json",data:JSON.stringify(o),error:function(t,e){console.log("err"),console.log(t),console.log(e),l('span.field-validation-valid[data-valmsg-for="Content"]').html("Une erreur est survenue : "+t.status+"
"+t.responseText+"
")},success:function(t){var e=t.Content;n.cmtInput.val(""),l('span.field-validation-valid[data-valmsg-for="Content"]').empty();var o=htmlize(e);l('
'+o+"
").blogcomment().appendTo(n.subCmts)},url:n.options.apictrlr})}}),l(document).ready(function(){l("[data-type='blogcomment']").blogcomment()})}(jQuery);