define("note_info",[],function(){var t=["","',"','',"","","","
"+getMsg("Create Time")+'
"+getMsg("Update Time")+'
"+getMsg("Post Url")+"",'
','http://blog.leanote.com/life/post/life-life-life-a-leanote','',"",' ',"
","
"].join(""),e=$(t),n=e.find("#noteInfoCreatedTime"),o=e.find("#noteInfoUpdatedTime"),i=(e.find("#noteInfoPostUrl"),e.find(".post-url-tr")),r=e.find(".post-url-wrap"),l=e.find("input"),d=e.find(".post-url-base"),s=e.find(".post-url-text"),a={$noteInfo:$("#noteInfo"),note:null,bind:function(){var t=this;$("#noteInfoDropdown").click(function(){t.render()}),e.find(".post-url-pencil").click(function(){r.addClass("post-url-edit"),l.val(decodeURI(t.note.UrlTitle)),l.focus()}),l.keydown(function(t){13===t.keyCode&&l.blur()}),l.blur(function(){r.removeClass("post-url-edit");var e=l.val();e&&ajaxPost("/member/blog/updateBlogUrlTitle",{noteId:t.note.NoteId,urlTitle:e},function(e){if(reIsOk(e)){var n=encodeURI(e.Item);t.note.UrlTitle=n,s.text(decodeURI(t.note.UrlTitle))}else alert(e.Msg||"error")})}),LEA.on("noteChanged",function(e){t.render(e)})},getPostUrl:function(t){return""},rendered:!1,render:function(t){var r=this;t||(t=Note.getCurNote()),t&&(r.note=t,n.html(goNowToDatetime(t.CreatedTime)),o.html(goNowToDatetime(t.UpdatedTime)),t.IsBlog?(i.removeClass("hide"),d.text(UserInfo.PostUrl+"/"),s.text(decodeURI(t.UrlTitle))):i.addClass("hide"),r.rendered||(r.$noteInfo.html(e),r.rendered=!0))},init:function(){this.bind()}};a.init()}); define("tips",[],function(){var d=['"].join(""),a=$(d),i={init:function(){$("#tipsBtn").click(function(){a.modal({show:!0})})}};i.init()}); define("history",[],function(){var t=['"].join(""),i=$(t),s=i.find(".history-content"),e=i.find(".history-list"),o=i.find(".history-num"),n={note:null,list:[],curIndex:0,renderContent:function(t){var i=this.list[t].Content;this.curIndex=t;var o="
",n="
";this.note.IsMarkdown&&(o="
",n="
"),s.html(o+i+n);var a=e.find("a");a.removeClass("active"),a.eq(t).addClass("active")},render:function(t){var s="";if(this.list=t,t)for(var n=0;n#'+(n+1)+""+goNowToDatetime(a.UpdatedTime)+""}e.html(s),this.renderContent(0),o.html(t.length),i.modal({show:!0})},bind:function(){var t=this;$("#contentHistory").click(function(){t.getHistories()}),e.on("click","a",function(){var i=$(this).data("index");t.renderContent(i)}),i.find(".back").click(function(){confirm(getMsg("confirmBackup"))&&(Note.curChangedSaveIt(!0),note=Note.cache[Note.curNoteId],setEditorContent(t.list[t.curIndex].Content,note.IsMarkdown),i.modal("hide"),Note.curChangedSaveIt(!0))})},getHistories:function(){var t=this,i=Note.getCurNote();t.note=i,ajaxGet("/noteContentHistory/listHistories",{noteId:Note.curNoteId},function(i){return isArray(i)?void t.render(i):void alert(getMsg("noHistories"))})},init:function(){this.bind()}};n.init()}); var urlPrefix=UrlPrefix;define("attachment_upload",["jquery.ui.widget","fileupload"],function(){function e(e){return"number"!=typeof e?"":e>=1e9?(e/1e9).toFixed(2)+" GB":e>=1e6?(e/1e6).toFixed(2)+" MB":(e/1e3).toFixed(2)+" KB"}function t(e,t){var a=$(e);$(t).bind("dragover",function(e){e.preventDefault();var t=window.dropZoneTimeoutAttach;t&&clearTimeout(t);var i=!1,o=e.target;do{if(o===a[0]){i=!0;break}o=o.parentNode}while(null!=o);i?a.addClass("hover"):a.removeClass("hover"),window.dropZoneTimeoutAttach=setTimeout(function(){window.dropZoneTimeoutAttach=null,a.removeClass("in hover")},100)})}t("#dropAttach","#uploadAttach");var a=function(){$(".dropzone .btn-choose-file").click(function(){$(this).parent().find("input").click()});var t=$("#attachUploadMsg");$("#uploadAttach").fileupload({dataType:"json",pasteZone:"",dropZone:$("#dropAttach"),formData:function(e){return[{name:"noteId",value:Note.curNoteId}]},add:function(a,i){var o=Note.getCurNote();if(!o||o.IsNew)return void alert("This note hasn't saved, please save it firstly!");var n=$('
×
');n.append(i.files[0].name+" ["+e(i.files[0].size)+"]"),t.html(n),i.context=t;var r=i.files[0].size,l=+GlobalConfigs.uploadAttachSize||100;if("number"==typeof r&&r>1048576*l)return n.find("img").remove(),n.removeClass("alert-info").addClass("alert-danger"),n.append(" Warning: File size is bigger than "+l+"M"),void setTimeout(function(e){return function(){e.remove()}}(n),3e3);var s;setTimeout(function(){s=i.submit()},10)},done:function(t,a){if(1==a.result.Ok)a.context.html(""),Attach.addAttach(a.result.Item);else{a.result;a.context.html("");var i=$('
×
');i.append("Error: "+a.files[0].name+" ["+e(a.files[0].size)+"] "+a.result.Msg),a.context.html(i),setTimeout(function(e){return function(){e.remove()}}(i),3e3)}$("#uploadAttachMsg").scrollTop(1e3)},fail:function(t,a){a.context.html("");var i=$('
×
');i.append("Error: "+a.files[0].name+" ["+e(a.files[0].size)+"] "+a.errorThrown),a.context.html(i),setTimeout(function(e){return function(){e.remove()}}(i),3e3),$("#uploadAttachMsg").scrollTop(1e3)}})};a()}); var urlPrefix=UrlPrefix;define("editor_drop_paste",["jquery.ui.widget","fileupload"],function(){function e(e){var i="__mcenew"+(new Date).getTime(),t='
0%
';this.containerStr=t,e.insertContent(t);var o=$("#"+i);this.container=o,this.id=i,this.processBar=o.find(".progress-bar")}function i(e,i){function t(e,t){o.parentNode.removeChild(o),i({width:e,height:t})}var o=document.createElement("img");o.onload=function(){t(o.clientWidth,o.clientHeight)},o.onerror=function(){t()},o.src=e;var a=o.style;a.visibility="hidden",a.position="fixed",a.bottom=a.left=0,a.width=a.height="auto",document.body.appendChild(o)}function t(e){var t=tinymce.activeEditor,a=t.dom,r=function(t){function r(e){a.setAttrib(n,"src",t.src),t.title&&a.setAttrib(n,"title",t.title),a.setAttrib(n,"id",null)}var n,s={};s.id="__mcenew"+o++,s.src="http://leanote.com/images/loading-24.gif",n=a.createHTML("img",s),tinymce.activeEditor.insertContent(n),n=a.get(s.id),i(e.src,r)},n="";if(fileIds=e.src.split("fileId="),2==fileIds.length&&fileIds[1].length=="53aecf8a8a039a43c8036282".length&&(n=fileIds[1]),n){var s=Note.getCurNote();s&&s.UserId!=UserInfo.UserId?!function(e){ajaxPost("/file/copyImage",{userId:UserInfo.UserId,fileId:n,toUserId:s.UserId},function(i){if(reIsOk(i)&&i.Id){var t=window.location.protocol+"//"+window.location.host;e.src=t+"/file/outputImage?fileId="+i.Id}r(e)})}(e):r(e)}else r(e)}e.prototype.update=function(e){var i=this;e=Math.ceil(100*e),e>=100&&(e=99),e+="%",$("#"+i.id+" .progress-bar").html(e).css("width",e)},e.prototype.replace=function(e){var t=this;i(e,function(){$("#"+t.id).replaceWith('')})},e.prototype.remove=function(){var e=this;$("#"+e.id).remove()};var o=1,a=function(){function e(e){return"number"!=typeof e?"":e>=1e9?(e/1e9).toFixed(2)+" GB":e>=1e6?(e/1e6).toFixed(2)+" MB":(e/1e3).toFixed(2)+" KB"}function i(){$("#upload").css("z-index",12);var e=+$("#mceToolbar").css("height").slice(0,-2);$("#upload").css("top",e-8),$("#upload").show()}function o(){$("#upload").css("z-index",0).css("top","auto").hide()}var a=$("#upload ul");$("#drop a").click(function(){$(this).parent().find("input").click()}),$("#upload").fileupload({dataType:"json",pasteZone:"",acceptFileTypes:/(\.|\/)(gif|jpg|jpeg|png|jpe)$/i,maxFileSize:21e4,dropZone:$("#drop"),formData:function(e){return[{name:"albumId",value:""}]},add:function(i,t){var o=$('
  • ');o.find("div").append(t.files[0].name+" ["+e(t.files[0].size)+"]"),t.context=o.appendTo(a);t.submit()},done:function(i,o){if(1==o.result.Ok){o.context.remove();var a={src:urlPrefix+"/file/outputImage?fileId="+o.result.Id};t(a)}else{o.context.empty();var r=$('
  • ');r.find("div").append("Error: "+o.files[0].name+" ["+e(o.files[0].size)+"] "+o.result.Msg),o.context.append(r),setTimeout(function(e){return function(){e.remove()}}(r),2e3)}$("#uploadMsg").scrollTop(1e3)},fail:function(i,t){t.context.empty();var o=$('
  • ');o.find("div").append("Error: "+t.files[0].name+" ["+e(t.files[0].size)+"] "+t.errorThrown),t.context.append(o),setTimeout(function(e){return function(){e.remove()}}(o),2e3),$("#uploadMsg").scrollTop(1e3)}}),$(document).on("drop dragover",function(e){e.preventDefault()}),$(document).bind("dragover",function(e){var t=$("#drop"),a=window.dropZoneTimeout;a?clearTimeout(a):(t.addClass("in"),i());var r=!1,n=e.target;do{if(n===t[0]){r=!0;break}n=n.parentNode}while(null!=n);r?t.addClass("hover"):t.removeClass("hover"),window.dropZoneTimeout=setTimeout(function(){window.dropZoneTimeout=null,t.removeClass("in hover"),o()},100)})},r=0,n=function(){var i,t;$("#editorContent, #wmd-input .editor-content").fileupload({dataType:"json",pasteZone:$("#editorContent, #wmd-input .editor-content"),dropZone:"",maxFileSize:21e4,url:"/file/pasteImage",paramName:"file",formData:function(e){return[{name:"from",value:"pasteImage"},{name:"noteId",value:Note.curNoteId}]},progress:function(e,t){i&&!i.IsMarkdown&&t.process.update(t.loaded/t.total)},add:function(o,a){var n=(new Date).getTime();if(!(500>n-r)){r=n;var s=Note.getCurNote();if(i=s,!s||s.IsNew)return void alert("This note hasn't saved, please save it firstly!");if(t=tinymce.EditorManager.activeEditor,!s.IsMarkdown)var l=new e(t);a.process=l;a.submit()}},done:function(e,t){if(1==t.result.Ok){var o=t.result,a=UrlPrefix,r=a+"/file/outputImage?fileId="+o.Id;i&&!i.IsMarkdown?t.process.replace(r):MD&&MD.insertLink(r,"title",!0)}else t.process.remove()},fail:function(e,t){i&&!i.IsMarkdown&&t.process.remove()}})};a(),n()}); requirejs.config({paths:{editor_drop_paste:"js/plugins/editor_drop_paste",attachment_upload:"js/plugins/attachment_upload","jquery.ui.widget":"js/plugins/libs-min/jquery.ui.widget",fileupload:"js/plugins/libs-min/jquery.fileupload","iframe-transport":"js/plugins/libs-min/jquery.iframe-transport",note_info:"js/plugins/note_info",tips:"js/plugins/tips",history:"js/plugins/history"},shim:{fileupload:{deps:["jquery.ui.widget","iframe-transport"]}}}),setTimeout(function(){require(["editor_drop_paste","attachment_upload"]),require(["note_info"]),setTimeout(function(){require(["tips"]),require(["history"])},10)});