/** * Base JS * * @author Hanzo - http://www.hanzo.es */ /* * Hanzo Interaction Utils */ jq.hanzoInteraction = function() { return { /* Forms */ overlayLabels : function(selectors) { jq(selectors).each(function() { if (jq(this).val() != "") { jq(this).closest('div').find('label').hide(); } jq(this).bind('focus', function() { if(jq(this).val() == "") { jq(this).closest('div').find('label').fadeTo('slow', '0.5'); } }); jq(this).bind('keydown', function(event) { if (event.keyCode != 9) { jq(this).closest('div').find('label').fadeOut(); } else { if(jq(this).val() == "") { jq(this).closest('div').find('label').fadeTo('slow', '1'); } } }); jq(this).bind('blur', function() { if(jq(this).val() == "") { jq(this).closest('div').find('label').fadeTo('slow', '1'); } }); }); }, selectToDiv : function(selectors) { jq(selectors).each(function() { var $select = jq(this); var new_select_id = "transformed_" + jq(this).attr('id'); var new_select = '
Desplegar
'; jq(this).css('display', 'none'); jq(this).after(new_select); // Copy select content into list content jq(this).find('option').each(function(n) { jq('div#'+new_select_id).find('ul').append('
  • '+jq(this).html()+'
  • '); if (jq(this).attr('selected')) jq('#' + new_select_id+'_'+n).addClass('selected'); }); // Default value jq('div#'+new_select_id).prepend('' + jq('div#'+new_select_id).find('ul li.selected').html() + ''); // Expand and colapse the list jq('div#'+new_select_id).find('strong, a.expand').click(function() { if (jq('div#'+new_select_id).hasClass('expanded')) { jq('div#'+new_select_id).removeClass('expanded'); } else { jq('div#'+new_select_id).addClass('expanded'); } return false; }); // Click event for each li jq('div#'+new_select_id).find('ul li').each(function(n) { jq(this).click(function() { var name = jq(this).attr('id').substring(0, jq(this).attr('id').indexOf('_')); var value = jq(this).attr('id').substring(jq(this).attr('id').indexOf('_') + 1, jq(this).attr('id').length); // Copy selected value in default value jq(this).closest('div').find('strong').html(jq(this).html()); // Hide list jq(this).closest('div').removeClass('expanded'); // Select the new li jq(this).closest('div').find('li.selected').removeClass('selected'); jq(this).addClass('selected'); // Update select value $select.children('option').eq(n).attr('selected', 'selected'); }); }); }); } } }(); /* * Hanzo Lightbox */ jq.hanzoLightbox = function() { return { init : function(content, opener) { var position = jq(content).offset(); jq(content).hide(); jq(opener).live('click', function() { jq.hanzoLightbox.addOverlay(content, position); return false; }); jq(content).find('.close_lightbox').live('click', function() { jq.hanzoLightbox.close(content); return false; }); }, close : function(content) { this.removeOverlay(); this.removeContent(content); }, addOverlay : function(content, position) { if (jq('#overlay').length == 0) { jq('body').append('
    '); jq('#overlay').css({ 'display': 'none', 'height': jq('body').height() + 'px' }); jq('#overlay').fadeIn('slow', function() { jq.hanzoLightbox.addContent(content, position); }); jq('#overlay').bind('click', function() { jq.hanzoLightbox.close(content); return false; }); } }, addContent : function(content, position) { if (jq('#lightbox').length == 0) { var width = jq(content).width(); var height = jq(content).height(); jq(content).wrap('