Skip to content
Ilia edited this page Apr 17, 2022 · 8 revisions

This API documentation is created for Webmin module developers to enable interaction with the theme core.

/*
 * Get theme version
 * theme.api.version([full], [long]);
 * @return string
 */
theme.api.version();

/*
 * Refresh page if allowed (consider changes)
 * theme.api.page.refresh();
 * @return string
 */
theme.api.page.refresh();

/*
 * Refresh page forcefully (ignore changes)
 * theme.api.page.refreshForce();
 * @return string
 */
theme.api.page.refreshForce();

/*
 * Get all headers from the latest call
 * theme.api.page.headers.getAll();
 * @return object
 */
theme.api.page.headers.getAll();

/*
 * Register permanent recurring events for page
 * theme.api.event.on.page
 *   .afterReplace: ƒ (callback, args)
 *   .beforeReplace: ƒ (callback, args)
 *   .beforeSend: ƒ (callback, args)
 *   .complete: ƒ (callback, args)
 *   .error: ƒ (callback, args)
 *   .popstate: ƒ (callback, args)
 *   .start: ƒ (callback, args)
 *   .success: ƒ (callback, args)
 */
theme.api.event.on.page.afterReplace(function(args, xhr, rs) { 
    myFunc('fn1', args, xhr, rs);
}, args );

/*
 * Register one time events for page
 * theme.api.event.one
 *   document:
 *     init: ƒ ()
 *     ready: ƒ ()
 *   page:
 *     afterReplace: ƒ (callback)
 *     beforeReplace: ƒ (callback)
 *     beforeSend: ƒ (callback)
 *     complete: ƒ (callback)
 *     reset: ƒ ()
 *     start: ƒ (callback)
 *     success: ƒ (callback)
 */

// Before page load
theme.api.event.one.document.init = function() {
    console.log('init');
};

// After page load (document is ready)
theme.api.event.one.document.ready = function() {
    console.log('ready');
};

// After page is loaded and after
// global replace event on page is run
theme.api.event.one.page.afterReplace(function() {
    console.log('run and unbind this event');
});
Clone this wiki locally