Skip to content

Instantly share code, notes, and snippets.

@rnmp rnmp/common.js
Created Aug 29, 2011

Embed
What would you like to do?
$(document).bind('keydown', 'h', function() {
$hex.toggle(function() {
$(this).hide();
}, function() {
$(this).show();
});
});
@xenda

This comment has been minimized.

Copy link

xenda commented Aug 29, 2011

Yo aplicaría el toggle al this del document:

 $(document).bind(....., function(){
  $(this).toggle(function(){
      $hex.hide();
     },function(){
      $hex.show();
    })
 } 
@xenda

This comment has been minimized.

Copy link

xenda commented Aug 29, 2011

Aunque depende de qué sea $hex, no lo he revisado :D

@rnmp

This comment has been minimized.

Copy link
Owner Author

rnmp commented Aug 29, 2011

$(function(){
  var $body = $('body'), 
      $color = $('.color'),
      $hex = $('.hex'),
      $prefix = $('.prefix'),
      $input_id = 'clipboard_handler';
  $body.prepend('<input id="'+$input_id+'" disabled type="text" />');
  $color.hover(function() {
    var $hex_code = $('.hex', this).text();
    $('#'+$input_id).val($hex_code).select();
  });
  $hex.each(function(){
    // This clears the HEX value provided
    $(this).text($(this).text().replace('#',''));
    $(this).prepend('<span class="prefix" />');
    $('.prefix', this).text('#');
  });

  $(document).bind('keydown', 'h', function(){
    $(this).toggle(function(){
      $hex.hide();
    }, function(){
      $hex.show();
    })
  });
});
@rnmp

This comment has been minimized.

Copy link
Owner Author

rnmp commented Aug 29, 2011

Así es el código completo, implementando tu solución. Que no funciona. D:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.