Sha256: 7452ad72222f9340aeb9575c6b2976e9ed2a774fcd1a1eb0783576a48a91010a

Contents?: true

Size: 1.15 KB

Versions: 16

Compression:

Stored size: 1.15 KB

Contents

/* eslint-disable no-prototype-builtins, no-restricted-syntax, no-param-reassign */
// require self

((exports) => {
  let callbacks = {};

  exports.onpopstate = (event) => {
    // Ensure the event is caused by user action
    if (event.isTrusted) {
      for (let callbackId in callbacks) {
        if (callbacks.hasOwnProperty(callbackId)) {
          callbacks[callbackId](event.state);
        }
      }
    }
  };

  const registerCallback = (callbackId, callback) => {
    callbacks[callbackId] = callback;
  };

  const unregisterCallback = (callbackId) => {
    callbacks[callbackId] = null;
  }

  const pushState = (url, state = null) => {
    if (window.history) {
      window.history.pushState(state, null, url);
    }
  };

  const replaceState = (url, state = null) => {
    if (window.history) {
      window.history.replaceState(state, null,  url);
    }
  };

  const state = () => {
    if (window.history) {
      return window.history.state;
    }
    return null;
  };

  exports.Decidim = exports.Decidim || {};
  exports.Decidim.History = {
    registerCallback,
    unregisterCallback,
    pushState,
    replaceState,
    state
  };
})(window);

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
decidim-core-0.24.3 app/assets/javascripts/decidim/history.js.es6
decidim-core-0.23.6 app/assets/javascripts/decidim/history.js.es6
decidim-core-0.24.2 app/assets/javascripts/decidim/history.js.es6
decidim-core-0.23.5 app/assets/javascripts/decidim/history.js.es6
decidim-core-0.24.1 app/assets/javascripts/decidim/history.js.es6
decidim-core-0.24.0 app/assets/javascripts/decidim/history.js.es6
decidim-core-0.24.0.rc2 app/assets/javascripts/decidim/history.js.es6
decidim-core-0.23.4 app/assets/javascripts/decidim/history.js.es6
decidim-core-0.24.0.rc1 app/assets/javascripts/decidim/history.js.es6
decidim-core-0.23.3 app/assets/javascripts/decidim/history.js.es6
decidim-core-0.23.2 app/assets/javascripts/decidim/history.js.es6
decidim-core-0.23.1 app/assets/javascripts/decidim/history.js.es6
decidim-core-0.23.1.rc1 app/assets/javascripts/decidim/history.js.es6
decidim-core-0.23.0 app/assets/javascripts/decidim/history.js.es6
decidim-core-0.22.0 app/assets/javascripts/decidim/history.js.es6
decidim-core-0.21.0 app/assets/javascripts/decidim/history.js.es6