From b22b8594300cd649af726ef010842f0809da1749 Mon Sep 17 00:00:00 2001 From: life Date: Thu, 24 Sep 2015 12:44:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/app/native.js | 62 ++++++++++++++++++++-------------- src/public/js/app/page.js | 13 +++---- src/public/js/common.js | 5 +++ src/public/js/dec/history.js | 8 +++++ src/public/themes/default.css | 1 + src/public/themes/default.less | 1 + 6 files changed, 57 insertions(+), 33 deletions(-) diff --git a/src/public/js/app/native.js b/src/public/js/app/native.js index 1c82c7f2..1eb62c12 100644 --- a/src/public/js/app/native.js +++ b/src/public/js/app/native.js @@ -181,28 +181,28 @@ var menu = new Menu(); // 右键菜单 var winHref = ''; var $curTarget; -$('#noteTitle, #searchNoteInput, #searchNotebookForList, #addTagInput, #wmd-input, #preview-contents, #editorContent, #presentation').on('contextmenu', function (e) { - e.preventDefault(); - var $target = $(e.target); - $curTarget = $target; - var text = $target.text(); - winHref = $target.attr('href'); - if(!winHref) { - winHref = text; - } - // 判断是否满足http://leanote.com - if(winHref) { - if (winHref.indexOf('http://127.0.0.1') < 0 && isURL(winHref)) { - } else { - winHref = false; - } - } +var openContextmenu = function (e, canCut2, canPaste2) { + e.preventDefault(); + var $target = $(e.target); + $curTarget = $target; + var text = $target.text(); + winHref = $target.attr('href'); + if(!winHref) { + winHref = text; + } + // 判断是否满足http://leanote.com + if(winHref) { + if (winHref.indexOf('http://127.0.0.1') < 0 && isURL(winHref)) { + } else { + winHref = false; + } + } - menu.canOpenInBroswer(!!winHref); - menu.canSaveAs($target.is('img') && $target.attr('src')); - var selectionType = window.getSelection().type.toUpperCase(); - // var clipData = gui.Clipboard.get().get(); - // menu.canPaste(clipData.length > 0); + menu.canOpenInBroswer(!!winHref); + menu.canSaveAs($target.is('img') && $target.attr('src')); + var selectionType = window.getSelection().type.toUpperCase(); + // var clipData = gui.Clipboard.get().get(); + // menu.canPaste(clipData.length > 0); var canPaste = true; var canCut = true; @@ -214,11 +214,23 @@ $('#noteTitle, #searchNoteInput, #searchNotebookForList, #addTagInput, #wmd-inpu canCut = false; } } - - menu.canCopy(selectionType === 'RANGE'); + + menu.canCopy(selectionType === 'RANGE'); menu.canPaste(canPaste); menu.canCut(canCut); - menu.popup(e.originalEvent.x, e.originalEvent.y); -}); \ No newline at end of file + if (typeof canCut2 !== 'undefined') { + menu.canCut(!!canCut2); + } + if (typeof canPaste2 !== 'undefined') { + menu.canPaste(!!canPaste2); + } + + menu.popup(e.originalEvent.x, e.originalEvent.y); +}; + +$('#noteTitle, #searchNoteInput, #searchNotebookForList, #addTagInput, #wmd-input, #preview-contents, #editorContent, #presentation').on('contextmenu', openContextmenu); +$('body').on('contextmenu', '.history-content', function (e) { + openContextmenu(e, false, false); +}); diff --git a/src/public/js/app/page.js b/src/public/js/app/page.js index 28f06cb0..e34c42f7 100644 --- a/src/public/js/app/page.js +++ b/src/public/js/app/page.js @@ -472,9 +472,11 @@ function initEditor() { + "Times New Roman=times new roman,times;" + "Courier New=courier new,courier;" + "Tahoma=tahoma,arial,helvetica,sans-serif;" - + "Verdana=verdana,geneva;" + "宋体=SimSun;" - + "新宋体=NSimSun;" + "黑体=SimHei;" - + "微软雅黑=Microsoft YaHei", + + "Verdana=verdana,geneva;" + + "宋体=SimSun;" + + "新宋体=NSimSun;" + + "黑体=SimHei;" + + "Microsoft YaHei=Microsoft YaHei", block_formats : "Header 1=h1;Header 2=h2;Header 3=h3;Header 4=h4;Paragraph=p", // This option specifies whether data:url images (inline images) should be removed or not from the pasted contents. // Setting this to "true" will allow the pasted images, and setting this to "false" will disallow pasted images. @@ -1708,11 +1710,6 @@ var Pren = { } }); - function isURL(str_url) { - var re = new RegExp("^((https|http|ftp|rtsp|mms|emailto)://).+"); - return re.test(str_url); - } - // 防止在本窗口打开 me.presentationO.on('click', 'a', function(e) { e.preventDefault(); diff --git a/src/public/js/common.js b/src/public/js/common.js index 06b67127..9fc4936a 100644 --- a/src/public/js/common.js +++ b/src/public/js/common.js @@ -1676,4 +1676,9 @@ var onClose = function(afterFunc) { } } +function isURL(str_url) { + var re = new RegExp("^((https|http|ftp|rtsp|mms|emailto)://).+"); + return re.test(str_url); +} + ContextTips.init(); diff --git a/src/public/js/dec/history.js b/src/public/js/dec/history.js index bc2652f8..19c370fd 100644 --- a/src/public/js/dec/history.js +++ b/src/public/js/dec/history.js @@ -100,6 +100,14 @@ define(function() { Note.curChangedSaveIt(true); } }); + + $historyContent.on('click', 'a', function(e) { + e.preventDefault(); + var href = $(this).attr('href'); + if(href && href.indexOf('http://127.0.0.1') < 0 && isURL(href)) { + openExternal(href); + } + }); }, getHistories: function () { diff --git a/src/public/themes/default.css b/src/public/themes/default.css index bcce1733..9f45f9bf 100644 --- a/src/public/themes/default.css +++ b/src/public/themes/default.css @@ -2629,6 +2629,7 @@ body, bottom: 0; right: 0; left: 0; + -webkit-user-select: text; padding-top: 5px; padding-right: 5px; padding-left: 10px; diff --git a/src/public/themes/default.less b/src/public/themes/default.less index 266a3a42..652ab05d 100644 --- a/src/public/themes/default.less +++ b/src/public/themes/default.less @@ -898,6 +898,7 @@ html, body, #page, #pageInner, #noteList, #notebook, #leftNotebook { bottom: 0; right: 0; left: 0; + -webkit-user-select: text; padding-top: 5px; padding-right: 5px; padding-left: 10px;