Skip to content

API: Update onload.js starter template #154

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
codeworksdev opened this issue Apr 26, 2018 · 0 comments
Closed

API: Update onload.js starter template #154

codeworksdev opened this issue Apr 26, 2018 · 0 comments

Comments

@codeworksdev
Copy link
Owner

codeworksdev commented Apr 26, 2018

The dist/frontend/js/onload.js starter template has been updated to support three conditions:

CONDITION 1

Adds support for new flags (#177, #195, #196) and defaults (#201).

UPDATED CODE

function mochi_init()
{
    this.setOption({
        CLICK_NAME                      : this.getDefaultOption( 'CLICK_NAME'                      ),
        DEBUG_MODE                      : this.getDefaultOption( 'DEBUG_MODE'                      ),
        ENABLE_SERVICE_WORKER           : this.getDefaultOption( 'ENABLE_SERVICE_WORKER'           ),
        LAZY_LOAD_PLUGINS               : this.getDefaultOption( 'LAZY_LOAD_PLUGINS'               ),
        SW_UPDATE_NOTIFICATIONS         : this.getDefaultOption( 'SW_UPDATE_NOTIFICATIONS'         ),
        SW_UPDATE_NOTIFICATIONS_OPTIONS : this.getDefaultOption( 'SW_UPDATE_NOTIFICATIONS_OPTIONS' ),
        SW_VERBOSE_SYNCING              : this.getDefaultOption( 'SW_VERBOSE_SYNCING'              ),
        SW_VERBOSE_SYNCING_OPTIONS      : this.getDefaultOption( 'SW_VERBOSE_SYNCING_OPTIONS'      ),
        });
};

CONDITION 2

Adds a simple condition to check if the MyMochiApplication extension has a defined onload public method (via the given callback function).

UPDATED CODE

$(document).ready(
    function(event)
    {
        $m.extend(
            'app',
            MyMochiApplication,
            function() {
                if (this.onload) this.onload()
                }
            );
    }
    );

CONDITION 3

Adds support for renamed hooks (#183) and a new addition (#188).

UPDATED CODE

function mochi_before       ()         {};
function mochi_init         ()         {};
function mochi_load         (data)     {};
function mochi_load_page    (data)     {};
function mochi_load_page0   (data)     {};
function mochi_load_view    (data)     {};
function mochi_load_view0   (data)     {};
function mochi_unload       (data)     {};
function mochi_unload_page  (data)     {};
function mochi_unload_page0 (data)     {};
function mochi_unload_view  (data)     {};
function mochi_unload_view0 (data)     {};
function mochi_last         ()         {};
function mochi_onchange     (data)     {};
function mochi_onmutation   (mutation) {};

Note: The data parameter is a simple object containing information regarding a specific hook. Please review the API documentation for more information.

@codeworksdev codeworksdev changed the title Minor update for onload.js starter template API: Update onload.js starter template May 21, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant