2022-03-08 15:55:41 +01:00
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
var ready = false;
|
|
|
|
|
|
|
|
$(document).on('click', '.WireTabs a', function($event) {
|
|
|
|
if(ready) window.location.href = $(this).attr('href');
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2023-03-10 19:41:40 +01:00
|
|
|
var $tabs = $('.WireTabs');
|
|
|
|
$tabs.css('opacity', 1.0);
|
|
|
|
$tabs.find('.uk-active').removeClass('uk-active');
|
2024-04-04 14:37:20 +02:00
|
|
|
$tabs.find('a.on').parent('li').trigger('click').addClass('uk-active');
|
2022-03-08 15:55:41 +01:00
|
|
|
|
2024-04-04 14:37:20 +02:00
|
|
|
$("a.CommentTextEdit").on('click', function() {
|
2022-03-08 15:55:41 +01:00
|
|
|
var $textarea = $("<textarea></textarea>");
|
|
|
|
var $parent = $(this).closest('.CommentTextEditable');
|
|
|
|
$parent.parent('.CommentText').removeClass('CommentTextOverflow');
|
|
|
|
$textarea.attr('name', $parent.attr('id'));
|
|
|
|
$textarea.addClass($parent.attr('data-textarea-class'));
|
|
|
|
//$textarea.height($parent.height());
|
|
|
|
$(this).remove(); // remove edit link
|
|
|
|
$textarea.val($parent.text());
|
|
|
|
$parent.after($textarea);
|
|
|
|
$parent.remove();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2024-04-04 14:37:20 +02:00
|
|
|
$(".CommentText").on('click', function() {
|
|
|
|
$(this).find('a.CommentTextEdit').trigger('click');
|
2022-03-08 15:55:41 +01:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".CommentItem").each(function() {
|
|
|
|
var $item = $(this);
|
|
|
|
var $table = $item.find(".CommentItemInfo");
|
|
|
|
var height = $table.height() + 30;
|
|
|
|
var $text = $item.find(".CommentText");
|
|
|
|
if($text.height() > height) {
|
|
|
|
$text.addClass('CommentTextOverflow');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/*
|
|
|
|
// for cite, email and website editor inputs (@todo)
|
2024-04-04 14:37:20 +02:00
|
|
|
$("a.CommentToggleSiblings").on('click', function() {
|
2022-03-08 15:55:41 +01:00
|
|
|
$(this).siblings().each(function() {
|
|
|
|
var $item = $(this);
|
|
|
|
if($item.attr('hidden')) {
|
|
|
|
$item.attr('hidden', false);
|
|
|
|
} else {
|
|
|
|
$item.attr('hidden', true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
*/
|
|
|
|
|
2024-04-04 14:37:20 +02:00
|
|
|
$("#CommentLimitSelect").on('change', function() {
|
2022-03-08 15:55:41 +01:00
|
|
|
window.location = './?limit=' + parseInt($(this).val());
|
|
|
|
});
|
2024-04-04 14:37:20 +02:00
|
|
|
$("#CommentListSort").on('change', function() {
|
2022-03-08 15:55:41 +01:00
|
|
|
window.location = './?sort=' + $(this).val();
|
|
|
|
});
|
|
|
|
|
|
|
|
function commentCheckboxClicked($checkbox) {
|
|
|
|
var $item = $checkbox.closest(".CommentItem");
|
|
|
|
if($checkbox.is(":checked")) {
|
|
|
|
$item.addClass('CommentChecked'); // .css('background-color', bgcolor);
|
|
|
|
} else {
|
|
|
|
$item.removeClass('CommentChecked'); // .css('background-color', '');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-04-04 14:37:20 +02:00
|
|
|
$(".CommentCheckbox").on('click', function() {
|
2022-03-08 15:55:41 +01:00
|
|
|
commentCheckboxClicked($(this));
|
|
|
|
});
|
|
|
|
|
2024-04-04 14:37:20 +02:00
|
|
|
$("#CommentCheckAll").on('click', function() {
|
2022-03-08 15:55:41 +01:00
|
|
|
var $items = $(".CommentCheckbox");
|
|
|
|
if($(this).is(":checked")) {
|
|
|
|
// $items.attr('checked', 'checked'); // JQM
|
|
|
|
$items.prop('checked', true);
|
|
|
|
} else {
|
|
|
|
// $items.removeAttr('checked'); // JQM
|
|
|
|
$items.prop('checked', false);
|
|
|
|
}
|
|
|
|
$items.each(function() {
|
|
|
|
commentCheckboxClicked($(this));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2024-04-04 14:37:20 +02:00
|
|
|
$("#CommentActions").on('change', function() {
|
2022-03-08 15:55:41 +01:00
|
|
|
var val = $(this).val();
|
|
|
|
if(!val.length) return;
|
|
|
|
var $checkedItems = $(".CommentChecked");
|
|
|
|
if($checkedItems.length) {
|
|
|
|
$checkedItems.each(function() {
|
|
|
|
if(val == 'reset-upvotes') {
|
|
|
|
// upvotes
|
2024-04-04 14:37:20 +02:00
|
|
|
$(this).find(".CommentUpvotes > input").val(0).trigger('change');
|
2022-03-08 15:55:41 +01:00
|
|
|
} else if(val == 'reset-downvotes') {
|
|
|
|
// downvotes
|
2024-04-04 14:37:20 +02:00
|
|
|
$(this).find(".CommentDownvotes > input").val(0).trigger('change');
|
2022-03-08 15:55:41 +01:00
|
|
|
} else {
|
|
|
|
// status
|
2024-04-04 14:37:20 +02:00
|
|
|
// $(this).find(".CommentStatus > input[value='" + val + "']").trigger('click'); // radios
|
2023-03-10 19:41:40 +01:00
|
|
|
$(this).find("select.CommentStatus").val(val); // select
|
2022-03-08 15:55:41 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
$checkedItems.effect('highlight', 500);
|
|
|
|
} else {
|
|
|
|
ProcessWire.alert($(this).attr('data-nochecked'));
|
|
|
|
}
|
|
|
|
$(this).val('');
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('change', '.CommentItem :input', function() {
|
|
|
|
var $this = $(this);
|
|
|
|
if($this.is("[type='checkbox']")) return;
|
|
|
|
$(this).closest('.CommentItem').addClass('CommentItemChanged');
|
|
|
|
});
|
|
|
|
|
2024-04-04 14:37:20 +02:00
|
|
|
$("#CommentListForm").on('submit', function() {
|
2022-03-08 15:55:41 +01:00
|
|
|
$(this).addClass('CommentListFormSubmitted');
|
|
|
|
});
|
|
|
|
|
|
|
|
window.addEventListener("beforeunload", function(e) {
|
|
|
|
if($(".CommentListFormSubmitted").length) return;
|
|
|
|
var $changes = $(".CommentItemChanged");
|
|
|
|
if($changes.length == 0) return;
|
|
|
|
var msg = $("#CommentListForm").attr('data-unsaved');
|
|
|
|
(e || window.event).returnValue = msg; // Gecko and Trident
|
|
|
|
return msg; // Gecko and WebKit
|
|
|
|
});
|
|
|
|
|
|
|
|
// for AdminThemeReno
|
|
|
|
var color = $(".WireTabs a.on").css('border-top-color');
|
|
|
|
$("#CommentListHeader").css('border-top-color', color);
|
|
|
|
|
|
|
|
ready = true;
|
|
|
|
});
|