/* * http://blog.z7z.eu */ $(document).ready(function () { root = $('#root').data('home'), type = 'POST'; $(this).on('keyup', '.tyrsene_', function () { this.value = this.value.replace(/[^0-9 A-Za-zА-Яа-я]/g, ''); }); $('.tyrsene_').keyup(function (key) { if (key.keyCode == 13) { var srch = $(this).val(); srch = srch.toLowerCase().replace(/\s/g, '+'); if (srch.length > 2) { window.location.href = root + '/статии/търсене/' + srch; } } }); $('#nav b').click(function () { var tova = $(this); $.ajax({ type: type, url: root + 'home/podmenu', data: { get_kat: 1, id: tova.data('id') } }).done(function (data) { $('.menu').remove(); tova.after(data); }).fail(function () { alert('Сървърът не отговаря !!!') }); }); $('#in').click(function () { login_djam('#444'); }); $('.cut_post').hover(function () { $('body').append('Виж още ...'); }, function () { $('.help').remove(); }).mousemove(function (e) { $('.help').css({ left: e.pageX + 10, top: e.pageY + 20 }); }); $('#open_comment').click(function () { if ($('#comment_form').is(':visible')) { $(this).html('Коментирай тази статия!'); } else { checkForm(); $(this).html('Скрий формата за коментар!'); } $('#comment_form').slideToggle(); }); ///Първоначално валидиране на формата за контакт $('#comment_form input,#comment_form textarea').bind('keyup input change', function () { checkForm(); }); $('#comment_form button').click(function () { if ($('#name').val().length > 2 && validate_email($('#email').val()) && $('#komentar_').val().length > 8 && $('#captcha_').val().length > 0) { var site; if ($('#site').val() == 'http://') { site = ''; } else { site = $('#site').val(); } $.ajax({ type: type, url: root + 'statiq/komentirane/', data: { comment: 1, id: $('#komentar').data('id'), name: $('#name').val(), email: $('#email').val(), site: site, komentar: $('#komentar_').val(), captcha: $('#captcha_').val() } }).done(function (data) { var d = eval(data); djam(d[0], d[1]); // window.location.href = window.location.href; }).fail(function () { alert('Сървърът не отговаря !!!') }); } }); $(document).on('click', '.hiks,.djam,.djam1', function () { close_djam(); window.location.href = window.location.href; }); }); function checkForm() { if ($('#name').val().length > 2) { $('.name').css({'color': 'green'}); } else { $('.name').css({'color': 'red'}); } if (validate_email($('#email').val())) { $('.email').css({'color': 'green'}); } else { $('.email').css({'color': 'red'}); } if (validate_url($('#site').val())) { $('.site').css({'color': 'green'}); } else { $('.site').css({'color': 'red'}); } if ($('#komentar_').val().length > 8) { $('.komentar_').css({'color': 'green'}); } else { $('.komentar_').css({'color': 'red'}); } if ($('#captcha_').val().length > 0) { $('.captcha_').css({'color': 'green'}); } else { $('.captcha_').css({'color': 'red'}); } if ($('#name').val().length > 2 && validate_email($('#email').val()) && $('#komentar_').val().length > 8 && $('#captcha_').val().length > 0) { $('#comment_form button').css({ 'cursor': 'pointer' }).attr('disabled', false); } else { $('#comment_form button').css({ 'cursor': 'not-allowed' }).attr('disabled', true); } }