Feature #31989 » 0001-Inline-auto-complete-for-issue-and-user-in-wiki-edit.patch
| app/controllers/auto_completes_controller.rb | ||
|---|---|---|
|
render :json => format_issues_json(issues)
|
||
|
end
|
||
|
def users
|
||
|
users = []
|
||
|
q = (params[:q] || params[:term]).to_s.strip
|
||
|
scope = nil
|
||
|
if params[:q].blank? && @project.present?
|
||
|
scope = @project.users
|
||
|
else
|
||
|
scope = User.all.limit(10)
|
||
|
end
|
||
|
users = scope.active.visible.sorted.like(params[:q]).to_a
|
||
|
render :json => format_users_json(users)
|
||
|
end
|
||
|
private
|
||
|
def find_project
|
||
| ... | ... | |
|
}
|
||
|
}
|
||
|
end
|
||
|
def format_users_json(users)
|
||
|
users.map {|user| {
|
||
|
'firstname' => user.firstname,
|
||
|
'lastname' => user.lastname,
|
||
|
'name' => user.name,
|
||
|
'login' => user.login
|
||
|
}
|
||
|
}
|
||
|
end
|
||
|
end
|
||
| app/helpers/application_helper.rb | ||
|---|---|---|
|
# Returns the javascript tags that are included in the html layout head
|
||
|
def javascript_heads
|
||
|
tags = javascript_include_tag('jquery-2.2.4-ui-1.11.0-ujs-5.2.3', 'application', 'responsive')
|
||
|
tags = javascript_include_tag('jquery-2.2.4-ui-1.11.0-ujs-5.2.3', 'tribute-3.7.3.min', 'application', 'responsive')
|
||
|
unless User.current.pref.warn_on_leaving_unsaved == '0'
|
||
|
tags << "\n".html_safe + javascript_tag("$(window).on('load', function(){ warnLeavingUnsaved('#{escape_javascript l(:text_warn_on_leaving_unsaved)}'); });")
|
||
|
end
|
||
| app/helpers/custom_fields_helper.rb | ||
|---|---|---|
|
# Return custom field html tag corresponding to its format
|
||
|
def custom_field_tag(prefix, custom_value)
|
||
|
css = "#{custom_value.custom_field.field_format}_cf"
|
||
|
css += ' wiki-edit' if custom_value.custom_field.full_text_formatting?
|
||
|
data = nil
|
||
|
if custom_value.custom_field.full_text_formatting?
|
||
|
css += ' wiki-edit'
|
||
|
data = {
|
||
|
:auto_complete => true,
|
||
|
:issues_url => auto_complete_issues_path(:project_id => custom_value.customized.project, :q => ''),
|
||
|
:users_url => auto_complete_users_path(:project_id => custom_value.customized.project, :q => '')
|
||
|
} if custom_value.customized && custom_value.customized.project
|
||
|
end
|
||
|
custom_value.custom_field.format.edit_tag self,
|
||
|
custom_field_tag_id(prefix, custom_value.custom_field),
|
||
|
custom_field_tag_name(prefix, custom_value.custom_field),
|
||
|
custom_value,
|
||
|
:class => css
|
||
|
:class => css,
|
||
|
:data => data
|
||
|
end
|
||
|
# Return custom field name tag
|
||
| app/views/documents/_form.html.erb | ||
|---|---|---|
|
<div class="box tabular">
|
||
|
<p><%= f.select :category_id, DocumentCategory.active.collect {|c| [c.name, c.id]} %></p>
|
||
|
<p><%= f.text_field :title, :required => true, :size => 60 %></p>
|
||
|
<p><%= f.text_area :description, :cols => 60, :rows => 15, :class => 'wiki-edit' %></p>
|
||
|
<p><%= f.text_area :description, :cols => 60, :rows => 15, :class => 'wiki-edit',
|
||
|
:data => {
|
||
|
:auto_complete => true,
|
||
|
:issues_url => auto_complete_issues_path(:project_id => @project, :q => ''),
|
||
|
:users_url => auto_complete_users_path(:project_id => @project, :q => '')
|
||
|
}
|
||
|
%></p>
|
||
|
<% @document.custom_field_values.each do |value| %>
|
||
|
<p><%= custom_field_tag_with_label :document, value %></p>
|
||
| app/views/issues/_edit.html.erb | ||
|---|---|---|
|
<% end %>
|
||
|
<% if @issue.notes_addable? %>
|
||
|
<fieldset><legend><%= l(:field_notes) %></legend>
|
||
|
<%= f.text_area :notes, :cols => 60, :rows => 10, :class => 'wiki-edit', :no_label => true %>
|
||
|
<%= f.text_area :notes, :cols => 60, :rows => 10, :class => 'wiki-edit',
|
||
|
:data => {
|
||
|
:auto_complete => true,
|
||
|
:issues_url => auto_complete_issues_path(:project_id => @issue.project, :q => ''),
|
||
|
:users_url => auto_complete_users_path(:project_id => @issue.project, :q => '')
|
||
|
},
|
||
|
:no_label => true %>
|
||
|
<%= wikitoolbar_for 'issue_notes', preview_issue_path(:project_id => @project, :issue_id => @issue) %>
|
||
|
<% if @issue.safe_attribute? 'private_notes' %>
|
||
| ... | ... | |
|
<%= hidden_field_tag 'issue_count', @issue_count if @issue_count %>
|
||
|
<% end %>
|
||
| app/views/issues/_form.html.erb | ||
|---|---|---|
|
<%= f.label_for_field :description, :required => @issue.required_attribute?('description') %>
|
||
|
<%= link_to_function content_tag(:span, l(:button_edit), :class => 'icon icon-edit'), '$(this).hide(); $("#issue_description_and_toolbar").show()' unless @issue.new_record? %>
|
||
|
<%= content_tag 'span', :id => "issue_description_and_toolbar", :style => (@issue.new_record? ? nil : 'display:none') do %>
|
||
|
<%= f.text_area :description,
|
||
|
:cols => 60,
|
||
|
<%= f.text_area :description, :cols => 60, :accesskey => accesskey(:edit), :class => 'wiki-edit',
|
||
|
:rows => [[10, @issue.description.to_s.length / 50].max, 20].min,
|
||
|
:accesskey => accesskey(:edit),
|
||
|
:class => 'wiki-edit',
|
||
|
:data => {
|
||
|
:auto_complete => true,
|
||
|
:issues_url => auto_complete_issues_path(:project_id => @issue.project, :q => ''),
|
||
|
:users_url => auto_complete_users_path(:project_id => @issue.project, :q => '')
|
||
|
},
|
||
|
:no_label => true %>
|
||
|
<% end %>
|
||
|
</p>
|
||
| app/views/issues/bulk_edit.html.erb | ||
|---|---|---|
|
<fieldset>
|
||
|
<legend><%= l(:field_notes) %></legend>
|
||
|
<%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %>
|
||
|
<%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit',
|
||
|
:data => {
|
||
|
:auto_complete => true,
|
||
|
:issues_url => auto_complete_issues_path(:project_id => @project, :q => ''),
|
||
|
:users_url => auto_complete_users_path(:project_id => @project, :q => '')
|
||
|
}
|
||
|
%>
|
||
|
<%= wikitoolbar_for 'notes' %>
|
||
|
<% if @safe_attributes.include?('private_notes') %>
|
||
| app/views/journals/_notes_form.html.erb | ||
|---|---|---|
|
:method => 'put',
|
||
|
:id => "journal-#{@journal.id}-form") do %>
|
||
|
<%= label_tag "notes", l(:description_notes), :class => "hidden-for-sighted", :for => "journal_#{@journal.id}_notes" %>
|
||
|
<%= text_area_tag 'journal[notes]', @journal.notes,
|
||
|
:id => "journal_#{@journal.id}_notes",
|
||
|
:class => 'wiki-edit',
|
||
|
:rows => (@journal.notes.blank? ? 10 : [[10, @journal.notes.length / 50].max, 100].min) %>
|
||
|
<%= text_area_tag 'journal[notes]', @journal.notes, :id => "journal_#{@journal.id}_notes", :class => 'wiki-edit',
|
||
|
:rows => (@journal.notes.blank? ? 10 : [[10, @journal.notes.length / 50].max, 100].min),
|
||
|
:data => {
|
||
|
:auto_complete => true,
|
||
|
:issues_url => auto_complete_issues_path(:project_id => @project, :q => ''),
|
||
|
:users_url => auto_complete_users_path(:project_id => @project, :q => '')
|
||
|
}
|
||
|
%>
|
||
|
<% if @journal.safe_attribute? 'private_notes' %>
|
||
|
<%= hidden_field_tag 'journal[private_notes]', '0' %>
|
||
|
<%= check_box_tag 'journal[private_notes]', '1', @journal.private_notes, :id => "journal_#{@journal.id}_private_notes" %>
|
||
| ... | ... | |
|
<%= link_to l(:button_cancel), '#', :onclick => "$('#journal-#{@journal.id}-form').remove(); $('#journal-#{@journal.id}-notes').show(); return false;" %></p>
|
||
|
<% end %>
|
||
|
<%= wikitoolbar_for "journal_#{@journal.id}_notes", preview_issue_path(:project_id => @project, :issue_id => @journal.issue) %>
|
||
|
<%= javascript_tag do %>
|
||
|
new inlineAutoComplete(document.getElementById("journal_<%= @journal.id %>_notes"));
|
||
|
<% end %>
|
||
| app/views/layouts/base.html.erb | ||
|---|---|---|
|
<meta name="keywords" content="issue,bug,tracker" />
|
||
|
<%= csrf_meta_tag %>
|
||
|
<%= favicon %>
|
||
|
<%= stylesheet_link_tag 'jquery/jquery-ui-1.11.0', 'application', 'responsive', :media => 'all' %>
|
||
|
<%= stylesheet_link_tag 'jquery/jquery-ui-1.11.0', 'tribute-3.7.3', 'application', 'responsive', :media => 'all' %>
|
||
|
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
|
||
|
<%= javascript_heads %>
|
||
|
<%= heads_for_theme %>
|
||
| app/views/messages/_form.html.erb | ||
|---|---|---|
|
<p>
|
||
|
<%= label_tag "message_content", l(:description_message_content), :class => "hidden-for-sighted" %>
|
||
|
<%= f.text_area :content, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'message_content' %></p>
|
||
|
<%= f.text_area :content, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'message_content',
|
||
|
:accesskey => accesskey(:edit),
|
||
|
:data => {
|
||
|
:auto_complete => true,
|
||
|
:issues_url => auto_complete_issues_path(:project_id => @project, :q => ''),
|
||
|
:users_url => auto_complete_users_path(:project_id => @project, :q => '')
|
||
|
}
|
||
|
%></p>
|
||
|
<%= wikitoolbar_for 'message_content', preview_board_message_path(:board_id => @board, :id => @message) %>
|
||
|
<!--[eoform:message]-->
|
||
| app/views/news/_form.html.erb | ||
|---|---|---|
|
<div class="box tabular">
|
||
|
<p><%= f.text_field :title, :required => true, :size => 60 %></p>
|
||
|
<p><%= f.text_area :summary, :cols => 60, :rows => 2 %></p>
|
||
|
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 15, :class => 'wiki-edit' %></p>
|
||
|
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 15, :class => 'wiki-edit',
|
||
|
:data => {
|
||
|
:auto_complete => true,
|
||
|
:issues_url => auto_complete_issues_path(:project_id => @project, :q => ''),
|
||
|
:users_url => auto_complete_users_path(:project_id => @project, :q => '')
|
||
|
}
|
||
|
%></p>
|
||
|
<p id="attachments_form"><label><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @news} %></p>
|
||
|
</div>
|
||
|
<%= wikitoolbar_for 'news_description', preview_news_path(:project_id => @project, :id => @news) %>
|
||
|
<%= wikitoolbar_for 'news_description', preview_news_path(:project_id => @project, :id => @news) %>
|
||
| app/views/news/show.html.erb | ||
|---|---|---|
|
<p><%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comments" %></p>
|
||
|
<%= form_tag({:controller => 'comments', :action => 'create', :id => @news}, :id => "add_comment_form", :style => "display:none;") do %>
|
||
|
<div class="box">
|
||
|
<%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit' %>
|
||
|
<%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit',
|
||
|
:data => {
|
||
|
:auto_complete => true,
|
||
|
:issues_url => auto_complete_issues_path(:project_id => @project, :q => ''),
|
||
|
:users_url => auto_complete_users_path(:project_id => @project, :q => '')
|
||
|
}
|
||
|
%>
|
||
|
<%= wikitoolbar_for 'comment_comments', preview_news_path(:project_id => @project, :id => @news) %>
|
||
|
</div>
|
||
|
<p><%= submit_tag l(:button_add) %></p>
|
||
| app/views/wiki/edit.html.erb | ||
|---|---|---|
|
<%= error_messages_for 'content' %>
|
||
|
<div class="box tabular">
|
||
|
<%= text_area_tag 'content[text]', @text, :cols => 100, :rows => 25,
|
||
|
:class => 'wiki-edit', :accesskey => accesskey(:edit) %>
|
||
|
<%= text_area_tag 'content[text]', @text, :cols => 100, :rows => 25, :accesskey => accesskey(:edit),
|
||
|
:class => 'wiki-edit',
|
||
|
:data => {
|
||
|
:auto_complete => true,
|
||
|
:issues_url => auto_complete_issues_path(:project_id => @project, :q => ''),
|
||
|
:users_url => auto_complete_users_path(:project_id => @project, :q => '')
|
||
|
}
|
||
|
%>
|
||
|
<% if @page.safe_attribute_names.include?('parent_id') && @wiki.pages.any? %>
|
||
|
<%= fields_for @page do |fp| %>
|
||
| config/routes.rb | ||
|---|---|---|
|
# Misc issue routes. TODO: move into resources
|
||
|
match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues'
|
||
|
match '/users/auto_complete', :to => 'auto_completes#users', :via => :get, :as => 'auto_complete_users'
|
||
|
match '/issues/context_menu', :to => 'context_menus#issues', :as => 'issues_context_menu', :via => [:get, :post]
|
||
|
match '/issues/changes', :to => 'journals#index', :as => 'issue_changes', :via => :get
|
||
|
match '/issues/:id/quoted', :to => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue'
|
||
| public/javascripts/application.js | ||
|---|---|---|
|
}
|
||
|
});
|
||
|
// missing forEach on NodeList for IE11
|
||
|
// #ToDo: Remove this when IE 11 is no longer supported
|
||
|
if (window.NodeList && !NodeList.prototype.forEach) {
|
||
|
NodeList.prototype.forEach = Array.prototype.forEach;
|
||
|
}
|
||
|
function checkAll(id, checked) {
|
||
|
$('#'+id).find('input[type=checkbox]:enabled').prop('checked', checked);
|
||
|
}
|
||
| ... | ... | |
|
$(window).resize(setFilecontentContainerHeight);
|
||
|
}
|
||
|
$(function () {
|
||
|
$('[title]').tooltip({
|
||
|
show: {
|
||
| ... | ... | |
|
}
|
||
|
});
|
||
|
});
|
||
|
function inlineAutoComplete(element) {
|
||
|
'use strict';
|
||
|
const issuesUrl = element.dataset.issuesUrl;
|
||
|
const usersUrl = element.dataset.usersUrl;
|
||
|
const remoteSearch = function(url, cb) {
|
||
|
const xhr = new XMLHttpRequest();
|
||
|
xhr.onreadystatechange = function ()
|
||
|
{
|
||
|
if (xhr.readyState === 4) {
|
||
|
if (xhr.status === 200) {
|
||
|
var data = JSON.parse(xhr.responseText);
|
||
|
cb(data);
|
||
|
} else if (xhr.status === 403) {
|
||
|
cb([]);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
xhr.open("GET", url, true);
|
||
|
xhr.send();
|
||
|
};
|
||
|
const tribute = new Tribute({
|
||
|
collection: [
|
||
|
{
|
||
|
trigger: '#',
|
||
|
values: function (text, cb) {
|
||
|
remoteSearch(issuesUrl + text, function (issues) {
|
||
|
return cb(issues);
|
||
|
});
|
||
|
},
|
||
|
lookup: 'label',
|
||
|
fillAttr: 'label',
|
||
|
selectTemplate: function (issue) {
|
||
|
return '#' + issue.original.id;
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
trigger: '@',
|
||
|
lookup: function (user, mentionText) {
|
||
|
return user.name + user.firstname + user.lastname + user.login;
|
||
|
},
|
||
|
values: function (text, cb) {
|
||
|
remoteSearch(usersUrl + text, function (users) {
|
||
|
return cb(users);
|
||
|
});
|
||
|
},
|
||
|
menuItemTemplate: function (user) {
|
||
|
return user.original.name;
|
||
|
},
|
||
|
selectTemplate: function (user) {
|
||
|
return '@' + user.original.login;
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
});
|
||
|
tribute.attach(element);
|
||
|
}
|
||
|
$(document).ready(setupAjaxIndicator);
|
||
|
$(document).ready(hideOnLoad);
|
||
|
$(document).ready(addFormObserversForDoubleSubmit);
|
||
| ... | ... | |
|
$(document).ready(setupAttachmentDetail);
|
||
|
$(document).ready(setupTabs);
|
||
|
$(document).ready(setupFilePreviewNavigation);
|
||
|
$(document).ready(function() {
|
||
|
const elements = document.querySelectorAll('[data-auto-complete=true]');
|
||
|
elements.forEach(function (element, index) {
|
||
|
new inlineAutoComplete(element);
|
||
|
});
|
||
|
})
|
||
| public/javascripts/tribute-3.7.3.min.js | ||
|---|---|---|
|
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Tribute=e()}}(function(){return function o(u,a,l){function s(t,e){if(!a[t]){if(!u[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(c)return c(t,!0);var i=new Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}var r=a[t]={exports:{}};u[t][0].call(r.exports,function(e){return s(u[t][1][e]||e)},r,r.exports,o,u,a,l)}return a[t].exports}for(var c="function"==typeof require&&require,e=0;e<l.length;e++)s(l[e]);return s}({1:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;i(e("./utils"));var F=i(e("./TributeEvents")),q=i(e("./TributeMenuEvents")),z=i(e("./TributeRange")),Y=i(e("./TributeSearch"));function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var u,a=e[Symbol.iterator]();!(i=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=function(){function B(e){var t=this,n=e.values,i=void 0===n?null:n,r=e.iframe,o=void 0===r?null:r,u=e.selectClass,a=void 0===u?"highlight":u,l=e.trigger,s=void 0===l?"@":l,c=e.autocompleteMode,d=void 0!==c&&c,f=e.selectTemplate,h=void 0===f?null:f,p=e.menuItemTemplate,v=void 0===p?null:p,m=e.lookup,g=void 0===m?"key":m,b=e.fillAttr,y=void 0===b?"value":b,w=e.collection,T=void 0===w?null:w,E=e.menuContainer,C=void 0===E?null:E,k=e.noMatchTemplate,S=void 0===k?null:k,x=e.requireLeadingSpace,M=void 0===x||x,A=e.allowSpaces,L=void 0!==A&&A,I=e.replaceTextSuffix,N=void 0===I?null:I,O=e.positionMenu,P=void 0===O||O,D=e.spaceSelectsMatch,R=void 0!==D&&D,_=e.searchOpts,W=void 0===_?{}:_,H=e.menuItemLimit,j=void 0===H?null:H;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,B),this.autocompleteMode=d,this.menuSelected=0,this.current={},this.inputEvent=!1,this.isActive=!1,this.menuContainer=C,this.allowSpaces=L,this.replaceTextSuffix=N,this.positionMenu=P,this.hasTrailingSpace=!1,this.spaceSelectsMatch=R,this.autocompleteMode&&(s="",L=!1),i)this.collection=[{trigger:s,iframe:o,selectClass:a,selectTemplate:(h||B.defaultSelectTemplate).bind(this),menuItemTemplate:(v||B.defaultMenuItemTemplate).bind(this),noMatchTemplate:"function"==typeof S?S.bind(t):S||function(){return""}.bind(t),lookup:g,fillAttr:y,values:i,requireLeadingSpace:M,searchOpts:W,menuItemLimit:j}];else{if(!T)throw new Error("[Tribute] No collection specified.");this.autocompleteMode&&console.warn("Tribute in autocomplete mode does not work for collections"),this.collection=T.map(function(e){return{trigger:e.trigger||s,iframe:e.iframe||o,selectClass:e.selectClass||a,selectTemplate:(e.selectTemplate||B.defaultSelectTemplate).bind(t),menuItemTemplate:(e.menuItemTemplate||B.defaultMenuItemTemplate).bind(t),noMatchTemplate:"function"==typeof S?S.bind(t):null,lookup:e.lookup||g,fillAttr:e.fillAttr||y,values:e.values,requireLeadingSpace:e.requireLeadingSpace,searchOpts:e.searchOpts||W,menuItemLimit:e.menuItemLimit||j}})}new z.default(this),new F.default(this),new q.default(this),new Y.default(this)}return function(e,t,n){t&&r(e.prototype,t),n&&r(e,n)}(B,[{key:"triggers",value:function(){return this.collection.map(function(e){return e.trigger})}},{key:"attach",value:function(e){if(!e)throw new Error("[Tribute] Must pass in a DOM node or NodeList.");if("undefined"!=typeof jQuery&&e instanceof jQuery&&(e=e.get()),e.constructor===NodeList||e.constructor===HTMLCollection||e.constructor===Array)for(var t=e.length,n=0;n<t;++n)this._attach(e[n]);else this._attach(e)}},{key:"_attach",value:function(e){e.hasAttribute("data-tribute")&&console.warn("Tribute was already bound to "+e.nodeName),this.ensureEditable(e),this.events.bind(e),e.setAttribute("data-tribute",!0)}},{key:"ensureEditable",value:function(e){if(-1===B.inputTypes().indexOf(e.nodeName)){if(!e.contentEditable)throw new Error("[Tribute] Cannot bind to "+e.nodeName);e.contentEditable=!0}}},{key:"createMenu",value:function(){var e=this.range.getDocument().createElement("div"),t=this.range.getDocument().createElement("ul");return e.className="tribute-container",e.appendChild(t),this.menuContainer?this.menuContainer.appendChild(e):this.range.getDocument().body.appendChild(e)}},{key:"showMenuFor",value:function(e,o){var u=this;if(!this.isActive||this.current.element!==e||this.current.mentionText!==this.currentMentionTextSnapshot){this.currentMentionTextSnapshot=this.current.mentionText,this.menu||(this.menu=this.createMenu(),e.tributeMenu=this.menu,this.menuEvents.bind(this.menu)),this.isActive=!0,this.menuSelected=0,this.current.mentionText||(this.current.mentionText="");var t=function(e){if(u.isActive){var t=u.search.filter(u.current.mentionText,e,{pre:u.current.collection.searchOpts.pre||"<span>",post:u.current.collection.searchOpts.post||"</span>",skip:u.current.collection.searchOpts.skip,extract:function(e){if("string"==typeof u.current.collection.lookup)return e[u.current.collection.lookup];if("function"==typeof u.current.collection.lookup)return u.current.collection.lookup(e,u.current.mentionText);throw new Error("Invalid lookup attribute, lookup must be string or function.")}});u.current.filteredItems=t;var n=u.menu.querySelector("ul");if(u.range.positionMenuAtCaret(o),!t.length){var i=new CustomEvent("tribute-no-match",{detail:u.menu});return u.current.element.dispatchEvent(i),void("function"==typeof u.current.collection.noMatchTemplate&&!u.current.collection.noMatchTemplate()||!u.current.collection.noMatchTemplate?u.hideMenu():"function"==typeof u.current.collection.noMatchTemplate?n.innerHTML=u.current.collection.noMatchTemplate():n.innerHTML=u.current.collection.noMatchTemplate)}u.current.collection.menuItemLimit&&(t=t.slice(0,u.current.collection.menuItemLimit)),n.innerHTML="";var r=u.range.getDocument().createDocumentFragment();t.forEach(function(e,t){var n=u.range.getDocument().createElement("li");n.setAttribute("data-index",t),n.addEventListener("mousemove",function(e){var t=a(u._findLiTarget(e.target),2),n=(t[0],t[1]);0!==e.movementY&&u.events.setActiveLi(n)}),u.menuSelected===t&&(n.className=u.current.collection.selectClass),n.innerHTML=u.current.collection.menuItemTemplate(e),r.appendChild(n)}),n.appendChild(r)}};"function"==typeof this.current.collection.values?this.current.collection.values(this.current.mentionText,t):t(this.current.collection.values)}}},{key:"_findLiTarget",value:function(e){if(!e)return[];var t=e.getAttribute("data-index");return t?[e,t]:this._findLiTarget(e.parentNode)}},{key:"showMenuForCollection",value:function(e,t){e!==document.activeElement&&this.placeCaretAtEnd(e),this.current.collection=this.collection[t||0],this.current.externalTrigger=!0,(this.current.element=e).isContentEditable?this.insertTextAtCursor(this.current.collection.trigger):this.insertAtCaret(e,this.current.collection.trigger),this.showMenuFor(e)}},{key:"placeCaretAtEnd",value:function(e){if(e.focus(),void 0!==window.getSelection&&void 0!==document.createRange){var t=document.createRange();t.selectNodeContents(e),t.collapse(!1);var n=window.getSelection();n.removeAllRanges(),n.addRange(t)}else if(void 0!==document.body.createTextRange){var i=document.body.createTextRange();i.moveToElementText(e),i.collapse(!1),i.select()}}},{key:"insertTextAtCursor",value:function(e){var t,n;(n=(t=window.getSelection()).getRangeAt(0)).deleteContents();var i=document.createTextNode(e);n.insertNode(i),n.selectNodeContents(i),n.collapse(!1),t.removeAllRanges(),t.addRange(n)}},{key:"insertAtCaret",value:function(e,t){var n=e.scrollTop,i=e.selectionStart,r=e.value.substring(0,i),o=e.value.substring(e.selectionEnd,e.value.length);e.value=r+t+o,i+=t.length,e.selectionStart=i,e.selectionEnd=i,e.focus(),e.scrollTop=n}},{key:"hideMenu",value:function(){this.menu&&(this.menu.style.cssText="display: none;",this.isActive=!1,this.menuSelected=0,this.current={})}},{key:"selectItemAtIndex",value:function(e,t){if("number"==typeof(e=parseInt(e))&&!isNaN(e)){var n=this.current.filteredItems[e],i=this.current.collection.selectTemplate(n);null!==i&&this.replaceText(i,t,n)}}},{key:"replaceText",value:function(e,t,n){this.range.replaceTriggerText(e,!0,!0,t,n)}},{key:"_append",value:function(e,t,n){if("function"==typeof e.values)throw new Error("Unable to append to values, as it is a function.");e.values=n?t:e.values.concat(t)}},{key:"append",value:function(e,t,n){var i=parseInt(e);if("number"!=typeof i)throw new Error("please provide an index for the collection to update.");var r=this.collection[i];this._append(r,t,n)}},{key:"appendCurrent",value:function(e,t){if(!this.isActive)throw new Error("No active state. Please use append instead and pass an index.");this._append(this.current.collection,e,t)}},{key:"detach",value:function(e){if(!e)throw new Error("[Tribute] Must pass in a DOM node or NodeList.");if("undefined"!=typeof jQuery&&e instanceof jQuery&&(e=e.get()),e.constructor===NodeList||e.constructor===HTMLCollection||e.constructor===Array)for(var t=e.length,n=0;n<t;++n)this._detach(e[n]);else this._detach(e)}},{key:"_detach",value:function(e){var t=this;this.events.unbind(e),e.tributeMenu&&this.menuEvents.unbind(e.tributeMenu),setTimeout(function(){e.removeAttribute("data-tribute"),t.isActive=!1,e.tributeMenu&&e.tributeMenu.remove()})}}],[{key:"defaultSelectTemplate",value:function(e){return void 0===e?null:this.range.isContentEditable(this.current.element)?'<span class="tribute-mention">'+(this.current.collection.trigger+e.original[this.current.collection.fillAttr])+"</span>":this.current.collection.trigger+e.original[this.current.collection.fillAttr]}},{key:"defaultMenuItemTemplate",value:function(e){return e.string}},{key:"inputTypes",value:function(){return["TEXTAREA","INPUT"]}}]),B}();n.default=o,t.exports=n.default},{"./TributeEvents":2,"./TributeMenuEvents":3,"./TributeRange":4,"./TributeSearch":5,"./utils":7}],2:[function(e,t,n){"use strict";function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r=function(){function r(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),this.tribute=e,this.tribute.events=this}return function(e,t,n){t&&i(e.prototype,t),n&&i(e,n)}(r,[{key:"bind",value:function(e){e.boundKeydown=this.keydown.bind(e,this),e.boundKeyup=this.keyup.bind(e,this),e.boundInput=this.input.bind(e,this),e.addEventListener("keydown",e.boundKeydown,!1),e.addEventListener("keyup",e.boundKeyup,!1),e.addEventListener("input",e.boundInput,!1)}},{key:"unbind",value:function(e){e.removeEventListener("keydown",e.boundKeydown,!1),e.removeEventListener("keyup",e.boundKeyup,!1),e.removeEventListener("input",e.boundInput,!1),delete e.boundKeydown,delete e.boundKeyup,delete e.boundInput}},{key:"keydown",value:function(t,n){t.shouldDeactivate(n)&&(t.tribute.isActive=!1,t.tribute.hideMenu());var i=this;t.commandEvent=!1,r.keys().forEach(function(e){e.key===n.keyCode&&(t.commandEvent=!0,t.callbacks()[e.value.toLowerCase()](n,i))})}},{key:"input",value:function(e,t){e.inputEvent=!0,e.keyup.call(this,e,t)}},{key:"click",value:function(e,t){var n=e.tribute;if(n.menu&&n.menu.contains(t.target)){var i=t.target;for(t.preventDefault(),t.stopPropagation();"li"!==i.nodeName.toLowerCase();)if(!(i=i.parentNode)||i===n.menu)throw new Error("cannot find the <li> container for the click");n.selectItemAtIndex(i.getAttribute("data-index"),t),n.hideMenu()}else n.current.element&&!n.current.externalTrigger&&(n.current.externalTrigger=!1,setTimeout(function(){return n.hideMenu()}))}},{key:"keyup",value:function(e,t){if(e.inputEvent&&(e.inputEvent=!1),e.updateSelection(this),27!==t.keyCode){if(!e.tribute.allowSpaces&&e.tribute.hasTrailingSpace)return e.tribute.hasTrailingSpace=!1,e.commandEvent=!0,void e.callbacks().space(t,this);if(!e.tribute.isActive)if(e.tribute.autocompleteMode)e.callbacks().triggerChar(t,this,"");else{var n=e.getKeyCode(e,this,t);if(isNaN(n)||!n)return;var i=e.tribute.triggers().find(function(e){return e.charCodeAt(0)===n});void 0!==i&&e.callbacks().triggerChar(t,this,i)}((e.tribute.current.trigger||e.tribute.autocompleteMode)&&!1===e.commandEvent||e.tribute.isActive&&8===t.keyCode)&&e.tribute.showMenuFor(this,!0)}}},{key:"shouldDeactivate",value:function(t){if(!this.tribute.isActive)return!1;if(0!==this.tribute.current.mentionText.length)return!1;var n=!1;return r.keys().forEach(function(e){t.keyCode===e.key&&(n=!0)}),!n}},{key:"getKeyCode",value:function(e,t,n){var i=e.tribute,r=i.range.getTriggerInfo(!1,i.hasTrailingSpace,!0,i.allowSpaces,i.autocompleteMode);return!!r&&r.mentionTriggerChar.charCodeAt(0)}},{key:"updateSelection",value:function(e){this.tribute.current.element=e;var t=this.tribute.range.getTriggerInfo(!1,this.tribute.hasTrailingSpace,!0,this.tribute.allowSpaces,this.tribute.autocompleteMode);t&&(this.tribute.current.selectedPath=t.mentionSelectedPath,this.tribute.current.mentionText=t.mentionText,this.tribute.current.selectedOffset=t.mentionSelectedOffset)}},{key:"callbacks",value:function(){var o=this;return{triggerChar:function(e,t,n){var i=o.tribute;i.current.trigger=n;var r=i.collection.find(function(e){return e.trigger===n});i.current.collection=r,i.inputEvent&&i.showMenuFor(t,!0)},enter:function(e,t){o.tribute.isActive&&o.tribute.current.filteredItems&&(e.preventDefault(),e.stopPropagation(),setTimeout(function(){o.tribute.selectItemAtIndex(o.tribute.menuSelected,e),o.tribute.hideMenu()},0))},escape:function(e,t){o.tribute.isActive&&(e.preventDefault(),e.stopPropagation(),o.tribute.isActive=!1,o.tribute.hideMenu())},tab:function(e,t){o.callbacks().enter(e,t)},space:function(e,t){o.tribute.isActive&&(o.tribute.spaceSelectsMatch?o.callbacks().enter(e,t):o.tribute.allowSpaces||(e.stopPropagation(),setTimeout(function(){o.tribute.hideMenu(),o.tribute.isActive=!1},0)))},up:function(e,t){if(o.tribute.isActive&&o.tribute.current.filteredItems){e.preventDefault(),e.stopPropagation();var n=o.tribute.current.filteredItems.length,i=o.tribute.menuSelected;i<n&&0<i?(o.tribute.menuSelected--,o.setActiveLi()):0===i&&(o.tribute.menuSelected=n-1,o.setActiveLi(),o.tribute.menu.scrollTop=o.tribute.menu.scrollHeight)}},down:function(e,t){if(o.tribute.isActive&&o.tribute.current.filteredItems){e.preventDefault(),e.stopPropagation();var n=o.tribute.current.filteredItems.length-1,i=o.tribute.menuSelected;i<n?(o.tribute.menuSelected++,o.setActiveLi()):n===i&&(o.tribute.menuSelected=0,o.setActiveLi(),o.tribute.menu.scrollTop=0)}},delete:function(e,t){o.tribute.isActive&&o.tribute.current.mentionText.length<1?o.tribute.hideMenu():o.tribute.isActive&&o.tribute.showMenuFor(t)}}}},{key:"setActiveLi",value:function(e){var t=this.tribute.menu.querySelectorAll("li"),n=t.length>>>0;e&&(this.tribute.menuSelected=parseInt(e));for(var i=0;i<n;i++){var r=t[i];if(i===this.tribute.menuSelected){r.classList.add(this.tribute.current.collection.selectClass);var o=r.getBoundingClientRect(),u=this.tribute.menu.getBoundingClientRect();if(o.bottom>u.bottom){var a=o.bottom-u.bottom;this.tribute.menu.scrollTop+=a}else if(o.top<u.top){var l=u.top-o.top;this.tribute.menu.scrollTop-=l}}else r.classList.remove(this.tribute.current.collection.selectClass)}}},{key:"getFullHeight",value:function(e,t){var n=e.getBoundingClientRect().height;if(t){var i=e.currentStyle||window.getComputedStyle(e);return n+parseFloat(i.marginTop)+parseFloat(i.marginBottom)}return n}}],[{key:"keys",value:function(){return[{key:9,value:"TAB"},{key:8,value:"DELETE"},{key:13,value:"ENTER"},{key:27,value:"ESCAPE"},{key:32,value:"SPACE"},{key:38,value:"UP"},{key:40,value:"DOWN"}]}}]),r}();n.default=r,t.exports=n.default},{}],3:[function(e,t,n){"use strict";function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.tribute=e,(this.tribute.menuEvents=this).menu=this.tribute.menu}return function(e,t,n){t&&i(e.prototype,t),n&&i(e,n)}(t,[{key:"bind",value:function(e){var t=this;this.menuClickEvent=this.tribute.events.click.bind(null,this),this.menuContainerScrollEvent=this.debounce(function(){t.tribute.isActive&&t.tribute.showMenuFor(t.tribute.current.element,!1)},300,!1),this.windowResizeEvent=this.debounce(function(){t.tribute.isActive&&t.tribute.range.positionMenuAtCaret(!0)},300,!1),this.tribute.range.getDocument().addEventListener("MSPointerDown",this.menuClickEvent,!1),this.tribute.range.getDocument().addEventListener("mousedown",this.menuClickEvent,!1),window.addEventListener("resize",this.windowResizeEvent),this.menuContainer?this.menuContainer.addEventListener("scroll",this.menuContainerScrollEvent,!1):window.addEventListener("scroll",this.menuContainerScrollEvent)}},{key:"unbind",value:function(e){this.tribute.range.getDocument().removeEventListener("mousedown",this.menuClickEvent,!1),this.tribute.range.getDocument().removeEventListener("MSPointerDown",this.menuClickEvent,!1),window.removeEventListener("resize",this.windowResizeEvent),this.menuContainer?this.menuContainer.removeEventListener("scroll",this.menuContainerScrollEvent,!1):window.removeEventListener("scroll",this.menuContainerScrollEvent)}},{key:"debounce",value:function(i,r,o){var u,a=this,l=arguments;return function(){var e=a,t=l,n=o&&!u;clearTimeout(u),u=setTimeout(function(){u=null,o||i.apply(e,t)},r),n&&i.apply(e,t)}}}]),t}();n.default=r,t.exports=n.default},{}],4:[function(e,t,n){"use strict";function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.tribute=e,this.tribute.range=this}return function(e,t,n){t&&i(e.prototype,t),n&&i(e,n)}(t,[{key:"getDocument",value:function(){var e;return this.tribute.current.collection&&(e=this.tribute.current.collection.iframe),e?e.contentWindow.document:document}},{key:"positionMenuAtCaret",value:function(r){var o,u=this,e=this.tribute.current,t=this.getTriggerInfo(!1,this.tribute.hasTrailingSpace,!0,this.tribute.allowSpaces,this.tribute.autocompleteMode);if(void 0!==t){if(!this.tribute.positionMenu)return void(this.tribute.menu.style.cssText="display: block;");o=this.isContentEditable(e.element)?this.getContentEditableCaretPosition(t.mentionPosition):this.getTextAreaOrInputUnderlinePosition(this.tribute.current.element,t.mentionPosition),this.tribute.menu.style.cssText="top: ".concat(o.top,"px;\n left: ").concat(o.left,"px;\n right: ").concat(o.right,"px;\n bottom: ").concat(o.bottom,"px;\n position: absolute;\n z-index: 10000;\n display: block;"),"auto"===o.left&&(this.tribute.menu.style.left="auto"),"auto"===o.top&&(this.tribute.menu.style.top="auto"),r&&this.scrollIntoView(),window.setTimeout(function(){var e={width:u.tribute.menu.offsetWidth,height:u.tribute.menu.offsetHeight},t=u.isMenuOffScreen(o,e),n=window.innerWidth>e.width&&(t.left||t.right),i=window.innerHeight>e.height&&(t.top||t.bottom);(n||i)&&(u.tribute.menu.style.cssText="display: none",u.positionMenuAtCaret(r))},0)}else this.tribute.menu.style.cssText="display: none"}},{key:"selectElement",value:function(e,t,n){var i,r=e;if(t)for(var o=0;o<t.length;o++){if(void 0===(r=r.childNodes[t[o]]))return;for(;r.length<n;)n-=r.length,r=r.nextSibling;0!==r.childNodes.length||r.length||(r=r.previousSibling)}var u=this.getWindowSelection();(i=this.getDocument().createRange()).setStart(r,n),i.setEnd(r,n),i.collapse(!0);try{u.removeAllRanges()}catch(e){}u.addRange(i),e.focus()}},{key:"replaceTriggerText",value:function(e,t,n,i,r){var o=this.getTriggerInfo(!0,n,t,this.tribute.allowSpaces,this.tribute.autocompleteMode);if(void 0!==o){var u=this.tribute.current,a=new CustomEvent("tribute-replaced",{detail:{item:r,instance:u,context:o,event:i}});if(this.isContentEditable(u.element)){e+="string"==typeof this.tribute.replaceTextSuffix?this.tribute.replaceTextSuffix:" ",this.pasteHtml(e,o.mentionPosition,o.mentionPosition+o.mentionText.length+!this.tribute.autocompleteMode)}else{var l=this.tribute.current.element,s="string"==typeof this.tribute.replaceTextSuffix?this.tribute.replaceTextSuffix:" ";e+=s;var c=o.mentionPosition,d=o.mentionPosition+o.mentionText.length+s.length;l.value=l.value.substring(0,c)+e+l.value.substring(d,l.value.length),l.selectionStart=c+e.length,l.selectionEnd=c+e.length}u.element.dispatchEvent(a)}}},{key:"pasteHtml",value:function(e,t,n){var i,r;r=this.getWindowSelection(),(i=this.getDocument().createRange()).setStart(r.anchorNode,t),i.setEnd(r.anchorNode,n),i.deleteContents();var o=this.getDocument().createElement("div");o.innerHTML=e;for(var u,a,l=this.getDocument().createDocumentFragment();u=o.firstChild;)a=l.appendChild(u);i.insertNode(l),a&&((i=i.cloneRange()).setStartAfter(a),i.collapse(!0),r.removeAllRanges(),r.addRange(i))}},{key:"getWindowSelection",value:function(){return this.tribute.collection.iframe?this.tribute.collection.iframe.contentWindow.getSelection():window.getSelection()}},{key:"getNodePositionInParent",value:function(e){if(null===e.parentNode)return 0;for(var t=0;t<e.parentNode.childNodes.length;t++){if(e.parentNode.childNodes[t]===e)return t}}},{key:"getContentEditableSelectedPath",value:function(e){var t=this.getWindowSelection(),n=t.anchorNode,i=[];if(null!=n){for(var r,o=n.contentEditable;null!==n&&"true"!==o;)r=this.getNodePositionInParent(n),i.push(r),null!==(n=n.parentNode)&&(o=n.contentEditable);return i.reverse(),{selected:n,path:i,offset:t.getRangeAt(0).startOffset}}}},{key:"getTextPrecedingCurrentSelection",value:function(){var e=this.tribute.current,t="";if(this.isContentEditable(e.element)){var n=this.getWindowSelection().anchorNode;if(null!=n){var i=n.textContent,r=this.getWindowSelection().getRangeAt(0).startOffset;i&&0<=r&&(t=i.substring(0,r))}}else{var o=this.tribute.current.element;if(o){var u=o.selectionStart;o.value&&0<=u&&(t=o.value.substring(0,u))}}return t}},{key:"getLastWordInText",value:function(e){var t=(e=e.replace(/\u00A0/g," ")).split(" ");return t[t.length-1].trim()}},{key:"getTriggerInfo",value:function(e,t,i,n,r){var o,u,a,l=this,s=this.tribute.current;if(this.isContentEditable(s.element)){var c=this.getContentEditableSelectedPath(s);c&&(o=c.selected,u=c.path,a=c.offset)}else o=this.tribute.current.element;var d=this.getTextPrecedingCurrentSelection(),f=this.getLastWordInText(d);if(r)return{mentionPosition:d.length-f.length,mentionText:f,mentionSelectedElement:o,mentionSelectedPath:u,mentionSelectedOffset:a};if(null!=d){var h,p=-1;if(this.tribute.collection.forEach(function(e){var t=e.trigger,n=e.requireLeadingSpace?l.lastIndexWithLeadingSpace(d,t):d.lastIndexOf(t);p<n&&(p=n,h=t,i=e.requireLeadingSpace)}),0<=p&&(0===p||!i||/[\xA0\s]/g.test(d.substring(p-1,p)))){var v=d.substring(p+1,d.length);h=d.substring(p,p+1);var m=v.substring(0,1),g=0<v.length&&(" "===m||" "===m);t&&(v=v.trim());var b=n?/[^\S ]/g:/[\xA0\s]/g;if(this.tribute.hasTrailingSpace=b.test(v),!g&&(e||!b.test(v)))return{mentionPosition:p,mentionText:v,mentionSelectedElement:o,mentionSelectedPath:u,mentionSelectedOffset:a,mentionTriggerChar:h}}}}},{key:"lastIndexWithLeadingSpace",value:function(e,t){for(var n=e.split("").reverse().join(""),i=-1,r=0,o=e.length;r<o;r++){var u=r===e.length-1,a=/\s/.test(n[r+1]);if(t===n[r]&&(u||a)){i=e.length-1-r;break}}return i}},{key:"isContentEditable",value:function(e){return"INPUT"!==e.nodeName&&"TEXTAREA"!==e.nodeName}},{key:"isMenuOffScreen",value:function(e,t){var n=window.innerWidth,i=window.innerHeight,r=document.documentElement,o=(window.pageXOffset||r.scrollLeft)-(r.clientLeft||0),u=(window.pageYOffset||r.scrollTop)-(r.clientTop||0),a="number"==typeof e.top?e.top:u+i-e.bottom-t.height,l="number"==typeof e.right?e.right:e.left+t.width,s="number"==typeof e.bottom?e.bottom:e.top+t.height,c="number"==typeof e.left?e.left:o+n-e.right-t.width;return{top:a<Math.floor(u),right:l>Math.ceil(o+n),bottom:s>Math.ceil(u+i),left:c<Math.floor(o)}}},{key:"getMenuDimensions",value:function(){var e={width:null,height:null};return this.tribute.menu.style.cssText="top: 0px;\n left: 0px;\n position: fixed;\n zIndex: 10000;\n display: block;\n visibility; hidden;",e.width=this.tribute.menu.offsetWidth,e.height=this.tribute.menu.offsetHeight,this.tribute.menu.style.cssText="display: none;",e}},{key:"getTextAreaOrInputUnderlinePosition",value:function(e,t,n){var i=null!==window.mozInnerScreenX,r=this.getDocument().createElement("div");r.id="input-textarea-caret-position-mirror-div",this.getDocument().body.appendChild(r);var o=r.style,u=window.getComputedStyle?getComputedStyle(e):e.currentStyle;o.whiteSpace="pre-wrap","INPUT"!==e.nodeName&&(o.wordWrap="break-word"),o.position="absolute",o.visibility="hidden",["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing"].forEach(function(e){o[e]=u[e]}),i?(o.width="".concat(parseInt(u.width)-2,"px"),e.scrollHeight>parseInt(u.height)&&(o.overflowY="scroll")):o.overflow="hidden",r.textContent=e.value.substring(0,t),"INPUT"===e.nodeName&&(r.textContent=r.textContent.replace(/\s/g," "));var a=this.getDocument().createElement("span");a.textContent=e.value.substring(t)||".",r.appendChild(a);var l=e.getBoundingClientRect(),s=document.documentElement,c=(window.pageXOffset||s.scrollLeft)-(s.clientLeft||0),d=(window.pageYOffset||s.scrollTop)-(s.clientTop||0),f={top:l.top+d+a.offsetTop+parseInt(u.borderTopWidth)+parseInt(u.fontSize)-e.scrollTop,left:l.left+c+a.offsetLeft+parseInt(u.borderLeftWidth)},h=window.innerWidth,p=window.innerHeight,v=this.getMenuDimensions(),m=this.isMenuOffScreen(f,v);m.right&&(f.right=h-f.left,f.left="auto");var g=this.tribute.menuContainer?this.tribute.menuContainer.offsetHeight:this.getDocument().body.offsetHeight;if(m.bottom){var b=g-(p-(this.tribute.menuContainer?this.tribute.menuContainer.getBoundingClientRect():this.getDocument().body.getBoundingClientRect()).top);f.bottom=b+(p-l.top-a.offsetTop),f.top="auto"}return(m=this.isMenuOffScreen(f,v)).left&&(f.left=h>v.width?c+h-v.width:c,delete f.right),m.top&&(f.top=p>v.height?d+p-v.height:d,delete f.bottom),this.getDocument().body.removeChild(r),f}},{key:"getContentEditableCaretPosition",value:function(e){var t,n,i="sel_".concat((new Date).getTime(),"_").concat(Math.random().toString().substr(2)),r=this.getWindowSelection(),o=r.getRangeAt(0);(n=this.getDocument().createRange()).setStart(r.anchorNode,e),n.setEnd(r.anchorNode,e),n.collapse(!1),(t=this.getDocument().createElement("span")).id=i,t.appendChild(this.getDocument().createTextNode("\ufeff")),n.insertNode(t),r.removeAllRanges(),r.addRange(o);var u=t.getBoundingClientRect(),a=document.documentElement,l=(window.pageXOffset||a.scrollLeft)-(a.clientLeft||0),s=(window.pageYOffset||a.scrollTop)-(a.clientTop||0),c={left:u.left+l,top:u.top+t.offsetHeight+s},d=window.innerWidth,f=window.innerHeight,h=this.getMenuDimensions(),p=this.isMenuOffScreen(c,h);p.right&&(c.left="auto",c.right=d-u.left-l);var v=this.tribute.menuContainer?this.tribute.menuContainer.offsetHeight:this.getDocument().body.offsetHeight;if(p.bottom){var m=v-(f-(this.tribute.menuContainer?this.tribute.menuContainer.getBoundingClientRect():this.getDocument().body.getBoundingClientRect()).top);c.top="auto",c.bottom=m+(f-u.top)}return(p=this.isMenuOffScreen(c,h)).left&&(c.left=d>h.width?l+d-h.width:l,delete c.right),p.top&&(c.top=f>h.height?s+f-h.height:s,delete c.bottom),t.parentNode.removeChild(t),c}},{key:"scrollIntoView",value:function(e){var t,n=this.menu;if(void 0!==n){for(;void 0===t||0===t.height;)if(0===(t=n.getBoundingClientRect()).height&&(void 0===(n=n.childNodes[0])||!n.getBoundingClientRect))return;var i=t.top,r=i+t.height;if(i<0)window.scrollTo(0,window.pageYOffset+t.top-20);else if(r>window.innerHeight){var o=window.pageYOffset+t.top-20;100<o-window.pageYOffset&&(o=window.pageYOffset+100);var u=window.pageYOffset-(window.innerHeight-r);o<u&&(u=o),window.scrollTo(0,u)}}}}]),t}();n.default=r,t.exports=n.default},{}],5:[function(e,t,n){"use strict";function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.tribute=e,this.tribute.search=this}return function(e,t,n){t&&i(e.prototype,t),n&&i(e,n)}(t,[{key:"simpleFilter",value:function(t,e){var n=this;return e.filter(function(e){return n.test(t,e)})}},{key:"test",value:function(e,t){return null!==this.match(e,t)}},{key:"match",value:function(e,t,n){n=n||{};t.length;var i=n.pre||"",r=n.post||"",o=n.caseSensitive&&t||t.toLowerCase();if(n.skip)return{rendered:t,score:0};e=n.caseSensitive&&e||e.toLowerCase();var u=this.traverse(o,e,0,0,[]);return u?{rendered:this.render(t,u.cache,i,r),score:u.score}:null}},{key:"traverse",value:function(e,t,n,i,r){if(t.length===i)return{score:this.calculateScore(r),cache:r.slice()};if(!(e.length===n||t.length-i>e.length-n)){for(var o,u,a=t[i],l=e.indexOf(a,n);-1<l;){if(r.push(l),u=this.traverse(e,t,l+1,i+1,r),r.pop(),!u)return o;(!o||o.score<u.score)&&(o=u),l=e.indexOf(a,l+1)}return o}}},{key:"calculateScore",value:function(n){var i=0,r=1;return n.forEach(function(e,t){0<t&&(n[t-1]+1===e?r+=r+1:r=1),i+=r}),i}},{key:"render",value:function(n,i,r,o){var u=n.substring(0,i[0]);return i.forEach(function(e,t){u+=r+n[e]+o+n.substring(e+1,i[t+1]?i[t+1]:n.length)}),u}},{key:"filter",value:function(u,e,a){var l=this;return a=a||{},e.reduce(function(e,t,n,i){var r=t;a.extract&&(r=(r=a.extract(t))||"");var o=l.match(u,r,a);return null!=o&&(e[e.length]={string:o.rendered,score:o.score,index:n,original:t}),e},[]).sort(function(e,t){var n=t.score-e.score;return n||e.index-t.index})}}]),t}();n.default=r,t.exports=n.default},{}],6:[function(e,t,n){"use strict";var i;Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r=((i=e("./Tribute"))&&i.__esModule?i:{default:i}).default;n.default=r,t.exports=n.default},{"./Tribute":1}],7:[function(e,t,n){"use strict";if(Array.prototype.find||(Array.prototype.find=function(e){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var t,n=Object(this),i=n.length>>>0,r=arguments[1],o=0;o<i;o++)if(t=n[o],e.call(r,t,o,n))return t}),window&&"function"!=typeof window.CustomEvent){var i=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n};void 0!==window.Event&&(i.prototype=window.Event.prototype),window.CustomEvent=i}},{}]},{},[6])(6)});
|
||
|
//# sourceMappingURL=tribute.min.js.map
|
||
| public/stylesheets/application.css | ||
|---|---|---|
|
.ui-menu .ui-menu-item:hover {font-weight:normal; color:#555; background:#759FCF; color:#fff !important; border:1px solid #759FCF;}
|
||
|
.ui-menu .ui-menu-item.ui-state-focus {font-weight:normal; color:#555; border-color:#759FCF;}
|
||
|
/* Custom tribute styles */
|
||
|
.tribute-container ul {
|
||
|
background-color: #fff;
|
||
|
border: 1px solid #ccc;
|
||
|
border-radius: 2px;
|
||
|
}
|
||
|
.tribute-container li.highlight {background-color: #759FCF; color:#fff;}
|
||
|
/************* Rouge styles *************/
|
||
|
/* generated by: pygmentize -f html -a .syntaxhl -S colorful */
|
||
|
.syntaxhl .hll { background-color: #ffffcc }
|
||
| public/stylesheets/tribute-3.7.3.css | ||
|---|---|---|
|
.tribute-container {
|
||
|
position: absolute;
|
||
|
top: 0;
|
||
|
left: 0;
|
||
|
height: auto;
|
||
|
max-height: 300px;
|
||
|
max-width: 500px;
|
||
|
overflow: auto;
|
||
|
display: block;
|
||
|
z-index: 999999; }
|
||
|
.tribute-container ul {
|
||
|
margin: 0;
|
||
|
margin-top: 2px;
|
||
|
padding: 0;
|
||
|
list-style: none;
|
||
|
background: #efefef; }
|
||
|
.tribute-container li {
|
||
|
padding: 5px 5px;
|
||
|
cursor: pointer; }
|
||
|
.tribute-container li.highlight {
|
||
|
background: #ddd; }
|
||
|
.tribute-container li span {
|
||
|
font-weight: bold; }
|
||
|
.tribute-container li.no-match {
|
||
|
cursor: default; }
|
||
|
.tribute-container .menu-highlighted {
|
||
|
font-weight: bold; }
|
||
| test/functional/auto_completes_controller_test.rb | ||
|---|---|---|
|
assert_include "Bug #13", response.body
|
||
|
end
|
||
|
def test_auto_complete_with_scope_all_should_search_other_projects
|
||
|
def test_issues_with_scope_all_should_search_other_projects
|
||
|
get :issues, :params => {
|
||
|
:project_id => 'ecookbook',
|
||
|
:q => '13',
|
||
| ... | ... | |
|
assert_include "Bug #13", response.body
|
||
|
end
|
||
|
def test_auto_complete_without_project_should_search_all_projects
|
||
|
def test_issues_without_project_should_search_all_projects
|
||
|
get :issues, :params => {
|
||
|
:q => '13'
|
||
|
}
|
||
| ... | ... | |
|
assert_include "Bug #13", response.body
|
||
|
end
|
||
|
def test_auto_complete_without_scope_all_should_not_search_other_projects
|
||
|
def test_issues_without_scope_all_should_not_search_other_projects
|
||
|
get :issues, :params => {
|
||
|
:project_id => 'ecookbook',
|
||
|
:q => '13'
|
||
| ... | ... | |
|
assert_equal 'Bug #13: Subproject issue two', issue['label']
|
||
|
end
|
||
|
def test_auto_complete_with_status_o_should_return_open_issues_only
|
||
|
def test_issues_with_status_o_should_return_open_issues_only
|
||
|
get :issues, :params => {
|
||
|
:project_id => 'ecookbook',
|
||
|
:q => 'issue',
|
||
| ... | ... | |
|
assert_not_include "closed", response.body
|
||
|
end
|
||
|
def test_auto_complete_with_status_c_should_return_closed_issues_only
|
||
|
def test_issues_with_status_c_should_return_closed_issues_only
|
||
|
get :issues, :params => {
|
||
|
:project_id => 'ecookbook',
|
||
|
:q => 'issue',
|
||
| ... | ... | |
|
assert_not_include "Issue due today", response.body
|
||
|
end
|
||
|
def test_auto_complete_with_issue_id_should_not_return_that_issue
|
||
|
def test_issues_with_issue_id_should_not_return_that_issue
|
||
|
get :issues, :params => {
|
||
|
:project_id => 'ecookbook',
|
||
|
:q => 'issue',
|
||
| ... | ... | |
|
assert_response :success
|
||
|
assert_include 'application/json', response.headers['Content-Type']
|
||
|
end
|
||
|
def test_users_should_accept_case_insensitive_term_param
|
||
|
get :users, :params => {
|
||
|
:q => 'JoHN'
|
||
|
}
|
||
|
assert_response :success
|
||
|
assert_include "John Smith", response.body
|
||
|
end
|
||
|
def test_users_should_return_json
|
||
|
get :users, :params => {
|
||
|
:q => 'john'
|
||
|
}
|
||
|
assert_response :success
|
||
|
json = ActiveSupport::JSON.decode(response.body)
|
||
|
assert_kind_of Array, json
|
||
|
user = json.first
|
||
|
assert_kind_of Hash, user
|
||
|
assert_equal 'John', user['firstname']
|
||
|
assert_equal 'Smith', user['lastname']
|
||
|
assert_equal 'John Smith', user['name']
|
||
|
assert_equal 'jsmith', user['login']
|
||
|
end
|
||
|
def test_users_with_project_and_without_term_should_return_project_users
|
||
|
get :users, :params => {
|
||
|
:project_id => 'onlinestore'
|
||
|
}
|
||
|
assert_response :success
|
||
|
json = ActiveSupport::JSON.decode(response.body)
|
||
|
assert_equal 2, json.count
|
||
|
assert_equal 'jsmith', json.first['login']
|
||
|
assert_equal 'miscuser8', json.last['login']
|
||
|
end
|
||
|
def test_users_without_project_and_with_term_should_search_in_all_users
|
||
|
get :users, :params => {
|
||
|
:q => 'm'
|
||
|
}
|
||
|
assert_response :success
|
||
|
assert_include "Redmine Admin", response.body
|
||
|
assert_include "Dave Lopper", response.body
|
||
|
end
|
||
|
end
|
||
| test/integration/routing/auto_completes_test.rb | ||
|---|---|---|
|
class RoutingAutoCompletesTest < Redmine::RoutingTest
|
||
|
def test_auto_completes
|
||
|
should_route 'GET /issues/auto_complete' => 'auto_completes#issues'
|
||
|
should_route 'GET /users/auto_complete' => 'auto_completes#users'
|
||
|
end
|
||
|
end
|
||