Skip to content
This repository has been archived by the owner on Aug 7, 2020. It is now read-only.

Commit

Permalink
prototyping plugin functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Fielding authored and Jonathan Fielding committed Feb 27, 2012
1 parent 7b7dfcd commit 5564034
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
14 changes: 12 additions & 2 deletions assets/js/core.js
@@ -1,11 +1,21 @@
var app = {'url_path': ''};

$(document.body).live('pagechange', function(event, eventData) { $(document.body).live('pagechange', function(event, eventData) {
var app = {'eventData': eventData};
var module_name = $(eventData.toPage).attr('data-module'); var module_name = $(eventData.toPage).attr('data-module');
var javascript_required = module_name +'.js' 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 //Each module should have a javascript file, we pull this in here
require([javascript_required],function(){ require([javascript_required],function(){
window[module_name].init(app); window[module_name].init(eventData);
}); });


}); });
6 changes: 3 additions & 3 deletions modules/sample/sample.js
Expand Up @@ -4,10 +4,10 @@ var sample = function(){
}; };


return { return {
init: function(app){ init: function(eventData){
//Handle receiving messages from the previous page //Handle receiving messages from the previous page
if(app.eventData.options.data){ if(eventData.options.data){
alert(app.eventData.options.data); alert(eventData.options.data);
} }
} }
} }
Expand Down
12 changes: 12 additions & 0 deletions 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();
});
}
};

}();
12 changes: 12 additions & 0 deletions plugins/sample_plugin/sample_plugin.js
@@ -0,0 +1,12 @@
app.sample_plugin = function(){
var privateProperties = {

};

return {
init: function(){
console.log('loaded first plugin');
}
};

}();

0 comments on commit 5564034

Please sign in to comment.