2015-03-31 14:27:26 +08:00
|
|
|
function editorMode(){this.writingHash="writing";this.normalHash="normal";this.isWritingMode=location.hash.indexOf(this.writingHash)>=0;this.toggleA=null}editorMode.prototype.toggleAText=function(isWriting){var self=this;setTimeout(function(){var toggleA=$(".toggle-editor-mode a");var toggleSpan=$(".toggle-editor-mode span");if(isWriting){toggleA.attr("href","#"+self.normalHash);toggleSpan.text(getMsg("normalMode"))}else{toggleA.attr("href","#"+self.writingHash);toggleSpan.text(getMsg("writingMode"))}},0)};editorMode.prototype.isWriting=function(hash){return hash.indexOf(this.writingHash)>=0};editorMode.prototype.init=function(){this.changeMode(this.isWritingMode);var self=this;$(".toggle-editor-mode").click(function(e){e.preventDefault();saveBookmark();var $a=$(this).find("a");var isWriting=self.isWriting($a.attr("href"));self.changeMode(isWriting);if(isWriting){setHash("m",self.writingHash)}else{setHash("m",self.normalHash)}restoreBookmark()})};editorMode.prototype.changeMode=function(isWritingMode){this.toggleAText(isWritingMode);if(isWritingMode){this.writtingMode()}else{this.normalMode()}$("#moreBtn i").removeClass("fa-angle-up").addClass("fa-angle-down")};editorMode.prototype.resizeEditor=function(){setTimeout(function(){resizeEditor()},10);setTimeout(function(){resizeEditor()},20);setTimeout(function(){resizeEditor()},500)};editorMode.prototype.normalMode=function(){var $c=$("#editorContent_ifr").contents();$c.contents().find("#writtingMode").remove();$c.contents().find('link[href$="editor-writting-mode.css"]').remove();$("#noteItemListWrap, #notesAndSort").show();$("#noteList").unbind("mouseenter").unbind("mouseleave");var theme=UserInfo.Theme||"default";theme+=".css";$("#themeLink").attr("href","/css/theme/"+theme);$("#mceToolbar").css("height","30px");this.resizeEditor();$("#noteList").width(UserInfo.NoteListWidth);$("#note").css("left",UserInfo.NoteListWidth)};editorMode.prototype.writtingMode=function(){$("#themeLink").attr("href","/css/theme/writting-overwrite.css");setTimeout(function(){var $c=$("#editorContent_ifr").contents();$c.contents().find("head").append('<link type="text/css" rel="stylesheet" href="/css/editor/editor-writting-mode.css" id="writtingMode">')},0);$("#noteItemListWrap, #notesAndSort").fadeOut();$("#noteList").hover(function(){$("#noteItemListWrap, #notesAndSort").fadeIn()},function(){$("#noteItemListWrap, #notesAndSort").fadeOut()});$("#mceToolbar").css("height","40px");this.resizeEditor();$("#noteList").width(250);$("#note").css("left",0)};editorMode.prototype.getWritingCss=function(){if(this.isWritingMode){return["/css/editor/editor-writting-mode.css"]}return[]};var em=new editorMode;var Resize={lineMove:false,mdLineMove:false,target:null,leftNotebook:$("#leftNotebook"),notebookSplitter:$("#notebookSplitter"),noteList:$("#noteList"),noteAndEditor:$("#noteAndEditor"),noteSplitter:$("#noteSplitter"),note:$("#note"),body:$("body"),leftColumn:$("#left-column"),rightColumn:$("#right-column"),mdSplitter:$("#mdSplitter2"),init:function(){var self=this;self.initEvent()},initEvent:function(){var self=this;$(".noteSplit").bind("mousedown",function(event){event.preventDefault();self.lineMove=true;$(this).css("background-color","#ccc");self.target=$(this).attr("id");$("#noteMask").css("z-index",99999)});self.mdSplitter.bind("mousedown",function(event){event.preventDefault();if($(this).hasClass("open")){self.mdLineMove=true}});self.body.bind("mousemove",function(event){if(self.lineMove){event.preventDefault();self.resize3Columns(event)}else if(self.mdLineMove){event.preventDefault();self.resizeMdColumns(event)}});self.body.bind("mouseup",function(event){self.stopResize();$("#noteMask").css("z-index",-1)});var everLeftWidth;$(".layout-toggler-preview").click(function(){var $t=$(this);var $p=self.leftColumn.parent();if($t.hasClass("open")){var totalWidth=$p.width();var minRightWidth=22;var leftWidth=totalWidth-minRightWidth;everLeftWidth=self.leftColumn.width();self.leftColumn.width(leftWidth);self.rightColumn.css("left","auto").width(minRightWidth);$t.removeClass("open");self.rightColumn.find(".la
|