Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

Work in progress. Will be implemented in Rogo 7.1 (October/November 2019)

Warning

Not yet merged into develop



In order to modernise Rogo we are modularising our javascript and implementing requirejs.

...

Table of Contents

Directory Structure

<base_dir>/js/src/core source files
<base_dir>/js/modules/contains core js modules
<base_dir>/js/contains core initialisation scripts
<functionality_dir>/js/src/functional area source files
<functionality_dir>/js/contains modules and initialisation scripts for functional area
<plugin_dir>/js/src/plugin source files
<plugin_dir>/js/modules/contains modules for plugin
<plugin_dir>/js/contains initialisation scripts for plugin


Important Files

<base_dir>/js/modules/requireconfig.min.jsmodule used to
store
access configurartion items
<base_dir>/js/main.min.jsconfigures module loading and default js modules
<base_dir>/js/rogo.min.jsinitialisation script - sets configuration items etc
<base_dir>/js/require.jsthe requirejs library


HTML File Structure

Each page in rogo will have the following js header where the rogo configuration is set, requirejs initiated and default modules loaded. Pages may have an additional js load to initiate page specifc modules.

...

Loading config into js

Config is loading loaded into the js via the rogoconfig element on the page. rogo.js reads the attributes in as follows:

...

Code Block
languagejs
titleexample.js
requirejs(['ui', 'jquery', 'jqueryvalidate', 'jqueryui'], function (UIUi, $) {
    var ui = new UIUi();
    // Validate ldap options, and toggle extra settings.
    $("#installForm").validate();
    $('#useLdap').change(function () {
        $('#ldapOptions').toggle();
    });
    $('#uselookupLdap').change(function () {
        $('#ldaplookupOptions').toggle();
    });

    $('#config').click(function() {
        ui.go_config();
    });
});

...

The jsxls module can then access the strings using the landlang_string method. i.e.

Code Block
languagejs
titleexample.js
requirejs(['jsxls', 'jquery', 'jqueryvalidate'], function (jsxlsJsxls, $) {
    $('#forgotten_pw').validate({
        messages: {
            email: jsxlsJsxls.lang_string['emailaddressinvalid'],
        }
    });
});

Coding Standards


  1. The first letter of variables included via RequireJS should be capitalised, and local variables should be lowercase


    Code Block
    languagejs
    titleexample.js
    requirejs(['ui', 'jquery'], function (Ui, $) {
        var ui = new Ui();
        
        $('#config').click(function() {
            ui.go_config();
        });
    });