lib/starter_web/assets/themes/j1/adapter/js/stickybits.js in j1_template-2019.4.8 vs lib/starter_web/assets/themes/j1/adapter/js/stickybits.js in j1_template-2019.4.10
- old
+ new
@@ -71,16 +71,15 @@
*/
'use strict';
{% comment %} Main
-------------------------------------------------------------------------------- {% endcomment %}
-j1.Stickybits = (function (j1, window) {
+j1.adapter['stickybits'] = (function () {
{% comment %} Set global variables
------------------------------------------------------------------------------ {% endcomment %}
var environment = '{{environment}}'; // Set environment
- var state = 'not_started';
var moduleOptions = {};
var _this;
var logger;
var logText;
var stickybitsInstance;
@@ -92,46 +91,51 @@
// -------------------------------------------------------------------------
// Initializer
// -------------------------------------------------------------------------
init: function () {
+ // initialize state flag
+ j1.adapter.stickybits.state = 'pending';
{% comment %} Set global variables
-------------------------------------------------------------------------- {% endcomment %}
_this = j1.adapter.stickybits;
logger = log4javascript.getLogger('j1.adapter.stickybits');
- state = 'started';
- logger.info('state: ' + state);
+ _this.setState('started');
+ logger.info('state: ' + _this.getState());
+ logger.info('Module is being initialized');
stickybitsInstance = stickybits('{{stickybits_options.selector}}', {
useStickyClasses: {{site.data.modules.j1_stickybits.default.useStickyClasses}},
stickyBitStickyOffset: "{{site.data.modules.j1_stickybits.default.offset}}px"
});
- state = 'finished';
- logger.info('state: ' + state);
- logger.info('Module is being initialized');
+ _this.setState('finished');
+ logger.info('state: ' + _this.getState());
+ logger.info('module initializing finished');
return true;
}, // END init
// -------------------------------------------------------------------------
// messageHandler: MessageHandler for J1 CookieConsent module
// Manage messages send from other J1 modules
// -------------------------------------------------------------------------
- messageHandler: function ( sender, message ) {
- var json_message = JSON.stringify(message, undefined, 2);
-
+ messageHandler: function ( sender, message ) {
+ var json_message = JSON.stringify(message, undefined, 2);
+
logText = 'Received message from ' + sender + ': ' + json_message;
logger.info(logText);
// -----------------------------------------------------------------------
// Process commands|actions
// -----------------------------------------------------------------------
if ( message.type === 'command' && message.action === 'module_initialized' ) {
- _this.setState('finished');
+ //
+ // Place handling of command|action here
+ //
logger.info(message.text);
}
//
// Place handling of other command|action here
@@ -139,20 +143,22 @@
return true;
}, // END messageHandler
// -------------------------------------------------------------------------
- // Set the current (processing) state of the module
+ // setState
+ // Set the current (processing) state of the module
// -------------------------------------------------------------------------
setState: function ( stat ) {
- state = stat;
+ j1.adapter.stickybits.state = stat;
}, // END setState
// -------------------------------------------------------------------------
- // Returns the current (processing) state of the module
+ // getState
+ // Returns the current (processing) state of the module
// -------------------------------------------------------------------------
getState: function () {
- return state;
+ return j1.adapter.stickybits.state;
} // END state
}; // END return
})(j1, window);