Elgg/Elgg — pull request #523 by ewinslow (2013-02-09 23:46:12+00:00)
Title: Refs #4494: Add AMD support

After the simplecache refactor this was so easy it made me want to weep.

Demo: http://elgg19.ewinslow.com/

In the dev console type `require(['text'])` and you can see the text plugin load correctly.

I'm sure there's more we can do, but this has the basics:

* AMD modules are assumed to be at the `js/module/name.js` view. So that makes the path `views/default/js/module/name.js.php` until we support straight .js files.
* `elgg_require_js('module/name')` will cause the aforementioned module to be loaded on page load.
* Includes the text plugin for requesting text files (e.g. client-rendered html templates)

Some gotchas + things to note:

* Because these are .php files and we're running them through the interpreter, we choke on things like `` even when they're in JS comments. Annoying, but not unmanageable.

Things to do:

* Register existing elgg classes/scripts as modules.
* Auto-registration: Don't want to have to explicitly register modules as external/cacheable.
* Support modules defined in non-views. i.e. "paths" argument of require.config
* Support shimming modules. i.e. "shim" argument of require.config