From da7d4a75cb6f47886a09b7b012ac62ab9ce04e21 Mon Sep 17 00:00:00 2001 From: Artyom Date: Thu, 21 Jul 2016 22:24:06 +0300 Subject: [PATCH] Allow Ctrl+Enter in small edit fields --- src/JS.hs | 4 ++-- src/View.hs | 7 ++++--- static/css.css | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/JS.hs b/src/JS.hs index 099bf25..5306c0d 100644 --- a/src/JS.hs +++ b/src/JS.hs @@ -384,7 +384,7 @@ makeTraitEditor = "class" : "fullwidth", "text" : content })[0]; area.onkeydown = function (event) { - if (event.keyCode == 13) { + if (event.keyCode == 13 || event.keyCode == 10) { submitTrait(traitNode, itemId, traitId, content, area.value); return false; } }; br = $("
")[0]; @@ -399,7 +399,7 @@ makeTraitEditor = info = $("", {"style":"float:right"})[0]; enter = $("", { "class": "edit-field-instruction", - "text" : "press Enter to save" })[0]; + "text" : "press Ctrl+Enter or Enter to save" })[0]; markdown = $("", { "href" : "/markdown", "target" : "_blank", diff --git a/src/View.hs b/src/View.hs index 91555c7..95abf7e 100644 --- a/src/View.hs +++ b/src/View.hs @@ -999,7 +999,7 @@ renderItemTraits item = cached (CacheItemTraits (item^.uid)) $ do (\val -> JS.addPro (JS.selectUid listUid, item^.uid, val) <> JS.assign val ("" :: Text)) Nothing - "press Enter to add" + "press Ctrl+Enter or Enter to add" textButton "edit off" $ JS.switchSectionsEverywhere(this, "normal" :: Text) @@ -1025,7 +1025,7 @@ renderItemTraits item = cached (CacheItemTraits (item^.uid)) $ do (\val -> JS.addCon (JS.selectUid listUid, item^.uid, val) <> JS.assign val ("" :: Text)) Nothing - "press Enter to add" + "press Ctrl+Enter or Enter to add" textButton "edit off" $ JS.switchSectionsEverywhere(this, "normal" :: Text) @@ -1189,7 +1189,8 @@ emptySpan w = span_ [style_ ("margin-left:" <> w)] mempty -- Use inputValue to get the value (works with input_ and textarea_) onEnter :: JS -> Attribute onEnter handler = onkeydown_ $ - T.format "if (event.keyCode == 13) {{} return false;}" [handler] + T.format "if (event.keyCode==13 || event.keyCode==10)\ + \ {{} return false;}" [handler] onCtrlEnter :: JS -> Attribute onCtrlEnter handler = onkeydown_ $ diff --git a/static/css.css b/static/css.css index 4c7fd5e..927a2f3 100644 --- a/static/css.css +++ b/static/css.css @@ -207,7 +207,7 @@ input { } .edit-field-instruction { - margin-right: 3.5em; + margin-right: 2em; font-size: 75%; vertical-align: 1px; color: #666;