K.I.T. – The Cold War

Ah, the good ol’ days.

A contract killer has been dispatched to assassinate the Russian double agent who betrayed Anna Chapman and nine other spies in the United States this spring.

Oh for the days of yore when we could count on good, old Godless Marxists coming over here and cleaning up their own messes for us. Say what you will about Ivan, he keeps his own house in order.

If a major studio executive hasn’t optioned the rights to this story by now they ought to check in to rehab for a week, because they are obviously smoking crack.

via Russian assassin sent to kill double agent who betrayed Anna Chapman | World news | The Guardian.

A jQuery Plugin Design Pattern

I’ve been using jQuery quite extensively and I recently started encapsulating my code using the jQuery plug-in design pattern. I really like the way it reads and it’s already starting to make my code both safer and more reusable.

One thing I find myself wanting to do quite frequently is to wire up the hover events to add a specific animation behaviour on mouseover and remove it on mouseout. This kind of thing fits quite nicely with jQuery’s architecture and I was able to write a nice little self-contained plug-in that does exactly that.

The official jQuery site offers us some direction on this point:

To make sure that your plugin doesn’t collide with other libraries that might use the dollar sign, it’s a best practice to pass jQuery to a self executing function (closure) that maps it to the dollar sign so it can’t be overwritten by another library in the scope of its execution.

EDIT: I’m now hosting this plugin source publicly on GitHub:

git://github.com/quantumtom/Test-jQuery-Plugin.git


(function($) {
	$.fn.addHoverFade = function(options) {
		// Use the default options 
		// if they haven't been overridden
		var myOptions = $.extend({}, $.fn.addHoverFade.defaults, options);

		return $(this)
			// Set the initial fade setting
			.fadeTo(myOptions.fadeSpeed, myOptions.opacityStart)

			// Wire up your new method
			.hover(
				function(){
					$(this).
						fadeTo(myOptions.fadeSpeed, myOptions.opacityFinish)
				},
				function(){
					$(this).
						fadeTo(myOptions.fadeSpeed, myOptions.opacityStart)
				});
			};

	// Initialize plugin defaults
	$.fn.addHoverFade.defaults = {
		fadeSpeed : "medium",
		opacityStart : "0.5",
		opacityFinish : "1.0"
	};
})(jQuery);

So, what we’re doing is chaining a new extension to the jQuery object. We do this by calling the public reference to the jQuery object – $ – and appending to its .fn() method. What we append to it is our new plugin and we do this by defining it as a function.

Once that’s done we define a property of our new plugin; we do this by assigning it the values of a dictionary object (remember, no such thing as an associative array in JavaScript).

Lastly, we pass all this back to the internal reference of the jQuery object. Ta-dah! You’ve wired up the plugin back into jQuery.

Accessing your new jQuery Plugin’s API extension

$(".my-html-class-attribute").addHoverFade();

Or we can specify to override the middle-of-the-road default options:

$("#the-example").addHoverFade({ opacityStart : "0.35", opacityFinish : "0.95", fadeSpeed : "fast" });

TL;DR

“So, where’s the demo?”

Here:

Not much to it, really. Now you have access to your custom method by just tagging it on to the end of your jQuery selector statement. You can optionally adjust the default configuration by specifying custom parameters when you call the method.

Old Venice and the Backdrops of “Boardwalk Empire”

It’s really fascinating to watch the recreation of Atlantic City during it’s “hey day” and I can’t help but be mesmerized by the backdrops for the exterior scenes shot there. I’ve always had a soft-spot for historical boardwalk scenes. Not really sure if it’s some weird obsession with the Monopoly boardgame or the secretive aspect of built-in speakeasies of the era.

I’m entranced because of its resemblance to the original appearance and intent of the boardwalk that stretched through the annexed communities of Ocean Park and Venice.

Jeff Stanton (the Historian Laureate of Ocean Park and Venice) lends his insight into the boardwalk’s origins as property of the firm in which Abbott Kinney was a partner:

Park Casino (actually a restaurant and tennis club) on June 23, 1891. Several months later they decided to purchase the surrounding tract of land for $175,000 from Captain Hutchinson, a British Army officer. The man had acquired the beach front property in the late 1870’s when he foreclosed on a series of loans made to the Machado family on parts of their La Ballona Rancho.