Created
November 22, 2012 18:21
-
-
Save ralt/4132456 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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