JavaScript

jQuery Conferences 2010: Call for speakers

Official jQuery Blog - Tue, 07/20/2010 - 15:14

We’d like to open up submissions for talks for our conferences in London and Boston.

The dates are currently being firmed up, but currently we’re eyeing these days: London: Sept 13-14; Boston: Oct 16-17. Please fill out the form if you’re interested in speaking at either of these events.

We will be sharing more information about these two epic events in the coming weeks.

Categories: JavaScript

The Official jQuery Podcast – Episodes 28 & 29

Official jQuery Blog - Fri, 07/09/2010 - 20:00

Episode 28 – Remy Sharp Part 3 – jQuery for Designers

In our final part with Remy Sharp we talk about his jQuery for Designers site. jQuery for Designers is a tutorial and screencast site which caters to designers and how to use jQuery to add interactive elements to your site. We discuss the difference between a developer and designer and the needs each has. Remy is the organizer of the Full Frontal JavaScript Conference in Brighton, England.  Plans are underway to have another conference again this November. Finally, we talk about Snap Bird a site which searches farther back in your twitter timeline then the Twitter API will provide you.

Missed previous episodes?  Part 1 – jsbin.com and Part 2 – HTML 5

You can subscribe to the show in iTunes or via the raw RSS feed or you can download the MP3.

Episode 29 – Rey Bomb #3

Rey and Ralph are joined again by Elijah Manor and Doug Neiner and this week we talk about the new JavaScript Tutorial site, Script Junkie. Rey is the editor of the site and both Elijah and Doug have written articles regarding jQuery and jQuery UI for the site.

We also review what is the top priority for the jQuery team right now and that is Mobile jQuery. Ralph gets you up to speed by outlining the problem scope, the research that the team is finding and lay out the current jQuery strategy for mobile.

You can subscribe to the show in iTunes or via the raw RSS feed or you can download the MP3.

Links from the show:

Script Junkie Articles

Elijah’s articles

  1. Six Things Every jQuery Developer Should Know
  2. How to Debug Your jQuery Code
  3. History and Back Button Support
  4. Intro to Error Handling in Ajax Apps
  5. Custom jQuery Events and Selector Filters
  6. How to Create Your Own jQuery Plugin
  7. jQuery Test-Driven Development

Doug’s article

  1. Introduction to Stateful Plugins and the Widget Factory

Mobile jQuery

  1. yayQuery Episode 18 – John Resig
  2. tx.js – John Resig talk on mobile – Part 1
  3. tx.js – John Resig talk on mobile – Part 2

Announcements

Carsonified Online jQuery Conference
Speakers: Rey Bango, John Resig, Karl Swedberg, Ben Alman
July 12, 2010 @ Noon EST
$150 Click for Discount info


O’Rielly Webinar

jQuery mistakes you’re probably making in your project
Speaker: Jonathan Sharp
July 13, 2010 @ 1PM EST
Free w/ Registration

We want to thank MediaTemple for hosting jQuery and the podcast files and we’d like to thank BrandLogic for the podcasting studio.

Follow the show on twitter for up to date information regarding upcoming guests athttp://twitter.com/jquerypodcast. Follow Ralph and Rey on Twitter as well.

You can send feedback about this episode or send in questions to podcast@jQuery.com or use the call-in number (804) 4jQuery, (804) 457-8379.

“jQuery Theme” created by Jonathan Neal

Categories: JavaScript

The Official jQuery Podcast – Episode 27 – Remy Sharp, Part 2

Official jQuery Blog - Fri, 06/18/2010 - 15:47

We again sit down with Remy Sharp in this second of a three part interview. This week we talk with Remy about HTML5 and the future of the spec and how to work with HTML5 today with JavaScript shims.

You can subscribe to the show in iTunes or via the raw RSS feed or you can download the MP3.

Here are the show notes for this episode:

Permanent Sponsors

Links mentioned… Sponsor


appendTo, the jQuery Company, provides consulting, training and support services for jQuery and jQuery UI world-wide. Founded by members of the jQuery Team, we are strong supporters and contributors to the jQuery Project and Open Source. Please visit us at:appendTo.com. Contact us at: +1(877) jQuery- Help or email us at: contact@appendTo.com

Wrap Up

Remy Sharp

Follow the show on twitter for up to date information regarding upcoming guests at http://twitter.com/jquerypodcast. Follow Ralph and Rey on Twitter as well.

You can send feedback about this episode or send in questions to podcast@jQuery.com or use the call-in number (804) 4jQuery, (804) 457-8379.

“jQuery Theme” created by Jonathan Neal

Categories: JavaScript

Seattle jQuery Open Space and Hack Attack with John Resig – July 5th

Official jQuery Blog - Mon, 06/14/2010 - 19:14

On Monday, July 5th, John Resig will be at the Seattle jQuery/JavaScript community meetup at Amazon’s brand new Van Vorst Meeting Center in South Lake Union for an afternoon of learning, openspace, hacking and, of course, pizza!

The fun begins at 1pm with a quick keynote and explanation of open space technology then the group will self organize into smaller sessions run in an open space style until 6pm.

There will be plenty of pizza, refreshments and networking space to meet like minded developers, so come and meet, eat, learn and play with some of the Pacific Northwest’s best front end and interface developers. Topics will be suitable for beginners all the way through to advanced jQuery and JavaScript programmers.

This awesome event is provided for free and but you need to register to get in. Be sure to get your ticket quick.

Categories: JavaScript

The Official jQuery Podcast – Episode 26 – Remy Sharp, Part 1

Official jQuery Blog - Fri, 06/11/2010 - 15:15

This week Ralph Whitbeck and Rey Bango talked with jQuery Developer Relations team member, Remy Sharp. We had an awesome long conversation with Remy. We’ve broke up his interview into three episodes. In this first episode we talk with Remy about jsbin.com, a quick and easy way to test javascript with html and be able to share and refine with others.

Find out what the inspiration was for jsbin. Find out how you can use jsbin to share JavaScript code with others. What is planned for future features and the challenges in making jsbin work on mobile devices like iPad/iPhone. In the upcoming episodes we will be discussing HTML5 and jQuery for Designers which will be released in the coming weeks.

You can subscribe to the show in iTunes or via the raw RSS feed or you can download the MP3.

Here are the show notes for this episode:

Permanent Sponsors

Links mentioned: Sponsor


appendTo, the jQuery Company, provides consulting, training and support services for jQuery and jQuery UI world-wide. Founded by members of the jQuery Team, we are strong supporters and contributors to the jQuery Project and Open Source. Please visit us at:appendTo.com. Contact us at: +1(877) jQuery- Help or email us at: contact@appendTo.com

Plugin of the week

jQuery UI 1.8.2
A recently released maintainence release for the UI Library makes the plugin of the week.

Tutorial of the week

A jQuery UI Combobox: Under the hood
Jörn Zaefferer walks us through the code behind widgets like autocomplete and combobox. A great look at the widget factory.

Wrap Up

Remy Sharp

Follow the show on twitter for up to date information regarding upcoming guests at http://twitter.com/jquerypodcast. Follow Ralph and Rey on Twitter as well.

You can send feedback about this episode or send in questions to podcast@jQuery.com or use the call-in number (804) 4jQuery, (804) 457-8379.

“jQuery Theme” created by Jonathan Neal

Categories: JavaScript

The Official jQuery Podcast – Episode 25 – Menno Van Slooten

Official jQuery Blog - Fri, 06/04/2010 - 14:39

This week Rey and I sat down with Menno Van Slooten at the Bay Area jQuery Conference 2010. Menno gave a presentation about automated UI testing and focused on a framework he has developed at eBuddy to do UI testing on our their web messenger.

Rey is travelling to TXJS this week so I had Doug Neiner sit in as we talk about this weeks plugin and tutorial of the week.

You can subscribe to the show in iTunes or via the raw RSS feed or you can download the MP3.

Here are the show notes for this episode:

Permanent Sponsors

Links mentioned: Sponsor

Interested in learning how Microsoft’s Web Platform and developer tools can make you a more productive web developer? If you’re currently working with PHP, Ruby, ASP or older versions of ASP.NET and want to hear how you can create amazing websites more easily with the latest innovations from Microsoft then register for a Web Camp near you!

Microsoft’s Web Camps are free, two-day events that allow you to learn and build on the Microsoft Web Platform. At camp, you will hear from Microsoft experts on the latest components of the platform, including ASP.NET Web Forms, ASP.NET MVC, jQuery,
Entity Framework, IIS, Visual Studio 2010 and much more.

We look forward to seeing you soon at a Web Camp near you! For more information and registration, head over to www.webcamps.ms

Plugin of the week

Signs of a poorly written jQuery Plugin

When you’re evaluating plugins for use in your application how do you know if the plugin you are using is any good. Remy Sharp wrote up a quick guide of some “red flags” to look for in poorly written plugins. Here are just a couple great tips on things to look for in a poor plugin:

Double jQuery
When you create a function on the jQuery.fn namespace this actually refers to the jQuery Collection being passed in so there is no need to wrap it again in a jQuery wrapper.

Wasteful each
Don’t bind an event on each element individually within the jQuery collection just bind it to the whole collection and forget the each. Binding it to each item individually is wasteful and slow.

Tutorial of the week

How to Debug Your jQuery Code by Elijah Manor
Tools, strategies and best practices for debugging your jQuery code.

Wrap Up

Menno Van Slooten

Follow the show on twitter for up to date information regarding upcoming guests at http://twitter.com/jquerypodcast. Follow Ralph and Rey on Twitter as well.

You can send feedback about this episode or send in questions to podcast@jQuery.com or use the call-in number (804) 4jQuery, (804) 457-8379.

“jQuery Theme” created by Jonathan Neal

Categories: JavaScript

The Official jQuery Podcast – Episode 24 – yayQuery

Official jQuery Blog - Fri, 05/28/2010 - 15:28

This week Ralph and Rey bring in the unicorns and unicows as we interview the hosts of the yayQuery podcast. We find out about their talks at the Bay Area jQuery Conference, status of yayQuery and the txjs Conference.

This weeks plugin of the week, jQuery UI Tooltip and the tutorial of the week, Why and how to create Microsoft Office Minibar with jQuery and CSS3, brought to you by Ralph and Rey.

You can subscribe to the show in iTunes or via the raw RSS feed or you can download the MP3.

Here are the show notes for this episode:

Permanent Sponsors

Links mentioned: Sponsor

Interested in learning how Microsoft’s Web Platform and developer tools can make you a more productive web developer? If you’re currently working with PHP, Ruby, ASP or older versions of ASP.NET and want to hear how you can create amazing websites more easily with the latest innovations from Microsoft then register for a Web Camp near you!

Microsoft’s Web Camps are free, two-day events that allow you to learn and build on the Microsoft Web Platform. At camp, you will hear from Microsoft experts on the latest components of the platform, including ASP.NET Web Forms, ASP.NET MVC, jQuery,
Entity Framework, IIS, Visual Studio 2010 and much more.

We look forward to seeing you soon at a Web Camp near you! For more information and registration, head over to www.webcamps.ms

Plugin of the week

jQuery UI Milestone release – Tooltip

Tooltip is a new widget that came out of the jQuery UI Planning Wiki. It is a jQuery Ui plugin built on top of the Widget Factory and utilized the new position utility plugin from jQuery UI 1.8

All you need is an element with a title attribute. Grab that element and call .tooltip() on it.

Example tooltip to play with: http://jsbin.com/abego

Tutorial of the week

Why and how to create Microsoft Office Minibar with jQuery and CSS3

Follow the show on twitter for up to date information regarding upcoming guests at http://twitter.com/jquerypodcast. Follow Ralph and Rey on Twitter as well.

You can send feedback about this episode or send in questions to podcast@jQuery.com or use the call-in number (804) 4jQuery, (804) 457-8379.

“jQuery Theme” created by Jonathan Neal

Categories: JavaScript

The Official jQuery Podcast – Episode 23 – Nicholas Zakas

Official jQuery Blog - Tue, 05/18/2010 - 12:46

We discovered a problem with the rss feed this morning. If you downloaded the show via iTunes/feed reader from Sunday till this morning you’ll want to redownload the show as the rss feed was downloading last weeks episode for this week. Problem fixed!! Sorry for the inconvenience!

This week Ralph and Rey sat down with Nicholas Zakas from Yahoo after his talk at the Bay Area jQuery Conference. We talk about his new book High Performance JavaScript, his talk at jQuery Conference and tips for jQuery developers to make their sites faster.

Rey and Ralph give us their tutorial and plugin of the week recommendations.

You can subscribe to the show in iTunes or via the raw RSS feed or you can download the MP3.

Here are the show notes for this episode:

Permanent Sponsors

Guest

  • Nicholas Zakas – principal front end engineer for the Yahoo! homepage.
Links from interview

YUI Theater — Nicholas Zakas, Stoyan Stefanov, Ross Harmes, Julien Lecomte, Matt Sweeney: “High Performance JavaScript” (92 min.)


Rey Bango’s video interview with Nicholas Zakas

Sponsor

Interested in learning how Microsoft’s Web Platform and developer tools can make you a more productive web developer? If you’re currently working with PHP, Ruby, ASP or older versions of ASP.NET and want to hear how you can create amazing websites more easily with the latest innovations from Microsoft then register for a Web Camp near you!

Microsoft’s Web Camps are free, two-day events that allow you to learn and build on the Microsoft Web Platform. At camp, you will hear from Microsoft experts on the latest components of the platform, including ASP.NET Web Forms, ASP.NET MVC, jQuery, Entity Framework, IIS, Visual Studio 2010 and much more.

We look forward to seeing you soon at a Web Camp near you! For more information and registration, head over to www.webcamps.ms

Plugin of the week

jQuery Offline – A jQuery plugin to facilitate conveniently working with local storage.

Tutorial of the week

Since this is Rey’s first tutorial of the week, he wanted to make sure you knew about the fantastic tutorials found at:

Wrap Up

Nicholas Zakas

Follow the show on twitter for up to date information regarding upcoming guests at http://twitter.com/jquerypodcast. Follow Ralph and Rey on Twitter as well.

You can send feedback about this episode or send in questions to podcast@jQuery.com or use the call-in number (804) 4jQuery, (804) 457-8379.

“jQuery Theme” created by Jonathan Neal

Categories: JavaScript

Prototype 1.7 RC2

Official Prototype News - Thu, 05/13/2010 - 22:34

We’ve just tagged Release Candidate 2 of Prototype 1.7, with the intent of putting out a final 1.7 release very soon.

In addition to the usual bug fixes, RC2 includes a late addition: the Element#purge method, used to dispose of an element (remove its event handlers and storage keys) before removing it from the page.

In addition, Element#update now performs a similar cleanup process on content that will be replaced via innerHTML. Both these additions should help keep memory usage down, especially for apps that create and destroy lots of DOM nodes.

Consult the CHANGELOG for further details.

Download, report bugs, and get help

Thanks to the many contributors who made this release possible!

Categories: JavaScript

Prototype 1.7 RC2

Official Prototype News - Thu, 05/13/2010 - 00:19

We’ve just tagged Release Candidate 2 of Prototype 1.7, with the intent of putting out a final 1.7 release very soon.

Categories: JavaScript

The Official jQuery Podcast – Episode 22 – James Senior

Official jQuery Blog - Fri, 05/07/2010 - 15:21

This week we interview James Senior of Microsoft while in attendance at the Bay Area jQuery Conference. We also announce the new co-host who replaces Elijah, Rey Bango, Head of Developer Relations on the jQuery team.

We also send out our thoughts to Elijah and his family as they live in the Nashville area and are dealing with the flooding that occurred this weekend. He and his family are fine and no damage to his house but he says many in his area are homeless with homes damaged by the flood. If you’d like to donate to help people in need due to the Nashville flooding, please consider giving to the American Red Cross Disaster Relief fund at redcross.org

You can subscribe to the show in iTunes or via the raw RSS feed or you can download the MP3.

Here are the show notes for this episode:

This episode is made possible by

Guests

  • James Senior – Web Technology Evangelist at Microsoft
Interview Sponsor

Interested in learning how Microsoft’s Web Platform and developer tools can make you a more productive web developer? If you’re currently working with PHP, Ruby, ASP or older versions of ASP.NET and want to hear how you can create amazing websites more easily with the latest innovations from Microsoft then register for a Web Camp near you!

Microsoft’s Web Camps are free, two-day events that allow you to learn and build on the Microsoft Web Platform. At camp, you will hear from Microsoft experts on the latest components of the platform, including ASP.NET Web Forms, ASP.NET MVC, jQuery, Entity Framework, IIS, Visual Studio 2010 and much more.

We look forward to seeing you soon at a Web Camp near you! For more information and registration, head over to www.webcamps.ms

Wrap Up

Follow the show on twitter for up to date information regarding upcoming guests at http://twitter.com/jquerypodcast. Follow Ralph and Rey on Twitter as well.

You can send feedback about this episode or send in questions to podcast@jQuery.com or use the call-in number (804) 4jQuery, (804) 457-8379.

“jQuery Theme” created by Jonathan Neal

Categories: JavaScript

Microsoft’s Proposal for Data Linking in jQuery. Feedback Requested.

Official jQuery Blog - Thu, 04/29/2010 - 01:23

Microsoft has submitted it’s second proposal to the jQuery Project outlining a plugin that allows properties within objects to be linked to each other. Termed “data linking”, the new plugin would allow changes made to a property of one object to effect a change on the property of a secondary object. The plugin leverages jQuery’s “special events” API to create a new event that will trigger when a change occurs on a bound object property. This would allow a developer to link properties in the following way:

var person = {};

$(“#name”).linkTo(“val”, person, “name”);

$(“#name”).val(“foo”);

alert(person.name); // foo

// … user changes value …
alert(person.name); // user typed value

The proposal has been submitted via the jQuery forums and Microsoft is actively soliciting community feedback:

http://forum.jquery.com/topic/proposal-for-adding-data-linking-to-jquery

A prototype of the data linking is available for review via Github:

http://github.com/nje/jquery-datalink

We’re pleased to see Microsoft’s continued contribution to our open source community and ask that you provide feedback in guiding this effort along.

Categories: JavaScript

The Official jQuery Podcast – Episode 21 – Rey Bomb #2

Official jQuery Blog - Sat, 04/24/2010 - 18:37

This week we have our second Rey Bomb episode and we discuss JSConf, Microsoft/jQuery relationship, Rey’s new job at Microsoft, the jQuery Conference that starts this weekend and news with Elijah.

You can subscribe to the show in iTunes or via the raw RSS feed or you can download the MP3.

Here are the show notes for this episode:

Permanent Sponsors

Wrap Up

Follow the show on twitter for up to date information regarding upcoming guests at http://twitter.com/jquerypodcast. Follow Ralph and Elijah on Twitter as well.

You can send feedback about this episode or send in questions to podcast@jQuery.com or use the call-in number (804) 4jQuery, (804) 457-8379.

“jQuery Theme” created by Jonathan Neal

Categories: JavaScript

The Official jQuery Podcast – Episode 20 – Barcamp Rochester

Official jQuery Blog - Fri, 04/16/2010 - 16:37

This week we provide you with three short interviews recorded at Barcamp Rochester earlier this month. John Resig gives us an update on the state of jQuery. Benjamin DeLillo tells us about a new WebGL library called WebGLU and Mich Cook of Yahoo introduces us to YUI3.

More into content

You can subscribe to the show in iTunes or via the raw RSS feed or you can download the MP3.

Here are the show notes for this episode:

Permanent Sponsors

Links from show Sponsor

This weeks podcast is brought to you by the Bay Area jQuery Conference 2010. Have you got your tickets to this amazing event yet? Would your company be interested in sponsoring the conference? Don’t wait, this event is sure to sell out fast!

Follow the show on twitter for up to date information regarding upcoming guests at http://twitter.com/jquerypodcast. Follow Ralph and Elijah on Twitter as well.

You can send feedback about this episode or send in questions to podcast@jQuery.com or use the call-in number (804) 4jQuery, (804) 457-8379.

“jQuery Theme” created by Jonathan Neal

Categories: JavaScript

The Official jQuery Podcast – Episode 19 – jQuery in Action, 2nd Ed.

Official jQuery Blog - Fri, 04/09/2010 - 16:28

This week we talked with Bear Bibeault and Yahuda Katz (@Wycats), authors of the upcoming book jQuery in Action: Second Edition. We discussed the intended audience of the book, how the chapters are laid out, the differences between the 1st and the 2nd editions, and much more.

You can subscribe to the show in iTunes or via the raw RSS feed or you can download the MP3.

Here are the show notes for this episode:

Permanent Sponsors

Guests
  • Bear Bibeault – Web Applications Architect from Austin, TX
  • Yahuda Katz – jQuery Development Team Member from San Francisco, CA
Interview
  • jQuery in Action: Second Edition
  • We’ve arranged with Bear and Yehuda’s publisher, Manning Publications, to give our listeners 35% off any version of jQuery in Action, 2nd Edition (ebook or print book). Go to www.manning.com, put the book in your cart, and at checkout, enter the promotional code jqpod to redeem the offer. The code is good until June 1, 2010.
Sponsor

This weeks podcast is brought to you by the Bay Area jQuery Conference 2010. Have you got your tickets to this amazing event yet? Would your company be interested in sponsoring the conference? Don’t wait, this event is sure to sell out fast!

Ralph’s Plugin of the week

The jQuery UI Growl is a plugin that uses the jQuery UI Modal Widget to simulate the Mac Growl notification effect. This plugin takes advantage of the jQuery Theme Roller, so you can easily change the look and feel of the plugin.

Elijah mentioned that you may also want to take a look at the Pines Notify jQuery Plugin, which also has jQuery Theme Roller support. In addition you can always check out the classic jGrowl jQuery Plugin.

Elijah’s Tutorial of the week

We briefly covered the topic of the jQuery Templating Proposal a couple of weeks ago, but this past week a short screencast was posted on Nettuts+ by Andrew Burgess entitled Quick Tip: An Introduction to jQuery Templating. In the short 5 minute screencast Andrew shows how to render the template, how to pass options, and how to reference the template index value. It is important to note that the content covered is currently only a proposal and the final Templating piece may be different from what is shown.

Wrap Up

Bear Bibeault

Yahuda Katz

Follow the show on twitter for up to date information regarding upcoming guests at http://twitter.com/jquerypodcast. Follow Ralph and Elijah on Twitter as well.

You can send feedback about this episode or send in questions to podcast@jQuery.com or use the call-in number (804) 4jQuery, (804) 457-8379.

“jQuery Theme” created by Jonathan Neal

Categories: JavaScript

Prototype 1.7 RC1: Sizzle, layout/dimensions API, event delegation, and more

Official Prototype News - Mon, 04/05/2010 - 16:46

We've just tagged the first release candidate of Prototype 1.7: a major new version with some major new features.

Sizzle as the selector engine (or mix in your own)

With Prototype 1.7, we've finally realized our long-held goal of moving to Sizzle, the middleware selector engine used by jQuery and others. I wrote our previous selector engine, used since 1.5.1, but nevertheless I'm excited to switch to a more robust engine that's shared between frameworks.

So Sizzle is the new default. But there's more to it than that. In moving to Sizzle, we've modularized the selector engine entirely. If you want to use Diego Perini's NWMatcher library in place of Sizzle, you can. Just check out the source code and build like so:

rake dist SELECTOR_ENGINE=nwmatcher

If you're a sentimentalist, you can use the legacy Prototype selector engine by specifying SELECTOR_ENGINE=legacy_selector. Or add your own selector engine by creating a subdirectory in vendor/ and following some simple conventions.

Element#on

Element#on is a new way to access the Prototype event API. It provides first-class support for event delegation and simplifies event handler removal.

In its simplest form, Element#on works just like Element#observe:

$("messages").on("click", function(event) { // ... });

An optional second argument lets you specify a CSS selector for event delegation. This encapsulates the pattern of using Event#findElement to retrieve the first ancestor element matching a specific selector. So this Prototype 1.6 code...

$("messages").observe("click", function(event) { var element = event.findElement("a.comment_link"); if (element) { // ... } });

...can be written more concisely with Element#on as:

$("messages").on("click", "a.comment_link", function(event, element) { // ... });

Element#on differs from Element#observe in one other important way: its return value is an object with a #stop method. Calling this method will remove the event handler. (Technically, this is an instance of a new class called Event.Handler.) With this pattern, there's no need to retain a reference to the handler function just so you can pass it to Element#stopObserving later.

For example, in Prototype 1.6, where you'd need to write something like...

start: function() { this.clickHandler = function(event) { // ... }; $("messages").observe("click", this.clickHandler); }, stop: function() { $("messages").stopObserving("click", this.clickHandler); }

...you can now write:

start: function() { this.clickHandler = $("messages").on("click", function(event) { // ... }); }, stop: function() { this.clickHandler.stop(); }

Also note that the Event.Handler class has a corresponding #start method that lets you re-attach an observer you've removed with #stop.

So, to review, Element#on is both a new approach to event observation and an implementation of event delegation. Feel free to eschew Element#observe and use Element#on exclusively; or use Element#on just for event delegation; or keep using Element#observe the way you always have.

Element.Layout: Your digital tape measure

The second major feature in 1.7 is Element.Layout, a class for pixel-perfect measurement of element dimensions and offsets.

Now you don't have to decide between properties like offsetWidth (which return numbers, but not the numbers you want) or retrieving computed styles (which have their own set of quirks and require a call to parseInt).

The simple case

If you want a one-off measurement of an element, use the new Element#measure:

$('troz').measure('width'); //-> 150 $('troz').measure('border-top'); //-> 5 // Offsets, too: $('troz').measure('top'); //-> 226

The argument passed to measure is one of a handful of intuitive names, most of which are derived from their CSS equivalents. So width means the width of the content box, just like in CSS — but we throw in extra properties (e.g., padding-box-width, margin-box-height) for some common measurements. This approach gives you far more granularity than common DHTML properties like offsetWidth and clientHeight.

These measurements are guaranteed to be in pixels. Even in IE. (In fact, Prototype works around a handful of IE quirks that would ordinarily result in inaccurate measurments.) It can even measure elements that are hidden, as long as their parents are visible. (Like when you want to animate an element from a hidden state and need to know how tall it will be.)

The complex case

If you need to measure several things at once, though, Element#measure is not the most efficient way to do it. Often an element will need a bit of manipulation before it reports its dimensions accurately, which means measurements can be costly.

The Element.Layout class tries to minimize that cost. It's a read-only subclass of Hash that remembers values in order to avoid re-computing.

First, use Element#getLayout to obtain an instance of Element.Layout:

var layout = $('troz').getLayout();

Now use Element.Layout#get to retrieve values, using the same property names you used for Element#measure:

layout.get('width'); //-> 150 layout.get('height'); //-> 500 layout.get('padding-left'); //-> 10 layout.get('margin-left'); //-> 25 layout.get('border-top'); //-> 5 layout.get('border-bottom'); //-> 5 layout.get('padding-box-width'); //-> 170 layout.get('border-box-height'); //-> 510 layout.get('width'); //-> 150

Here's where the remembered values (or memoization, if you prefer) come in. When I ask for width, Prototype measures the element – which, as we discussed, is a costly operation — and returns a value. A few lines later, I ask for width again, and I get the same value. But this time it didn't do any measuring. It remembered the value from last time.

There's more. When I ask for border-box-height, Prototype knows that's just height plus border-top plus border-bottom. All three of those properties are already memoized, since I asked for them earlier, so it skips the measurement phase and just gives me the sum.

How does it know when an element's dimensions change? It doesn't. Don't hang onto an instance of Element.Layout for too long; it's meant for short-term efficiency, not long-term caching. You can grab a new instance by calling Element#getLayout again.

Believe it or not, this is the short version. Read the documentation to learn more.

JSON fixes, ES5 compliance

The JSON interface slated for ECMAScript 5 is already being implemented in major browsers. It uses many of the same method names as Prototype's existing JSON implementation, but with different behavior, so we rewrote ours to be ES5-compliant and to fall back to the native JSON support where possible. A few other methods, like Object.keys, received similar treatment.

And, of course, bug fixes

Consult the CHANGELOG for further details.

Download, report bugs, and get help

As always: thanks to the many contributors who made this release possible!

Categories: JavaScript

Prototype 1.7 RC1: Sizzle, layout/dimensions API, event delegation, and more

Official Prototype News - Mon, 04/05/2010 - 16:42

We've just tagged the first release candidate of Prototype 1.7: a major new version with some major new features.

Categories: JavaScript