Sha256: 4514a67e5d22b90e6bb8edadf0fccb37587800105aa76849b71c48de0301da35

Contents?: true

Size: 1.59 KB

Versions: 46

Compression:

Stored size: 1.59 KB

Contents

//= require_self
//= require_tree ./history

pageflow.History = function(slideshow, adapter) {
  slideshow.on('slideshowchangepage', function(event, options) {
    var hash = slideshow.currentPage().attr('id');

    if (options.back) {
      adapter.replaceState(null, '', adapter.hash());
    }
    else if (options.ignoreInHistory) {
      adapter.replaceState(null, '', hash);
    }
    else {
      adapter.replaceState(options, '', adapter.hash());
      adapter.pushState(null, '', hash);
    }
  });

  adapter.on('popstate', function(event) {
    if (!adapter.state()) {
      return;
    }

    slideshow.goToByPermaId(adapter.hash(), _.extend({
      back: true
    }, _.pick(adapter.state(), 'direction', 'transition')));
  });

  adapter.on('hashchange', function() {
    slideshow.goToByPermaId(adapter.hash());
  });

  this.getLandingPagePermaId = function() {
    return adapter.hash() || pageParameter();
  };

  this.start = function() {
    adapter.replaceState(null, '', slideshow.currentPage().attr('id'));
  };

  this.back = _.bind(adapter.back, adapter);

  function pageParameter() {
    var match = window.location.href.match(/page=([^&]*)/);
    return match ? match[1] : '';
  }
};

pageflow.History.create = function(slideshow, options) {
  options = options || {};

  var adapter;

  if (options.simulate) {
    adapter = new pageflow.History.SimulatedAdapter();
  }
  else if (pageflow.browser.has('pushstate support')) {
    adapter = new pageflow.History.PushStateAdapter();
  }
  else {
    adapter = new pageflow.History.HashAdapter();
  }

  return new pageflow.History(slideshow, adapter);
};

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
pageflow-14.5.2 app/assets/javascripts/pageflow/history.js
pageflow-15.0.2 app/assets/javascripts/pageflow/history.js
pageflow-15.0.1 app/assets/javascripts/pageflow/history.js
pageflow-15.0.0 app/assets/javascripts/pageflow/history.js
pageflow-14.5.1 app/assets/javascripts/pageflow/history.js
pageflow-14.5.0 app/assets/javascripts/pageflow/history.js
pageflow-15.0.0.rc2 app/assets/javascripts/pageflow/history.js
pageflow-15.0.0.rc1 app/assets/javascripts/pageflow/history.js
pageflow-15.0.0.beta4 app/assets/javascripts/pageflow/history.js
pageflow-15.0.0.beta3 app/assets/javascripts/pageflow/history.js
pageflow-14.4.0 app/assets/javascripts/pageflow/history.js
pageflow-15.0.0.beta2 app/assets/javascripts/pageflow/history.js
pageflow-15.0.0.beta1 app/assets/javascripts/pageflow/history.js
pageflow-14.3.0 app/assets/javascripts/pageflow/history.js
pageflow-14.2.1 app/assets/javascripts/pageflow/history.js
pageflow-14.2.0 app/assets/javascripts/pageflow/history.js
pageflow-14.1.1 app/assets/javascripts/pageflow/history.js
pageflow-14.1.0 app/assets/javascripts/pageflow/history.js
pageflow-14.0.0 app/assets/javascripts/pageflow/history.js
pageflow-14.0.0.rc2 app/assets/javascripts/pageflow/history.js