$(document).ready( function() { // Hide On Load $('.hideOnLoad').addClass('hide').removeAttr('style'); // Oculto el login $('#loginForm').hide(); $('#gotoLogin').click(function() { $(this).parent().parent().children('li').hide(); $('#loginForm').fadeIn(); $('#LoginUserName').focus(); return false; }); $('#loginCancel').click(function() { $(this).parent().parent().hide(); $(this).parent().parent().parent().children('li').show(); return false; }); // despliega mas tabs $('#navigation .more a.ref').click(function() { var insideLink = $(this).html(); if($(this).parent().hasClass('active')) { if(!$(this).parent().hasClass('keep')) { $(this).parent().removeClass('active'); $(this).parent().find('span').remove(); $(this).html(insideLink.replace('', '').replace('', '')); } } else { $(this).parent().addClass('active').prepend('').append(''); $(this).html('...'); } $('#moreTabs').toggle(); return false; }); // Click en cualquier parte del documento cierra los menues $(document).click( function() { var tab = '#navigation .more a.ref'; var insideLink = $(tab).html(); $('#moreTabs').hide(); if($(tab).parent().hasClass('active')) { if(!$(tab).parent().hasClass('keep')) { $(tab).parent().removeClass('active'); $(tab).parent().find('span').remove(); $(tab).html(insideLink.replace('', '').replace('', '')); } } }); // Capturo los clicks de apagar tag // $('#tagsNavigation sup').click( function() { // var goto = '/action/blocktag/'+$(this).attr('rel'); // $.post(goto, { }, function(data) {}); // $(this).hide('slow'); // $('#todaytag_'+$(this).attr('rel')).hide('slow'); // return false; // }); // Grisar noticia leida $('.post a.capturePost').livequery('click', function() { var post = $(this).parent().parent(); if(!post.parent().parent().hasClass('main')) { post.addClass('read'); } return false; }); // Capturo los clicks que van a posts $('.capturePost').livequery('click', function(event) { var id = $(this).attr('rel'); id = id.replace('nofollow ', ''); var location = $(this).attr('href'); if($(this).hasClass('new')) { var newWindow=true; } $.post('/action/post/'+id, { referer: window.location }, function(data) { if(newWindow) { window.open(location,'','scrollbars=yes,menubar=yes,null,null,resizable=yes,toolbar=yes,location=yes,status=yes'); } else { window.location = location; } }); return false; }); // Voto $('.voteit').click( function() { var divVotes = $(this).parent(); var votes = parseFloat(divVotes.find('.number').html()); var params = $(this).attr('rel'); $.post('/action/up/'+params, {}, function() { divVotes.find('.voteit').fadeOut('slow', function() { divVotes.find('.voteit').remove(); divVotes.append(''); divVotes.find('.voted').fadeIn('slow'); }); divVotes.find('.number').text(votes+1); }); return false; }); // Capturo los links a Denuncias $('.bury').click( function(event) { var id = $(this).attr('rel'); $.post('/action/bury/'+id, { referer: window.location }, function(data) {}); if($('.bury').hasClass('keep')) { $(this).parent().parent().parent().addClass('read'); } else { $(this).parent().parent().parent().parent().parent().parent().parent().slideUp('slow'); } return false; }); // Customize link $('#subnav .customize').click( function() { if(!$(this).hasClass('keep')) { $('#customizeTab').parent().slideToggle('slow'); return false; } }); // Mostrar help en formularios $('form.inner fieldset ol li .text').focus(function() { if(!$(this).parent().hasClass('error')) { $(this).parent().attr({style:'z-index:21; position:relative;'}); $(this).parent().find('.help').fadeIn(); } }); // Ocultar help en formularios $('form.inner fieldset ol li .text').blur(function() { if(!$(this).parent().hasClass('error')) { $(this).parent().attr({style:'z-index:0; position:relative;'}); $(this).parent().find('.help').fadeOut(); } }); // Invite friends $('#inviteForm .cancel').click( function() { // setcookie var domain = window.location.host; domain = domain.split('.'); domain = domain[domain.length-2]+'.'+domain[domain.length-1]; createCookie('kg_invited', true, 999, domain); $('#inviteForm').slideUp(); return false; }); // Remove div $('.menu .remove').click( function() { // get div var container = $(this).parent().parent().parent().parent().parent(); container.slideUp('slow', function() { var cName = container.attr('id'); container.remove(); // setcookie var domain = window.location.host; domain = domain.split('.'); domain = domain[domain.length-2]+'.'+domain[domain.length-1]; createCookie('remove_'+cName, true, 999, domain); }); return false; }); }); function createCookie(name,value,days,domain) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/; domain="+domain; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } // Messages var iMessage = 0; function showMessage(str, where, seconds) { if(!where) { where = '#main'; } if(!seconds) { seconds = 10000; } var id = 'mes'+iMessage; var message = '
'; $(where).prepend(message).hide().fadeIn(); window.setTimeout('hideMessage(\''+id+'\')', seconds); iMessage++; } function hideMessage(id) { $('#'+id).fadeOut(); } // Forms if( document.addEventListener && jQuery.browser['opera']!=true ) document.addEventListener( 'DOMContentLoaded', inner, false ); function inner(){ // Hide forms $('form.inner').hide().end(); // Processing $('form.inner').find('label').not('.nocmx').each( function(i){ var labelContent = this.innerHTML; var labelWidth = document.defaultView.getComputedStyle( this, '' ).getPropertyValue( 'width' ); var labelSpan = document.createElement( 'span' ); labelSpan.style.display = 'block'; labelSpan.style.width = labelWidth; labelSpan.innerHTML = labelContent; this.style.display = '-moz-inline-box'; this.innerHTML = null; this.appendChild( labelSpan ); } ).end(); // Show forms $( 'form.inner' ).show().end(); } // Cambiar textos function replaceByRel(cont) { var transformer = $(cont); transformer.html(transformer.attr('rel')); }