(function($){ $.fn.checkboxes = function(options) { var settings = $.extend({ callback: null, class: '' }, options); return this.each(function() { var obj = $(this); var className = ''; if ( settings.class != '' ) { className = ' ' + settings.class; } $(this).find('input[type=checkbox]').each(function() { if ( $(this).attr('id') != undefined ) { $(this).after(''); } else { $(this).after(''); } $(this).hide(); if ( $(this).is(':checked') ) { $(this).next('span.input-checkbox').addClass('input-checkbox-checked'); $(this).next().next('span.input-checkbox-name').addClass('input-checkbox-name-checked'); } }); $(this).find('span.input-checkbox').each(function() { $(this).click(function() { if ( $(this).hasClass('input-checkbox-checked') ) { $(this).removeClass('input-checkbox-checked'); $(this).next('span.input-checkbox-name').removeClass('input-checkbox-name-checked'); $(this).prev('input[type=checkbox]').attr('checked', false); } else { $(this).removeClass('input-checkbox-error').addClass('input-checkbox-checked'); $(this).next('span.input-checkbox-name').removeClass('input-checkbox-name-error').addClass('input-checkbox-name-checked'); $(this).prev('input[type=checkbox]').attr('checked', true); } if ( typeof settings.callback == 'function' ) { settings.callback.call($(this)); } }); }); $(this).find('input[type=radio]').each(function() { $(this).after(''); $(this).hide(); if ( $(this).is(':checked') || $(this).attr('checked') == 'checked' ) { $(this).next('span.input-radio').addClass('input-radio-checked'); } }); $(this).find('span.input-radio').click(function() { var inputRadio = $(this).prev('input[type=radio]'); findRadioInputs(inputRadio.attr('name')); $(this).addClass('input-radio-checked'); inputRadio.attr('checked', true); }); function findRadioInputs(inputName) { if ( inputName != undefined ) { obj.find("input[name='" + inputName + "']").each(function() { $(this).attr('checked', false); $(this).next('span.input-radio').removeClass('input-radio-checked'); }); } } }); }; $.fn.isRequiredChecked = function() { var ret = false; if ( $(this).hasClass('require') ) { if ( $(this).attr('checked') == 'checked' ) { $(this).next('span.input-checkbox').removeClass('input-checkbox-error'); $(this).next().next('span.input-checkbox-name').removeClass('input-checkbox-name-error'); ret = true; } else { $(this).next('span.input-checkbox').addClass('input-checkbox-error'); $(this).next().next('span.input-checkbox-name').addClass('input-checkbox-name-error'); } } return ret; }; $.fn.checkedCheckboxes = function() { $(this).find('input[type=checkbox]').attr('checked', true); $(this).find('span.input-checkbox').addClass('input-checkbox-checked'); }; $.fn.uncheckedCheckboxes = function() { $(this).find('input[type=checkbox]').attr('checked', false); $(this).find('span.input-checkbox').removeClass('input-checkbox-checked'); }; $.fn.removeCheckboxes = function() { $(this).find('span.input-radio').remove(); $(this).find('span.input-checkbox').remove(); }; })(jQuery);(function($){ $.fn.sendForm = function(options) { var settings = $.extend({ url: $(this).attr('action'), sendData: {}, reload: false, reloadTimeout: 2000 }, options); var url = settings.url; var formData = settings.sendData; var returnJson = []; $(this).find(':input').not(':submit').each(function() { if ( $(this).attr('name') != undefined ) { if ( $(this).attr('type') == 'checkbox' ) { if ( $(this).is(':checked') ) { formData[$(this).attr('name')] = $(this).val(); } else { formData[$(this).attr('name')] = 0; } } else if($(this).attr('type') == 'radio'){ if ( $(this).attr('checked') == 'checked' ) { formData[$(this).attr('name')] = $(this).val(); } } else { formData[$(this).attr('name')] = $(this).val(); } } }); $.ajax({ type: "post", url: url, cache: false, async: false, dataType: 'json', data: formData, beforeSend: function(){$("#message-box").html('');}, success: function(oJsonObject) { if(settings.reload) { setTimeout(function() { location.reload(); }, settings.reloadTimeout); } returnJson = oJsonObject; } }); return returnJson; }; })(jQuery);$(document).ready(function() { var messageBox = $(".panel-login .login-status"); var loginBox = true; $(".loginForm").submit(function() { var error = false; var inputLogin = $(this).find("input[name=login]"); var inputPassword = $(this).find("input[name=pass]"); var responseError = false; messageBox = $(this).parents('.panel-login').find('.login-status'); messageBox.removeClass('green red'); if ( inputLogin.val() == '' ) { inputLogin.parent().addClass('error'); error = true; } else { inputLogin.parent().removeClass('error'); } if ( inputPassword.val() == '' ) { inputPassword.parent().addClass('error'); error = true; } else { inputPassword.parent().removeClass('error'); } if ( error ) { generatenote(txtEnterTheRequiredFields, 'error'); } else { messageBox.html('').show(); $.ajax({ type: "post", url: "loginuser", cache: false, async: false, dataType: 'json', data: {login: inputLogin.val(), password: inputPassword.val(), loging: 1}, success: function(oJsonObject) { var time = oJsonObject.time; var limit = oJsonObject.limit; // messageBox.find('span').fadeOut(300, function() { // $(this).remove(); // }); if ( oJsonObject.status == 'true' || oJsonObject.status == true ) { if ( oJsonObject.error != undefined ) { if ( oJsonObject.error == 'inactive' ) { $.showMessage('Konto jest nieaktywne', 'error', 2000); } else { $.showMessage('Wystąpił błąd podczas logowania', 'error', 2000); } } else { $(".loginForm .submit .button").hide(); generatenote('Poprawne logowanie','success'); setTimeout(function(){document.location.href = 'moje-konto';}, 1000); } } else { switch(oJsonObject.error) { case 'LIMIT': generatenote('Konto zablokowane! Pozostało: ' + time + ' min.', 'error'); break; case 'PASSWORD': generatenote('Błąd! niewłaściwe dane. Pozostało prób: ' + limit + '', 'error'); break; default: generatenote('Błąd! niewłaściwe dane', 'error'); break; } } }, error: function (request, status, error) { responseError = true; } }); if ( responseError ) { //generatenote(txtErrorOccurred, 'error'); } } return false; }); jQuery.showMessage = function(message, type, time) { messageBox.removeClass('green red'); if ( type == 'error' ) { messageBox.addClass('red'); } if ( type == 'success' ) { messageBox.addClass('green'); } messageBox.html(message); messageBox.fadeIn(500, function() { if ( time != undefined ) { setTimeout(function() { messageBox.fadeOut(); }, time); } }); }; });