This commit is contained in:
1 parent
d77be150d9
commit
5210c9d2e6
11 files changed
+732
-284
No files matched your search
@@ -128,12 +128,12 @@
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
/* Simple gradients for cross-browser compatibility */
|
||||
.wheel-segment-yellow { fill: #ffdd00; }
|
||||
.wheel-segment-green { fill: #88ff00; }
|
||||
.wheel-segment-red { fill: #ff5500; }
|
||||
.wheel-segment-pink { fill: #ff44aa; }
|
||||
.wheel-segment-blue { fill: #00ccff; }
|
||||
/* Simple solid fills for segment color classes */
|
||||
.wheel-segment-red { fill: #ff3131; }
|
||||
.wheel-segment-green { fill: #7ed957; }
|
||||
.wheel-segment-purple { fill: #8c52ff; }
|
||||
.wheel-segment-orange { fill: #ff914d; }
|
||||
.wheel-segment-blue { fill: #1da3e7; }
|
||||
|
||||
/* Divider between segments */
|
||||
.wheel-divider {
|
||||
|
||||
+19
-34
@@ -20,7 +20,6 @@ jQuery(document).ready(function($) {
|
||||
var isSpinning = false;
|
||||
var accumulatedRotation = 0;
|
||||
var wheelSpins = wof_data.spins_left;
|
||||
var dailySpinAvailable = wof_data.daily_spin_available;
|
||||
var l10n = wof_data.l10n;
|
||||
|
||||
// Nastavitve animacije
|
||||
@@ -59,12 +58,22 @@ jQuery(document).ready(function($) {
|
||||
showPrizePopup(prize);
|
||||
isSpinning = false;
|
||||
|
||||
updateButtonState();
|
||||
if (wheelSpins > 0) {
|
||||
spinButton.prop('disabled', false).text(l10n.spin_button);
|
||||
} else {
|
||||
spinButton.prop('disabled', true).text(l10n.no_spins_left);
|
||||
}
|
||||
}
|
||||
|
||||
// Prikaz nagrade
|
||||
function showPrizePopup(prize) {
|
||||
var html = '<h3>' + l10n.congratulations + '</h3><p>' + l10n.you_won + ' <strong>' + prize.name + '</strong></p>';
|
||||
var isTryAgain = window.wof_spin_result.is_try_again === 1 || prize.is_try_again === 1;
|
||||
var html = '';
|
||||
if (isTryAgain) {
|
||||
html = '<p><strong>' + prize.name + '</strong></p>';
|
||||
} else {
|
||||
html = '<h3>' + l10n.congratulations + '</h3><p>' + l10n.you_won + ' <strong>' + prize.name + '</strong></p>';
|
||||
}
|
||||
if (window.wof_spin_result.discount_code) {
|
||||
html += '<p>' + l10n.discount_code_sent + '</p>';
|
||||
}
|
||||
@@ -78,31 +87,9 @@ jQuery(document).ready(function($) {
|
||||
}
|
||||
}
|
||||
|
||||
// Posodobitev stanja gumba
|
||||
function updateButtonState() {
|
||||
if (isSpinning) return;
|
||||
|
||||
if (dailySpinAvailable) {
|
||||
spinButton.prop('disabled', false).text(l10n.free_daily_spin || 'FREE DAILY SPIN');
|
||||
} else if (wheelSpins > 0) {
|
||||
spinButton.prop('disabled', false).text(l10n.spin_button);
|
||||
} else {
|
||||
spinButton.prop('disabled', true).text(l10n.no_spins_left);
|
||||
}
|
||||
}
|
||||
|
||||
// Klik na gumb za vrtenje
|
||||
spinButton.on('click', function() {
|
||||
if (isSpinning) return;
|
||||
|
||||
var spinType = 'paid'; // Privzeto je plačan
|
||||
|
||||
// Preveri, ali najprej porabimo dnevnega
|
||||
if (dailySpinAvailable) {
|
||||
spinType = 'daily';
|
||||
} else if (wheelSpins <= 0) {
|
||||
return; // Ničesar za porabiti
|
||||
}
|
||||
if (isSpinning || wheelSpins <= 0) return;
|
||||
|
||||
isSpinning = true;
|
||||
spinButton.prop('disabled', true).text(l10n.spinning);
|
||||
@@ -116,16 +103,10 @@ jQuery(document).ready(function($) {
|
||||
},
|
||||
data: {
|
||||
wheel_id: wof_data.wheel_id,
|
||||
spin_type: spinType
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
window.wof_spin_result = response.data;
|
||||
|
||||
// Posodobimo stanje
|
||||
if (spinType === 'daily') {
|
||||
dailySpinAvailable = false;
|
||||
}
|
||||
wheelSpins = response.data.remaining_spins;
|
||||
updateSpinsCounter();
|
||||
|
||||
@@ -156,13 +137,17 @@ jQuery(document).ready(function($) {
|
||||
function handleError(message) {
|
||||
resultDiv.html('<p>' + message + '</p>').addClass('error').fadeIn(300);
|
||||
isSpinning = false;
|
||||
updateButtonState();
|
||||
if(wheelSpins > 0){
|
||||
spinButton.prop('disabled', false).text(l10n.spin_button);
|
||||
}
|
||||
}
|
||||
|
||||
// Inicializacija
|
||||
function init() {
|
||||
updateSpinsCounter();
|
||||
updateButtonState();
|
||||
if (wheelSpins <= 0) {
|
||||
spinButton.prop('disabled', true).text(l10n.no_spins_left);
|
||||
}
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
Reference in new issue
Block a user