2020-05-01 22:46:15 +08:00
|
|
|
$(document).ready( function() {
|
2020-05-05 23:50:48 +08:00
|
|
|
|
|
|
|
$(".modal-close").on('click', function() {
|
|
|
|
$(this).parents(".modal").hide();
|
|
|
|
$(".bg-mask").hide();
|
|
|
|
});
|
|
|
|
|
2020-05-08 13:08:29 +08:00
|
|
|
// pop up new rating modal
|
2020-07-03 15:36:23 +08:00
|
|
|
$("#addMarkPanel button").each(function() {
|
2022-11-09 13:56:50 -05:00
|
|
|
$(this).on('click', function(e) {
|
2020-05-05 23:50:48 +08:00
|
|
|
e.preventDefault();
|
|
|
|
let title = $(this).text().trim();
|
2020-07-03 15:36:23 +08:00
|
|
|
$(".mark-modal__title").text(title);
|
|
|
|
$(".mark-modal__body textarea").val("");
|
2020-05-05 23:50:48 +08:00
|
|
|
let status = $(this).data('status')
|
|
|
|
$("input[name='status'][value='"+status+"']").prop("checked", true)
|
|
|
|
$(".bg-mask").show();
|
|
|
|
$(".mark-modal").show();
|
|
|
|
|
|
|
|
// if wish, hide rating widget in modal
|
|
|
|
if ($(this).attr("id") == "wishButton") {
|
2020-07-10 21:28:09 +08:00
|
|
|
// console.log($(this).attr("id"))
|
2020-05-05 23:50:48 +08:00
|
|
|
$(".mark-modal .rating-star-edit").hide();
|
|
|
|
} else {
|
|
|
|
$(".mark-modal .rating-star-edit").show();
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2020-05-08 13:08:29 +08:00
|
|
|
// pop up modify mark modal
|
2022-11-09 13:56:50 -05:00
|
|
|
$(".mark-panel a.edit").on('click', function(e) {
|
2020-05-05 23:50:48 +08:00
|
|
|
e.preventDefault();
|
2020-07-03 15:36:23 +08:00
|
|
|
let title = $(".mark-panel__status").text().trim();
|
|
|
|
$(".mark-modal__title").text(title);
|
2020-05-05 23:50:48 +08:00
|
|
|
$(".bg-mask").show();
|
|
|
|
$(".mark-modal").show();
|
|
|
|
});
|
|
|
|
|
|
|
|
// readonly star rating of detail display section
|
|
|
|
let ratingLabels = $("#main .rating-star");
|
2020-05-01 22:46:15 +08:00
|
|
|
$(ratingLabels).each( function(index, value) {
|
|
|
|
let ratingScore = $(this).data("rating-score") / 2;
|
|
|
|
$(this).starRating({
|
|
|
|
initialRating: ratingScore,
|
2020-05-05 23:50:48 +08:00
|
|
|
readOnly: true,
|
2020-05-01 22:46:15 +08:00
|
|
|
});
|
|
|
|
});
|
2020-05-05 23:50:48 +08:00
|
|
|
// readonly star rating at aside section
|
|
|
|
ratingLabels = $("#aside .rating-star");
|
|
|
|
$(ratingLabels).each( function(index, value) {
|
|
|
|
let ratingScore = $(this).data("rating-score") / 2;
|
|
|
|
$(this).starRating({
|
|
|
|
initialRating: ratingScore,
|
|
|
|
readOnly: true,
|
|
|
|
starSize: 15,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// editable rating star in modal
|
|
|
|
ratingLabels = $("#modals .rating-star-edit");
|
|
|
|
$(ratingLabels).each( function(index, value) {
|
|
|
|
let ratingScore = $("input[type='hidden'][name='rating']").val() / 2;
|
|
|
|
let label = $(this);
|
|
|
|
label.starRating({
|
|
|
|
initialRating: ratingScore,
|
|
|
|
starSize: 20,
|
|
|
|
onHover: function(currentIndex, currentRating, $el){
|
|
|
|
$("input[type='hidden'][name='rating']").val(currentIndex);
|
|
|
|
},
|
|
|
|
onLeave: function(currentIndex, currentRating, $el){
|
|
|
|
$("input[type='hidden'][name='rating']").val(currentRating * 2);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// hide rating star when select wish
|
2020-12-07 15:47:49 +01:00
|
|
|
const WISH_CODE = "wish";
|
2020-07-03 15:36:23 +08:00
|
|
|
if ($("#statusSelection input[type='radio']:checked").val() == WISH_CODE) {
|
2020-05-05 23:50:48 +08:00
|
|
|
$(".mark-modal .rating-star-edit").hide();
|
|
|
|
}
|
2022-11-09 13:56:50 -05:00
|
|
|
$("#statusSelection input[type='radio']").on('click', function() {
|
2020-05-05 23:50:48 +08:00
|
|
|
if ($(this).val() == WISH_CODE) {
|
|
|
|
$(".mark-modal .rating-star-edit").hide();
|
|
|
|
} else {
|
|
|
|
$(".mark-modal .rating-star-edit").show();
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// show confirm modal
|
2022-11-09 13:56:50 -05:00
|
|
|
$(".mark-panel a.delete").on('click', function(e) {
|
2020-05-05 23:50:48 +08:00
|
|
|
e.preventDefault();
|
2020-07-03 15:36:23 +08:00
|
|
|
$(".confirm-modal").show();
|
2020-05-05 23:50:48 +08:00
|
|
|
$(".bg-mask").show();
|
|
|
|
});
|
|
|
|
|
|
|
|
// confirm modal
|
2022-11-09 13:56:50 -05:00
|
|
|
$(".confirm-modal input[type='submit']").on('click', function(e) {
|
2020-05-05 23:50:48 +08:00
|
|
|
e.preventDefault();
|
2020-07-03 15:36:23 +08:00
|
|
|
$(".mark-panel form").submit();
|
2020-05-05 23:50:48 +08:00
|
|
|
});
|
2020-05-01 22:46:15 +08:00
|
|
|
|
2020-07-05 20:14:19 +08:00
|
|
|
|
|
|
|
// hide long text
|
2020-07-05 20:52:30 +08:00
|
|
|
$(".entity-desc__content").each(function() {
|
|
|
|
let copy = $(this).clone()
|
|
|
|
.addClass('entity-desc__content--folded')
|
|
|
|
.css("visibility", "hidden");
|
|
|
|
$(this).after(copy);
|
|
|
|
if ($(this).height() > copy.height()) {
|
|
|
|
$(this).addClass('entity-desc__content--folded');
|
|
|
|
$(this).siblings(".entity-desc__unfold-button").removeClass("entity-desc__unfold-button--hidden");
|
|
|
|
}
|
|
|
|
copy.remove();
|
|
|
|
});
|
2020-07-05 20:14:19 +08:00
|
|
|
|
|
|
|
// expand hidden long text
|
2022-11-09 13:56:50 -05:00
|
|
|
$(".entity-desc__unfold-button a").on('click', function() {
|
2020-07-05 20:52:30 +08:00
|
|
|
$(this).parent().siblings(".entity-desc__content").removeClass('entity-desc__content--folded');
|
|
|
|
$(this).parent(".entity-desc__unfold-button").remove();
|
2020-07-05 20:14:19 +08:00
|
|
|
});
|
2021-08-29 20:43:08 +02:00
|
|
|
|
|
|
|
// disable delete mark button after click
|
|
|
|
const confirmDeleteMarkButton = $('.confirm-modal__confirm-button > input');
|
2022-11-09 13:56:50 -05:00
|
|
|
confirmDeleteMarkButton.on('click', function() {
|
2021-08-29 20:43:08 +02:00
|
|
|
confirmDeleteMarkButton.prop("disabled", true);
|
|
|
|
});
|
2020-07-05 20:52:30 +08:00
|
|
|
|
2021-08-29 20:50:54 +02:00
|
|
|
// disable sumbit button after click
|
|
|
|
const confirmSumbitMarkButton = $('.mark-modal__confirm-button > input');
|
2022-11-09 13:56:50 -05:00
|
|
|
confirmSumbitMarkButton.on('click', function() {
|
2021-08-29 20:50:54 +02:00
|
|
|
confirmSumbitMarkButton.prop("disabled", true);
|
|
|
|
confirmSumbitMarkButton.closest('form')[0].submit();
|
|
|
|
});
|
|
|
|
|
2020-05-01 22:46:15 +08:00
|
|
|
});
|