// ---------- Start Your Journey (Function) --------------------------------------------------
function startTheJourney() {
$('.top-cover').eq(0).addClass('hide');
$('body').eq(0).css('overflow', 'visible');
playMusicOnce();
setTimeout(function() {
// Looping the aos animate
$('.aos-animate').each(function(i, el){
// If the parent is not 'Top Cover'
if ($(el).closest('.top-cover').length == 0) {
// Remove 'aos-animate' class
$(el).removeClass('aos-animate');
setTimeout(function(){
// Add 'aos-amimate' class
$(el).addClass('aos-animate');
}, 1000);
}
});
}, 50);
setTimeout(function(){
$('.top-cover').eq(0).remove();
}, 3000);
}
// ---------- ALERT --------------------------------------------------
var $alert = $('#alert'); // alert
var $alertClose = $('#alert .alert-close'); // alert close
var $alertText = $('#alert .alert-text'); // Alert Text
// ---------- Hide Alert (Function) --------------------------------------------------
function hideAlert() {
$alert.removeClass(); // Remove All Class
$alert.addClass('alert hide'); // hiding alert
}
// ---------- Show Alert (Function) --------------------------------------------------
function showAlert(message, status) {
if (status != '') {
$alert.removeClass(); // Remove All Class
$alert.addClass('alert show ' + status);
$alertText.text(message);
setTimeout(hideAlert, 3000);
}
}
// ---------- MODAL ---------------------------------------------------------------------------------
var $modal = $('#modal');
var $modalContents = $('.modal-content');
// ---------- Open Modal (Function) --------------------------------------------------
function openModal() {
$modal.html('');
if ($modal.css('display') == 'none') {
$modal.css('display', 'flex');
}
$modalContents.each(function(i, modal){
$(modal).hide();
});
$('html').css('overflow', 'hidden');
}
// ---------- Close Modal (Function) --------------------------------------------------
function closeModal() {
if ($modal.css('display') == 'flex') {
$modal.css('display', 'none');
}
$('html').css('overflow', 'scroll');
$modal.html('');
}
// ---------- Close Modal [ON CLICK] --------------------------------------------------
$(document).on('click', '.close-modal', closeModal);
// ---------- Copy to (Function) --------------------------------------------------
function copyToClipboard(text) {
var dummy = document.createElement("textarea");
// to avoid breaking orgain page when copying more words
// cant copy when adding below this code
// dummy.style.display = 'none'
document.body.appendChild(dummy);
//Be careful if you use texarea. setAttribute('value', value), which works with "input" does not work with "textarea". – Eduard
dummy.value = text;
dummy.select();
document.execCommand("copy");
document.body.removeChild(dummy);
showAlert('Berhasil di salin ke papan klip', 'success');
}
// ---------- URLify (Function) --------------------------------------------------
function urlify(text) {
var lineBreak = '';
var urlRegex = /(https?:\/\/[^\s]+)/g;
return text.replace(urlRegex, function(url) {
var finalURL = url;
if (url.indexOf('
') > -1) {
finalURL = url.replace(/
/g, '');
lineBreak = '
';
}
return '' + finalURL + '' + lineBreak;
});
// or alternatively
// return text.replace(urlRegex, '$1')
}
// ---------- Copy Account [ON CLICK] ---------------------------------------------------------------
$(document).on('click', '.copy-account', function(e){
e.preventDefault();
var book = $(this).closest('.book');
var number = $(book).find('.account-number');
copyToClipboard(number.html());
});
// ---------- Number Format (Variables) ---------------------------------------------------------------
var numberFormat = new Intl.NumberFormat('ID', {
// style: 'currency',
// currency: 'IDR',
});
// ---------- Disabled Dragging an image [ON DRAGSTART] -----------------------------------------------
$('img').on('dragstart', function(e){
e.preventDefault();
});
// ---------- Textarea [ON KEY, FOCUS] -----------------------------------------------------------------
$(document).on('keyup focus', 'textarea', function(e){
e.preventDefault();
this.style.height = '1px';
this.style.height = (this.scrollHeight) + 'px';
}).on('focusout', 'textarea', function(e){
e.preventDefault();
this.style.height = 24 + 'px';
});
/* ==============================
CALLING
============================== */
// ---------- Sending Data (Only) By AJAX --------------------------------------------------
function ajaxCall(data, callback) {
if (data) {
$.ajax({
type: 'post',
dataType: 'json',
data: data,
success: function(result){
if (result.error === false) {
callback(result);
} else {
callback(result);
}
},
});
}
}
// ---------- Sending Data And Media BY AJAX --------------------------------------------------
function ajaxMultiPart(data, beforeSend, callback) {
if (data) {
$.ajax({
type: 'post',
dataType: 'json',
contentType: false,
processData: false,
data: data,
beforeSend: beforeSend,
success: function(result){
if (result.error === false) {
callback(result);
} else {
showAlert(result.message, 'error');
$('.gift-next').prop('disabled', false);
$('.gift-submit').prop('disabled', false);
$('.gift-submit').html('Konfirmasi');
}
},
});
}
}
// ---------- Calling Modal [ON CLICK] --------------------------------------------------
$(document).on('click', '[data-modal]', function(e){
e.preventDefault();
var element = this;
var modal = $(element).data('modal');
var data = {
'status': 'modal',
'modal': modal
}
// Delete Comment
if (modal == 'delete_comment') {
var comment = $(element).data('comment');
data['comment'] = comment;
}
ajaxCall(data, function(result){
if (result.modal != '') {
openModal();
$modal.append(result['modal']);
}
});
});
// ---------- Deleting [ON CLICK] --------------------------------------------------
$(document).on('click', '[data-delete]', function(e){
e.preventDefault();
var element = this;
var status = $(element).data('delete');
var data = {
'status': status
};
if (status == 'delete_comment') {
var comment = $(element).data('comment');
data['comment'] = comment;
}
ajaxCall(data, function(result){
if (result.callback == 'comment') {
closeModal();
showAlert(result.message, 'success');
}
});
});
/* ==============================
COVERS
============================== */
// ---------- Slider Options (Function) --------------------------------------------------
function sliderOptions() {
return {
centerMode: true,
slidesToShow: 1,
variableWidth: true,
autoplay: true,
autoplaySpeed: 3000,
infinite: true,
speed: 500,
fade: true,
cssEase: 'linear',
dots: false,
arrows: false,
pauseOnFocus: false,
pauseOnHover: false,
draggable: false,
touchMove: false
};
};
// Is Cover Played
var isCoverPlayed = false;
// COVER CONFIGURATION
(function coverConfiguration() {
var windowWidth = $(window).width(), // Window Width
smallScreen = window.matchMedia( "(max-width: 1024px)" ); // Small screen
// If width matched
if (windowWidth > '1020' && windowWidth < '1030') {
isCoverPlayed = false; // cover is not played
}
// COVERS
if (typeof window.COVERS != 'undefined') {
// COVERS LOOP
$(window.COVERS).each(function(i, cover){
var position = cover.position, // position
details = cover.details, // details
element = cover.element, // element
coverInner = $(element).closest('.cover-inner'); // Cover Inner
// If element does exist
if ($(element).length > 0) {
// if the position is MAIN
if (position == 'MAIN') {
// COVERS
// If Cover Inner does exist
if (coverInner.length) {
$(coverInner).removeClass('covers'); // Remove class 'covers'
if (details.desktop != '' || details.mobile != '') {
$(coverInner).addClass('covers'); // Add Class to cover-inner
}
}
}
// if cover has been slicked
if ($(element).hasClass('slick-initialized')) {
$(element).slick('unslick'); // stop the slider
}
$(element).html(''); // empty element
// if the small screen does not match (DESKTOP SIZE)
if (!smallScreen.matches) {
// if cover desktop is not empty
if (details.desktop != '') {
// if the position is MAIN and the cover is not played
if (position == 'MAIN' && !isCoverPlayed) {
isCoverPlayed = true; // Played the cover
}
$(element).append(details.desktop); // Append new cover elements into cover
$(element).slick(sliderOptions()); // Start the slider
if (coverInner.length) $(coverInner).removeClass('mobile').addClass('desktop'); // Add class desktop
}
} else {
// the screen is small (MOBILE SIZE)
// if cover desktop is not empty
if (details.mobile != '') {
// if the position is MAIN and the cover is not played
if (position == 'MAIN' && !isCoverPlayed) {
isCoverPlayed = true; // Played the cover
}
$(element).append(details.mobile); // Append new cover elements into cover
$(element).slick(sliderOptions()); // Start the slider
if (coverInner.length) $(coverInner).removeClass('desktop').addClass('mobile'); // Add class desktop
}
}
}
});
}
}());
/* ================================================
SAVE THE DATE
============================================= */
// ----------- COUNTDOWN (Function) ------------------------------------------------------
(function countdown(){
if (typeof window.EVENT != 'undefined') {
var schedule = window.EVENT,
event = new Date(schedule * 1000).getTime(),
start = setInterval(rundown, 1000);
// Rundown
function rundown() {
var now = new Date().getTime(),
distance = event - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24)), // days
hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)), // hours
minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)), // minutes
seconds = Math.floor((distance % (1000 * 60)) / 1000); // seconds
if (distance < 0) {
clearInterval(start);
$('.count-day').text('0');
$('.count-hour').text('0');
$('.count-minute').text('0');
$('.count-second').text('0');
} else {
$('.count-day').text(days);
$('.count-hour').text(hours);
$('.count-minute').text(minutes);
$('.count-second').text(seconds);
}
}
}
}());
/* ==============================
RSVP
============================== */
// ---------- Attendance Toggle (Function) --------------------------------------------------
function attendanceToggle(input) {
var attendanceCome = $('.attendance-value.come');
var attendanceNotCome = $('.attendance-value.not-come');
var come = 'Datang', // Come
notCome = 'Tidak Datang'; // Not Come
if (typeof window.RSVP != 'undefined') {
come = window.RSVP['button_text']['attend']; // Attend
notCome = window.RSVP['button_text']['not_attend']; // Not Attend
}
$(attendanceCome).html(come);
$(attendanceNotCome).html(notCome);
if ($(input).is(':checked')) {
if ($(input).next('.attendance-value.come').length > 0) {
$(attendanceCome).html(' ' + come);
$('#rsvp-guest-amount').slideDown();
}
if ($(input).next('.attendance-value.not-come').length > 0) {
$(attendanceNotCome).html(' ' + notCome);
$('#rsvp-guest-amount').slideUp();
}
}
}
// ---------- Attendance [ON CLICK] --------------------------------------------------
$(document).on('change', '[name="attendance"]', function(e){
e.preventDefault();
attendanceToggle(this);
})
// ---------- Change Confirmation [ON CLICK] --------------------------------------------------
$(document).on('click', '.change-confirmation', function(e){
e.preventDefault();
$('.rsvp-inner').find('.rsvp-form').fadeIn();
$('.rsvp-inner').find('.rsvp-confirm').hide();
});
// ---------- Plus Button [ON CLICK] --------------------------------------------------
$(document).on('click', '[data-quantity="plus"]', function(e){
e.preventDefault();
var fieldName = $(this).attr('data-field');
var $input = $('input[name="' + fieldName + '"]');
var currentVal = parseInt($input.val());
var bool = $input.prop('readonly');
if (!bool) {
if (!isNaN(currentVal)) {
if (currentVal < $input.prop('max')) {
$input.val(currentVal + 1);
}
} else {
$input.val(1);
}
}
});
// ---------- Minus Button [ON CLICK] --------------------------------------------------
$(document).on('click', '[data-quantity="minus"]', function(e){
e.preventDefault();
var fieldName = $(this).attr('data-field');
var $input = $('input[name="' + fieldName + '"]');
var currentVal = parseInt($input.val());
var bool = $input.prop('readonly');
if (!bool) {
if (!isNaN(currentVal)) {
$input.val(currentVal - 1);
if (currentVal <= 0) {
$input.val(0);
}
} else {
$input.val(0);
}
}
});
// ---------- Quantity Control [ON CHANGE] --------------------------------------------------
$(document).on('change', '[data-quantity="control"]', function(e){
e.preventDefault();
var max = $(this).prop('max');
var value = $(this).val();
if (value > max) {
$(this).val(max);
}
});
// ---------- Comment Form [ON SUBMIT] --------------------------------------------------
$(document).on('submit', '#comment-form', function(e){
e.preventDefault();
var form = $(this);
var data = $(this).serialize();
var comment = $(this).find('[name="comment"]');
if (comment.val() == '') {
comment.focus();
} else {
ajaxCall(data, function(result){
var newcomen='
' + escape(item.title) + '
' : '') + '' + escape(label) + '
' + '' + escape(desc) + '
' + '