Skip to content
zzolo edited this page Aug 2, 2011 · 10 revisions

Merlin is the custom JS framework built for CBU by TC. Merlin is named for because it is meant to help creating wizards. The idea is to provide the TC application with a Merlin component object that defines the wizard based on a complex configuration object.

File(s)

The main Merlin file is in static/js/tc.gam.merlin.js.

Developing

This section will go through making a Merlin Wizard.

Example

The best way to understand making a Merlin wizard is to read the in-depth example in the code.

Initializing Merlin Application

The app_page variable stores a feature, a feature is a function that runs an app.components. For example, the following will get a Merlin wizard going. Note that tc.gam.widgets.example_widget is defined in the example files described above.

jQuery(document).ready(function(e) {
    // Create object for the page application, which is the container
    // for Features.  Features are functions that accept the app object.
    var app_page = {
        data: {},
        features: [],
        prevent_logging: false
    };
    
    // Push a feature.  This feature contains an app.component that is a
    // new merlin object.  This merlin object is defined above.
    app_page.features.push(function(app) {
        // Add the example component (merlin example widget) here.
        app.components.example_component = new tc.merlin(app, tc.gam.widgets.example_widget);
    });
    
    // Create app.
    tc.app(app_page);
});

Inline Documentation

There is a fair amount of inline documentation in the code. Please see Documentation

Merlin is magical, FYI.

/*         Magic!!
      __________________
    .-'  \ _.-''-._ /  '-.
  .-/\   .'.      .'.   /\-.
 _'/  \.'   '.  .'   './  \'_
:======:======::======:======:  
 '. '.  \     ''     /  .' .'
   '. .  \   :  :   /  . .'
     '.'  \  '  '  /  '.'
       ':  \:    :/  :'
         '. \    / .'
           '.\  /.'
             '\/'
*/