173 lines
5.0 KiB
JavaScript
173 lines
5.0 KiB
JavaScript
var x13TreeChecked = {};
|
|
|
|
$(document).ready(function()
|
|
{
|
|
if (!x13retro_compatible)
|
|
{
|
|
$('#products').parents('.form-group').addClass('products-block');
|
|
$('#categories').parents('.form-group').addClass('categories-block');
|
|
$('#default_category').parents('.form-group').addClass('cat-default-block');
|
|
}
|
|
|
|
x13lazyload();
|
|
|
|
$('#method').on('change', function()
|
|
{
|
|
if ($(this).val() == 3) { // reassign
|
|
$('.cat-default-block').show();
|
|
}
|
|
else {
|
|
$('.cat-default-block').hide();
|
|
}
|
|
});
|
|
|
|
$('#products_from').on('change', function()
|
|
{
|
|
if ($(this).val() == 2) { // products
|
|
$('.categories-block').hide();
|
|
$('#cat_info').hide();
|
|
$('.products-block').show();
|
|
}
|
|
else {
|
|
$('.products-block').hide();
|
|
$('.categories-block').show();
|
|
$('#cat_info').show();
|
|
}
|
|
});
|
|
|
|
$(document).on('click', '.tt-suggestion.tt-is-under-cursor', function() {
|
|
$('#default_category option').remove();
|
|
$('#new_categories input[type="checkbox"]').trigger('change');
|
|
});
|
|
|
|
// $(document).on('change', '#new_categories input[type="checkbox"]', function()
|
|
// {
|
|
// if (typeof $(this).attr('checked') !== 'undefined') {
|
|
// $('#default_category').append($("<option></option>").attr('value', $(this).val()).text($(this).parent().find('label').text()));
|
|
// } else {
|
|
// $('#default_category option[value="' + $(this).val() +'"]').remove();
|
|
// }
|
|
// });
|
|
|
|
$('#new_categories input[type="checkbox"]').each(function(i, el)
|
|
{
|
|
if (selected_new_categories.indexOf(parseInt($(el).val())) > -1 ) {
|
|
$('#default_category').append($("<option></option>").attr('value', $(this).val()).text($(el).parent().find('label').text()));
|
|
}
|
|
});
|
|
|
|
$('#check-all-new_categories').live('click', function()
|
|
{
|
|
$('#default_category option').remove();
|
|
$('#new_categories input[type="checkbox"]').each(function(i, el) {
|
|
$('#default_category').append($("<option></option>").attr('value', $(this).val()).text($(el).parent().find('label').text()));
|
|
});
|
|
});
|
|
|
|
$('.tree-item-name>input').live('click', function()
|
|
{
|
|
$('#default_category option').remove();
|
|
$('#new_categories input[type="checkbox"]:checked').each(function (i, el) {
|
|
$('#default_category').append($("<option></option>").attr('value', $(this).val()).text($(el).parent().find('label').text()));
|
|
});
|
|
});
|
|
|
|
$('.tree-folder-name>input').live('click', function()
|
|
{
|
|
$('#default_category option').remove();
|
|
|
|
$('#new_categories input[type="checkbox"]:checked').each(function (i, el) {
|
|
$('#default_category').append($("<option></option>").attr('value', $(this).val()).text($(el).parent().find('label').text()));
|
|
});
|
|
});
|
|
|
|
|
|
$(document).on('click', '#uncheck-all-new_categories', function() {
|
|
$('#default_category option').remove();
|
|
});
|
|
|
|
$(document).on('change', 'input.product_row', function()
|
|
{
|
|
var attr = $(this).attr('checked');
|
|
var val = $(this).val();
|
|
var input_name = $(this).parents('table').attr('id');
|
|
|
|
x13changeTreeChecked(attr, val);
|
|
|
|
$('#' + input_name + '_checked').val(Object.keys(x13TreeChecked).toString());
|
|
});
|
|
|
|
$('#x13massupdate_details').on('click', function(e)
|
|
{
|
|
e.preventDefault;
|
|
|
|
$('#x13massupdate_details_div').toggle(function() {
|
|
$(document).scrollTo('#x13massupdate_details_div');
|
|
});
|
|
});
|
|
|
|
$('#method').trigger('change');
|
|
$('#products_from').trigger('change');
|
|
|
|
$('#checkme_products').on('click', function() {
|
|
x13markProductsCheckboxes($('#products_container'));
|
|
$(this).prop('checked', false);
|
|
});
|
|
});
|
|
|
|
function x13changeTreeChecked(attr, val)
|
|
{
|
|
if (typeof attr !== 'undefined' && attr) {
|
|
x13TreeChecked[val] = true;
|
|
} else {
|
|
delete x13TreeChecked[val];
|
|
}
|
|
}
|
|
|
|
function x13getFoundProducts(table) {
|
|
// table.find('tbody tr').each(function (i, el)
|
|
// {
|
|
// var $input = $(el).find('input[type="checkbox"]');
|
|
// });
|
|
}
|
|
|
|
function x13showTreeChecked(table)
|
|
{
|
|
table.find('tbody tr').each(function (i, el)
|
|
{
|
|
var $input = $(el).find('input[type="checkbox"]');
|
|
var attr = $input.attr('checked');
|
|
|
|
if (typeof attr === 'undefined' || !attr) {
|
|
$input.parents('tr').hide();
|
|
}
|
|
});
|
|
}
|
|
|
|
function x13markProductsCheckboxes(parent) {
|
|
parent.find('input[type=checkbox]').each(function( i, el) {
|
|
$(el).trigger('click');
|
|
});
|
|
}
|
|
|
|
function x13showTreeAll(table)
|
|
{
|
|
table.find('tbody tr').show();
|
|
}
|
|
|
|
function x13getTreeChecked()
|
|
{
|
|
return x13TreeChecked;
|
|
}
|
|
|
|
function x13lazyload()
|
|
{
|
|
$('img.lazy').lazyload({
|
|
effect: 'fadeIn',
|
|
threshold: 100,
|
|
skip_invisible: true,
|
|
container: $('#products_container')
|
|
});
|
|
$('#products_container').trigger('scroll');
|
|
}
|