mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Merge branch 'master' into pu
This commit is contained in:
commit
763b84d0b9
5 changed files with 129 additions and 66 deletions
|
@ -23,7 +23,7 @@ git_clone_uri_anon = https://aur.archlinux.org/%s.git
|
|||
git_clone_uri_priv = ssh://aur@aur.archlinux.org/%s.git
|
||||
max_rpc_results = 5000
|
||||
max_depends = 1000
|
||||
aur_request_ml = aur-requests@archlinux.org
|
||||
aur_request_ml = aur-requests@lists.archlinux.org
|
||||
request_idle_time = 1209600
|
||||
request_archive_time = 15552000
|
||||
auto_orphan_age = 15552000
|
||||
|
|
|
@ -31,7 +31,7 @@ name = aur.db
|
|||
|
||||
[options]
|
||||
aur_location = https://aur.archlinux.org
|
||||
aur_request_ml = aur-requests@archlinux.org
|
||||
aur_request_ml = aur-requests@lists.archlinux.org
|
||||
enable-maintenance = 0
|
||||
maintenance-exceptions = 127.0.0.1
|
||||
commit_uri = https://aur.archlinux.org/cgit/aur.git/log/?h=%s&id=%s
|
||||
|
|
|
@ -199,3 +199,8 @@ label.confirmation,
|
|||
.error {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.article-content > div {
|
||||
overflow: hidden;
|
||||
transition: height 1s;
|
||||
}
|
||||
|
|
|
@ -46,70 +46,94 @@ if (isset($pkgname)) {
|
|||
html_header($title, $details);
|
||||
?>
|
||||
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jquery@1.9.1/jquery.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
function collapseDependsList(list) {
|
||||
list = $(list);
|
||||
list = document.getElementById(list);
|
||||
|
||||
// Hide everything past a given limit. Don't do anything if we don't have
|
||||
// enough items, or the link already exists.
|
||||
var limit = 20,
|
||||
linkid = list.attr('id') + 'link',
|
||||
items = list.find('li').slice(limit);
|
||||
if (items.length <= 1 || $('#' + linkid).length > 0) {
|
||||
const limit = 20;
|
||||
const linkid = list.getAttribute('id') + 'link';
|
||||
const items = Array.from(list.querySelectorAll('li')).slice(limit);
|
||||
if (items.length <= 1 || document.getElementById(linkid)) {
|
||||
return;
|
||||
}
|
||||
items.hide();
|
||||
list.after('<p><a id="' + linkid + '" href="#">Show More…</a></p>');
|
||||
|
||||
items.forEach(function(item) {
|
||||
item.style.display = 'none';
|
||||
});
|
||||
|
||||
const link = document.createElement('a');
|
||||
link.id = linkid;
|
||||
link.href = '#';
|
||||
link.textContent = 'Show More…';
|
||||
|
||||
const showMore = document.createElement('p');
|
||||
showMore.appendChild(link);
|
||||
|
||||
list.insertAdjacentElement('afterend', showMore);
|
||||
|
||||
// add link and wire it up to show the hidden items
|
||||
$('#' + linkid).click(function(event) {
|
||||
link.addEventListener('click', function(event) {
|
||||
event.preventDefault();
|
||||
list.find('li').show();
|
||||
|
||||
items.forEach(function(item) {
|
||||
item.style.display = '';
|
||||
});
|
||||
|
||||
// remove the full <p/> node from the DOM
|
||||
$(this).parent().remove();
|
||||
event.target.parentNode.removeChild(event.target);
|
||||
});
|
||||
}
|
||||
|
||||
function collapseComment(div) {
|
||||
var linkid = div.attr('id') + 'link',
|
||||
inner = div.find('div'),
|
||||
height = inner.height(),
|
||||
maxheight = 200;
|
||||
const linkid = div.getAttribute('id') + 'link';
|
||||
const inner = div.querySelector('div');
|
||||
// max height of a collapsed comment.
|
||||
const maxheight = 200;
|
||||
const height = inner.offsetHeight;
|
||||
|
||||
if (height <= maxheight)
|
||||
return;
|
||||
|
||||
inner.css({ 'overflow': 'hidden', 'height': maxheight + 'px' });
|
||||
inner.addClass('collapsed');
|
||||
inner.after('<p><a id="' + linkid + '" href="#">Show More…</a></p>');
|
||||
inner.style.height = maxheight + 'px';
|
||||
inner.classList.add('collapsed');
|
||||
|
||||
$('#' + linkid).click(function(event) {
|
||||
var inner = $(this).parent().parent().find('div');
|
||||
const link = document.createElement('a');
|
||||
link.id = linkid;
|
||||
link.href = '#';
|
||||
link.textContent = 'Show More…';
|
||||
|
||||
const showMore = document.createElement('p');
|
||||
showMore.appendChild(link);
|
||||
|
||||
inner.insertAdjacentElement('afterend', showMore);
|
||||
|
||||
link.addEventListener('click', function(event) {
|
||||
const showMoreLink = event.target;
|
||||
const inner = showMoreLink.parentNode.parentNode.querySelector('div');
|
||||
var newheight;
|
||||
|
||||
if (inner.hasClass('collapsed')) {
|
||||
inner.css({ 'height': 'auto' });
|
||||
newheight = inner.height();
|
||||
inner.css({ 'height': maxheight });
|
||||
$(this).text('Collapse');
|
||||
if (inner.classList.contains('collapsed')) {
|
||||
inner.style.height = height + 'px';
|
||||
showMoreLink.textContent = 'Collapse';
|
||||
} else {
|
||||
newheight = maxheight;
|
||||
$(this).text('Show More…');
|
||||
newheight = maxheight + 'px';
|
||||
inner.style.height = newheight;
|
||||
showMoreLink.textContent = 'Show More…';
|
||||
}
|
||||
|
||||
inner.animate({ 'height': newheight });
|
||||
inner.toggleClass('collapsed');
|
||||
inner.classList.toggle('collapsed');
|
||||
event.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
collapseDependsList("#pkgdepslist");
|
||||
collapseDependsList("#pkgreqslist");
|
||||
collapseDependsList("#pkgsrcslist");
|
||||
$(".article-content").each(function() {
|
||||
collapseComment($(this));
|
||||
});
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
collapseDependsList("pkgdepslist");
|
||||
collapseDependsList("pkgreqslist");
|
||||
collapseDependsList("pkgsrcslist");
|
||||
|
||||
Array.from(document.querySelectorAll('.article-content')).forEach(collapseComment);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
@ -169,37 +169,71 @@ if ($comment_section == "package") {
|
|||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.edit-comment').click(function () {
|
||||
var parent_element = this.parentElement,
|
||||
parent_id = parent_element.id,
|
||||
comment_id = parent_id.substr(parent_id.indexOf('-') + 1),
|
||||
edit_form = $(parent_element).next(),
|
||||
_this = $(this);
|
||||
add_busy_indicator(_this);
|
||||
$.getJSON('<?= get_uri('/rpc') ?>', {
|
||||
type: 'get-comment-form',
|
||||
arg: comment_id,
|
||||
base_id: <?= intval($row["PackageBaseID"]) ?>,
|
||||
pkgbase_name: <?= json_encode($pkgbase_name) ?>
|
||||
}, function (data) {
|
||||
remove_busy_indicator(_this);
|
||||
if (data.success) {
|
||||
edit_form.html(data.form);
|
||||
edit_form.find('textarea').focus();
|
||||
} else {
|
||||
alert(data.error);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
function add_busy_indicator(sibling) {
|
||||
const img = document.createElement('img');
|
||||
img.src = "/images/ajax-loader.gif";
|
||||
img.classList.add('ajax-loader');
|
||||
img.style.height = 11;
|
||||
img.style.width = 16;
|
||||
img.alt = "Busy…";
|
||||
|
||||
function add_busy_indicator(sibling) {
|
||||
sibling.after('<img src="/images/ajax-loader.gif" class="ajax-loader" width="16" height="11" alt="Busy…" />');
|
||||
sibling.insertAdjacentElement('afterend', img);
|
||||
}
|
||||
|
||||
function remove_busy_indicator(sibling) {
|
||||
const elem = sibling.nextElementSibling;
|
||||
elem.parentNode.removeChild(elem);
|
||||
}
|
||||
|
||||
function getParentsUntil(elem, className) {
|
||||
// Limit to 10 depth
|
||||
for ( ; elem && elem !== document; elem = elem.parentNode) {
|
||||
if (elem.matches(className)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function remove_busy_indicator(sibling) {
|
||||
sibling.next().remove();
|
||||
return elem;
|
||||
}
|
||||
|
||||
function handleEditCommentClick(event) {
|
||||
event.preventDefault();
|
||||
const parent_element = getParentsUntil(event.target, '.comment-header');
|
||||
const parent_id = parent_element.id;
|
||||
const comment_id = parent_id.substr(parent_id.indexOf('-') + 1);
|
||||
// The div class="article-content" which contains the comment
|
||||
const edit_form = parent_element.nextElementSibling;
|
||||
|
||||
const params = new URLSearchParams({
|
||||
type: "get-comment-form",
|
||||
arg: comment_id,
|
||||
base_id: <?= intval($row["PackageBaseID"]) ?>,
|
||||
pkgbase_name: <?= json_encode($pkgbase_name) ?>
|
||||
});
|
||||
|
||||
const url = '<?= get_uri('/rpc') ?>' + '?' + params.toString();
|
||||
|
||||
add_busy_indicator(event.target);
|
||||
|
||||
fetch(url, {
|
||||
method: 'GET'
|
||||
})
|
||||
.then(function(response) { return response.json(); })
|
||||
.then(function(data) {
|
||||
remove_busy_indicator(event.target);
|
||||
if (data.success) {
|
||||
edit_form.innerHTML = data.form;
|
||||
edit_form.querySelector('textarea').focus();
|
||||
} else {
|
||||
alert(data.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const divs = document.querySelectorAll('.edit-comment');;
|
||||
for (let div of divs) {
|
||||
div.addEventListener('click', handleEditCommentClick);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Add table
Reference in a new issue