Skip to content

Commit

Permalink
arkhitech#37 Added textcomplete invocation for CK Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
amenk committed May 19, 2016
1 parent 84400ff commit e41c163
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions app/views/hooks/redmine_mentions/_edit_mentionable.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<% users_regex = users.collect{|u| "#{Setting.plugin_redmine_mentions['trigger']}#{u.login}"}.join('|')%>
<% regex_highlight = '/\B('+users_regex+')\b/g' %>
<script>
$('#issue_notes,#issue_description').textcomplete([
var textcompleteOptions = [
{
mentions: <%= users.collect{|u| "#{u.firstname} #{u.lastname} - <small>#{u.login}</small>"}.to_json.html_safe %>,
match: <%=regex_find%>,
Expand All @@ -27,12 +27,27 @@
return '<%=Setting.plugin_redmine_mentions['trigger']%>' + name + ' ';
}
}
]).overlay([
];

$('#issue_notes,#issue_description').textcomplete(textcompleteOptions).overlay([
{
match: new RegExp(<%=regex_highlight%>),
css: {
'background-color': '#C6D5F3',
}
}
]);

if (typeof CKEDITOR != 'undefined') {
CKEDITOR.on("instanceReady", function(event)
{
$('#issue_edit_textarea iframe').each(function(index, element) {
if ($(element).data('mentionable-active') == 'yes') {
return;
}
$(element).data('mentionable-active', 'yes');
$(element).contents().find('body').textcomplete(textcompleteOptions); // overlay not working in this case
})
});
}
</script>

0 comments on commit e41c163

Please sign in to comment.