2015-09-05 23:30:24 +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){if(!hash){hash=location.hash}return hash.indexOf(this.writingHash)>=0};editorMode.prototype.init=function(){this.$themeLink=$("#themeLink");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()}};editorMode.prototype.resizeEditor=function(){setTimeout(function(){resizeEditor()},10);setTimeout(function(){resizeEditor()},20);setTimeout(function(){resizeEditor()},500)};editorMode.prototype.normalMode=function(){$("#noteItemListWrap, #notesAndSort").show();$("#noteList").unbind("mouseenter").unbind("mouseleave");var theme=UserInfo.Theme||"default";theme+=".css";var $themeLink=$("#themeLink");if(this.$themeLink.attr("href").indexOf("writting-overwrite.css")!=-1){this.$themeLink.attr("href","/css/theme/"+theme)}$("#noteList").width(UserInfo.NoteListWidth);$("#note").css("left",UserInfo.NoteListWidth)};editorMode.prototype.writtingMode=function(){if(this.$themeLink.attr("href").indexOf("writting-overwrite.css")==-1){this.$themeLink.attr("href","/css/theme/writting-overwrite.css")}$("#noteItemListWrap, #notesAndSort").fadeOut();$("#noteList").hover(function(){$("#noteItemListWrap, #notesAndSort").fadeIn()},function(){$("#noteItemListWrap, #notesAndSort").fadeOut()});this.resizeEditor();$("#noteList").width(250);$("#note").css("left",0);Note.toggleWriteable()};editorMode.prototype.getWritingCss=function(){if(this.isWritingMode){return["/css/editor/editor-writting-mode.css"]}return[]};var em=new editorMode;LEA.em=em;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(".layout-resizer").removeClass("open");$(".preview-container").hide()}else{$t.addClass("open");self.rightColumn.find(".layout-resizer").addClass("open");self.leftColumn.width(everLeftWidth);$(".preview-container").show();self.rightColumn.css("left",everLeftWidth).w
|