summaryrefslogtreecommitdiffstats
path: root/public
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2021-02-25 04:07:37 +0000
committerGo MAEDA <maeda@farend.jp>2021-02-25 04:07:37 +0000
commit2f3222e0bdaacae4a2d17224d61a18cb060e9031 (patch)
tree7a2cd47e7fad3318cb71674db1e9d81dd975e7b7 /public
parent3fd832f14ceb728896bcc31293197a790298be01 (diff)
downloadredmine-2f3222e0bdaacae4a2d17224d61a18cb060e9031.tar.gz
redmine-2f3222e0bdaacae4a2d17224d61a18cb060e9031.zip
Auto complete wiki page links (#33820).
Patch by Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@20755 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'public')
-rw-r--r--public/javascripts/application.js55
1 files changed, 38 insertions, 17 deletions
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index feabd9ca9..770d5900c 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -1113,24 +1113,45 @@ function inlineAutoComplete(element) {
};
const tribute = new Tribute({
- trigger: '#',
- values: function (text, cb) {
- if (event.target.type === 'text' && $(element).attr('autocomplete') != 'off') {
- $(element).attr('autocomplete', 'off');
+ collection: [
+ {
+ trigger: '#',
+ values: function (text, cb) {
+ if (event.target.type === 'text' && $(element).attr('autocomplete') != 'off') {
+ $(element).attr('autocomplete', 'off');
+ }
+ remoteSearch(getDataSource('issues') + text, function (issues) {
+ return cb(issues);
+ });
+ },
+ lookup: 'label',
+ fillAttr: 'label',
+ requireLeadingSpace: true,
+ selectTemplate: function (issue) {
+ return '#' + issue.original.id;
+ },
+ noMatchTemplate: function () {
+ return '<span style:"visibility: hidden;"></span>';
+ }
+ },
+ {
+ trigger: '[[',
+ values: function (text, cb) {
+ remoteSearch(getDataSource('wiki_pages') + text, function (wikiPages) {
+ return cb(wikiPages);
+ });
+ },
+ lookup: 'label',
+ fillAttr: 'label',
+ requireLeadingSpace: true,
+ selectTemplate: function (wikiPage) {
+ return '[[' + wikiPage.original.value + ']]';
+ },
+ noMatchTemplate: function () {
+ return '<span style:"visibility: hidden;"></span>';
+ }
}
- remoteSearch(getDataSource('issues') + text, function (issues) {
- return cb(issues);
- });
- },
- lookup: 'label',
- fillAttr: 'label',
- requireLeadingSpace: true,
- selectTemplate: function (issue) {
- return '#' + issue.original.id;
- },
- noMatchTemplate: function () {
- return '<span style:"visibility: hidden;"></span>';
- }
+ ]
});
tribute.attach(element);