Files
redline.com.pl/modules/dualpricedisplaypro/views/js/admin.js
2024-11-11 18:46:54 +01:00

168 lines
9.5 KiB
JavaScript

/*
* 2018 Singleton software
*
* @author Singleton software <info@singleton-software.com>
* @copyright 2018 Singleton software
*/
$(document).ready(function() {
$('#tax_excl_color, #tax_incl_color, #old_prices_color').prop('readonly', true);
$('.taxInclColor, .taxExclColor, #old_prices_color').mColorPicker({
'imageFolder' : '../img/admin/'
});
$('#mColorPickerImg').css({
'background-image':"url('../img/admin/colorpicker.png')"
});
$('#mColorPickerImgGray').css({
'background-image':"url('../img/admin/graybar.jpg')"
});
$('#mColorPickerFooter').css({
'background-image':"url('../img/admin/grid.gif')",
});
$('#mColorPickerInput').css({
'color':'black',
});
displayOldPricesSection(parseInt($("input[name='show_old_prices']:checked").val()) == 1);
$("input[name='show_old_prices']").click(function() {
displayOldPricesSection(parseInt($("input[name='show_old_prices']:checked").val()) == 1);
});
displayAdvancedSettingsSection(parseInt($("input[name='show_advanced_settings']:checked").val()) == 1);
$("input[name='show_advanced_settings']").click(function() {
displayAdvancedSettingsSection(parseInt($("input[name='show_advanced_settings']:checked").val()) == 1);
});
$('form.dualpricedisplaypro').before(getElementsMenu());
wrapElements();
$('.nav-tabs a').click(function() {
selectedCategory = $(this).attr('data-category');
$('#opened_tab').val($(this).attr('data-category'));
$.each(getCategories(), function (index, value) {
if (value['class'] == selectedCategory) {
$('form.dualpricedisplaypro .panel-heading').html(value['title'] + ' Configuration');
}
});
});
});
function wrapElements() {
$.each(getAllElementsByCategories(), function (index, value) {
$(value['element']).parents(".form-group").last().addClass(value['category']);
});
$.each(getCategories(), function (index, value) {
$('.' + value['class']).wrapAll('<div id="' + value['class'] + '_parent" class="tab-pane fade in elementsParents' + ($('#opened_tab').val() == value['class'] ? ' active' : '') + '"></div>');
});
$('.elementsParents').wrapAll('<div class="tab-content"></div>');
}
function getElementsMenu() {
menu = '<ul class="nav nav-tabs">';
$.each(getCategories(), function (index, value) {
menu += '<li' + ($('#opened_tab').val() == value['class'] ? ' class="active"' : '') + '><a data-toggle="tab" href="#' + value['class'] + '_parent" data-category="' + value['class'] + '">' + value['title'] + '</a></li>';
});
menu += '</ul>';
return menu;
}
function getCategories() {
categories = [];
categories.push({'class' : 'places_of_display', 'title' : trans.placesOfDisplay});
categories.push({'class' : 'advanced_settings_of_display', 'title' : trans.advancedSettingsOfDisplay});
categories.push({'class' : 'standard_prices', 'title' : trans.standardPrices});
categories.push({'class' : 'old_prices', 'title' : trans.oldPrices});
categories.push({'class' : 'dom_elements_paths', 'title' : trans.domElementsPaths});
return categories;
}
function getAllElementsByCategories() {
elementsByCategories = [];
elementsByCategories.push({'element' : 'input[name="show_on_home_page"]:eq(0)', 'category' : 'places_of_display'});
elementsByCategories.push({'element' : 'input[name="show_in_product_detail"]:eq(0)', 'category' : 'places_of_display'});
elementsByCategories.push({'element' : 'input[name="show_in_categories"]:eq(0)', 'category' : 'places_of_display'});
elementsByCategories.push({'element' : 'input[name="show_in_add_to_cart_popup"]:eq(0)', 'category' : 'places_of_display'});
elementsByCategories.push({'element' : 'input[name="show_in_asociative_products"]:eq(0)', 'category' : 'places_of_display'});
elementsByCategories.push({'element' : '.customerGroups:eq(0)', 'category' : 'advanced_settings_of_display'});
elementsByCategories.push({'element' : '.languages:eq(0)', 'category' : 'advanced_settings_of_display'});
elementsByCategories.push({'element' : '.currencies:eq(0)', 'category' : 'advanced_settings_of_display'});
elementsByCategories.push({'element' : 'input[name="show_price_if"]:eq(0)', 'category' : 'advanced_settings_of_display'});
elementsByCategories.push({'element' : '.pricesToShow:eq(0)', 'category' : 'standard_prices'});
elementsByCategories.push({'element' : 'input[name="tax_excl_first"]:eq(0)', 'category' : 'standard_prices'});
elementsByCategories.push({'element' : '#size_ratio_between_prices:eq(0)', 'category' : 'standard_prices'});
elementsByCategories.push({'element' : '.taxInclColor:eq(0)', 'category' : 'standard_prices'});
elementsByCategories.push({'element' : '.taxExclColor:eq(0)', 'category' : 'standard_prices'});
elementsByCategories.push({'element' : 'input[name="show_tax_incl_label"]:eq(0)', 'category' : 'standard_prices'});
elementsByCategories.push({'element' : '.taxInclLabelName:eq(0)', 'category' : 'standard_prices'});
elementsByCategories.push({'element' : 'input[name="show_tax_excl_label"]:eq(0)', 'category' : 'standard_prices'});
elementsByCategories.push({'element' : '.taxExclLabelName:eq(0)', 'category' : 'standard_prices'});
elementsByCategories.push({'element' : 'input[name="show_old_prices"]:eq(0)', 'category' : 'old_prices'});
elementsByCategories.push({'element' : '.oldPricesToShow:eq(0)', 'category' : 'old_prices'});
elementsByCategories.push({'element' : 'input[name="old_price_tax_excl_first"]:eq(0)', 'category' : 'old_prices'});
elementsByCategories.push({'element' : 'input[name="old_price_before_standard_price"]:eq(0)', 'category' : 'old_prices'});
elementsByCategories.push({'element' : '#size_ratio_old_prices:eq(0)', 'category' : 'old_prices'});
elementsByCategories.push({'element' : '.oldPricesColor:eq(0)', 'category' : 'old_prices'});
elementsByCategories.push({'element' : 'input[name="show_line_through_old_prices"]:eq(0)', 'category' : 'old_prices'});
elementsByCategories.push({'element' : 'input[name="show_advanced_settings"]:eq(0)', 'category' : 'dom_elements_paths'});
elementsByCategories.push({'element' : '#miniature_root_path:eq(0)', 'category' : 'dom_elements_paths'});
elementsByCategories.push({'element' : '#detail_price_path:eq(0)', 'category' : 'dom_elements_paths'});
elementsByCategories.push({'element' : '#detail_quantity_path:eq(0)', 'category' : 'dom_elements_paths'});
elementsByCategories.push({'element' : '#detail_parent_path:eq(0)', 'category' : 'dom_elements_paths'});
if (isPs17) {
elementsByCategories.push({'element' : '#miniature_price_path:eq(0)', 'category' : 'dom_elements_paths'});
elementsByCategories.push({'element' : '#miniature_old_price_path:eq(0)', 'category' : 'dom_elements_paths'});
elementsByCategories.push({'element' : '#quickview_parent_path:eq(0)', 'category' : 'dom_elements_paths'});
} else {
elementsByCategories.push({'element' : '#catalog_price_path:eq(0)', 'category' : 'dom_elements_paths'});
elementsByCategories.push({'element' : '#side_product_miniature_parent_path:eq(0)', 'category' : 'dom_elements_paths'});
elementsByCategories.push({'element' : '#side_product_miniature_price_path:eq(0)', 'category' : 'dom_elements_paths'});
elementsByCategories.push({'element' : '#accessories_miniature_parent_path:eq(0)', 'category' : 'dom_elements_paths'});
elementsByCategories.push({'element' : '#accessories_miniature_price_path:eq(0)', 'category' : 'dom_elements_paths'});
elementsByCategories.push({'element' : '#compared_product_miniature_parent_path:eq(0)', 'category' : 'dom_elements_paths'});
elementsByCategories.push({'element' : '#compared_product_miniature_price_path:eq(0)', 'category' : 'dom_elements_paths'});
}
elementsByCategories.push({'element' : '#summary_popup_parent_path:eq(0)', 'category' : 'dom_elements_paths'});
elementsByCategories.push({'element' : '#summary_popup_product_path:eq(0)', 'category' : 'dom_elements_paths'});
return elementsByCategories;
}
function displayOldPricesSection(isDisplay) {
displayField(".oldPricesToShow:eq(0)", isDisplay);
displayField("#old_prices_color:eq(0)", isDisplay);
displayField("input[name='show_line_through_old_prices']:eq(0)", isDisplay);
displayField("input[name='old_price_tax_excl_first']:eq(0)", isDisplay);
displayField("#size_ratio_old_prices:eq(0)", isDisplay);
displayField("input[name='old_price_before_standard_price']:eq(0)", isDisplay);
}
function displayAdvancedSettingsSection(isDisplay) {
displayField("#miniature_root_path:eq(0)", isDisplay);
displayField("#miniature_price_path:eq(0)", isDisplay);
displayField("#miniature_old_price_path:eq(0)", isDisplay);
displayField("#detail_price_path:eq(0)", isDisplay);
displayField("#detail_quantity_path:eq(0)", isDisplay);
displayField("#detail_parent_path:eq(0)", isDisplay);
if (isPs17) {
displayField("#miniature_price_path:eq(0)", isDisplay);
displayField("#miniature_old_price_path:eq(0)", isDisplay);
displayField("#quickview_parent_path:eq(0)", isDisplay);
} else {
displayField("#catalog_price_path:eq(0)", isDisplay);
displayField("#side_product_miniature_parent_path:eq(0)", isDisplay);
displayField("#side_product_miniature_price_path:eq(0)", isDisplay);
displayField("#accessories_miniature_parent_path:eq(0)", isDisplay);
displayField("#accessories_miniature_price_path:eq(0)", isDisplay);
displayField("#compared_product_miniature_parent_path:eq(0)", isDisplay);
displayField("#compared_product_miniature_price_path:eq(0)", isDisplay);
}
displayField("#summary_popup_parent_path:eq(0)", isDisplay);
displayField("#summary_popup_product_path:eq(0)", isDisplay);
}
function displayField(identification, isDisplay) {
if (isDisplay) {
$(identification).parents(".form-group").show();
} else {
$(identification).parents(".form-group").hide();
}
}