Web Info & Tutorials

October 16th, 2007

PROTOTYPE 1.6.0 RC1: CHANGES TO THE CLASS AND EVENT APIS, HASH REWRITE, AND BUG FIXES

Sam Stephenson has announced Prototype 1.6.0 RC1 which has "fixed a handful of bugs and made some changes to the Class and Event APIs in response to your feedback. We’ve also addressed a long-standing issue with the Hash class."

For example, they show how they changed from:

JAVASCRIPT:
  1.  
  2. var Foo = Class.create();
  3. Class.extend(Foo, { /* instance methods */ });
  4.  

to:

JAVASCRIPT:
  1.  
  2. var Foo = Class.create();
  3. Foo.addMethods({ /* instance methods */ });
  4.  

Other changes are:

  • Completely rewriten of the Hash class
  • Changes to the Event API
  • Element#wrap now returns the newly created wrapper element instead of the element being wrapped.
  • document.getElementsByClassName and Element#getElementsByClassName are now deprecated, since native implementations of these methods return a live NodeList, while we can only return a static Array. Please use $$ or Element#select instead.
October 16th, 2007

MOO ON US: SURVEY UPDATE

We goofed in our recent survey story; we left out MooTools from the "Frameworks" category. While it wasn't an option in the original survey, over 11% of those surveyed wrote it in. If we'd actually included Moo as an option, it's likely to have scored even higher.

Many apologies for the gaffe; those responsible have been sacked, spat upon, flogged, and keel-hauled. We updated the PDF with this information as well as the number of respondents: 826.

October 16th, 2007

AJAXIAN FEATURED TUTORIAL: WHEN IS YOUR PAGE READY?

In this tutorial, Patrick Hunlock takes us through a page's ready states and shows how to write JavaScript code to determine when a page's DOM elements are loaded and available:

The problem with window.onload is that it assumes that no other script or library will want to attach an onload event of its own. And in this day of booming frameworks and endless pre-written snippets, that is no longer a certainty. Indeed, as your Javascript applications become larger you my find yourself stumbling over your own code!

Patrick provides step-by-step explanations and code that shows how to register events so they don't conflict with other libraries or code snippets down the road:

startStack=function() { };  // A stack of functions to run onload/domready
	
registerOnLoad = function(func) {
   var orgOnLoad = startStack;
   startStack = function () {
      orgOnLoad();
      func();
      return;
   }
}
	
var ranOnload=false; // Flag to determine if we've ran the starting stack already.
	
if (document.addEventListener) {
  // Mozilla actually has a DOM READY event.
   document.addEventListener(\"DOMContentLoaded\", function(){if (!ranOnload) {ranOnload=true; startStack();}}, false);
}  else if (document.all && !window.opera) {
  // This is the IE style which exploits a property of the (standards defined) defer attribute
  document.write(\"< \/scr\" + \"ipt>\");
  document.getElementById(\"DOMReady\").onreadystatechange=function(){
    if (this.readyState==\"complete\"&&(!ranOnload)){
      ranOnload=true;
      startStack();
    }
  }
}
	
var orgOnLoad=window.onload;
window.onload=function() {
   if (typeof(orgOnLoad)=='function') {
      orgOnLoad();
   }
   if (!ranOnload) {
     ranOnload=true;
     startStack();
   }
}
October 16th, 2007

GROUPSWIKI AND PROTOEDIT

Ben Nolan has unstoppered sourced GroupsWiki (which we first talked most nearly a assemblage ago). GroupsWiki is a seeable wiki, and doesn’t order users to see a primary wiki markup.

Part of the promulgation is Ben’s application (tentatively titled protoedit) which is a minimalist flush book application cursive using Prototype. (The application is in /javascripts/application.js). I haven’t had a quantity to vantage discover the application in a standalone warning - but it’s relatively direct to accommodate up. The application is diminutive (<15k of javascript), decent and object-oriented - and Safari 2 compatible.

Ben did a exhibit at Railsconf on using useful javascript (the enumerable functions in prototype.js) and exhibit whatever examples from the rich-text-editor in his slides.

GroupsWiki