fix #1768 split tags by comma

stable
Juanfran 2014-12-11 09:16:51 +01:00
parent 947ac85669
commit 9b7d60e0a9
1 changed files with 16 additions and 0 deletions

View File

@ -101,6 +101,7 @@ module.directive("tgColorizeTags", ColorizeTagsDirective)
LbTagLineDirective = ($rs) -> LbTagLineDirective = ($rs) ->
ENTER_KEY = 13 ENTER_KEY = 13
COMMA_KEY = 188
template = """ template = """
<div class="tags-container"></div> <div class="tags-container"></div>
@ -163,6 +164,10 @@ LbTagLineDirective = ($rs) ->
resetInput() resetInput()
hideSaveButton() hideSaveButton()
removeInputLastCharacter = (input) =>
inputValue = input.val()
input.val inputValue.substring(0, inputValue.length - 1)
## Events ## Events
$el.on "keypress", "input", (event) -> $el.on "keypress", "input", (event) ->
return if event.keyCode != ENTER_KEY return if event.keyCode != ENTER_KEY
@ -173,6 +178,9 @@ LbTagLineDirective = ($rs) ->
if event.keyCode == ENTER_KEY if event.keyCode == ENTER_KEY
saveInputTag() saveInputTag()
else if event.keyCode == COMMA_KEY
removeInputLastCharacter(target)
saveInputTag()
else else
if target.val().length if target.val().length
showSaveButton() showSaveButton()
@ -231,6 +239,7 @@ module.directive("tgLbTagLine", ["$tgResources", LbTagLineDirective])
TagLineDirective = ($rootScope, $repo, $rs, $confirm, $qqueue) -> TagLineDirective = ($rootScope, $repo, $rs, $confirm, $qqueue) ->
ENTER_KEY = 13 ENTER_KEY = 13
ESC_KEY = 27 ESC_KEY = 27
COMMA_KEY = 188
template = """ template = """
<div class="tags-container"></div> <div class="tags-container"></div>
@ -335,6 +344,10 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm, $qqueue) ->
resetInput() resetInput()
hideSaveButton() hideSaveButton()
removeInputLastCharacter = (input) =>
inputValue = input.val()
input.val inputValue.substring(0, inputValue.length - 1)
## Events ## Events
$el.on "keypress", "input", (event) -> $el.on "keypress", "input", (event) ->
return if event.keyCode not in [ENTER_KEY, ESC_KEY] return if event.keyCode not in [ENTER_KEY, ESC_KEY]
@ -345,6 +358,9 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm, $qqueue) ->
if event.keyCode == ENTER_KEY if event.keyCode == ENTER_KEY
saveInputTag() saveInputTag()
else if event.keyCode == COMMA_KEY
removeInputLastCharacter(target)
saveInputTag()
else if event.keyCode == ESC_KEY else if event.keyCode == ESC_KEY
resetInput() resetInput()
hideInput() hideInput()