Sha256: 514b438b5ea29e3a4dc0a07cc3f42b42cd1aa46312dbf61e8c06837f555fe7b7

Contents?: true

Size: 1.33 KB

Versions: 13

Compression:

Stored size: 1.33 KB

Contents

window.Commontator = {};
Commontator._ = window._.noConflict();
Commontator.initMentions = function() {
    $('.commontator .field textarea:not(.mentions-added)').each(function(_index, textarea){
        $textarea = $(textarea);
        $form = $textarea.parents('form');
        threadId = $textarea.parents('.thread').attr('id').match(/[\d]+/)[0];
        $textarea.addClass('mentions-added');
        currentValue = $textarea.val();
        $textarea.mentionsInput({
            elastic: false,
            showAvatars: false,
            allowRepeat: true,
            minChars: 3,
            onDataRequest:function (mode, query, callback) {
                $.getJSON('/commontator/threads/' + threadId + '/mentions.json', {q: query}, function(responseData) {
                    callback.call(this, responseData.mentions);
                });
            }
        });
        $textarea.val(currentValue);
        $textarea.on('focusout', function(){
            $textarea.mentionsInput('getMentions', function(mentions){
                $form.find('input[name="mentioned_ids[]"]').remove();
                $(mentions).each(function(_index, mention){
                    $input = $('<input>', { type: 'hidden', name: 'mentioned_ids[]', value: mention.id });
                    $form.append($input)
                });
            });
        });
    });
};

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
commontator-7.0.1 app/assets/javascripts/commontator/mentions.js
commontator-7.0.0 app/assets/javascripts/commontator/mentions.js
commontator-6.3.2 app/assets/javascripts/commontator/mentions.js
commontator-6.3.1 app/assets/javascripts/commontator/mentions.js
commontator-6.3.0 app/assets/javascripts/commontator/mentions.js
commontator-6.2.1 app/assets/javascripts/commontator/mentions.js
commontator-6.2.0 app/assets/javascripts/commontator/mentions.js
commontator-6.1.1 app/assets/javascripts/commontator/mentions.js
commontator-6.1.0 app/assets/javascripts/commontator/mentions.js
commontator-6.0.1 app/assets/javascripts/commontator/mentions.js
commontator-6.0.0 app/assets/javascripts/commontator/mentions.js
commontator-6.0.0.pre.2 app/assets/javascripts/commontator/mentions.js
commontator-6.0.0.pre.1 app/assets/javascripts/commontator/mentions.js