Adding directive for disabling long line edition

stable
Alejandro Alonso 2014-08-18 14:46:23 +02:00
parent 8778391d8a
commit 335c9d47a3
2 changed files with 24 additions and 1 deletions

View File

@ -444,3 +444,26 @@ ProjectUrl = ($navurls) ->
return {get: get} return {get: get}
module.factory("$projectUrl", ["$tgNavUrls", ProjectUrl]) module.factory("$projectUrl", ["$tgNavUrls", ProjectUrl])
#############################################################################
## Limite line size in a text area
#############################################################################
LimitLineLengthDirective = () ->
link = ($scope, $el, $attrs) ->
maxColsPerLine = parseInt($el.attr("cols"))
$el.on "keyup", (event) ->
code = event.keyCode
lines = $el.val().split("\n")
_.each lines, (line, index) ->
lines[index] = line.substring(0, maxColsPerLine - 2)
$el.val(lines.join("\n"))
return {link:link}
module.directive("tgLimitLineLength", LimitLineLengthDirective)

View File

@ -3,6 +3,6 @@ a.close(href="", title="close")
form form
h2.title(tg-i18n="common.new-bulk") h2.title(tg-i18n="common.new-bulk")
fieldset fieldset
textarea(tg-i18n="placeholder:common.one-item-line", ng-model="new.bulk", data-required="true", data-linewidth="200") textarea(cols="200", wrap="off", tg-limit-line-length, tg-i18n="placeholder:common.one-item-line", ng-model="new.bulk", data-required="true", data-linewidth="200")
a.button.button-green(href="", tg-i18n="title:common.save") a.button.button-green(href="", tg-i18n="title:common.save")
span(tg-i18n="common.save") span(tg-i18n="common.save")