Cruiser Behaviors Library
Written by on April 3rd, 2007 in Ajax News.
Dan Yoder has created the Cruiser Behaviors Library, extensible stylesheets for decorating
DOM elements with interfaces and event handlers.
Cruiser uses Prototype, and is inspired by the Behaviour library itself.
A simple example shows the library in action. A new behaviour of “strike out a link with the special class of ‘demo’” is added to the page by doing:
Creating a strikable class
-
-
Strikeable = Class.create();
-
Strikeable.prototype = {
-
strike : function() {
-
var html = this.innerHTML;
-
this.innerHTML =
-
html.tagify(’del’);
-
}
-
}
-
Creating an ESS file
An ESS file is extended CSS and this sample looks like:
-
-
a.demo { mixin: Strikeable; click: strike; }
-
Tie in the ESS
To link in this ESS file you need to use a link tag similar to CSS:
-
-
<link rel=”extended-stylesheet” type=”text/ess” href=”/stylesheets/demo.ess”/>
-
Read more details on Cruiser.
Source: Ajaxian
Original Article: http://ajaxian.com/archives/cruiser-behaviors-library
