Skip to content
This repository was archived by the owner on Dec 21, 2022. It is now read-only.

Commit d356fd3

Browse files
committed
New tab on project clickin Collection
1 parent 39f4b92 commit d356fd3

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

static/js/project.js

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,39 @@ function itemDiv (item, itemType, ownerUsernamePath, nameField,
2020
'"></i>'
2121
}
2222

23+
24+
var project_href_url =
25+
itemType + '?user=' + encodeURIComponent(eval('item.' + ownerUsernamePath)) +
26+
'&' + itemType + '=' + encodeURIComponent(item[nameField]);
27+
28+
var target = 'target="_self"';
29+
30+
if (options.linkTarget) {
31+
if (options.linkTarget == "_blank") {
32+
target = 'target="_blank" rel="noopener noreferrer"';
33+
} else {
34+
target = 'target="' + options.linkTarget + '"';
35+
}
36+
}
37+
38+
var html_a_start_tag =
39+
'<a ' +
40+
target +
41+
' ' +
42+
'href="' + project_href_url + '"' +
43+
'>';
44+
2345
div.innerHTML +=
24-
'<a target="' + (options.linkTarget || '_self')
25-
+ '" href="' + itemType +
26-
'?user=' + encodeURIComponent(eval('item.' + ownerUsernamePath)) +
27-
'&' + itemType + '=' + encodeURIComponent(item[nameField]) +
28-
'"><img class="thumbnail" alt="' +
29-
(item.thumbnail ? escapeHtml(item[nameField]) : '') +
30-
'" title="' + escapeHtml(item[descriptionField]) +
31-
(item.thumbnail ? '" src="' + escapeHtml(item.thumbnail) + '"' : '') +
32-
'"><span class="' + itemType + '-name">' + escapeHtml(item[nameField]) +
33-
'</span></a>';
46+
html_a_start_tag +
47+
'<img class="thumbnail" alt="' +
48+
(item.thumbnail ? escapeHtml(item[nameField]) : '') +
49+
'" title="' + escapeHtml(item[descriptionField]) +
50+
(item.thumbnail ? '" src="' + escapeHtml(item.thumbnail) + '"' : '') +
51+
'">' +
52+
'<span class="' + itemType + '-name">' +
53+
escapeHtml(item[nameField]) +
54+
'</span>' +
55+
'</a>';
3456

3557
if (extraFields) {
3658
Object.keys(extraFields).forEach(function (fieldName) {

templates/collection.tmp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@
9090
isPublished: 'ispublished',
9191
author: 'username'
9292
},
93-
withCollectionControls: true
93+
withCollectionControls: true,
94+
linkTarget: '_blank'
9495
}
9596
)
9697
);

0 commit comments

Comments
 (0)