There's broad interest here I think in improving the core Drupal Javascript. Shall we channel this into a Drupal Enhancement Proposal (DEP), http://drupal.org/node/39407? Here's some rough beginnings, please jump in.
Title: Javascript Library Improvements
Status: Early draft for discussion
Reference: See http://groups.drupal.org/ajax-developers
Introduction
This DEP aims to improve Drupal's built-in Javascript library, making it extensible and introducing a Drupal Javascript namespace to prevent namespace collisions.
Motivation
Drupal 4.7 introduced a slim and well designed set of Javascript utility functions (drupal.js) and behaviors (autocomplete, collapse, etc.). As Drupal contributors continue to develop Javascript and AJAX behaviors, there is an emerging consensus around ways we could make Drupal's Javascript library more readily extensible while solving issues such as namespace collisions. There is also interest in the possibility of adopting or piggybacking on one of the several leading Javascript/AJAX utility libraries (jQuery, Prototype, etc.).
The purpose of this DEP is to work through these broad issues and come up with a community consensus on the best ways to strengthen our core Javascript implementation
Approach
Possibilities for discussion:
- Introduce Drupal Javascript namespace:
var Drupal = { utlities: { addClass: function(node, class) { }, ... } ... behaviors: {}, ... }and then register behaviors (in their own .js files):
if (Drupal) { Drupal.behaviors['autocomplete'] = { attach: function() { ... } remove: function() { ... } run: function() { ... } } } - Evaluate merits and feasibility of adopting an external utility library (jQuery, Prototype, etc.). Issues to be examined: license compatibility, etc.
Comments
thank you for writing this..
thank you for writing this.. I've been so damn swamped lately..
I agree with this 100%. thanks for all the work your doing nedjo.
I invite everybody to join
I invite everybody to join http://groups.drupal.org/drupal-js for the task of refactoring drupal.js.
Necessary?
I don't really think that a whole group is necessary, just for the task of 'refactoring drupal.js'. Surely using this group would be enough? After all, once this task is done, there's nothing more to be said, and the group will close. I would think that a single thread would do for this, rather than a dedicated group.
Jeremy Epstein - GreenAsh
Jeremy Epstein - GreenAsh
Let's plan a bit more and then code
I appreciate your enthusiasm, Konstantin. My feeling is that we would do better to discuss and plan a bit more before wading too far into coding a solution. There are some early decisions to make that will have a big impact on what directions we take. If we work these through first, we'll can probably save time in the end by not coding solutions that don't fit. A DEP is the process we've set up as a community for working through large proposed changes or new initiatives, and it seems to fit this case. In any case, I'd appreciate hearing your ideas or comments on the draft I posted here. I'm interested to hear your ideas on what our coding approaches should be.
I've joined the new group you created, and created an issue on drupal.org, http://drupal.org/node/66148. I propose that we (a) work out the general approach here in this post over the next week or two, (b) post a DEP for the initiative on drupal.org, and then (c) move the actual implementation to http://groups.drupal.org/drupal-js. How does that sound?
JavaScript Namespace solution.
Hi all, if you're looking for a way to manage your library's namespace, Ajile might be what you need. It's a JavaScript namespacing library (http://ajile.iskitz.com/) that makes it pretty easy to define and use namespaces in JavaScript.
jQuery
I vote for jQuery (if there is an election :)). After having tried all the more famous libraries, read a whole lot of reviews and tested some, I have found jQuery to be my favorite. It has a small footprint and is easily extended through addon functions. I hope to see it in use in Drupal, so I don't have to include it myself :)
jQuery is in
Yeah it's already in the Drupal 5.0 CVS repository. See http://drupal.org/node/88439 (jQuery 1.0.2) and http://drupal.org/node/69786 (original integration). There is also a patch for Drupal 4.7: http://drupal.org/node/88979
This whole thread is old,
This whole thread is old, although temporally it's not actually that old, so I had to blink twice.