Archive

Posts Tagged ‘Namespace.js:’

Namespace.js: take a wild guess….

March 24th, 2009 No comments

Let’s lead with code:

PLAIN TEXT

JAVASCRIPT:

  1. Namespace(‘foo.bar’);

  2. foo.bar.myFunction = function() {};

  3. Namespace(‘com.example’, {

  4.    MyClass: function() { return {}; }

  5. });

  6. var obj = new com.example.MyClass();

  7. Namespace.use(‘com.example.MyClass’);

  8. var obj2 = new MyClass();

  9. // include com/example/RemoteClass.js

  10. Namespace.include(‘com.example.RemoteClass’);

  11. var obj3 = new com.example.RemoteClass();

  12. Namespace.registerNativeExtensions();

  13. ‘com.foo.bar’.namespace();

Reading the code above is probably all you need to know about the new, library independant, JavaScript library Namespace.js, created by Maxime Bouroumeau-Fuseau.

The goals for the library are:

  • Simple API
  • Framework independent
  • Remote file loading (synchronously or async)
  • Tested against Firefox 3.x, Safari 3.x, IE 6/7 and Opera 9.5
  • Highly configurable
  • Events
  • Optionally add methods to native objects

You can see more in the How To.