...
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.
...
<base_dir>/js/modules/requireconfig.min.js | module used to store access configurartion items |
<base_dir>/js/main.min.js | configures module loading and default js modules |
<base_dir>/js/rogo.min.js | initialisation script - sets configuration items etc |
<base_dir>/js/require.js | the requirejs library |
...
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 | ||||
---|---|---|---|---|
| ||||
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 | ||||
---|---|---|---|---|
| ||||
requirejs(['jsxls', 'jquery', 'jqueryvalidate'], function (jsxlsJsxls, $) { $('#forgotten_pw').validate({ messages: { email: jsxlsJsxls.lang_string['emailaddressinvalid'], } }); }); |
Coding Standards
- The first letter of variables included via RequireJS should be capitalised, and local variables should be lowercase
Code Block language js title example.js requirejs(['ui', 'jquery'], function (Ui, $) { var ui = new Ui(); $('#config').click(function() { ui.go_config(); }); });