From 57fd068ba9f889fdb59de3cf8b435046c9d36bcb Mon Sep 17 00:00:00 2001 From: lmm214 Date: Sat, 25 Feb 2023 15:57:37 +0800 Subject: [PATCH] Memos --- README.md | 2 + css/main.css | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++ js/oper.js | 56 ++++++++++------------ manifest.json | 2 +- popup.html | 24 +++++----- 5 files changed, 168 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index e9b386f..477396a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ ## 更新日志 +2023.02.26 更改 Memos 可见范围按钮样式。 + 2023.02.25 修复 v0.11.0 下随机按钮失效。(api amount 失效导致,换用 stats 获取总条数) ![iShot_2023-02-06_19 16 28](https://user-images.githubusercontent.com/1472390/216958098-1f4fab2a-e77c-41bd-8ba3-5786f42744d7.png) diff --git a/css/main.css b/css/main.css index 7361161..d7ba76e 100644 --- a/css/main.css +++ b/css/main.css @@ -246,4 +246,134 @@ input.inputer{border-bottom: 1px solid #ccc;width:75%;} animation-duration: .3s; -webkit-animation-fill-mode: both; animation-fill-mode: both; +} + +.\!hidden{ + display: none!important; +} +.selector-wrapper { + position: relative; + display: flex; + height: 2rem; + flex-direction: column; + align-items: flex-start; + justify-content: flex-start +} +.selector-wrapper>.current-value-container { + display: flex; + height: 100%; + width: 100%; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; + flex-direction: row; + align-items: center; + justify-content: space-between; + border-radius: .25rem; + border-width: 1px; + --tw-bg-opacity: 1; + background-color: rgb(255 255 255 / var(--tw-bg-opacity)); + padding-left: .5rem; + padding-right: .25rem; +} +.selector-wrapper>.current-value-container>.value-text { + margin-right: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + font-size: .875rem +} +.selector-wrapper>.current-value-container>.value-text { + width: calc(100% - 20px) +} +.selector-wrapper>.current-value-container>.lock-text { + margin-right: .25rem; + display: flex; + width: 1rem; + flex-shrink: 0; + flex-direction: row; + align-items: center; + justify-content: center +} +.selector-wrapper>.current-value-container>.arrow-text { + display: flex; + width: 1rem; + flex-shrink: 0; + flex-direction: row; + align-items: center; + justify-content: center +} +.selector-wrapper>.current-value-container>.arrow-text>.icon-img { + height: auto; + width: 1rem; + opacity: .4 +} +.selector-wrapper>.items-wrapper { + position: absolute; + bottom: 100%; + left: 0px; + z-index: 1; + margin-top: .25rem; + margin-left: -.5rem; + display: flex; + width: auto; + flex-direction: column; + align-items: flex-start; + justify-content: flex-start; + overflow-y: auto; + border-radius: .375rem; + --tw-bg-opacity: 1; + background-color: rgb(255 255 255 / var(--tw-bg-opacity)); + padding: .25rem; + -ms-overflow-style: none; + scrollbar-width: none +} +.selector-wrapper>.items-wrapper::-webkit-scrollbar { + display: none +} +.selector-wrapper>.items-wrapper { + min-width: calc(100% + 16px); + max-height: 256px; + box-shadow: 0 0 8px #0003 +} +.selector-wrapper>.items-wrapper>.item-lock { + display: flex; + width: 100%; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; + flex-direction: column; + align-items: flex-start; + justify-content: flex-start; + white-space: nowrap; + border-radius: .25rem; + padding-left: .75rem; + padding-right: .75rem; + font-size: .875rem; + line-height: 2rem +} +.selector-wrapper>.items-wrapper>.item-lock:hover { + --tw-bg-opacity: 1; + background-color: rgb(243 244 246 / var(--tw-bg-opacity)) +} +.selector-wrapper>.items-wrapper>.item-lock.selected { + --tw-text-opacity: 1; + color: rgb(22 163 74 / var(--tw-text-opacity)) +} + +.selector-wrapper>.items-wrapper>.tip-text { + padding: .25rem .75rem; + font-size: .875rem; + --tw-text-opacity: 1; + color: rgb(75 85 99 / var(--tw-text-opacity)) +} +.selector-wrapper>.selector-disabled { + cursor: not-allowed; + pointer-events: none; + --tw-bg-opacity: 1; + background-color: rgb(229 231 235 / var(--tw-bg-opacity)); + --tw-text-opacity: 1; + color: rgb(156 163 175 / var(--tw-text-opacity)) } \ No newline at end of file diff --git a/js/oper.js b/js/oper.js index 2115a25..4f63444 100644 --- a/js/oper.js +++ b/js/oper.js @@ -12,13 +12,14 @@ get_info(function (info) { chrome.storage.sync.set( { memo_lock: 'PUBLIC'} ) + $("#lock-now").text("所有人可见") } - if(memoNow !== "PUBLIC"){ - $('#locked').show() - $('#unlock').hide() - }else{ - $('#locked').hide() - $('#unlock').show() + if(memoNow == "PUBLIC"){ + $("#lock-now").text("所有人可见") + }else if(memoNow == "PRIVATE"){ + $("#lock-now").text("仅自己可见") + }else if(memoNow == "PROTECTED"){ + $("#lock-now").text("登录用户可见") } $('#apiUrl').val(info.apiUrl) if (info.open_action === 'upload_image') { @@ -39,6 +40,12 @@ $("textarea[name=text]").blur(function () { ) }) +$("textarea[name=text]").on('keydown', function (ev) { + if (ev.code === 'Enter' && (ev.ctrlKey || ev.metaKey)) { + $('#content_submit_text').click() + } +}) + //监听拖拽事件,实现拖拽到窗口上传图片 initDrag() @@ -216,12 +223,17 @@ $('#tags').click(function () { }) }) -$('#unlock,#locked').click(function () { - get_info(function (info) { - var nowlock = info.memo_lock - var lockDom = '公开仅自己登录可见' - $("#visibilitylist").html(lockDom).slideToggle(500) - }) +$('#lock').click(function () { + $("#lock-wrapper").toggleClass( "!hidden", 1000 ); +}) + +$(document).on("click",".item-lock",function () { + $("#lock-wrapper").toggleClass( "!hidden", 1000 ); + $("#lock-now").text($(this).text()) + _this = $(this)[0].dataset.type; + chrome.storage.sync.set( + {memo_lock: _this} + ) }) dayjs.extend(window.dayjs_plugin_relativeTime) @@ -374,26 +386,6 @@ get_info(function (info) { }) }) -$(document).on("click",".item-lock",function () { - _this = $(this)[0].dataset.type - if(_this !== "PUBLIC"){ - $('#locked').show() - $('#unlock').hide() - }else{ - $('#locked').hide() - $('#unlock').show() - } - chrome.storage.sync.set( - {memo_lock: _this}, - function () { - $.message({ - message: '设置成功,当前为: '+ _this - }) - $('#visibilitylist').hide() - } - ) -}) - $(document).on("click",".item-container",function () { var tagHtml = $(this).text()+" " add(tagHtml); diff --git a/manifest.json b/manifest.json index 4fc6306..548e9e5 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "__MSG_extName__", - "version": "2023.02.25", + "version": "2023.02.26", "action": { "default_popup": "popup.html", "default_icon": "assets/logo_24x24.png", diff --git a/popup.html b/popup.html index 50f184a..44ee793 100644 --- a/popup.html +++ b/popup.html @@ -68,24 +68,22 @@ -
- - - - -
-
- - - - -
+
+
+ +
+
+
仅自己可见
+
登录用户可见
+
所有人可见
+
+
@@ -93,7 +91,7 @@
-
+