Cruiser Behaviors Library

Written by on April 3rd, 2007 in Ajax News.

Cruiser

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

JAVASCRIPT:

  1.  
  2. Strikeable = Class.create();
  3. Strikeable.prototype = {
  4.   strike : function() {
  5.     var html = this.innerHTML;
  6.     this.innerHTML =
  7.       html.tagify(’del’);
  8.   }
  9. }
  10.  

Creating an ESS file

An ESS file is extended CSS and this sample looks like:

CSS:

  1.  
  2. a.demo { mixin: Strikeable; click: strike; }
  3.  

Tie in the ESS

To link in this ESS file you need to use a link tag similar to CSS:

HTML:

  1.  
  2. <link rel=”extended-stylesheet” type=”text/ess” href=”/stylesheets/demo.ess”/>
  3.  

Read more details on Cruiser.

Source: Ajaxian
Original Article: http://ajaxian.com/archives/cruiser-behaviors-library

Leave a Reply

You must be logged in to post a comment.



Site Navigation