You searched for: 'native'

Friday, November 9th, 2007

Pseudo-custom events in Prototype 1.6

Category: Articles, Examples, JavaScript, Prototype

Andrew Dupont has written a tutorial on how to normalize proprietary browser events using Prototype’s new custom events feature.

The piece is interesting as it talks about how the Prototype core team originally went down the wrong path trying to boil the ocean with great features that were a bit too much. And then:

we refocused, trimmed the fat, and added a whole bunch of features to the event system while still excluding thie kitchen sink. We picked some low-hanging fruit; for instance, we normalized the event object so that properties like target exist in all browsers, and we ensured events fire in the scope of the element in IE (so that this refers to the proper thing).

But we also added cross-browser support for custom events. Now developers can fire their own events alongside native browser events and can listen for both types with the same API. Custom events will make Prototype add-ons at least 50% more righteous, allowing for even more control than the standard callback pattern. Imagine TableKit firing an event when a cell gets edited, or PWC firing an event when a dialog is resized.

Since the 1.6 RC1 release, several people have asked whether we have any plans to add native support for mouseenter, mouseleave, or mousewheel. I think we ought not, lest the event codebase become an unholy thicket of special-casing. That’s the sort of environment where bugs thrive.

But, as Sam points out, the addition of custom events makes it easy for third parties to add their own support for proprietary browser events. To demonstrate, today we’ll write 20 lines of code to add sane, cross-browser support for mouse wheel events.

I’m calling these pseudo-custom events because they serve the same purpose as standard browser events: they report on certain occurrences in the UI. Here we’re using custom events to act as uniform façades to inconsistently-implemented events. Together we’ll write some code to generate mouse:wheel events. At the end of this article, you’ll know enough to be able to write code to generate mouse:enter and mouse:leave events document-wide.

This leads you into the example itself which takes you through a number of iterations before ending up with:

javascript

  1. (function() {
  2.   function wheel(event) {
  3.     var realDelta;
  4.  
  5.     // normalize the delta
  6.     if (event.wheelDelta) // IE & Opera
  7.       realDelta = event.wheelDelta / 120;
  8.     else if (event.detail) // W3C
  9.       realDelta = -event.detail / 3;
  10.  
  11.     if (!realDelta) return;
  12.  
  13.     var customEvent = event.element().fire("mouse:wheel", {
  14.      delta: realDelta });
  15.     if (customEvent.stopped) event.stop();
  16.   }
  17.  
  18.  document.observe("mousewheel",     wheel);
  19.  document.observe("DOMMouseScroll", wheel);
  20. })();

Posted by Dion Almaer at 11:35 am
2 Comments

++++-
4 rating from 48 votes

JavaScript 2: News and Opinion

Category: JavaScript

Brendan has been talking about ES4 for a long time now, and we have been a little surprised at how little people had been paying attention to it. But, of course, it is like an election. People ignore it until it gets close and then they look at the issues “oh wait a minute. that guy would do WHAT?”.

This has lead to the explosion of interest, and blog-fare. To finish up the week, we wanted to link to Brendan’s latest thoughts on ES4 news and opinion which includes a new known incompatibilities document:

Some news on language size: the proposed ECMAScript 4th edition (ES4) grammar is a bit more than twice as big as ES3’s, counting several ways (concrete productions, abstract syntax tree node types).

This is not out of line given the eight years since ES3, which came less than three years after ES1. Much of ES4 has been developed and shipped in ES3-based languages: AS3 in Flash, JS1.6 and 1.7 in Firefox, Opera’s extensions including array destructuring. And we’re being generous with syntactic conveniences, which desugar to a smaller core language.

On the compatibility front, we have a new document on known incompatibilities between ES3 (ECMA-262 Edition 3 the spec, not real-world behavior of ES3 implementations in browsers — note well) and ES4.

Neither a hidden and unready alternative proposal, nor general objections from a minority in the group, should halt a standard in progress. ES4 should be delayed or abandoned only on technical demerits, demonstrated specifically. There are enough implementors working together to make a standard, and ES4 as it has evolved has always been the expected successor standard. To block it based on general fears and opinions prejudges both the final standard and the market for it. The market, not Ecma TC39-TG1, should decide ES4’s fate.

It should be clear by now that the majority of TG1, who favor ES4, want to keep the group from splitting, or otherwise risking incompatible forks of ES3. Everyone loses in that scenario.

We wouldn’t have spent all the time in the wiki and at meetings if we all, including me, didn’t want a win-win outcome for all players. And I personally suggested to Chris in March that Microsoft could be a big winner by backing ES4 and supporting it in IE.

Is it still possible for everyone to win? I have to say I’m not as positive as I used to be. If we all work on testable compatibility via the reference implementation, then I’m somewhat more hopeful. But it will take a better stance than rejection of ES4 “in whole [and] in part” to get somewhere.

Posted by Dion Almaer at 11:27 am
8 Comments

+++--
3.6 rating from 25 votes

Wednesday, November 7th, 2007

Prototype 1.6, Script.aculo.us 1.8 and The Book.

Category: Announcements, Book Reviews, Books, JavaScript, Prototype, Scriptaculous

This is a big day for Protoscript friends. The triple release. The big one. This post is a long one two as it discusses:

Prototype 1.6

They cleaned up, and 1.6 is a really nice piece of work. A lot of little nit-picks are now solved, and you are left with the lean mean machine that you know and love.

Highlights

  • Ajax transport objects are now automatically wrapped in an Ajax.Response object.
  • Ajax.Response includes support for accessing JSON response bodies as JavaScript objects via the responseJSON property.
  • The class API now includes full support for inheritance and superclass method calls. (See Mislav’s tutorial for more info.)
  • Class objects now have an addMethods method for adding instance methods after creation.
  • Elements can be created easily with the new Element(...) syntax.
  • Element#insert provides a unified API to DOM element and HTML fragment insertion.
  • Element#select is an alias for getElementsBySelector and is now the preferred way to find elements by class name.
  • Element#wrap lets you easily wrap an element inside another element in place.
  • Enumerable methods on Array are now backed by native Array#forEach implementations when possible.
  • Enumerable now has aliases for equivalent JavaScript 1.6 Array methods, and support for JavaScript 1.6’s context parameter for automatic callback binding.
  • Enumerable#grep now calls the match method on its first argument, so you can use it to e.g. filter an array of DOM nodes by CSS selector.
  • Event objects are now automatically extended with instance methods, so you can write e.g. event.stop() instead of Event.stop(event).
  • Prototype’s event API now supports firing DOM-based custom events with Element#fire.
  • The new dom:loaded custom event fires when the entire document has loaded and is ready for manipulation.
  • Function#curry allows for partial application of function arguments.
  • Function#wrap facilitates simple aspect-oriented programming and provides the basis for Prototype’s superclass method call mechanism.
  • Function#delay delays invocation of the function by the given number of seconds.
  • Function#defer schedules the function to run as soon as the interpreter is idle.
  • The Hash API has changed, and you must now use Hash#get and Hash#set instead of directly accessing properties on Hash instances.
  • String#interpolate is a shortcut for instantiating a Template from the string and calling evaluate on it.
  • Object properties can now be used in template replacement strings.

Script.aculo.us 1.8

This is the last release before 2.0 comes out and features:

  • Complete rewrite of Ajax.InPlaceEditor and Ajax.InPlaceCollectionEditor
  • Full CSS inheritance in Effect.Morph
  • New core effect: Effect.Tween
  • Sound: play mp3 files for sound effects; uses native playback on IE and available plugins whereever possible
  • Duration and distance options for Effect.Shake
  • Performance improvements
  • Tons of bugfixes

The Book (Reviewed by Stu Halloway)

The skinny: If you develop with Prototype and Scriptaculous, you need
this book.

Prototype and script.aculo.us: You Never Knew JavaScript Could Do This! is a long book, by Pragmatic Press standards. At first glance,
this might seem doubly odd, since the libraries themselves are quite
small, totaling only in the 100s of KB. But before I even opened the
book, I hoped that the length might be justified, for two reasons:

  1. Prototype and Scripty (hereafter P&S) are packed with dense,
    expressive, beautiful code, and they can do far more than their size
    might suggest.
  2. Along with several other Ajax libraries, P&S embody a modern
    JavaScript style that embraces functional programming. This new style
    is not well covered in the JavaScript books currently in print (as of
    November 2007), so to learn P&S you also have to learn to think about
    JavaScript in a new way.

Once inside the book, I was delighted to find that both of my hopes
were addressed. Porteneuve dives straight into the deep end,
embracing JavaScript’s functional style immediately in Chapter 2 and
never dumbing down the example code. (Don’t worry, there are forward
and backward references to help you along. This is especially nice if
you are reading the electronic copy of the book.) You may need to
read some sections of this book multiple times, and that is a good
thing.

The coverage of both Prototype and Scriptaculous is thorough. Of
course the marquee features receive due attention: Prototype’s
Ajax.Request and Scriptaculous’s Effects each have their own
chapters. More interesting to me is the thorough coverage of the less
visible parts:

  • Prototype’s functional capabilities are significantly enhanced for
    the 1.6 release. Chapter 4 shows how to use curry, bind (including
    multiple argument invocation), delay, and defer. You can even do some
    lightweight Aspect-Oriented Programming (AOP) with the new wrap method.
  • Chapter 7, “Playing with the DOM is Finally Fun”, nicely mixes
    tutorial and reference. The Staff Manager example motivates each
    section, but each individual section also acts as a reference for a
    set of DOM extensions.
  • The Event mechanism has been rewritten and enhanced for Prototype
    1.6. Chapter 6 covers the new unified event handling. Porteneuve
    motivates the event model by contrasting three approaches: the IE
    way, the standards way, and the Prototype way. With 1.6, portability
    improves again with synthetic events that fill gaps in the browser
    event model, e.g. dom:loaded. You can even fire and respond to your
    own custom events.
  • I have been using Scripty for years and I never even noticed the
    sound API (Chapter 20).

Of course, no reviewer feels complete until a few nits have been
picked. So here are a few:

  • Porteneuve embraces Prototype’s approach to JavaScript and the web
    (as do I). That said, there are many other approaches. It would be
    great to have an overview of the philosophical differences that set
    P&S apart from other JavaScript libraries.
  • The book’s style is casual, even by Prag standards.
  • Prototype and Scriptaculous are a rich buffet, and the book
    documents nearly every bite. Sometimes the book could be more
    opinionated about the menu. For example, I hate the $break feature in
    Prototype. Maybe Porteneuve does too–the example is certainly
    contrived.

These flaws are relatively minor. Overall I was impressed by the
amount of information in the book. I have been using P&S for years,
and I learned something new in almost every chapter.

For years, developers at software conferences have asked me “What is
the best way to learn Prototype and Scripty?” Until today, my answer
has always been “Read the source code.” Not any more. If you are
building applications with P&S, you need to read this book.

Posted by Dion Almaer at 3:22 pm
13 Comments

++++-
4 rating from 58 votes

Monday, November 5th, 2007

Dojo 1.0 Released: The Granddaddy is Born

Category: Announcements, Dojo

Ben and I have been talking about Dojo forever. We talked about Net Windows and MochiKit before it, and when a slew of JavaScript hackers came together to create Dojo we knew it would be a good thing.

Dojo was more than an XHR wrapper, which consisted of the majority of libraries that appeared on the scene right after Ajax came to life. Dojo always felt like the standard library that JavaScript never had. It wasn’t just for the browser, it was for all JavaScript.

Recently the Dojo team decided that this was all well and good, but the pragmatic reality was that the browser was where their users were using them, so it was time for a rewrite. From scratch they rebuilt a fast lean Dojo core that only has what you need. They kept the core philosophy, and the build system is still there, as well as the great widget system.

The end result is Dojo 1.0, a huge milestone for the project as they took 1.0 so seriously.

Recent Features

  • Accessibility including keyboard navigation, low vision support, and ARIA markup for assistive technologies
  • High performance grid widget supporting 100,000+ rows of data
  • Browser-native 2-D and 3-D charting
  • A full library of easy-to-use, attractive UI controls
  • Universal data access for simple and fast data-driven widget development
  • Internationalization with localizations provided for 13 major languages
  • CSS-driven themes to make customization and extension simple
  • Dojo Offline, based on Google Gears, which makes offline applications easy to build
  • Support for the OpenAjax Alliance Hub 1.0 to guarantee interoperability with other toolkits
  • Native 2-D and 3-D vector graphics drawing
  • Access to many more widgets and extensions through the Dojo package system

Take a look at the full press release or watch our chat with Alex about the release. Alex is always great to talk too as he is very honest, and carries the torch nicely for the Open Web. Congrats to the entire Dojo team.

Comet Daily

SitePen has also released a new website dedicated to the discussion of Comet: Comet Daily. A group of the Comet experts are all signed up and ready to show you that PUSH is back!

Posted by Dion Almaer at 9:18 am
22 Comments

++++-
4.1 rating from 62 votes

Thursday, November 1st, 2007

Monthly Ajaxian Roundup for October, 2007: JavaScript wars, Java reborn, and Browsers wake up

Category: Roundup

October has been a busy month. We are currently in a political and emotional roller-coaster that peaked after the ECMAScript 4 Language Overview was released. It is as though EC4 just sprang up, when in fact it has been chugging along for ages. Brendan has been talking about it for some time. At this point opinions are being aired all over the shop and as I finished the last post, I hope we can de-polarise the situation and get to work.

Browsers seem to be taking the charge recently. Webkit keeps adding great features, and with Leopard we now have Safari 3 churning out.

Mozilla is also branching out with projects such as Prism and Mobile Firefox. IE8 is still dark.

I covered the fact that Sun has announced how they have a new Java Plugin that is in the works. Many still scoff at Applets, which may by itself be the downfall. However, if Sun pulls it off, I think that Applets have a real place on the Web. Before you scoff think about how cheesy little XHR lay dormant for so long. Java down right in the browser can be a nice bridge to advanced functionality where you still can script away in JavaScript.

JavaScript on the Web keeps getting more featureful too though. I was really proud of out Blog.gears example that shows the path for rich read/write mashups, in this case also working offline. The open source Google Caja can also help us have the freedom to allow JavaScript to be in a page and not collide to do evil things. Caja makes a lot of sense when you think about OpenSocial.

All in all a great month, and here is to an exciting November that includes OpenSocial APIs, Dojo 1.0, and more.

The Details

Dojo

Ext

GWT

jQuery

Prototype

YUI

Gears / Offline

Browsers

JavaScript

CSS

Other:

Posted by Dion Almaer at 10:00 am
11 Comments

+++--
3.7 rating from 15 votes

Monday, October 29th, 2007

Mozilla Prism: Save As Web Application

Category: Firefox

Mozilla has announced a new application that has been placed in Labs called Prism. Prism takes WebRunner and let’s it integrate nicely into the target operating system.

This means that you can take any web site that you currently visit a lot, and place it in its own process, and you can launch it like any other application. It sits on your desktop for you to run. A modest goal.

I actually do this on my Mac by wrapping a Webkit component with some native sauce, and you can then even add extra features on top such as special quick keys, and menu items, etc. Many people do this of course and there are apps out there like Mail Plane.

What will be interesting to see is how features will be added to do more with the desktop. Adobe AIR allows you to talk to OS services in many ways, and some of us want even more native support. Mike Chambers of Adobe puts his view on some of Mozilla’s comments in the post too.

What do you think?

Posted by Dion Almaer at 7:36 am
16 Comments

+++--
3 rating from 28 votes

Thursday, October 18th, 2007

Ken Russell on the new Java Plugin

Category: Java, Podcasts, Recording

After we posted about the news that Sun has rewritten the browser Java plugin system, we got a chance to sit down with the lead engineer on the project, Ken Russell.

He got to tell us about the fun implementation issues behind the rewrite. It turns out that the new system is mostly written in Java itself, and there is a very thin bridge to the browser. The JVM also runs in its own OS process, so if the JVM crashes it doesn’t affect the browser.

There were also other tidbits, such as having JNLP working natively in the browser, and how this could be used to allow other scripting engines such as JRuby to run in the browser. One JNLP extension, and everyone can share JRuby.

Posted by Dion Almaer at 10:00 am
21 Comments

+++--
3.1 rating from 113 votes

Tuesday, October 16th, 2007

Prototype 1.6.0 RC1: Changes to the Class and Event APIs, Hash rewrite, and bug fixes

Category: JavaScript, Library, Prototype

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. var Foo = Class.create();
  2. Class.extend(Foo, { /* instance methods */ });

to:

javascript

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

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.

Posted by Dion Almaer at 5:56 pm
9 Comments

++++-
4.1 rating from 34 votes

Monday, October 15th, 2007

Script.aculo.us 1.8 preview

Category: Prototype, Scriptaculous

Thomas Fuchs announced a preview release of the Script.aculo.us effects library. Script.aculo.us v1.8 Preview includes:

  • Prototype 1.6 (lastest trunk version)
  • Complete rewrite of Ajax.InPlaceEditor and Ajax.InPlaceCollectionEditor
  • Full CSS inheritance in Effect.Morph
  • New core effect: Effect.Tween
  • Sound: play mp3 files for sound effects; uses native playback on IE and available plugins whereever possible
  • Performance improvements
  • Tons of bugfixes

You can find the full CHANGELOG here.

Posted by Rey Bango at 8:15 am
11 Comments

+++--
3 rating from 45 votes

Tuesday, October 9th, 2007

Filespots: Is it Vista? Or the web?

Category: Sencha, Showcase

Filespots is an online file management system that allows you to store, manage, share, and version your files on the web.

The application uses Ext 2.0, and it shows. If you are a Vista user, you will be surprised to see how similar the look and feel of this web application is.

Glen Lipka discussed this in his review. He mentions that when your web app tries to look like a desktop app, it is likely to get compared to them. It is hard to compare performance and such between a web app and a native desktop one.

Compared to other web applications though, Glen is a huge fan, and some of his concerns (e.g. no right click context menus) have already been addresses in new versions of Filespots.

Just take a look:

Posted by Dion Almaer at 9:00 am
15 Comments

++++-
4.4 rating from 93 votes

Wednesday, October 3rd, 2007

Monthly Ajaxian Roundup for September, 2007: JavaScript mashups take a step forward

Category: Roundup

September was a big month for Ajax development in my opinion. The new JavaScript API that lets you do cross domain secure read-write tells us what will be possible in the future. Now mashups can go from the useful read-only mashing, to powerful applications that let you do everything you need too.

We also saw more tips and tricks in JavaScript land, as well as expansions to new worlds.

Thanks for spending time participating in the community, and I look forward to the Autumn.

Dojo

Ext

Prototype

jQuery

YUI

Browsers

JavaScript

Offline

iPhone

Adobe

Ajaxian Featured Tutorials

Design

Comet

Showcases

Posted by Dion Almaer at 5:30 am
2 Comments

+++--
3.3 rating from 29 votes

Tuesday, October 2nd, 2007

Persistent Objects with Persevere the client and Jsponic the server

Category: JavaScript, Library

Kris Zyp has made a charge in the persistent JavaScript space by releasing both a client and a server to handle JSON persistence.

Persevere s an open source persistent object mapping framework for JavaScript in the browser. Persevere allows programmers to access, traverse, and manipulate persisted data easily with standard JavaScript syntax and intuitive Persistent JavaScript (PJS). Persevere implements the PJS API and maps JavaScript objects to persistent storage objects remotely through JSON based RESTful web services following the JSPON (JavaScript Persistent Object Notation) data interchange specification. Persevere accesses persisted object graphs provided through JSPON data sources which can represent various underlying sources such as database tables and can even span domains. Persevere can provide orthogonal persistence and lazy loading support with standard JavaScript property access and modification through JavaScript optional pre-processing, such that persisted data can be modified with plain JavaScript, for example:

javascript

  1. var result = pjs.load("data or query id"); // load a object mapped to
  2. persistent data
  3. var object = result[1]; // access items from a result
  4. var value = object.prop; // lazy loading is performed when necessary
  5. object.prop = "new value"; // change a property and it is automatically sent
  6. to the server to be persisted
  7. result.push({name:"new object/row"}) // adding and removing rows/objects
  8. from persisted data can be done with normal JS array methods
  9. Array.remove(result,object); // or splice

Persevere can also be used without preprocessing, or it can provide these
capabilities natively with JavaScript 1.7. Persevere allows supports
application code to be persisted and exist within these object graphs, to
facilitate a unique “live programming” approach to object oriented design
and organization.

Jsponic provides a server implementation of the JSPON protocol, and therefore is ideal as a backend for Persevere (or any other JSPON client). Jsponic is a Java-based server that implements the JSPON protocol for exposing persistent data storage as RESTful JSON web services, and with full capabilities for modification of persisted data, execution of remote/distributed JavaScript methods, and data centric object level security. Jsponic includes an internal dynamic object database, and supports standard SQL tables, XML files, and web service, and exposes these data sources through JSON. Jsponic also implements the PJS specification, and provides persistent object mapping in a server local JavaScript environment (Rhino) which facilitates distributed remote calls between the client and server with both environments referencing and sharing access to the same persisted data.

Persevere and Jsponic can be used independently of each other, as communication is based completely on JSON (JSPON and JSON-RPC), and it is easy to implement these publicly available specifications to write your own client to connect to Jsponic or build your web service as a backend to Persevere. Persevere and Jsponic both come with the JSPON Object Browser to facilitate testing, accessing, and manipulating JSPON data to simplify building your own client or server.

Posted by Dion Almaer at 7:59 am
8 Comments

+++--
3.4 rating from 28 votes

A breath of fresh AIR from Adobe

Category: Adobe

Okay so it was a corny title but I couldn’t help myself.

Adobe has released AIR Beta 2. This release tackles a number of issues and dramatically improves desktop integration. What’s new:

  • System Tray icon/Dock Bar Bounce
  • Synchronous database API
  • Native menus
  • Drag and drop enhancements including bitmap support
  • Windowing improvements such as Z-order control and enhanced Activation and focus support
  • Improved Install dialog look and feel
  • Application-initiated runtime updates
  • HTML security model improvements
  • Mouse support for double-click and scroll-wheel
  • Per-machine runtime installs
  • Performance and memory enhancements
  • XSLT support
  • Support for Windows 2000
  • Hundreds of bug fixes

Full details of these changes can be found in the Developer FAQ.

Security Updates

Adobe spent a lot of time revamping the security model for AIR specifically breaking out security into two sandboxes to allow developers to better manage their security needs:

Capability

AIR Application Sandbox

AIR Classic sandbox

Default access to AIR API’s?

Yes

No

Access to functions written in Application Sandbox that use AIR APIs via SandboxBridge?

N/A

Yes

Can load remote script? For example, <script src=“remote_url”></script>

No

Yes

Can execute cross-domain requests (XHR)?

Yes

Yes

Support for getting strings to code after load event?

  • eval() function
  • setTimeout(“string”, milis)
  • setInterval(“string”, milis)
  • "javascript: " urls
  • attribute handlers on elements such as onclick=“myClick()" that are inserted via innnerHTML
  • creation of script tags and setting textContent

No

Yes

Ajax frameworks will work without any changes?

No

Yes

The AIR HTML Security FAQ goes into great detail about the rationale behind the changes and how they might effect AIR application development.

Important Links

Adobe AIR
http://labs.adobe.com/technologies/air/

Develop with Adobe AIR with HTML and JavaScript
http://labs.adobe.com/technologies/air/develop_ajax.html

Migration instructions (moving from Beta 1 to Beta 2)
http://labs.adobe.com/wiki/index.php/AIR:Migration

AIR SDK for Building Applications:
http://www.adobe.com/go/getairsdk

Sample Applications:
http://www.adobe.com/go/air_samples

AIR Dreamweaver CS3 extension
http://labs.adobe.com/wiki/index.php/AIR:Dreamweaver_CS3_Extension

Aptana plugin (beta 2 compatible)
http://www.aptana.com/air/

Posted by Rey Bango at 6:30 am
10 Comments

+++--
3.4 rating from 15 votes

Monday, October 1st, 2007

Dojo and the script tags

Category: Dojo, JavaScript

Alex has written about some new script tag support added in Dojo 0.9:

For a long time systems like Flex and Laszlo have had a corner on naturally mixing behavior with markup. HTML’s native <script> tag doesn’t provide any context, and worse, can’t provide a way to be triggered by a particular event or action (outside of proprietary extensions). Several use-cases are important:

  • Scoped execution
  • Event-driven execution
  • Attachment vs. replacement

In Dojo 0.9 we took a hard look at them and devised <script type="dojo/method"> and <script type="dojo/connect">. Lets take a quick tour and show how it makes writing event handlers natural, building new widgets a snap, and over-riding built-in behavior trivial.

So, you can take code like this:

  1. <script type="text/javascript">
  2.    dojo.addOnLoad(function(){
  3.       var cp = dojo.widget.byId("cp");
  4.       dojo.event.connect(cp, "onDownloadStart",
  5.            function(){
  6.                dojo.debug("started downloading:", cp.href);
  7.                // advanced behavior here
  8.            }
  9.        );
  10.  
  11.        // more configuration...
  12.    });
  13. </script>
  14. <div dojoType="dojo:ContentPane" widgetId="cp">
  15. ...
  16. </div>

and replace it with the script tag way of attaching an event:

  1. <div dojoType="dijit.layout.ContentPane">
  2.     <script type="dojo/connect" event="onDownloadStart">
  3.         console.debug("started downloading:", this.href);
  4.         // advanced behavior here
  5.     </script>
  6.     ...
  7. </div>

This definitely looks a little different on the eyes.

Posted by Dion Almaer at 5:43 am
9 Comments

+++--
3.5 rating from 37 votes

Friday, September 28th, 2007

DOMAssistant 2.0 released. Adds chainability, Ajax, and more

Category: Ajax, Library

The folks at 456 bereastreet are reporting about the newest release of Robert Nyman’s DOM Assistant.

In case you aren’t aware of DOM Assistant:

DOMAssistant is plainly an extremely efficient way to work tightly on conjunction with the DOM without worrying about web browser caveats and inconsistencies. No matter what you do, you will always get back a proper reference to the actual DOM element, or an array of references to DOM elements. This means that you can use DOMAssistant for the tasks you want to, and then just hook in your own scripts or other JavaScript libraries wherever and whenever you want to.

DOM Assistant v2.0 now includes several new features which should appeal to those looking for robust functionality in an extremely lightweight library:

  • Chainability
  • Basic Ajax capabilities
  • New DOMReady() method to better identify when the DOM is fully loaded
  • XPath support

If you’re looking for a tiny alternative to the slew of JS libs out there, then DOMAssistant might be right up your alley. You can find more details about DOMAssistant via the library’s website.

Posted by Rey Bango at 9:51 am
5 Comments

+++--
3.2 rating from 24 votes

Thursday, September 27th, 2007

WebRunner 0.7 Released

Category: Offline

Adobe’s AIR runtime gets a lot of press for bringing web apps to the desktop but Mark Finkle’s WebRunner is looking to be an alternative force in this space.

WebRunner is a simple XULRunner based browser that hosts web applications without the normal web browser user interface.

WebRunner 0.7 was just released with improved configuration capabilities and file system organization. New webapp bundles have also been added for Facebook and Twitter to compliment the existing profiles for:

  • Gmail
  • Goggle Calendar
  • Google Docs
  • Google Groups
  • Google Analytics

WebRunner and the webapp bundles are available for Windows, Linux and Mac.

Posted by Rey Bango at 7:00 am
5 Comments

+++--
3.5 rating from 18 votes