Sha256: 195365a075485876f2c22967a300d2c3f1b738000e3d66d437e01ff35d669859

Contents?: true

Size: 1.14 KB

Versions: 7

Compression:

Stored size: 1.14 KB

Contents

// Copyright (c) 2008-2013 Michael Dvorkin and contributors.
//
// Fat Free CRM is freely distributable under the terms of MIT license.
// See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
//------------------------------------------------------------------------------
crm.textarea_user_autocomplete = function(el_id) {
  if (! jQuery('#areacomplete_' + el_id)[0]) {
    jQuery('#' + el_id).areacomplete({
      wordCount: 1,
      mode: "outter",
      on: {
        query: function(text,cb) {
          // Only autocomplete if search term starts with '@'
          if (text.indexOf("@") != 0) { return []; }

          var words = [];
          for( var i=0; i < _ffcrm_users.length; i++ ) {
            var name_query = text.replace("@",'').toLowerCase();
            if (_ffcrm_users[i].toLowerCase().indexOf(name_query) != -1 ) {
              words.push(_ffcrm_users[i]);
            }
          }
          cb(words, text.replace("@",''));
        },
        selected: function(text, data) {
          var username_regEx = new RegExp("\\((@[^)]+)\\)");
          return text.match(username_regEx)[1];
        }
      }
    });
  }
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fat_free_crm-0.13.2 app/assets/javascripts/crm_textarea_autocomplete.js
fat_free_crm-0.12.3 app/assets/javascripts/crm_textarea_autocomplete.js
fat_free_crm-0.12.2 app/assets/javascripts/crm_textarea_autocomplete.js
fat_free_crm-0.13.1 app/assets/javascripts/crm_textarea_autocomplete.js
fat_free_crm-0.12.1 app/assets/javascripts/crm_textarea_autocomplete.js
fat_free_crm-0.13.0 app/assets/javascripts/crm_textarea_autocomplete.js
fat_free_crm-0.12.0 app/assets/javascripts/crm_textarea_autocomplete.js