Skip to content

Instantly share code, notes, and snippets.

@ralt
Created November 22, 2012 18:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralt/4132456 to your computer and use it in GitHub Desktop.
Save ralt/4132456 to your computer and use it in GitHub Desktop.
define(function () {
function getAllPaths() {
return [{
path: "",
url: "ui/notifications",
callback: function (notifications) {
notifications.init()
}
}, {
path: "option=com_community&view=profile",
url: "ui/profile",
callback: function (profile) {
profile.init()
}
}, {
path: "option=com_community&view=inbox&task=read",
url: "ui/inbox.read",
callback: function (inbox) {
inbox.init()
}
}]
}
function init() {
var paths = getCurrentPathModules();
$.each(paths, function () {
require([this.url], this.callback)
})
}
function getCurrentPathModules() {
var paths = getAllPaths(),
currentPathModules = [];
$.each(paths, function () {
if ((new RegExp(this.path)).test(window.location.search)) {
currentPathModules.push(this)
}
});
return currentPathModules;
}
var $ = jQuery;
return {
init: init
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment