02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Defines default values for the plugin<br />

$.fn.dateZoom.defaults = {<br />

"fontsize" : "110%",<br />

"easing" : "swing",<br />

"duration" : "600",<br />

"callback" : null<br />

};<br />

// Defines a utility function that is available outside of the<br />

// plugin if a user is so inclined to use it<br />

$.fn.dateZoom.zoom = function(element, size, opts)<br />

{<br />

$(element).animate({<br />

"font-size" : size<br />

},{<br />

"duration" : opts.duration,<br />

"easing" : opts.easing,<br />

"complete" : opts.callback<br />

})<br />

.dequeue() // Prevents jumpy animation<br />

.clearQueue(); // Ensures only one animation occurs<br />

};<br />

})(<strong>jQuery</strong>);<br />

Implementing Your Plugin<br />

CHAPTER 10■ EXTENDING JQUERY<br />

At this point, your plugin is ready to implement. All that remains is to include the file <strong>and</strong> select a set of<br />

elements to run it on.<br />

Including the Plugin File<br />

To include the plugin file, you need to modify footer.inc.php <strong>and</strong> add a new script tag. As with the<br />

validDate plugin, the dateZoom plugin needs to be included before init.js, so that the method is<br />

available to be called:<br />

<br />

<br />

google.load("jquery", "1");<br />

<br />

<br />

<br />

<br />

357

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!