Blockstrap Modules

Modules are JavaScript files with a pre-defined pattern designed to communicate with core.

The current modules distributed with core include:


An example skeleton module that has only a single test function should be constructed as follows:

(function($) 
{
    // EMPTY OBJECT
    var example = {};
    // THIS IS AN EXAMPLE FUNCTION
    example.test = function()
    {
        // THIS WOULD BE ACCESSED AS FOLLOWS
        // $.fn.blockstrap.example.test();
        alert('Test Activated');
    }
    // MERGE THE NEW FUNCTIONS WITH CORE
    $.extend(true, $.fn.blockstrap, {example:example});
})
(jQuery);

When including a theme module within your theme you are required to add a new function as seen in themes/default/js/modules/theme.js.

(function($) 
{
    // EMPTY OBJECT
    var theme = {};
    // THIS IS CALLED EACH TIME NEW CONTENT IS ADDED TO DOM
    theme.new = function()
    {
        // BY DEFAULT THIS DOES NOTHING YET
    }
    // MERGE THE NEW FUNCTIONS WITH CORE
    $.extend(true, $.fn.blockstrap, {theme:theme});
})
(jQuery);

Please note that the priority theme auto-includes filters and button actions as seen in themes/priority/js/modules/theme.js:

(function($) 
{
    // EMPTY OBJECT
    var theme = {};
    // THIS IS CALLED EACH TIME NEW CONTENT IS ADDED TO DOM
    theme.new = function()
    {
        alert('theme.new activated');
    }
    // OPTIONALLY AUTO-LOADED THEME FILTERS
    // ADD AS MANY AS YOU LIKE
    theme.filters.test = function(bs, data)
    {
        return data;
    }
    // OPTIONALLY AUTO-LOADED BUTTON FUNCTIONS
    // ADD AS MANY AS YOU LIKE
    theme.buttons.test = function()
    {
        alert('Button Clicked');
    }
    // MERGE THE NEW FUNCTIONS WITH CORE
    $.extend(true, $.fn.blockstrap, {theme:theme});
})
(jQuery);

This is because all filters and buttons set correctly within theme modules autommatically get assigned.

You make pick and choose which modules to include within your theme or easily write and include your own with configuration as follows:

{
    "modules": [
        "my_new_module"
    ]
}

Please note that some modules may try to utilize other modules and at the moment there is very limited support for missing modules.

In addition, there is currently no module dependency management.


  1. Related Articles
  2. Accounts
  3. API
  4. Buttons
  5. Contacts
  6. Blockchains
  7. Data
  8. Filters
  9. Forms
  10. Security
  11. Styles
  12. Templates
  13. Table of Contents