To Maintain A Healthy Level Of Insanity

  1. At Lunch Time, Sit In Your Parked Car With Sunglasses on and point a Hair Dryer At Passing Cars. See If They Slow Down.
  2. Page Yourself Over The Intercom. Don’t Disguise Your Voice!
  3. Every Time Someone Asks You To Do Something, ask If They Want Fries with that.
  4. In the Memo Field Of All Your Checks, Write “For Marijuana”.
  5. Skip down the hall Rather Than Walk and see how many looks you get.
  6. Order a Diet Water whenever you go out to eat,with a serious face.
  7. Specify That Your Drive-through Order Is “To Go”.
  8. Five Days In Advance, Tell Your Friends You Can’t Attend Their Party Because You have a headache.
  9. When The Money Comes Out The ATM, Scream “I Won! I Won!”
  10. When Leaving the Zoo, Start Running towards theParking lot, Yelling “Run For Your Lives! They’re Loose!”
  11. Tell Your Children Over Dinner, “Due To The Economy, We Are Going To Have To Let One Of You Go.”

And The Final Way To Keep A Healthy Level Of Insanity

PICK UP A BOX OF CONDOMS AT THE PHARMACY, GO TO THE COUNTER AND ASK WHERE THE FITTING ROOM IS.

jQueryUI dialog as loading screen (replace blockUI)

I like being able to manually control my loading screen with my ajax calls. Previously I was using the blockUI jQuery plugin. It’s a great plugin. You may turn an overlay on your entire screen or just a layer on or off by simply calling

$(selector).block();

and

$(selector).unblock();

Since at work they are hosting the jQueryUI package, I thought it’s a good idea to use as a few external plugins as possible. So I worked on using the jQueryUI dialog widget as the blockUI plugin. My goal is to replace the $(selector).block() and $(selector).unblock() conveniences. I think I got pretty close.

Click for a jQueryUI dialog as loading screen demonstration.

Step 1:
Create a layer in my html to be used as the loading screen.

<div id="loadingScreen"></div>

Step 2:
Style the loading screen with a nice loading icon. Want more customized loading icons? Check out the ajax loading icons site.

#loadingScreen {
	background: url(../images/loading.gif) no-repeat 5px 8px;
	padding-left: 25px;
}

Step 3:
Create a js file so I can include on all of the pages where I need the loading screen.

$(document).ready(function() {
	// create the loading window and set autoOpen to false
	$("#loadingScreen").dialog({
		autoOpen: false,	// set this to false so we can manually open it
		dialogClass: "loadingScreenWindow",
		closeOnEscape: false,
		draggable: false,
		width: 460,
		minHeight: 50,
		modal: true,
		buttons: {},
		resizable: false,
		open: function() {
			// scrollbar fix for IE
			$('body').css('overflow','hidden');
		},
		close: function() {
			// reset overflow
			$('body').css('overflow','auto');
		}
	}); // end of dialog
});
function waitingDialog(waiting) { // I choose to allow my loading screen dialog to be customizable, you don't have to
	$("#loadingScreen").html(waiting.message &amp;&amp; '' != waiting.message ? waiting.message : 'Please wait...');
	$("#loadingScreen").dialog('option', 'title', waiting.title &amp;&amp; '' != waiting.title ? waiting.title : 'Loading');
	$("#loadingScreen").dialog('open');
}
function closeWaitingDialog() {
	$("#loadingScreen").dialog('close');
}

Step 4:
It’s kind of annoying I think that the dialog widget doesn’t give you a ‘closable’ option. Because I don’t want my loading screen to be closable, the only way I could figure out to get rid of the little ‘X’ on the upper right corner of the title bar is to give your dialog a css class and then hide the ‘X’ using the css below:

/* hide the close x on the loading screen */
.loadingScreenWindow .ui-dialog-titlebar-close {
	display: none;
}

Simply show the loading screen by calling

waitingDialog({});

or with custom title & message

waitingDialog({title: "Hi", message: "I'm loading..."});

Call

closeWaitingDialog();

to hide the loading screen.

Click for a jQueryUI dialog as loading screen demonstration.

Ajax Call
Someone asked for an example of how to utilize the loading screen in an ajax call.

waitingDialog({});
$.ajax({
  url: "testAjax.php",
  success: function(data){
  $('#data').html(data);
	closeWaitingDialog();
  }
});

Click for a jQueryUI dialog as loading screen demonstration with AJAX call.

jQuery selection copy

Here’s a jQuery scenario I encountered today at work. I found the solution interesting.

I have 2 identical selection dropdowns. When I select from the first one I want to copy the selection value into the second. However, I also have a change event attached to the second selection dropdown. In order to make sure I trigger the second dropdown’s change event, instead of doing:

$('#firstSelection').change(function() {
	$('#secondSelection').val($(this).val());
});

I have to do the following:

$('#firstSelection').change(function() {
	var selectedIndex = $(this).attr('selectedIndex');
	$('#secondSelection').attr('selectedIndex', selectedIndex).change();
});

Funny colts' players tweets

This is funny if you are a Colts fan like me :)

Obviously, the title is a joke, but the joke is indeed courtesy of Colts rookie cornerback Jerraud Powers. Like many of us this past Sunday, Colts players Jerraud Powers and Pierre Garcon were watching the Jets play the Bengals in Cincinnati. However, unlike the good old days, when people would call and talk to one another during the course of the game, “Jpeezy25″ and “ShowTimeP85″ decided to use Twitter to talk trash about each other, their Colts teammates, and about other NFL players.

Of course, the winner in all this is us, the fans, because the entertainment value of Pierre Garcon calling Jerraud Powers as slow as Peyton Manning cannot be measured in mere dollars. Just entertainment is priceless. Here is there Twitter conversation from this weekend:

Jpeezy25 how is that a flag….Revis is locking this clown down and they calling some cheap stuff…
ShowTimeP85 Revis holds 95% of the time….don’t be bias
Jpeezy25 agggghhh u WRs these days are babied..we can even touch yall but u can push us all day and dont get calls. Revis is not holding
ShowTimeP85 it goes both ways yall hold we push off
Jpeezy25 Garcon…u cant be serious…i know a guy name Austin Collie…nuff said
ShowTimeP85 lol thats him…I don’t push off..yall be so far off I don’t have to push off…my speed push yall off far enough…
Jpeezy25 haaaa u funny..we can race tomorrow..me and lace the fastest dudes on the team besides Taj
ShowTimeP85 don’t put your money on it…
ShowTimeP85 your about as fast as Peyton…
Jpeezy25 now that was jus disrespectful man…take that back, im hurt
ShowTimeP85 lol…
Jpeezy25 now everybody retweeting that man..haaa

The Twitter party was later joined by Seahawks running back (an former Colts back) Justin Forsett, who was also watching the game. Garcon is quite the Twitter maven, with chatty friends like Redskins linebacker London Fletcher, Bengals defensive tackle Pat Sims, 49ers linebacker Takeo Spikes, Colts cornerback Jacob Lacey, and Bills wide receiver Terrell Owens in his Tweet roll.

Of course, the absolute master of Twitter from the Colts locker room is Raheem Brock. When he’s not Tweeting updates on Dallas Clark doing a cover of “Juicy” he’s posting pictures of the bill at Ruth Chris Steakhouse (Tip to LovinBlue)for the annual rookie d-line dinner. When it comes to Twitter, it is Raheem Brock’s world and the rest of us are loving it! I mean seriously, how can you not love a Colts player who Tweets this after the Patriots lost their first Wild Card Playoff Game under Bill Belichick:

Peace out patriots!nd we have no room on the bandwagon for patriots fans yall can kick rocks….barefoot! Lol bout to study these ravens!

There was also this little Tweet from Brock, made just prior to the Ravens v. Patriots playoff game:

I’m cleanin up the house this morn nd some papers fell on the floor in front of me..my study notes from playn bmore…think its a sign.lol

The hilarity of Powers complaining about Austin Collie pushing off and Raheem Brock telling Patriots fans to kick rocks barefoot all provide the kind of honest, unfiltered dialogue that we fans are often denied. Press conferences are too scripted and locker-room interviews too bland for the access to feel real. Here, on Twitter, the interaction feels real. Sometimes, it can backfire and make you look like a crass, immature fool, like Chris Johnson’s Tweet this weekend did.

Here, it just makes the players seem like human friggin beings, not the mindless, “blah blah blah” stiffs we see plastered all over ESPN and the like.

And while a significant amount of the Tweeting is silly in nature, one constant theme is pushed by the players when they are Tweeting either during or after work:

RaheemBrock Feels good to be working in jan!

ShowTimeP85 Practice…focused
Jpeezy25 Just got to work, preparing for Baltimore…gotta b great this time of year.

Again, hard not to like guys who think and Tweet this way. Go Colts!

BTW, if you want to follow some of the colts players on twitters:
Jerraud Powers: JPeezy25
Raheem Brock: RaheemBrock
Pierre Garcon: ShowtimeP85
Jacob Lacey: YungLace27
Pat McAfee: ThePattyMac

Football and blonde

A guy took his blonde girlfriend to her first football game. They had great seats right behind their team’s bench. After the game, he asked her how she liked the experience.

‘Oh, I really liked it,’ she replied, ‘especially the tight pants and all the big muscles, but I just couldn’t understand why they were killing each other over 25 cents.’

Dumbfounded, her date asked, ‘What do you mean?’

‘Well, they flipped a coin, one team got it and then for the rest of the game, all they kept screaming was: ‘Get the quarter back! Get the quarter back!’ I’m like….Helloooooo? It’s only 25 cents!!!!!!!!!!!

Creative overlay/popup with jQuery

While doing a presentation on jQuery at work today, I went over a particular example I put together earlier today. I thought I’d share it with you here.

In the past, we have used popups for editing values inside of a input box. The most well known example I can think of is smilies on a forum script.

There are shortcuts to insert smilies on the right side of the your textarea. Then if you want more, you click on the more link. A popup window shows up, in the new window, you may click on any of the smiley to insert the shortcut into the textarea where your post is.

There is nothing wrong with the old way. It’s working fine but I believe there is a better way to handle this kind of scenario.

Take a look at this example. (More complete example)

When you click on “Edit Input”, a layer slides out and then if you click on anywhere else on the page to indicate you are done with that input field, the layer goes away. On the layer that slides out, you may display more smiley shortcuts.

Benefits of the new way:

  1. You are not making another http request
  2. You are not opening another window so you don’t have to worry about popup blockers
  3. You don’t have to worry about the parent window child window crap in javascript
  4. The layer is on the same page as your regular input, it’s a lot easier to access its content
  5. Your code is probably is easier to understand.

HTML:

<div class="editing"><span id="trigger">Edit Input</span>
<div id="toolWrapper">Some kind of editing tool</div>
</div>

Very simple. Just an input box with a layer next to it. Within the layer is a trigger link (you may use an nice image icon if you wish).

CSS:

#trigger {
	cursor: pointer;
}
#toolWrapper {
	position:absolute;
	z-index:100;
	top:20px;
	left:20px;
	background:#eee;
	border:1px solid #111;
	display:none;
	-moz-border-radius: 6px;
	-webkit-border-radius: 6px;
	width:250px;
	padding-right:20px;
	height:200px;
}
div.editing {
	position: relative;
	display: inline;
}

The CSS utilizes the positioning trick. The outer wrapper (div.editing) is relatively positioned so the insider layer (#toolWrapper) may be positioned absolute to the outer one.

jQuery:

$(function() {
	$("#trigger").click(function() {
		$('#toolWrapper').toggle(function() {
			$(document).click(function(event) {
				if (!($(event.target).is('#toolWrapper') || $(event.target).parents('#toolWrapper').length || $(event.target).is('#trigger'))) {
					$('#toolWrapper').hide(500);
				}
			});
		});
	});
});

Uses the new toggle(showOrHide) method – the logic depends on where you click on the page. I will let you digest it yourself. Read the jQuery api if you need :)

Now take a look the time editor I wrote for work. It uses the slider widget from jQuery UI. I will not go over the javascript used. Feel free to view source if you are curious.

jQuery just got a new forum!! WOOHOO. I never liked discussion groups anyway. Forum is much more preference community format for me.

Firebug command line

If you do any javascript programming at all, you absolutely need to get the firebug plugin for firefox. It’s by far the best free tool out there. I’ve had the plugin since it first came out. However, I just learned about its command line feature today when I was reading this peeling away jQuery wrapper post.

How did I miss such any important new feature? Once you can get auto updates for plugins for firefox, you stop visiting the plugin site. So you don’t really pay attention to all of its new features. I am however extremely happy to learn about it today.

firebug command line

jQuery tip: Did you know you could prevent an event from executing more than once by doing

$("#someAnchorId").one("click", function(){
    //implementation
});

Mystique Theme

I spent most of the day customizing the Mystique wordpress theme. The theme is ridiculously great. It has all of the features I’d ever dream of. In fact, I got rid of some of my plugins + widgets because this theme covers them.

Also, the theme author uses jQuery on all of the UI effects. Another score for jQuery :)

YOU + YOU rule my world! Thank you!

Added a new page Nostalgic Old Layouts.