
$(function () {
    //wysyłanie formularza paginacji
    $('select[name=per_page]').change(function () {
        $(this).parent().submit();
    });
});
$(function () {
    "use strict";
    if($('.tooltipster-top').length>0){
        $('.tooltipster-top').tooltipster({
            position: "top"
        });
    }
});
// Chosen
$(function () {
    "use strict";
    // Włączenie chosen - dodawanie i edycja newsa - wybór kategorii
    if($('.chosenSelect').length>0){
        $('.chosenSelect').chosen();
    }
});

// Date time picker
$(function () {
    "use strict";
    if($('.datePicker').length>0){
        $('.datePicker').datetimepicker({
            timepicker:false,
            format:'d-m-Y',
            closeOnDateSelect:true,
            scrollInput: false
        });
    }
});

$(window).load(function() {
    if($('#RealizujKupon[data-reveal-open="true"]').length>0){
        $('#RealizujKupon[data-reveal-open="true"]').foundation('open');
    }
});

$(function () {
    "use strict";

    $('#delete_delete').change(function () {
        if (this.checked) {
            $('#deleteButton').removeAttr('disabled');
        } else {
            $('#deleteButton').attr('disabled', 'disabled');
        }
    });

    if($('#usersList').length>0){
        $('#usersList').dataTable({
            ordering: false,
            searching: false,
            paging: false,
            info: false,
            "order": [
                [0, "desc"]
            ],
            "dom": '<f<t><"bottom"ilp>><"clear">',
            language: {
                url: language,
            }
        });
        $('.searchDataTables').on( 'keyup', function () {
            var table = $(this).attr('data-table');
            $('#'+table).DataTable().search( this.value ).draw();
        } );
    }
});


$(function () {
    "use strict";
    if($('#ticketsList').length>0){
        $('#ticketsList').dataTable({
            ordering: true,
            searching: true,
            paging: true,
            columnDefs: [
                { "orderable": false, "targets": 4 }
            ],
            select: true,
            info: false,
            "dom": '<f<t><"bottom"ilp>><"clear">',
            language: {
                url: language,
            }
        });
    }
});


$(function () {
    "use strict";
    if($('#tableUserAuction').length>0){
        $('#tableUserAuction').dataTable({
            ordering: true,
            searching: true,
            paging: true,
            "columnDefs": [
                { "orderable": false, "targets": 11 }
            ],
            select: true,
            info: false,
            "order": [
                [0, "desc"]
            ],
            "dom": '<f<t><"bottom"ilp>><"clear">',
            language: {
                url: language,
            }
        });
    }
});


$(function () {
    "use strict";
    if($('#logsTable').length>0){
        $('#logsTable').dataTable({
            ordering: false,
            searching: false,
            paging: false,
            info: false,
            "order": [
                [0, "desc"]
            ],
            "dom": '<f<t><"bottom"ilp>><"clear">',
            language: {
                url: language,
            }
        });
    }
});

$(function() {
    if($('#tableTransactions').length>0){
        $('#tableTransactions').dataTable({
            url: Routing.generate('wi_admin_users_datatables_transactions', { user: user }),
            columns: [
                { "data": "id" },
                { "data": "dateCreated" },
                { "data": "virtualCurrencyQuantity" },
                { "data": "price" },
                { "data": "status" },
                { "data": "virtualCurrencyName" },
            ],
            processing: true,
            serverSide: true,
            ordering: true,
            searching: true,
            paging: true,
            info: false,
            "order": [
                [0, "desc"]
            ],
            "dom": '<f<t><"bottom"ilp>><"clear">',
            language: {
                url: language,
            }
        });
    }
});

$(function() {
    if($('#tableVirTransactions').length>0){
        $('#tableVirTransactions').dataTable({
            url: Routing.generate('wi_admin_users_datatables_virtual_transactions', { user: user }),
            columns: [
                { "data": "id" },
                { "data": "dateCreated" },
                { "data": "amount" },
                { "data": "virtualCurrencyName" },
                { "data": "virtualTransactionType" },
            ],
            processing: true,
            serverSide: true,
            ordering: true,
            searching: true,
            paging: true,
            info: false,
            "order": [
                [0, "desc"]
            ],
            "dom": '<f<t><"bottom"ilp>><"clear">',
            language: {
                url: language,
            }
        });
    }
});

$(function () {
    "use strict";
    $('#userLogsTable').dataTable({
        ordering: false,
        searching: false,
        paging: false,
        info: false,
        "order": [
            [0, "desc"]
        ],
        "dom": '<f<t><"bottom"ilp>><"clear">',
        language: {
            url: language,
        }
    });
});

$(function () {
    "use strict";
    if($('#avatarList').length>0){
        $('#avatarList').dataTable({
            ordering: false,
            searching: false,
            paging: false,
            info: false,
            "order": [
                [0, "desc"]
            ],
            "dom": '<f<t><"bottom"ilp>><"clear">',
            language: {
                url: language,
            }
        });
    }
});

$(function () {
    "use strict";
    if($('#InterestList').length>0){
        $('#InterestList').dataTable({
            ordering: true,
            searching: false,
            paging: false,
            info: false,
            "order": [
                [0, "desc"]
            ],
            "dom": '<f<t><"bottom"ilp>><"clear">',
            language: {
                url: language,
            }
        });
    }
});

$(function () {
    "use strict";
    if($('#logTypesList').length>0){
        $('#logTypesList').dataTable({
            ordering: true,
            searching: false,
            paging: false,
            info: false,
            "order": [
                [0, "desc"]
            ],
            "dom": '<f<t><"bottom"ilp>><"clear">',
            language: {
                url: language,
            }
        });
    }
});
