Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use images for buttons #266

Closed
icaroniz opened this issue Apr 3, 2014 · 2 comments
Closed

Use images for buttons #266

icaroniz opened this issue Apr 3, 2014 · 2 comments

Comments

@icaroniz
Copy link

icaroniz commented Apr 3, 2014

I managed to use an image for some buttons as some Unicode characters couldn't be displayed on some computers. I had to set the display to an img tag. For example:

$('.keyboard').keyboard({
  display: {
    'a': '<img src="path/to/my/accept_image.png" />:Accept',
    'c': '<img src="path/to/my/cancel_image.png" />:Cancel'
  }
});

The problem is that, as the button text is more than one character, the button is shown as a wide, so I had to fix this too. Wouldn't it be nice if this feature could be implemented in the library?

P.S: I've encountered some problems that I'm still fixing such as the images are transformed back to text when the button triggers the mouseout event.

Before hover:
Before hovering the buttons

After hover:
After hovering the buttons

@Mottie
Copy link
Owner

Mottie commented Apr 3, 2014

Hi @icaroniz!

Right now, in the calculator demo, the images are adding as backgrounds using the unique class names for each button. Allowing for adding HTML directly in the display option definition should also be acceptable. I'll put it on my to-do list :)

@icaroniz
Copy link
Author

icaroniz commented Apr 3, 2014

Didn't notice that example. Maybe my approach was more complicated than necessary...

By the way, I found out that in the mouseleave and mousewheel events, the restoration of the original text uses jQuery.text() instead of jQuery.html(). Changing this would solve my earlier problem.

Thanks for the advice!

@Mottie Mottie closed this as completed in 510bfd0 May 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants