Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

prototyping plugin functionality

  • Loading branch information...
commit 5564034058601793b4fc2f0536870fe73d633ff6 1 parent 7b7dfcd
Jonathan Fielding authored
View
14 assets/js/core.js
@@ -1,11 +1,21 @@
+var app = {'url_path': ''};
+
$(document.body).live('pagechange', function(event, eventData) {
- var app = {'eventData': eventData};
var module_name = $(eventData.toPage).attr('data-module');
var javascript_required = module_name +'.js'
+ if(window.location.pathname.match('modules')){
+ app.url_path = '../../';
+ }
+
+ //Load the plugins into the app
+ require([app.url_path + 'plugins/add_plugins.js'],function(){
+ add_plugins.init();
+ });
+
//Each module should have a javascript file, we pull this in here
require([javascript_required],function(){
- window[module_name].init(app);
+ window[module_name].init(eventData);
});
});
View
6 modules/sample/sample.js
@@ -4,10 +4,10 @@ var sample = function(){
};
return {
- init: function(app){
+ init: function(eventData){
//Handle receiving messages from the previous page
- if(app.eventData.options.data){
- alert(app.eventData.options.data);
+ if(eventData.options.data){
+ alert(eventData.options.data);
}
}
}
View
12 plugins/add_plugins.js
@@ -0,0 +1,12 @@
+var add_plugins = function(){
+ return {
+ init: function(){
+ //add all plugins to the app
+
+ require([app.url_path + 'plugins/sample_plugin/sample_plugin.js'],function(){
+ app.sample_plugin.init();
+ });
+ }
+ };
+
+}();
View
12 plugins/sample_plugin/sample_plugin.js
@@ -0,0 +1,12 @@
+app.sample_plugin = function(){
+ var privateProperties = {
+
+ };
+
+ return {
+ init: function(){
+ console.log('loaded first plugin');
+ }
+ };
+
+}();
Please sign in to comment.
Something went wrong with that request. Please try again.