diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee index 9c0b3d070..0a183c008 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee @@ -86,11 +86,35 @@ class App.TicketZoomArticleNew extends App.Controller @render() ) + # set expand of text area only once + @bind('ui::ticket::shown', (data) => + return if data.ticket_id.toString() isnt @ticket.id.toString() + console.log('SHOW, ui::ticket::shown', data.ticket_id) + @tokanice() + ) + # rerender, e. g. on language change @bind('ui:rerender', => @render() ) + tokanice: -> + source = "#{App.Config.get('api_path')}/users/search" + a = -> + $('.content.active .js-to, .js-cc, js-bcc').tokenfield( + createTokensOnBlur: true + autocomplete: { + source: source + minLength: 2 + }, + ).on('tokenfield:createtoken', (e) -> + if !e.attrs.value.match(/@/) || e.attrs.value.match(/\s/) + e.preventDefault() + return false + true + ) + App.Delay.set(a, 500, undefined, 'tags') + setPossibleArticleTypes: => actionConfig = App.Config.get('TicketZoomArticleAction') keys = _.keys(actionConfig).sort() @@ -147,15 +171,7 @@ class App.TicketZoomArticleNew extends App.Controller position: 'right' ) - configure_attributes = [ - { name: 'customer_id', display: 'Recipients', tag: 'user_autocompletion', null: false, placeholder: 'Enter Person or Organization/Company', minLengt: 2, disableCreateObject: false }, - ] - - controller = new App.ControllerForm( - el: @$('.recipients') - model: - configure_attributes: configure_attributes - ) + @tokanice() @$('[data-name="body"]').ce({ mode: 'richtext' @@ -334,6 +350,7 @@ class App.TicketZoomArticleNew extends App.Controller @hideSelectableArticleType() $(window).off 'click.ticket-zoom-select-type' + @tokanice() hideSelectableArticleType: => @el.find('.js-articleTypes').addClass('is-hidden') diff --git a/app/assets/javascripts/app/lib/base/bootstrap-tokenfield.js b/app/assets/javascripts/app/lib/base/bootstrap-tokenfield.js index 5b2759d49..38d2822a6 100644 --- a/app/assets/javascripts/app/lib/base/bootstrap-tokenfield.js +++ b/app/assets/javascripts/app/lib/base/bootstrap-tokenfield.js @@ -2,6 +2,10 @@ * bootstrap-tokenfield * https://github.com/sliptree/bootstrap-tokenfield * Copyright 2013-2014 Sliptree and other contributors; Licensed MIT + * + * Edit: Felix + * - remove maxTokenWidth + * */ (function (factory) { @@ -250,25 +254,6 @@ var $tokenLabel = $token.find('.token-label') , $closeButton = $token.find('.close') - // Determine maximum possible token label width - if (!this.maxTokenWidth) { - this.maxTokenWidth = - this.$wrapper.width() - $closeButton.outerWidth() - - parseInt($closeButton.css('margin-left'), 10) - - parseInt($closeButton.css('margin-right'), 10) - - parseInt($token.css('border-left-width'), 10) - - parseInt($token.css('border-right-width'), 10) - - parseInt($token.css('padding-left'), 10) - - parseInt($token.css('padding-right'), 10) - parseInt($tokenLabel.css('border-left-width'), 10) - - parseInt($tokenLabel.css('border-right-width'), 10) - - parseInt($tokenLabel.css('padding-left'), 10) - - parseInt($tokenLabel.css('padding-right'), 10) - parseInt($tokenLabel.css('margin-left'), 10) - - parseInt($tokenLabel.css('margin-right'), 10) - } - - $tokenLabel.css('max-width', this.maxTokenWidth) if (this.options.html) $tokenLabel.html(attrs.label) else diff --git a/app/assets/javascripts/app/views/ticket_zoom/article_new.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/article_new.jst.eco index 7f7142818..a4d1ae0b3 100644 --- a/app/assets/javascripts/app/views/ticket_zoom/article_new.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom/article_new.jst.eco @@ -41,19 +41,19 @@