-
Notifications
You must be signed in to change notification settings - Fork 21
Javascript Model-View-Controller framework inspired by Ruby on Rails and CakePHP. You want to use it to organize your code and develop Javascript code faster thanks to conventions.
Set functions applied onReady – controllers may be applied to by controllerName / action combinations (not governed by the name of file)
$.jlm.bind('app_controller.beforeFilter', function () {
...
});
</code>
<code>
$.jlm.bind('pages.admin_edit', function() {
...
});
JLM has two forms of components auto-applied and those initiated with a start-up method.
Componant Code run on listed or all controller/actions
// SelectActions is called on all admin pages - this is applied to custom MVC in your app
$.jlm.component('SelectActions', '*', function() {
// code to manage to deletion, publication or classification of content when listed
});
Say a app need to provide users control over mp3 files. SoundManager is added to vendors. Then I build a component with code required to meet my need the outline is below
// A component which I plan to use somewhere
$.jlm.addComponent('mp3Manager', {
startup: function() {
// start up sound manager
},
playSound: function () {
// play sound manager - this function would manipulate the content of mp3 div to display a control to call stopSound
},
stopSound: function () {
// stop the sound
},
editTitle: function () {
// change title of mp3
},
insertInstance: function () {
// insert into content - put code into
}
});</code>
<code>
// You can apply it to custom MVC with the following app/jlm/examples.js
$.jlm.bind('music.admin_index', function() {
// start up the mp3Manager
$.jlm.components.mp3Manager.startup();
// apply function to a.mp3 click to call
$('#mp3List a.mp3').click($.jlm.components.mp3Manager.playSound());
// edit the title of mp3
$('#mp3List a.editTitle).click($.jlm.components.mp3Manager.editTitle());
});
/* elsewhere I would want to call mp3Manager eg when display mp3s to insert - then I call */
Javascript source projects made available to JLM
HTML Block templates with Placehodlers for script vars & l18n
Add controllers, components, vendors, views to app/jlm – these are then included in the JLM output.
JLM outputs the source of the wildflower/jlm/ & app/jlm/. The output is cached to app/tmp/cache/