Archive

Archive for the ‘Libraries’ Category

Namespace.js: take a wild guess….

March 24th, 2009

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.

admin Javascript, Libraries , ,

KeyTable: Instant keyboard navigation in a table

March 18th, 2009

Allan Jardine is up to his old tricks again (his tricks are: creating helpful small tools!). This time he has created KeyTable, a library that adds the ability to use the keyboard to navigate around an HTML table.

Events can be bound (and unbound) to cells as required by the developer, allowing increased accessibility to Javascript enhanced tables. This library is somewhat similar to QFocuser that was posted on Ajaxian back at the start of the month, but specialises in table navigation. KeyTable also integrates nicely with DataTables, such that paging and sorting is taken into account.

To get started you just need to var keys = new KeyTable(); and then you can add init params for fine grained work, and you can also add events:

PLAIN TEXT

JAVASCRIPT:

  1. /* Example event listener */

  2. keys.event.focus( 1, 3, function() {

  3. /* processing on cell 1,3 … */

  4. } ); 

  5. /* this is exactly the same as */

  6. keys.event.focus( $(’#example tbody tr:eq(3) td:eq(1)’)[0], function() {

  7. /* processing on cell 1,3 … */

  8. } );

The front page has an example that uses jEditable allowing you to mouse around, hit enter, change a field, and go back:

javascrip

admin Javascript, Libraries , ,

Hello world!

March 3rd, 2009
eXTReMe Tracker