1
1
mirror of https://github.com/aelve/guide.git synced 2024-11-23 12:15:06 +03:00

Allow Ctrl+Enter in small edit fields

This commit is contained in:
Artyom 2016-07-21 22:24:06 +03:00
parent a0fb2bb3c2
commit da7d4a75cb
3 changed files with 7 additions and 6 deletions

View File

@ -384,7 +384,7 @@ makeTraitEditor =
"class" : "fullwidth", "class" : "fullwidth",
"text" : content })[0]; "text" : content })[0];
area.onkeydown = function (event) { area.onkeydown = function (event) {
if (event.keyCode == 13) { if (event.keyCode == 13 || event.keyCode == 10) {
submitTrait(traitNode, itemId, traitId, content, area.value); submitTrait(traitNode, itemId, traitId, content, area.value);
return false; } }; return false; } };
br = $("<br>")[0]; br = $("<br>")[0];
@ -399,7 +399,7 @@ makeTraitEditor =
info = $("<span>", {"style":"float:right"})[0]; info = $("<span>", {"style":"float:right"})[0];
enter = $("<span>", { enter = $("<span>", {
"class": "edit-field-instruction", "class": "edit-field-instruction",
"text" : "press Enter to save" })[0]; "text" : "press Ctrl+Enter or Enter to save" })[0];
markdown = $("<a>", { markdown = $("<a>", {
"href" : "/markdown", "href" : "/markdown",
"target" : "_blank", "target" : "_blank",

View File

@ -999,7 +999,7 @@ renderItemTraits item = cached (CacheItemTraits (item^.uid)) $ do
(\val -> JS.addPro (JS.selectUid listUid, item^.uid, val) <> (\val -> JS.addPro (JS.selectUid listUid, item^.uid, val) <>
JS.assign val ("" :: Text)) JS.assign val ("" :: Text))
Nothing Nothing
"press Enter to add" "press Ctrl+Enter or Enter to add"
textButton "edit off" $ textButton "edit off" $
JS.switchSectionsEverywhere(this, "normal" :: Text) 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) <> (\val -> JS.addCon (JS.selectUid listUid, item^.uid, val) <>
JS.assign val ("" :: Text)) JS.assign val ("" :: Text))
Nothing Nothing
"press Enter to add" "press Ctrl+Enter or Enter to add"
textButton "edit off" $ textButton "edit off" $
JS.switchSectionsEverywhere(this, "normal" :: Text) 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_) -- Use inputValue to get the value (works with input_ and textarea_)
onEnter :: JS -> Attribute onEnter :: JS -> Attribute
onEnter handler = onkeydown_ $ 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 :: JS -> Attribute
onCtrlEnter handler = onkeydown_ $ onCtrlEnter handler = onkeydown_ $

View File

@ -207,7 +207,7 @@ input {
} }
.edit-field-instruction { .edit-field-instruction {
margin-right: 3.5em; margin-right: 2em;
font-size: 75%; font-size: 75%;
vertical-align: 1px; vertical-align: 1px;
color: #666; color: #666;