Last active
November 3, 2019 02:10
-
-
Save cat-in-136/d7119a6cb521f73956b772095b6db9f4 to your computer and use it in GitHub Desktop.
Revisions
-
cat-in-136 renamed this gist
Nov 3, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
cat-in-136 created this gist
Nov 3, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,63 @@ <script src="https://unpkg.com/[email protected]/dist/tribute.min.js"></script> <link type="text/css" href="https://unpkg.com/[email protected]/dist/tribute.css" rel="stylesheet"> <script> //<![CDATA[ function inlineAutoComplete(element) { 'use strict'; // do not attach if Tribute is already initialized if (element.dataset.tribute === 'true') {return;} 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({ trigger: '#', values: function (text, cb) { remoteSearch(issuesUrl + text, function (issues) { return cb(issues); }); }, lookup: 'label', fillAttr: 'label', requireLeadingSpace: true, selectTemplate: function (issue) { return '#' + issue.original.id; } }); tribute.attach(element); } $(document).on('focus', '.wiki-edit', function(event) { $(this).attr({'data-auto-complete': 'true', 'data-issues-url': '/issues/auto_complete?project_id' + ViewCustomize.context.project.identifier + '&q='}); inlineAutoComplete(event.target); }); //]]> </script> <style> .tribute-container ul { background-color: #fff; border: 1px solid #ccc; border-radius: 2px; } .tribute-container li.highlight {background-color: #759FCF; color:#fff;} </style>