Files
movies/resources/js/app.js
T

124 lines
2.8 KiB
JavaScript
Raw Normal View History

2024-12-29 16:36:49 +02:00
import './bootstrap';
2025-02-01 15:31:47 +02:00
import './star_rating';
2025-08-11 21:40:50 +03:00
import './theme-switcher';
2025-02-01 15:31:47 +02:00
import $ from 'jquery';
2025-02-10 01:58:12 +02:00
import Lightbox from "bs5-lightbox";
import './OwlCarousel2-2.3.4/dist/owl.carousel';
$('.show-slider').owlCarousel({
loop:true,
margin:10,
nav:true,
items: 7
});
$('.similar-show-slider').owlCarousel({
loop:true,
margin:10,
nav:true,
items: 7
});
const options = {
keyboard: true,
size: 'fullscreen'
};
document.querySelectorAll('.lightbox-toggle').forEach((el) => el.addEventListener('click', (e) => {
e.preventDefault();
const lightbox = new Lightbox(el, options);
lightbox.show();
}));
2025-02-01 15:31:47 +02:00
$(".my-rating").starRating({
starSize: 20,
totalStars: 10,
callback: function(currentRating, $el){
let type = $($el[0]).data('type');
let id = $($el[0]).data('id');
let url = '/rate/'+type+'/'+id+'/'+currentRating;
var self = this
$.ajax({
url: url,
method: 'GET',
success: function(data){
$(self).attr('data-rating', currentRating)
}
});
}
});
2025-08-16 15:38:07 +03:00
$('.mark-action').on('click', function (e) {
2025-02-01 15:31:47 +02:00
e.preventDefault();
let url = '/lists/' + $(this).data('list') + '/' + $(this).data('id') + '/' + $(this).data('type');
var self = this
$.ajax({
url: url,
method: 'GET',
success: function(data){
if(data.added) {
$(self).addClass('seen');
} else {
$(self).removeClass('seen');
}
}
});
return false;
});
2025-08-16 15:38:07 +03:00
$('.like-action').on('click', function (e) {
2025-02-01 15:31:47 +02:00
e.preventDefault();
let url = '/lists/' + $(this).data('list') + '/' + $(this).data('id') + '/' + $(this).data('type');
var self = this
$.ajax({
url: url,
method: 'GET',
success: function(data){
if(data.added) {
$(self).addClass('liked');
} else {
$(self).removeClass('liked');
}
}
});
return false;
});
2025-02-02 14:23:11 +02:00
$('.remove-from-watchlist').on('click', function(e){
e.preventDefault();
let url = '/lists/watched/' + $(this).data('id') + '/' + $(this).data('type');
var self = this
$.ajax({
url: url,
method: 'GET',
success: function(data){
if(!data.added) {
$(self).closest('.large-list-item').remove();
}
}
});
return false;
});
2025-10-09 00:22:54 +03:00
$('.list-action').on('click', function(e){
e.preventDefault();
let url = '/lists/' + $(this).data('list') + '/' + $(this).data('id') + '/' + $(this).data('type');
var self = this
$.ajax({
url: url,
method: 'GET',
success: function(data){
// Show a success message
alert('Movie ' + (data.added ? 'added to' : 'removed from') + ' list');
}
});
return false;
});