jQuery(document).ready((function(e){if(wpdiscuzAjaxObj.wmuLazyLoadImages){function a(){for(var a=e("#wpdcom img"),t=0;t<a.length;t++){var n=e(a[t]),d=n.attr("wmu-data-src");d&&n.attr("src",d)}}a(),wpdiscuzAjaxObj.wmuImagesInit=a}e(document).delegate(".wmu-replace-attachment-input","change",(function(){var a=e(this),t=a.closest(".wmu-attachment"),n=a.closest(".wmu-attachment-replace").data("wmu-attachment"),d=this.files[0];if(d){var m=parseInt(wpdiscuzAjaxObj.isNativeAjaxEnabled,10),c=new FormData;c.append("action","wmuReplaceAttachment"),c.append("attachmentId",n),c.append("wmu_replace_nonce",wpdiscuzAjaxObj.wmuReplaceNonce||""),c.append("wmu_replace_file",d),wpdiscuzAjaxObj.getAjaxObj(m,!0,c).done((function(n){if(n.success)!function(a,t){var n=a.closest(".wmu-comment-attachments"),d={images:".wmu-attached-images",videos:".wmu-attached-videos",files:".wmu-attached-files"};if(null!==t.imagesHtml){var m=n.find(".wmu-attached-images");""!==t.imagesHtml?(m.length||(m=e('<div class="wmu-attached-images"></div>'),n.append(m)),m.html(t.imagesHtml)):m.length&&m.remove(),"images"!==t.oldType&&(a.remove(),(i=e(d[t.oldType],n)).length&&!i.children(".wmu-attachment").length&&i.remove()),"images"!==t.newType&&((c=e(d[t.newType],n)).length||(c=e('<div class="wmu-attached-'+t.newType+'"></div>'),n.append(c)),c.append(t.attachmentHtml))}else if(t.oldType!==t.newType){var c,i;(c=e(d[t.newType],n)).length||(c=e('<div class="wmu-attached-'+t.newType+'"></div>'),n.append(c)),a.remove(),c.append(t.attachmentHtml),(i=e(d[t.oldType],n)).length&&!i.children(".wmu-attachment").length&&i.remove()}else a.replaceWith(t.attachmentHtml);"function"==typeof wpdiscuzAjaxObj.wmuAddLightBox&&wpdiscuzAjaxObj.wmuAddLightBox(),"function"==typeof wpdiscuzAjaxObj.wmuImagesInit&&wpdiscuzAjaxObj.wmuImagesInit()}(t,n.data);else{var d=n.data&&n.data.errorCode?n.data.errorCode:"",m=d&&wpdiscuzAjaxObj[d]?wpdiscuzAjaxObj[d]:n.data&&n.data.error?n.data.error:"";m&&wpdiscuzAjaxObj.setCommentMessage(m,"error",4e3)}e("#wpdiscuz-loading-bar").fadeOut(250),a.val("")})).fail((function(t,n,d){console.log(d),e("#wpdiscuz-loading-bar").fadeOut(250),a.val("")}))}}))}));