text: (function(){SG.Articles=function(){},SG.Articles.prototype=new SG.Publisher,SG.Articles.prototype.parseContent=function(e){var t=e.text();marked=SG.markSettingNoHightlight();var a=marked(t);a=SG.replaceCodeChar(a),e.html(a),emojify.run(e.get(0))},jQuery(document).ready(function(e){e("#submit").on("click",function(t){t.preventDefault();if(!e(".validate-form").validate().form())return!1;0==e("input[type=radio]:checked").val()?(e("#content").val(CKEDITOR.instances.myeditor.getData()),window.localStorage&&localStorage.removeItem("autosaveKey"),e("#txt").val(CKEDITOR.instances.myeditor.document.getBody().getText())):e("#content").val(e("#markdown-content").val());(new SG.Articles).publish(this,function(e){"undefined"==typeof cacheKey&&(cacheKey="article"),purgeComposeDraft(uid,cacheKey),setTimeout(function(){e.id?window.location.href="/articles/"+e.id:window.location.href="/articles"},1e3)})}),e(document).keypress(function(t){!t.ctrlKey||10!=t.which&&13!=t.which||e("#submit").click()}),e(".add-collection").on("click",function(t){t.preventDefault();var i=e("#title").data("id");e.getJSON("/subject/mine?article_id="+i,function(t){if(t.ok){a(t.data.subjects),e("body").addClass("modal-open"),e(".add-self").fadeIn()}})}),e(".add-self .close").on("click",function(){e("body").removeClass("modal-open"),e(".add-self").fadeOut()});var t="";e(".add-self .search-btn").on("click",function(){var i=e(".add-self .search-input").val();if(""!=i){t=e("#self-note-list").html(),e("#self-note-list").html("");var s=e(".add-self .modal-collections-placeholder");s.show();var n=e("#title").data("id");e.getJSON("/subject/mine?kw="+encodeURIComponent(i)+"&article_id="+n,function(t){if(s.hide(),t.ok){var i=t.data.subjects;0==i.length?e("#self-note-list").html('<div class="default">未找到相关专栏</div>'):a(i)}else e("#self-note-list").html('<div class="default">'+t.msg+"</div>")})}else e("#self-note-list").html(t)}),e(".add-self .search-input").on("change",function(){""==e(this).val()&&e("#self-note-list").html(t)}),e(document).keypress(function(t){10!=t.which&&13!=t.which||e(".add-self .search-btn").click()}),e(".add-self").on("click",".action-btn",function(){var t=e(this).parent(),a=t.data("sid"),i=e("#title").data("id"),s=this;e(this).hasClass("push")?e.post("/subject/contribute",{sid:a,article_id:i},function(t){t.ok?e(s).removeClass("push").addClass("remove").before(' <span class="status has-add">已收入</span>').text("移除"):alert(t.error)}):e.post("/subject/remove_contribute",{sid:a,article_id:i},function(a){a.ok?(e(s).removeClass("remove").addClass("push").text("收入"),t.children(".status").remove()):alert(a.error)})});function a(t){var a="";for(var i in t){var s=t[i];a+='<li><a href="/subject/'+s.id+'" class="avatar-collection"><img src="'+s.cover+'"></a><div class="collection-info" data-sid="'+s.id+'"><a href="/subject/'+s.id+'" class="collection-name">'+s.name+'</a><div class="meta">'+s.username+" 编</div>",s.had_add?a+=' <span class="status has-add">已收入</span><a class="action-btn remove">移除</a>':a+='<a class="action-btn push">收入</a>',a+="</div></li>"}e("#self-note-list").html(a)}})}).call(this);