<img src="media/banner-docs.svg" alt="ApplicationPrototype Modules Documentation">

ApplicationPrototype Modules

Why application-prototype-modules?

Quick Example

// App = a booted ApplicationBuilder on which the framework's lib() has run (see Getting Started)
App.require('/application-prototype-modules/lib.js').then(function (loader) {
    loader(); // Application.moduleRegister('/application-prototype-modules', ['custom-elements/lib', 'elements/popup', ...])

    App.require(['popup :: elements/popup', 'notify :: elements/notify']).then(function (libs) {
        var notify = libs.notify();                      // one notification container
        document.body.appendChild(notify.node());
        notify.position('top', 'right');

        libs.popup.confirm('Publish the article?', function (answer) {
            if (answer) notify.info('Published', 'The article is now public');
            else notify.warn('Not published');
        });
    });
});

Module Overview

Module Path required What it does Size Docs
Popup elements/popup alert(), confirm(), prompt() and bare popup() dialogs over a full-screen overlay: title, text, websymbols icon, buttons with callbacks, light / dark / clean themes, outside-click handling, animated classes 526 JS + 189 CSS elements/popup
Notify elements/notify Toast notification manager: log / info / warn / error / debug rows with a message and detail lines, per-type auto-expiry, click callbacks, one container positioned at any of ten places; forwards alert / confirm / prompt / popup to the Popup 360 JS + 855 CSS elements/notify
Notify Service elements/notify-service Ten Notify managers, one per position (top, bottom, top left, ..., left, right), attached to document.body; position(&#x27;top&#x27;, &#x27;right&#x27;) picks one, the service itself proxies the bottom-left manager 121 JS elements/notify-service
Context Menu elements/context-menu Absolutely positioned menu built from an options array: text, icon, action (function or URL), nested list, per-item render, style classes, a draggable "headbar" item; show(true) at the mouse, &#x27;mouse-viewport&#x27; keeps it on screen; auto-hides on the next mouseup 390 JS + 101 CSS elements/context-menu
Crop Sections elements/crop-sections Side-by-side panels that share the free width: fixed-width or fluid sections, collapse to a 48 px vertical tab with a CSS 3D rotation, header + scrolling articles, attach / detach, lookup by name, re-layout every 500 ms 287 JS + 310 CSS elements/crop-sections
Tree Node elements/tree-node Org-chart style tree of &#x3C;tree-node&#x3E; elements: append(), remove(), parent(), parents(), childs(), siblings(); connectors drawn in CSS, highlighted on hover 87 JS + 168 CSS elements/tree-node
custom-elements/lib custom-elements/lib Registers the custom elements of this repository for lazy loading (&#x3C;sgapps-scroller&#x3E; -> custom-elements/scroller) through the framework's custom-elements module 12 JS custom-elements/lib
sgapps-scroller custom-elements/scroller &#x3C;sgapps-scroller&#x3E;: a zero-size marker that turns an overflow: hidden box into a wheel- and drag-scrollable area by translating its siblings with a generated transform rule; limits, speeds, axis flags, synchronised boxes, a bubbling sgapps-scroll event 643 JS + 7 CSS custom-elements/scroller
Grid Panel gadgets/grid-panel Tiled dashboard layout editor: click two cells (or double-click one) to place a block, a self-growing cell grid, blocks with a content container and x() / y() / width() / height() setters, settings() snapshot and restore 642 JS + 98 CSS gadgets/grid-panel
Wrapper gadgets/wrapper Same-origin Blob-URL iframe sandbox (86 lines, no dependencies beyond extensions/prototype): node(), container(), document(), window(), whenLoaded(); header / code / base options for the generated document 86 JS gadgets/wrapper
Routing (not in lib.js) application-patterns/routing Static routing pattern: an array of routes (string, RegExp or function path) mapped to component modules and shared resource modules; components(routes).load() resolves the current URL, loads the resources once and renders the components in order 421 JS application-patterns/routing

All 10 names are registered by lib.js at the repository root:

// lib.js -- module.exports = loader
loader.list = [{
    path: __dirname,                       // the folder lib.js was loaded from
    modules: [
        'custom-elements/lib',
        'custom-elements/scroller',
        'elements/context-menu',
        'elements/crop-sections',
        'elements/tree-node',
        'elements/popup',
        'elements/notify',
        'elements/notify-service',
        'gadgets/wrapper',
        'gadgets/grid-panel'
    ]
}];

application-patterns/routing is a separate mini-framework with its own package.json; it is loaded by path (see its page) and is not part of the lib.js list. elements/popup/user/login and elements/popup/user/registration are application-specific sign-in / sign-up forms built on the Popup that require modules not shipped here (elements/google-re-capcha, resources/user); they are described on the Popup page as examples.
Every module page has a Use Cases (or Code Examples) section and can be opened in the playground (the play button in the corner lists them by category).

Getting Started

The modules need the framework and a static server. Serve this repository next to your site (git clone, here at /application-prototype-modules/) and register the modules with a root-relative path or an absolute URL -- lib.js registers the module names under its own folder (__dirname), and every module loads its sub-files (elements/popup/style.css, elements/crop-sections/template.tpl, gadgets/grid-panel/grid.js, ...) relative to its own file with module.resourceUrl() / module.require().

<!-- Browser: the framework's two script tags -->
<script src="/application-prototype/ApplicationPrototype.js"></script>
<script src="/application-prototype/ApplicationBuilder.js"></script>
<script>
    var App = new ApplicationBuilder({
        onready: function () {
            var App = this;
            App.modulePath('/application-prototype/constructors');

            // 1. the framework's built-in modules (extensions/prototype, uri-load, request, custom-elements, async, ...) by name
            App.require(['extensions/prototype', 'lib'], function (libs) {
                libs.lib();

                // 2. the modules of this repository by name: lib.js -> Application.moduleRegister('/application-prototype-modules', [...])
                App.require('/application-prototype-modules/lib.js').then(function (loader) {
                    loader();

                    // 3. any module
                    App.require('elements/notify-service').then(function (NotifyService) {
                        var notifications = NotifyService();
                        notifications.position('top', 'right').info('Ready', 'All modules registered');
                    }, console.error);
                }, console.error);
            });
        }
    });
</script>

The playground pages boot the same way (the framework from the SGApps CDN, https://cdn.sgapps.io/components/application-prototype, and the modules from the working copy above docs/ -- or from https://cdn.sgapps.io/components/application-prototype-modules when only docs/ is served), so every snippet on the module pages can be pasted into a page booted like the one above.
Full Getting Started Guide | Playground

License

The modules are original work of SGApps.IO, Copyright 2020-2026 Sergiu Gordienco Vasile, published under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International licence (the LICENSE file at the repository root): you may use and redistribute them with attribution for non-commercial purposes, without modification. Commercial use or derivative work needs a written agreement -- sgapps.io/contact.
The documentation site vendors Docsify (MIT), Prism (MIT) and, for the playground editor only, CodeMirror 3.15 (MIT) under docs/vendor/; none of them is loaded by the modules themselves.
By Sergiu Gordienco | sgapps.io

Open Playground

sgapps.io