Moved to App.Utils.replaceTags() and fixed quoting issues.

This commit is contained in:
Martin Edenhofer 2016-03-09 08:09:56 +01:00
parent 18e407693a
commit f6deecacd4
4 changed files with 46 additions and 54 deletions

View file

@ -2,6 +2,9 @@ class App.WidgetTextModule extends App.Controller
constructor: ->
super
if !@data
@data = {}
# remember instances
@bindElements = []
if @selector
@ -26,22 +29,10 @@ class App.WidgetTextModule extends App.Controller
update: =>
allRaw = App.TextModule.all()
all = []
data = @data || @
for item in allRaw
if item.active is true
attributes = item.attributes()
attributes.content = attributes.content.replace( /#\{{0,2}(.+?)\s{0,2}\}/g, ( index, key ) ->
key = key.replace( /@/g, 'data.' )
varString = "#{key}" + ''
#console.log( "tag replacement env: ", data)
try
#console.log( "tag replacement: " + key, varString )
key = eval (varString)
catch error
#console.log( "tag replacement error: " + error )
key = ''
return key
)
attributes.content = App.Utils.replaceTags(attributes.content, @data)
all.push attributes
# set new data

View file

@ -83,7 +83,8 @@
if (e.keyCode == 38 && active.prev().size()) {
active = active.prev()
} else if ( e.keyCode == 40 && active.next().size() ) {
}
else if (e.keyCode == 40 && active.next().size()) {
active = active.next()
}
@ -94,7 +95,8 @@
if (active.position().top < 0) {
// scroll up
menu.scrollTop( menu.scrollTop() + active.position().top )
} else if ( active.position().top + active.height() > menu.height() ) {
}
else if ( active.position().top + active.height() > menu.height() ) {
// scroll down
var invisibleHeight = active.position().top + active.height() - menu.height()
menu.scrollTop( menu.scrollTop() + invisibleHeight )
@ -204,7 +206,7 @@
// set position of widget
Plugin.prototype.updatePosition = function() {
this.$widget.find('.dropdown-menu').scrollTop( 300 );
this.$widget.find('.dropdown-menu').scrollTop(300)
if (!this.$element.is(':visible')) return
// get cursor position
@ -372,13 +374,13 @@
var item = result[i]
var element = $('<li>')
element.attr('data-id', item.id)
element.text(App.Utils.htmlEscape(item.name))
element.text(item.name)
element.addClass('u-clickable u-textTruncate')
if (i == result.length-1) {
element.addClass('is-active')
}
if (item.keywords) {
element.append($('<kbd>').text(App.Utils.htmlEscape(item.keywords)))
element.append($('<kbd>').text(item.keywords))
}
elements = elements.add(element)
}
@ -400,8 +402,7 @@
$.fn[pluginName] = function (options) {
return this.each(function () {
if (!$.data(this, 'plugin_' + pluginName)) {
$.data(this, 'plugin_' + pluginName,
new Plugin( this, options ));
$.data(this, 'plugin_' + pluginName, new Plugin(this, options))
}
});
}

View file

@ -101,7 +101,7 @@ class AgentTicketActionLevel0Test < TestCase
data: {
name: 'some name' + random,
keywords: random,
content: 'some content #{@ticket.customer.lastname}' + random,
content: 'some content #{ticket.customer.lastname}' + random,
},
)