Needed to add a hover effect on some table rows and wanted to make it look nice. Think I managed to get it quite smooth in the end and thought I could share it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| // In the document ready event
$(function()
{
// Attach handler
$('table tbody').delegate('tr', 'hover', hoverHandler);
});
function hoverHandler(event)
{
switch(event.type)
{
// When mouse comes over
case 'mouseover':
$(this)
// Stop animation where it is
.stop(true)
// Start fading up
.animate({backgroundColor:'#fd8'}, 'fast');
break;
// When mouse goes out
case 'mouseout':
$(this)
// Jump to end of animation
.stop(true, true)
// Start fading down
.animate({backgroundColor:'transparent'}, 'slow');
break;
}
} |
You can check out a live version here: hover-effect.html
I would like to have used a class instead of a hard-coded color though. I tried to use addClass and removeClass, but with animation those proved to be quite buggy in this case. The problem with hard-coded colors is first of all that it generally is much better to collect styles in style-sheets than to have them spread out in other code. Secondly, doing it this way will override any background-color the rows might have had before you hovered over them.
A case where the second can ruin things a bit is if you have alternated background colors. This could be worked around if you take it into account in the handler though. Just for fun I tried to do just that: hover-effect-alt.html
Note that this might not work so well if your table is dynamic (if you sort, add or remove rows for example). But anyways, looks pretty cool I think
This is just a little step-by-step guide for how you can open up an open an elevated Command Prompt under Windows 7 (and Windows Vista I think). That is, a Command Prompt with Administrator privileges which allows you to do more stuff than you usually can.
Continue reading →
In PHP there is a very handy function called ucfirst which
Returns a string with the first character of str capitalized, if that character is alphabetic.
Needed that in JavaScript, but discovered there was no such thing.
Continue reading →
Have some server-side data that you would like to grab through an AJAX call? For example by using the jQuery.ajax method?
A really easy way of doing this is by using the JSON format.
Continue reading →
So, I was fooling around the other day with an HTML table and wanted to make the odd rows slightly darker. Figured I could use for example an 80% transparent black PNG to do that (or could have just assigned a darker color, but where’s the fun in that?). Either way, ended up making a little something that I thought I could share just for the fun of it. I learned a few things, so maybe someone else can too
So, here’s how to make a small transparent PNG filler image on-the-fly using PHP
Continue reading →
Sending a basic email message in a C# application is quite easy thanks to a class called SmptClient.
We simply need an address to send to, an address to send from, the message we want to send and the client:
var from = new MailAddress("me@example.com", "Me");
var to = new MailAddress("you@example.com", "You");
var message = new MailMessage(from, to)
{
Subject = "Greetings!",
Body = "How are you doing today?",
};
var client = new SmtpClient("smtp.example.com");
using (client)
{
try
{
client.Send(message);
}
catch (SmtpException e)
{
Console.WriteLine(e.Message);
}
}
That was pretty simple, wasn’t it? But what if we need to authenticate with our server? And what if we want to send our message in a more secure manner?
Continue reading →
Stumbled over the concept of Universal Greeting Time on IRC a little while ago. Found it kind of brilliant
UGT (abbr.): Universal Greeting Time.
UGT is convention initially established in #mipslinux on irc.openprojects.net (now irc.freenode.net) but slowly taking over the world. It states that it is always morning when person comes into a channel, and it is always late night when person leaves. Local time of any member of channel is irrelevant. Resistance is futile. Your ass will be laminated. (geoman is exception to this rule – his ass will be fried instead).
Used as follows:
Good (UGT) Morning, Everyone! or good morning (ugt) (on entry to channel).
Good (UGT) Night – when leaving it.
The idea behind establishing this convention was to eliminate noise generated almost every time someone comes in and greets using some form of day-time based greeting, and then channel members on the other side of the globe start pointing out that it’s different time of the day for them. Now, instead of spending time figuring out what time of day is it for every member of the channel, we spend time explaining newcomers benefits of UGT.
Source: UGT
Good night!
Posted in Random
|
Tagged Chat, Concept
|