<script src="..../media/lib_..../js/require/require.min.js" type="text/javascript"></script>
<script type="text/javascript">
var jooDependencies = [];
var jooPaths = [];
jQuery(document).ready(function () {
"use strict";
var dependencies, paths, allKeys, config = {
baseUrl: 'http://l..../media',
shim: {},
paths: {}
};
// Additional dependencies
jQuery.each(jooDependencies, function(index, dependency) {
config.shim[dependency.key] = dependency.value;
});
// Additional paths
allKeys = [ ];
jQuery.each(jooPaths, function(index, path) {
allKeys.push(path.key);
config.paths[path.key] = path.value;
});
// Require.js allows us to configure shortcut alias
require.config(config);
require(allKeys, function(Core) {
});
});
jooDependencies.push({key:'underscore', value:{exports: '_'}});
jooDependencies.push({key:'backbone', value:{deps: ['underscore'], exports: 'Backbone'}});jooDependencies.push({key:'ajaxbutton', value:{exports: 'XtAjaxButton'}});jooPaths.push({key:'ajaxbutton', value: 'http://l..../media/lib_..../js/utils/jquery.jooajaxbutton'}); jooPaths.push({key:'underscore', value: 'http://l..../media/lib_..../js/backbone/lodash.min'}); jooPaths.push({key:'backbone', value: 'http://l..../media/lib_..../js/backbone/backbone.min'}); </script>
What do you think? Opinions?
Thanks,Anibal--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-cm...@googlegroups.com.
To post to this group, send an email to joomla-...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
For more options, visit https://groups.google.com/groups/opt_out.
Hi,
--
You received this message because you are subscribed to a topic in the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/joomla-dev-cms/s2Wqo7eNKfo/unsubscribe?hl=en-GB.
To unsubscribe from this group and all of its topics, send an email to joomla-dev-cm...@googlegroups.com.
require.config(something)
require.config(something2)
require.config(something3)
require(something, callback)
require(something2, callback)
require(something2, callback)
require.config(all data passed to addScript)
require(something, callback)
require(something2, callback)
require(something2, callback)

The idea is to begin moving Javascript vanilla code as modules. For example, in the GSoC project to migrate from MooTools
change the existing API calls in the PHP and solve the problem in the HTML Document classes that render the JS statements
var config = {/*config object, rendered by Joomla*/}; require.config(config); require(['scripts added via addScript() + other RequireJS things'], function (Core) { //here some core configuration if need //here inline scripts add via addScriptDeclaration() });
--
You received this message because you are subscribed to a topic in the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/joomla-dev-cms/s2Wqo7eNKfo/unsubscribe?hl=en-GB.
To unsubscribe from this group and all of its topics, send an email to joomla-dev-cm...@googlegroups.com.
/**
* Adds a linked javascript module to the page.
*
* Example:
*
* $doc->addJavascriptModule('mediamanager', 'media/media/js/mediamanager.js');
* $doc->addJavascriptModule('installation', 'installation/template/js/installation.js', array('mediamanager'));
*
* Reference: Why AMD? http://requirejs.org/docs/whyamd.html
*
* @param string $moduleId Value of module identication in the module loader.
* @param string $url URL to the linked script
* @param array $dependencies Array of module dependencies
*
* @return JDocument instance of $this to allow chaining
*
* @since 11.1
*/
public function addJavascriptModule($moduleId, $url, $dependencies = array())
....
I've minimally tested it. I'm going to give it more testing implementing the jQuery installer. Please, let me know if it's Ok. Hi,
1. Yes, you are right :-) It's comming in the next commit.
2. About jQuery/.ready for in head.php:
Conservative option: It's safest (and slower). Modules are loaded after jQuery.ready, and everything else (latest actor to join the party). All modules have jQuery access (even mootools modules).
Open option: No jQuery.ready. Modules are loaded in parallel. As previous jQuery instance is not managed, each module must implement its own .ready to have jQuery as a dependency, or load its own jQuery instance (beyond previous Mootool and JQuery instances ;-) ).
Extreme option: Drop addScript and addScriptDeclaration, everything is loaded as module, and there's a directory of known modules. Dependencies are fine-grained. ;-)
Until now, I've implemented the Conservative option. It adds a delay, but it works. The open option can be more fine tuned, but the developer has to remember to add jQuery.ready.
Which is the best alternative at this moment?
Thanks,
Anibal
To unsubscribe from this topic, visit https://groups.google.com/d/topic/joomla-dev-cms/s2Wqo7eNKfo/unsubscribe?hl=en-GB.
nice, I was about to propose moving require.config configuration to
To unsubscribe from this topic, visit https://groups.google.com/d/topic/joomla-dev-cms/s2Wqo7eNKfo/unsubscribe?hl=en-GB.
To unsubscribe from this group and all of its topics, send an email to joomla-dev-cm...@googlegroups.com.
To post to this group, send an email to joomla-...@googlegroups.com.
--
addJavascriptModule('jquery');
addJavascriptModule('some-other', dependencies=> jquery);
addJavascriptModule('some-other1', dependencies=> jquery);
addJavascriptModule('myscript', dependencies=> jquery, some-other, some-other1);
You can just specify the path, and leave the dependency declaration in the module (better approach).
jquery -> underscore -> backbone -> yourmodule (this one has define['backbone'])