google.load("jquery", "1.4.0"); google.setOnLoadCallback(function() { $('ul#commenti_dal_blog').innerfade({ animationtype: 'slide', speed: 1600, timeout: 6000, type: 'sequence', containerheight: '100px' }); $('ul#commenti_dal_network').innerfade({ animationtype: 'slide', speed: 1600, timeout: 6000, type: 'sequence', containerheight: '100px' }); $('ul.sf-menu').superfish({ delay: 500, /* one second delay on mouseout */ animation: {opacity:'show',height:'show'}, /* fade-in and slide-down animation */ speed: 'fast', /* faster animation speed */ autoArrows: false, /* disable generation of arrow mark-up */ dropShadows: false /* disable drop shadows */ }); /* Fixing IE7 Z-Index Issues */ var zIndexNumber = 1000; $('div').each(function() { $(this).css('zIndex', zIndexNumber); zIndexNumber -= 10; }); $("#msg_info").fadeOut(8000); $("#msg_error").fadeOut(8000); if ( $("#form_contattaci").length ) { $("#form_contattaci").validate(); } if ( $("#form_topic").length ) { $("#form_topic").validate(); } /* PROFILO */ $("#st_password").val(""); if ( $("#form_setting").length ) { $("#form_setting").validate({ rules: { nickname: { required: true, minlength: 3, maxlength: 45, nickname: true }, domicilio: { required: true, minlength: 6, maxlength: 50, domicilio: true }, st_password: { minlength: 8, maxlength: 100, password: true }, st_confirm_password: { minlength: 8, maxlength: 100, equalTo: "#st_password" } }, messages: { confirm_password: { equalTo: "Le password non sono identiche. Riprova." } } }); } /* PROFILO - FINE */ /* ACCOUNT */ if(jQuery().validate) { jQuery.validator.addMethod("nome", function(value, element) { return this.optional(element) || /^[a-zA-Z ']+$/i.test(value); }, "Hai inseriro valori non conformi."); jQuery.validator.addMethod("userid", function(value, element) { return this.optional(element) || /^[a-zA-Z0-9]+$/i.test(value); }, "Hai inseriro valori non conformi."); jQuery.validator.addMethod("nickname", function(value, element) { return this.optional(element) || /^[a-zA-Z0-9 '&]+$/i.test(value); }, "Hai inseriro valori non conformi."); jQuery.validator.addMethod("password", function(value, element) { return this.optional(element) || /^[a-zA-Z0-9\.,;!$%&^]+$/i.test(value); }, "Hai inseriro valori non conformi."); jQuery.validator.addMethod("domicilio", function(value, element) { return this.optional(element) || /^[a-zA-Z ,'\.]+$/i.test(value); }, "Hai inseriro valori non conformi."); jQuery.validator.addMethod("tag", function(value, element) { return this.optional(element) || /^[a-zA-Z0-9 àùèéòì,']+$/i.test(value); }, "Hai inseriro valori non conformi."); } if ( $("#form_account").length ) { $("#form_account").validate({ rules: { nome: { required: true, minlength: 3, maxlength: 45, nome: true }, cognome: { required: true, minlength: 3, maxlength: 45, nome: true }, email: { required: true, email: true, maxlength: 100 }, userid: { required: true, minlength: 6, maxlength: 15, userid: true }, password: { required: true, minlength: 8, maxlength: 100, password: true }, confirm_password: { required: true, minlength: 8, maxlength: 100, equalTo: "#password" }, captcha_input: { required: true, maxlength: 12 } }, messages: { confirm_password: { equalTo: "Le password non sono identiche. Riprova." } } }); } $("#password").blur(function() { if ( $("#confirm_password").length ) { $("#confirm_password").valid(); } }); $("#userid").keyup(function() { if ( $("#userid").val().length > 5 ) { var ajaxOpts = { type: "post", url: "/aj_account_check_userid/", data: "&userid=" + $("#userid").val(), success: function(data) { $("#check_userid").html( data ); } }; $.ajax(ajaxOpts); } else { var data = ''; $("#check_userid").html( data ); } }); /* ACCOUNT - FINE */ /* COMMENTI ARTICOLI */ if ( $("#form_commenti").length ) { $("#form_commenti").validate({ rules: { commento: { required: true, minlength: 2, maxlength: 2000 } } }); } /* COMMENTI ARTICOLI - FINE */ /* LOGIN */ if ( $("#form_login").length ) { $("#form_login").validate({ rules: { userid: { required: true }, password: { required: true } } }); } /* LOGIN - FINE */ /* AUTOCOM */ function formatItem(row) { return row[0] + " (id: " + row[1] + ")"; } function formatResult(row) { return row[0].replace(/(<.+?>)/gi, ''); } if ( $("#domicilio").length ) { $("#domicilio").autocomplete("/aj_comuni/", { width: 266, mustMatch: false, autoFill: false, minChars: 3 }); $("#domicilio").result(function(event, data, formatted) { if (data) $(this).parent().next().find("input").val(data[0]); }); } $("#clear").click(function() { $(":input").unautocomplete(); }); /* AUTOCOM - FINE */ /* ADD COMMENTI */ $("#add_commento").click(function() { var commenti_serialize = $("#form_commenti").serialize(); $.ajax({ type: "post", url: "/aj_commenti_ins/", /* data: "&articolo=" + $("#articolo").val() + "&commento=" + $("#commento").val(), */ data: commenti_serialize + "&sid=" + Math.floor(999999999*Math.random()), dataType: "html", success: function(data) { /* pulizia degli input */ $("#commento").val(""); $.ajax({ type: "post", url: "/aj_commenti_sel/", data: "&articolo=" + $("#articolo").val() + "&id=" + data + "&sid=" + Math.floor(999999999*Math.random()), dataType: "html", success: function(data) { $("#list-of-comments").html( data ); $("#last_entry").fadeIn(1000); /* strillo */ $.ajax({ type: "post", url: "/aj_commenti_strillo/", data: "&articolo=" + $("#articolo").val() + "&sid=" + Math.floor(999999999*Math.random()), dataType: "html" }); /* fine strillo */ } }); } }); return false; }); /* ADD COMMENTI - FINE */ /* ADD POST */ $("#add_post").click(function() { var post_serialize = $("#form_post").serialize(); $.ajax({ type: "post", url: "/aj_post_ins/", data: post_serialize + "&sid=" + Math.floor(999999999*Math.random()), dataType: "html", success: function(data) { /* pulizia degli input */ $("#post").val(""); $.ajax({ type: "post", url: "/aj_post_sel/", data: "&topic=" + $("#topic").val() + "&id=" + data + "&sid=" + Math.floor(999999999*Math.random()), dataType: "html", success: function(data) { $("#list-of-posts").html( data ); $("#last_entry").fadeIn(1000); /* strillo */ /*$.ajax({ type: "post", url: "/aj_commenti_strillo/", data: "&articolo=" + $("#articolo").val() + "&sid=" + Math.floor(999999999*Math.random()), dataType: "html" });*/ /* fine strillo */ } }); } }); return false; }); /* ADD POST - FINE */ /* CLOSE TOPIC */ $("a.notifica").live("click", function(){ var topic_notifica = $(this).attr("href"); topic_notifica = topic_notifica.split('|'); var topic = topic_notifica[0]; var notifica = topic_notifica[1]; if ( notifica == 1 ) { var azione = 'interrompere la notifica'; } else { var azione = 'notificare la discussione per email'; } if (confirm('Desideri veramente ' + azione + '?')) { $.ajax({ type: "post", url: "/aj_topic_notifica/", data: "&topic=" + topic + "¬ifica=" + notifica + "&sid=" + Math.floor(999999999*Math.random()), dataType: "html", success: function(data) { $(".bnotifica").html( data ); } }); } return false; }); /* CLOSE TOPIC - FINE*/ $("a.mod").click(function() { if (confirm('Desideri veramente modificare il commento?')) { var id = $(this).attr("href"); $("#comment-" + id + " .action").hide(); $("#comment-" + id + " .comment").slideUp('', function() { //var textarea = "Text to change"; //$(this).html(textarea).slideDown(); $.ajax({ type: "post", url: "/aj_commenti_upd_form/", data: "&commento=" + id + "&sid=" + Math.floor(999999999*Math.random()), dataType: "html", success: function(data) { $("#commento_mod_" + id).val(data); $("#form_mod_" + id).slideDown(); } }); }); } return false; }); $(".mod_commento").click(function() { var id = $(this).attr("id"); var commenti_serialize_mod = $("#form_commenti_mod_" + id).serialize(); //alert(commenti_serialize_mod); $.ajax({ type: "post", url: "/aj_commenti_upd/", data: commenti_serialize_mod + "&sid=" + Math.floor(999999999*Math.random()), dataType: "html", success: function(data) { $("#commento_mod_" + id).val(""); $("#form_mod_" + id).hide(); $("#comment-" + id + " .comment").html( data ).fadeIn(); $("#comment-" + id + " .action").show(); } }); return false; }); $("a.mod_post").click(function() { if (confirm('Desideri veramente modificare il post?')) { var id = $(this).attr("href"); $("#post-" + id + " .action").hide(); $("#post-" + id + " .post").slideUp('', function() { //var textarea = "Text to change"; //$(this).html(textarea).slideDown(); $.ajax({ type: "post", url: "/aj_post_upd_form/", data: "&post=" + id + "&sid=" + Math.floor(999999999*Math.random()), dataType: "html", success: function(data) { $("#post_mod_" + id).val(data); $("#form_mod_" + id).slideDown(); } }); }); } return false; }); $(".mod_post").click(function() { var id = $(this).attr("id"); var post_serialize_mod = $("#form_post_mod_" + id).serialize(); //alert(post_serialize_mod); $.ajax({ type: "post", url: "/aj_post_upd/", data: post_serialize_mod + "&sid=" + Math.floor(999999999*Math.random()), dataType: "html", success: function(data) { $("#post_mod_" + id).val(""); $("#form_mod_" + id).hide(); $("#post-" + id + " .post").html( data ).fadeIn(); $("#post-" + id + " .action").show(); } }); return false; }); }); function linkTo( url ) { window.open( url ); }