diff options
author | Go MAEDA <maeda@farend.jp> | 2020-10-25 00:01:14 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2020-10-25 00:01:14 +0000 |
commit | 74d4d86a14cd683de9a70ffcae6db79344cdef2d (patch) | |
tree | 783632f7234cce4156f28e90bc031f5f1a26dd64 /public | |
parent | d57674962ad938b46128fd671133d651f6a78b15 (diff) | |
download | redmine-74d4d86a14cd683de9a70ffcae6db79344cdef2d.tar.gz redmine-74d4d86a14cd683de9a70ffcae6db79344cdef2d.zip |
Store inline autocomplete data sources in a JS variable (#34122).
Patch by Marius BALTEANU.
git-svn-id: http://svn.redmine.org/redmine/trunk@20191 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'public')
-rw-r--r-- | public/javascripts/application.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 825d96c88..90a5189fe 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1045,11 +1045,15 @@ $(function () { function inlineAutoComplete(element) { 'use strict'; + // do not attach if Tribute is already initialized - if (element.dataset.tribute === 'true') {return;} + if (element.dataset.tribute === 'true') {return}; + + const getDataSource = function(entity) { + const dataSources = JSON.parse(rm.AutoComplete.dataSources); - const issuesUrl = element.dataset.issuesUrl; - const usersUrl = element.dataset.usersUrl; + return dataSources[entity]; + } const remoteSearch = function(url, cb) { const xhr = new XMLHttpRequest(); @@ -1074,7 +1078,7 @@ function inlineAutoComplete(element) { if (event.target.type === 'text' && $(element).attr('autocomplete') != 'off') { $(element).attr('autocomplete', 'off'); } - remoteSearch(issuesUrl + text, function (issues) { + remoteSearch(getDataSource('issues') + text, function (issues) { return cb(issues); }); }, |