Fixed inline translations with &, < and > issues.

This commit is contained in:
Martin Edenhofer 2015-11-20 10:53:56 +01:00
parent da047e6286
commit 28dcee225d

View file

@ -34,7 +34,7 @@ class Widget extends App.Controller
$('body') $('body')
.on 'focus.translation', '.translation', (e) -> .on 'focus.translation', '.translation', (e) ->
element = $(e.target) element = $(e.target)
element.data 'before', element.html() element.data 'before', element.text()
element element
.on 'blur.translation', '.translation', (e) => .on 'blur.translation', '.translation', (e) =>
console.log('blur') console.log('blur')
@ -42,12 +42,7 @@ class Widget extends App.Controller
source = element.attr('title') source = element.attr('title')
# get new translation # get new translation
translation_new = element.html() translation_new = element.text()
translation_new = ('' + translation_new)
.replace(/<.+?>/g, '')
# set new translation
element.html(translation_new)
# update translation # update translation
return if element.data('before') is translation_new return if element.data('before') is translation_new
@ -58,7 +53,7 @@ class Widget extends App.Controller
App.i18n.setMap(source, translation_new) App.i18n.setMap(source, translation_new)
# replace rest in page # replace rest in page
$(".translation[title='#{source}']").html(translation_new) $(".translation[title='#{source}']").text(translation_new)
# update permanent translation mapString # update permanent translation mapString
translation = App.Translation.findByAttribute('source', source) translation = App.Translation.findByAttribute('source', source)