149 lines
6.1 KiB
JavaScript
149 lines
6.1 KiB
JavaScript
function mp_event_wo_commerce_price_format(price) {
|
|
let currency_position = jQuery('input[name="currency_position"]').val();
|
|
let currency_symbol = jQuery('input[name="currency_symbol"]').val();
|
|
let currency_decimal = jQuery('input[name="currency_decimal"]').val();
|
|
let currency_thousands_separator = jQuery('input[name="currency_thousands_separator"]').val();
|
|
let currency_number_of_decimal = jQuery('input[name="currency_number_of_decimal"]').val();
|
|
let price_text = '';
|
|
|
|
price = price.toFixed(currency_number_of_decimal);
|
|
// console.log('price= '+ price);
|
|
let total_part = price.toString().split(".");
|
|
total_part[0] = total_part[0].replace(/\B(?=(\d{3})+(?!\d))/g, currency_thousands_separator);
|
|
price = total_part.join(currency_decimal);
|
|
|
|
if (currency_position === 'right') {
|
|
price_text = price + currency_symbol;
|
|
} else if (currency_position === 'right_space') {
|
|
price_text = price + ' ' + currency_symbol;
|
|
} else if (currency_position === 'left') {
|
|
price_text = currency_symbol + price;
|
|
} else {
|
|
price_text = currency_symbol + ' ' + price;
|
|
}
|
|
// console.log('price= '+ price_text);
|
|
return price_text;
|
|
}
|
|
(function ($) {
|
|
//added by sumon
|
|
$(document).on('click', '.mp_event_visible_event_time', function (e) {
|
|
e.preventDefault();
|
|
let target=$(this);
|
|
$('.mp_event_more_date_list:visible').each(function (index){
|
|
$(this).slideUp('fast').siblings('.mp_event_visible_event_time').slideDown('slow').siblings('.mp_event_hide_event_time').slideUp('slow');
|
|
}).promise().done(function (){
|
|
target.slideUp('fast').siblings('.mp_event_more_date_list , .mp_event_hide_event_time').slideDown('slow');
|
|
});
|
|
});
|
|
$(document).on('click', '.mp_event_hide_event_time', function (e) {
|
|
e.preventDefault();
|
|
$('.mp_event_more_date_list:visible').each(function (index){
|
|
$(this).slideUp('fast').siblings('.mp_event_visible_event_time').slideDown('slow').siblings('.mp_event_hide_event_time').slideUp('slow');
|
|
});
|
|
});
|
|
}(jQuery));
|
|
|
|
|
|
(function ($) {
|
|
"use strict";
|
|
let mp_event_input_name_list = {
|
|
mp_event_title: 'data-event-title',
|
|
search_with_city: 'data-city-name',
|
|
search_with_category: 'data-category',
|
|
search_with_organizer: 'data-organizer'
|
|
};
|
|
for (let name in mp_event_input_name_list) {
|
|
$(document).on('change keyup', '[name="' + name + '"] ', function (e) {
|
|
e.preventDefault();
|
|
mp_event_search_result($(this));
|
|
});
|
|
}
|
|
$(document).on('change', '.search_with_start_date , .search_with_end_date', function (e) {
|
|
e.preventDefault();
|
|
mp_event_search_result($(this));
|
|
});
|
|
|
|
function mp_event_search_result(target) {
|
|
let parent = target.closest('.search_sort_code_area');
|
|
if(check_search_value_exit(parent)) {
|
|
let result = 0;
|
|
let date_check = mp_event_date_check(parent);
|
|
parent.find('.all_event_list .event_item').each(function () {
|
|
let active_event = 1;
|
|
for (let name in mp_event_input_name_list) {
|
|
if (mp_event_single_text_check(parent, name) && active_event > 0) {
|
|
active_event = mp_event_single_text_search(parent, $(this), name);
|
|
}
|
|
}
|
|
if (date_check && active_event > 0) {
|
|
active_event = mp_event_date_search(parent, $(this));
|
|
}
|
|
if (active_event > 1) {
|
|
result++;
|
|
$(this).slideDown('fast');
|
|
} else {
|
|
$(this).slideUp('fast');
|
|
}
|
|
}).promise().done(function () {
|
|
if (result > 0) {
|
|
parent.find('.all_event_list').slideDown('fast');
|
|
parent.find('.search_result_empty').slideUp('fast');
|
|
} else {
|
|
parent.find('.all_event_list').slideUp('fast');
|
|
parent.find('.search_result_empty').slideDown('fast');
|
|
}
|
|
});
|
|
}else{
|
|
parent.find('.all_event_list').slideDown('fast');
|
|
parent.find('.all_event_list .event_item').each(function () {
|
|
$(this).slideDown('fast');
|
|
});
|
|
parent.find('.search_result_empty').slideUp('fast');
|
|
}
|
|
}
|
|
|
|
function date_convert_to_str(date) {
|
|
date = new Date(date).getTime();
|
|
if (date && date !== 'NaN') {
|
|
return date;
|
|
} else {
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
function mp_event_single_text_check(parent, inputName) {
|
|
let inputText = parent.find('[name="' + inputName + '"]').val();
|
|
return (inputText && inputText.length > 0) ? 1 : false;
|
|
}
|
|
|
|
function mp_event_single_text_search(parent, item, inputName) {
|
|
let target = parent.find('[name="' + inputName + '"]');
|
|
let inputText = target.val();
|
|
let currentValue = item.attr(mp_event_input_name_list[inputName]);
|
|
return (currentValue.match(new RegExp(inputText, "i"))) ? 2 : 0;
|
|
}
|
|
|
|
function mp_event_date_check(parent) {
|
|
let start_date = date_convert_to_str(parent.find('.search_with_start_date').val());
|
|
let end_date = date_convert_to_str(parent.find('.search_with_end_date').val());
|
|
return (start_date > 0 && end_date > 0) ? 1 : false;
|
|
}
|
|
|
|
function mp_event_date_search(parent, target) {
|
|
let start_date = date_convert_to_str(parent.find('.search_with_start_date').val());
|
|
let end_date = date_convert_to_str(parent.find('.search_with_end_date').val());
|
|
let event_date = date_convert_to_str(target.attr('data-date-time'));
|
|
return (event_date > start_date && end_date > event_date) ? 2 : 0;
|
|
}
|
|
|
|
function check_search_value_exit(parent) {
|
|
let date_result = mp_event_date_check(parent);
|
|
let active_event = 0;
|
|
for (let name in mp_event_input_name_list) {
|
|
if (mp_event_single_text_check(parent, name)) {
|
|
active_event = 1;
|
|
}
|
|
}
|
|
return (date_result || active_event > 0)?1:false;
|
|
}
|
|
}(jQuery)); |