summaryrefslogtreecommitdiffstats
path: root/web_src/js/features
diff options
context:
space:
mode:
authorJohn Olheiser <42128690+jolheiser@users.noreply.github.com>2020-02-11 19:53:18 -0600
committerGitHub <noreply@github.com>2020-02-11 20:53:18 -0500
commitd67e9b9629557df1e355f0a864792c194b3e8848 (patch)
treef7138acd6776fe08ebb40b840d898fbb47234d4a /web_src/js/features
parent2399bad1f1a4ab36b2fd05745beaea5fb1f53dab (diff)
downloadgitea-d67e9b9629557df1e355f0a864792c194b3e8848.tar.gz
gitea-d67e9b9629557df1e355f0a864792c194b3e8848.zip
SVG Octicon fixes (#10237)
* SVG fixes Signed-off-by: jolheiser <john.olheiser@gmail.com> * Colorize span->svg only Signed-off-by: jolheiser <john.olheiser@gmail.com> * @silverwind suggestions Signed-off-by: jolheiser <john.olheiser@gmail.com> * Alphabetical Signed-off-by: jolheiser <john.olheiser@gmail.com> * Convert suburl and staticPrefix to window.config Signed-off-by: jolheiser <john.olheiser@gmail.com> * De-structure Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Diffstat (limited to 'web_src/js/features')
-rw-r--r--web_src/js/features/contextPopup.js31
1 files changed, 20 insertions, 11 deletions
diff --git a/web_src/js/features/contextPopup.js b/web_src/js/features/contextPopup.js
index 34b6d50357..5acfa9c293 100644
--- a/web_src/js/features/contextPopup.js
+++ b/web_src/js/features/contextPopup.js
@@ -1,15 +1,19 @@
-export default function initContextPopups(suburl) {
+import { svg } from '../utils.js';
+
+const { AppSubUrl } = window.config;
+
+export default function initContextPopups() {
const refIssues = $('.ref-issue');
if (!refIssues.length) return;
refIssues.each(function () {
const [index, _issues, repo, owner] = $(this).attr('href').replace(/[#?].*$/, '').split('/').reverse();
- issuePopup(suburl, owner, repo, index, $(this));
+ issuePopup(owner, repo, index, $(this));
});
}
-function issuePopup(suburl, owner, repo, index, $element) {
- $.get(`${suburl}/api/v1/repos/${owner}/${repo}/issues/${index}`, (issue) => {
+function issuePopup(owner, repo, index, $element) {
+ $.get(`${AppSubUrl}/api/v1/repos/${owner}/${repo}/issues/${index}`, (issue) => {
const createdAt = new Date(issue.created_at).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });
let body = issue.body.replace(/\n+/g, ' ');
@@ -34,19 +38,24 @@ function issuePopup(suburl, owner, repo, index, $element) {
labels = `<p>${labels}</p>`;
}
- let octicon;
+ let octicon, color;
if (issue.pull_request !== null) {
if (issue.state === 'open') {
- octicon = 'green octicon-git-pull-request'; // Open PR
+ color = 'green';
+ octicon = 'octicon-git-pull-request'; // Open PR
} else if (issue.pull_request.merged === true) {
- octicon = 'purple octicon-git-merge'; // Merged PR
+ color = 'purple';
+ octicon = 'octicon-git-merge'; // Merged PR
} else {
- octicon = 'red octicon-git-pull-request'; // Closed PR
+ color = 'red';
+ octicon = 'octicon-git-pull-request'; // Closed PR
}
} else if (issue.state === 'open') {
- octicon = 'green octicon-issue-opened'; // Open Issue
+ color = 'green';
+ octicon = 'octicon-issue-opened'; // Open Issue
} else {
- octicon = 'red octicon-issue-closed'; // Closed Issue
+ color = 'red';
+ octicon = 'octicon-issue-closed'; // Closed Issue
}
$element.popup({
@@ -57,7 +66,7 @@ function issuePopup(suburl, owner, repo, index, $element) {
html: `
<div>
<p><small>${issue.repository.full_name} on ${createdAt}</small></p>
- <p><i class="octicon ${octicon}"></i> <strong>${issue.title}</strong> #${index}</p>
+ <p><span class="${color}">${svg(octicon, 16)}</span> <strong>${issue.title}</strong> #${index}</p>
<p>${body}</p>
${labels}
</div>