Files
interblue.pl/modules/pshowimporter/views/js/config_matchfieldscsv.js
2024-10-25 14:16:28 +02:00

159 lines
4.1 KiB
JavaScript

$(function () {
$(document).on('click', '.configshow', function () {
$('.configcontent').slideToggle("slow", function () {
var o = $(this).prev('.panel-heading');
if (o.css('margin-bottom') === "-20px")
o.css('margin-bottom', "15px");
else if (o.css('margin-bottom') === "15px")
o.css('margin-bottom', "-20px");
});
});
$('.configshow').click();
// $('.panel-filecontents').css({
// "top": $('.panel.alert-success').offset().top + "px",
// "right": "10px",
// "position": "fixed",
// "z-index": "99999",
// "width": $('#module_content').width() + "px",
// "overflow": "hidden"
// });
// $('#module_content').css('margin-top', '200px');
// $('.panel-filecontents').draggable({handle: ".panel-heading"});
//
// $(".panel-filecontents").resizable({
// maxHeight: 600,
// maxWidth: 1000,
// minHeight: 200,
// minWidth: 150
// });
// $(document).on('change', '.typeSelect', function () {
//
// console.log($(this).attr('name'));
//
// var name = $(this).attr('name');
// var value = $(this).val();
//
// $('select[name="' + name.replace('type', 'product') + '"]').hide();
// $('select[name="' + name.replace('type', 'feature') + '"]').hide();
//
// if (value.search('product') === 0)
// $('select[name="' + name.replace('type', 'product') + '"]').show();
//
// if (value.search('feature') === 0)
// $('select[name="' + name.replace('type', 'feature') + '"]').show();
//
// });
// var FILE_COLS = $('.fileCol').length - 1;
//
// $(document).on('click', '.clone', function () {
// var col = $(this).attr('data-col')
// elements = $('.fileCol' + col);
// ++FILE_COLS;
// var i = 0;
//
// var toBind = [];
//
// elements.each(function () {
// var html = $(this)[0].outerHTML;
//
// $(this).find('select').each(function () {
//
// var name = $(this).attr('name');
// var newName = name;
//
// do
// {
// newName += '_';
// } while ($('select[name="' + newName + '"]').length);
//
// toBind.push('name="' + newName + '"');
//
// html = html.replace('name="' + name + '"', 'name="' + newName + '"');
//
// });
//
// var toReplace = ['fileCol'];
//
// for (x in toReplace)
// {
// html = html.replace(toReplace[x] + col, toReplace[x] + FILE_COLS);
// }
//
// $('.configRow' + i).append(html);
//
// ++i;
// });
//
// });
function checkMatches()
{
var matched = [];
$('select').each(function () {
val = $(this).val();
if (val === 'none')
return;
matched.push(val.replace('product.', ''));
});
for (key1 in should_match)
{
var glob_found = false;
for (key2 in should_match[key1])
{
var found = false;
for (i in matched)
{
if (matched[i] === should_match[key1][key2])
{
found = true;
break;
}
}
if (found)
{
glob_found = true;
break;
}
}
if (!glob_found)
{
console.log(should_match[key1]);
return should_match[key1][0];
}
}
return true;
}
$('form#matchingFields').on('submit', function (e) {
var check = checkMatches();
if (checkMatches() !== true && !confirm('Jesteś pewny? W podstawowej konfiguracji zaznaczyłeś ze chcesz coś importować jednak tutaj tego nie dopasowałeś: ' + check))
{
e.preventDefault();
return false;
}
});
});