Files
leanote/public/js/plugins/main.min.js

7 lines
35 KiB
JavaScript
Raw Permalink Normal View History

2015-10-10 16:55:36 +08:00
define("note_info",[],function(){var t=["<table>","<tr><th>"+getMsg("Create Time")+'</th><td id="noteInfoCreatedTime"></td></tr>',"<tr><th>"+getMsg("Update Time")+'</th><td id="noteInfoUpdatedTime"></td></tr>','<tr class="post-url-tr">',"<th>"+getMsg("Post Url")+"</th>","<td>",'<div class="post-url-wrap">','<span class="post-url-base">http://blog.leanote.com/life/post/</span><span><span class="post-url-text">life-life-life-a-leanote</span>','<input type="text" class="form-control">',"</span>",' <a class="post-url-pencil" title="'+getMsg("update")+'"><i class="fa fa-pencil"></i></a>',"</div>","</td>","</tr>","</table>"].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=['<div class="modal fade bs-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">','<div class="modal-dialog modal-sm">','<div class="modal-content">','<div class="modal-header">','<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>','<h4 class="modal-title" class="modalTitle">'+getMsg("editorTips")+"</h4>","</div>",'<div class="modal-body">'+getMsg("editorTipsInfo")+"</div>",'<div class="modal-footer">','<button type="button" class="btn btn-default" data-dismiss="modal">'+getMsg("close")+"</button>","</div>","</div>","</div>","</div>"].join(""),a=$(d),i={init:function(){$("#tipsBtn").click(function(){a.modal({show:!0})})}};i.init()});
define("history",[],function(){var t=['<div class="modal fade history-modal" tabindex="-1" role="dialog" aria-hidden="true">','<div class="modal-dialog modal-lg ">','<div class="modal-content">','<div class="modal-header">','<h4 class="modal-title" class="modalTitle">NaN',"</div>",'<div class="modal-body clearfix">','<div class="history-list-wrap pull-left">','<div class="history-list-header">'+getMsg("history")+' (<span class="history-num"></span>)</div>','<div class="history-list list-group"></div>',"</div>",'<div class="history-content-wrap pull-left">','<div class="history-content-header">','<a class="btn btn-primary back">'+getMsg("restoreFromThisVersion")+"</a>",'<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>',"</div>",'<div class="history-content"></div>',"</div>","</div>",'<div class="modal-footer hide">','<button type="button" class="btn btn-default" data-dismiss="modal">'+getMsg("close")+"</button>","</div>","</div>","</div>","</div>"].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="<div>",n="</div>";this.note.IsMarkdown&&(o="<pre>",n="</pre>"),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<t.length;++n){var a=t[n];s+='<a class="list-group-item" data-index="'+n+'"><span class="badge">#'+(n+1)+"</span>"+goNowToDatetime(a.UpdatedTime)+"</a>"}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()});
2015-11-22 23:18:07 +08:00
var urlPrefix=UrlPrefix;define("attachment_upload",["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 o=!1,i=e.target;do{if(i===a[0]){o=!0;break}i=i.parentNode}while(null!=i);o?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,o){var i=Note.getCurNote();if(!i||i.IsNew)return void alert("This note hasn't saved, please save it firstly!");var r=$('<div class="alert alert-info"><img class="loader" src="/images/ajax-loader.gif"> <a class="close" data-dismiss="alert">×</a></div>');r.append(o.files[0].name+" <small>[<i>"+e(o.files[0].size)+"</i>]</small>"),t.html(r),o.context=t;var n=o.files[0].size,l=+GlobalConfigs.uploadAttachSize||100;if("number"==typeof n&&n>1048576*l)return r.find("img").remove(),r.removeClass("alert-info").addClass("alert-danger"),r.append(" Warning: File size is bigger than "+l+"M"),void setTimeout(function(e){return function(){e.remove()}}(r),3e3);var s;setTimeout(function(){s=o.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 o=$('<div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div>');o.append("<b>Error:</b> "+a.files[0].name+" <small>[<i>"+e(a.files[0].size)+"</i>]</small> "+a.result.Msg),a.context.html(o),setTimeout(function(e){return function(){e.remove()}}(o),3e3)}$("#uploadAttachMsg").scrollTop(1e3)},fail:function(t,a){a.context.html("");var o=$('<div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div>');o.append("<b>Error:</b> "+a.files[0].name+" <small>[<i>"+e(a.files[0].size)+"</i>]</small> "+a.errorThrown),a.context.html(o),setTimeout(function(e){return function(){e.remove()}}(o),3e3),$("#uploadAttachMsg").scrollTop(1e3)}})};a()});
define("editor_drop_paste",["fileupload"],function(){function e(){var e=$("#editorContent").children(),t=e&&e.length>0?e[e.length-1]:null;t&&"P"==t.tagName||$("#editorContent").append('<p><br data-mce-bogus="1"></p>')}function t(t){var i="__mcenew"+(new Date).getTime(),o='<div contenteditable="false" id="'+i+'" class="leanote-image-container"><img class="loader" src="/images/ajax-loader.gif"><div class="progress"><div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="2" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">0%</div></div></div>';this.containerStr=o,t.insertContent(o),e();var a=$("#"+i);this.container=a,this.id=i,this.processBar=a.find(".progress-bar")}function i(e,t){function i(e,i){o.parentNode.removeChild(o),t({width:e,height:i})}var o=document.createElement("img");o.onload=function(){i(o.clientWidth,o.clientHeight)},o.onerror=function(){i()},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 o(e){var t=tinymce.activeEditor,o=t.dom,n=function(t){function n(e){o.setAttrib(r,"src",t.src),t.title&&o.setAttrib(r,"title",t.title),o.setAttrib(r,"id",null)}var r,s={};s.id="__mcenew"+a++,s.src="/images/loading-24.gif",r=o.createHTML("img",s),tinymce.activeEditor.insertContent(r),r=o.get(s.id),i(e.src,n)},r="";if(fileIds=e.src.split("fileId="),2==fileIds.length&&fileIds[1].length=="53aecf8a8a039a43c8036282".length&&(r=fileIds[1]),r){var s=Note.getCurNote();s&&s.UserId!=UserInfo.UserId?!function(e){ajaxPost("/file/copyImage",{userId:UserInfo.UserId,fileId:r,toUserId:s.UserId},function(t){reIsOk(t)&&t.Id&&(e.src="/api/file/getImage?fileId="+t.Id),n(e)})}(e):n(e)}else n(e)}t.prototype.update=function(e){var t=this;e=Math.ceil(100*e),e>=100&&(e=99),e+="%",$("#"+t.id+" .progress-bar").html(e).css("width",e)},t.prototype.replace=function(e){var t=this;i(e,function(){$("#"+t.id).replaceWith('<img src="'+e+'" />')})},t.prototype.remove=function(){var e=this;$("#"+e.id).remove()};var a=1,n=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(){$("#upload").css("z-index",12);var e=+$("#mceToolbar").css("height").slice(0,-2);$("#upload").css("top",e-8),$("#upload").show()}function i(){$("#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(t,i){var o=$('<li><div class="alert alert-info"><img class="loader" src="/images/ajax-loader.gif"> <a class="close" data-dismiss="alert">×</a></div></li>');o.find("div").append(i.files[0].name+" <small>[<i>"+e(i.files[0].size)+"</i>]</small>"),i.context=o.appendTo(a);i.submit()},done:function(t,i){if(1==i.result.Ok){i.context.remove();var a={src:"/api/file/getImage?fileId="+i.result.Id};o(a)}else{i.context.empty();var n=$('<li><div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div></li>');n.find("div").append("<b>"+getMsg("Error")+":</b> "+i.files[0].name+" <small>[<i>"+e(i.files[0].size)+"</i>]</small> "+i.result.Msg),i.context.append(n),setTimeout(function(e){return function(){e.remove()}}(n),2e3)}$("#uploadMsg").scrollTop(1e3)},fail:function(t,i){i.context.empty();var o=$('<li><div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div></li>');o.find("div").append("<b>"+getMsg("Error")+":</b> "+i.files[0].name+" <small>[<i>"+e(i.files[0].size)+"</i>]</small> "+i.errorThrown),i.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 o=$("#drop"),a=window.dropZoneTimeout;a?clearTimeout(a):(o.addClass("in"),t());var n=!1,r=e.target;do{if(r==
2015-11-22 23:18:07 +08:00
requirejs.config({paths:{editor_drop_paste:"js/plugins/editor_drop_paste",attachment_upload:"js/plugins/attachment_upload",fileupload:"js/plugins/libs-min/fileupload",note_info:"js/plugins/note_info",tips:"js/plugins/tips",history:"js/plugins/history"},shim:{}}),setTimeout(function(){require(["editor_drop_paste","attachment_upload"]),require(["note_info"]),setTimeout(function(){require(["tips"]),require(["history"])},10)});
2015-11-22 23:26:59 +08:00
!function(e){"use strict";e(window.jQuery)}(function(e){"use strict";var t=0;e.ajaxTransport("iframe",function(i){if(i.async){var n,r,o;return{send:function(s,a){n=e('<form style="display:none;"></form>'),n.attr("accept-charset",i.formAcceptCharset),o=/\?/.test(i.url)?"&":"?","DELETE"===i.type?(i.url=i.url+o+"_method=DELETE",i.type="POST"):"PUT"===i.type?(i.url=i.url+o+"_method=PUT",i.type="POST"):"PATCH"===i.type&&(i.url=i.url+o+"_method=PATCH",i.type="POST"),r=e('<iframe src="javascript:false;" name="iframe-transport-'+(t+=1)+'"></iframe>').bind("load",function(){var t,o=e.isArray(i.paramName)?i.paramName:[i.paramName];r.unbind("load").bind("load",function(){var t;try{if(t=r.contents(),!t.length||!t[0].firstChild)throw new Error}catch(i){t=void 0}a(200,"success",{iframe:t}),e('<iframe src="javascript:false;"></iframe>').appendTo(n),n.remove()}),n.prop("target",r.prop("name")).prop("action",i.url).prop("method",i.type),i.formData&&e.each(i.formData,function(t,i){e('<input type="hidden"/>').prop("name",i.name).val(i.value).appendTo(n)}),i.fileInput&&i.fileInput.length&&"POST"===i.type&&(t=i.fileInput.clone(),i.fileInput.after(function(e){return t[e]}),i.paramName&&i.fileInput.each(function(t){e(this).prop("name",o[t]||i.paramName)}),n.append(i.fileInput).prop("enctype","multipart/form-data").prop("encoding","multipart/form-data")),n.submit(),t&&t.length&&i.fileInput.each(function(i,n){var r=e(t[i]);e(n).prop("name",r.prop("name")),r.replaceWith(n)})}),n.append(r).appendTo(document.body)},abort:function(){r&&r.unbind("load").prop("src","javascript".concat(":false;")),n&&n.remove()}}}}),e.ajaxSetup({converters:{"iframe text":function(t){return t&&e(t[0].body).text()},"iframe json":function(t){return t&&e.parseJSON(e(t[0].body).text())},"iframe html":function(t){return t&&e(t[0].body).html()},"iframe script":function(t){return t&&e.globalEval(e(t[0].body).text())}}})}),!function(e){e(jQuery)}(function(e,t){var i=0,n=Array.prototype.slice,r=e.cleanData;e.cleanData=function(t){for(var i,n=0;null!=(i=t[n]);n++)try{e(i).triggerHandler("remove")}catch(o){}r(t)},e.widget=function(t,i,n){var r,o,s,a,l={},p=t.split(".")[0];t=t.split(".")[1],r=p+"-"+t,n||(n=i,i=e.Widget),e.expr[":"][r.toLowerCase()]=function(t){return!!e.data(t,r)},e[p]=e[p]||{},o=e[p][t],s=e[p][t]=function(e,t){return this._createWidget?void(arguments.length&&this._createWidget(e,t)):new s(e,t)},e.extend(s,o,{version:n.version,_proto:e.extend({},n),_childConstructors:[]}),a=new i,a.options=e.widget.extend({},a.options),e.each(n,function(t,n){return e.isFunction(n)?void(l[t]=function(){var e=function(){return i.prototype[t].apply(this,arguments)},r=function(e){return i.prototype[t].apply(this,e)};return function(){var t,i=this._super,o=this._superApply;return this._super=e,this._superApply=r,t=n.apply(this,arguments),this._super=i,this._superApply=o,t}}()):void(l[t]=n)}),s.prototype=e.widget.extend(a,{widgetEventPrefix:o?a.widgetEventPrefix:t},l,{constructor:s,namespace:p,widgetName:t,widgetFullName:r}),o?(e.each(o._childConstructors,function(t,i){var n=i.prototype;e.widget(n.namespace+"."+n.widgetName,s,i._proto)}),delete o._childConstructors):i._childConstructors.push(s),e.widget.bridge(t,s)},e.widget.extend=function(i){for(var r,o,s=n.call(arguments,1),a=0,l=s.length;l>a;a++)for(r in s[a])o=s[a][r],s[a].hasOwnProperty(r)&&o!==t&&(e.isPlainObject(o)?i[r]=e.isPlainObject(i[r])?e.widget.extend({},i[r],o):e.widget.extend({},o):i[r]=o);return i},e.widget.bridge=function(i,r){var o=r.prototype.widgetFullName||i;e.fn[i]=function(s){var a="string"==typeof s,l=n.call(arguments,1),p=this;return s=!a&&l.length?e.widget.extend.apply(null,[s].concat(l)):s,a?this.each(function(){var n,r=e.data(this,o);return r?e.isFunction(r[s])&&"_"!==s.charAt(0)?(n=r[s].apply(r,l),n!==r&&n!==t?(p=n&&n.jquery?p.pushStack(n.get()):n,!1):void 0):e.error("no such method '"+s+"' for "+i+" widget instance"):e.error("cannot call methods on "+i+" prior to initialization; attempted to call method '"+s+"'")}):this.each(function(){var t=e.data(this,o);t?t.option(s||{})._init():e.data(this,o,new r(s,th