Sha256: c2baa434993d617019b423947e847d073d438a1d7dd40b2b0be350218503a294

Contents?: true

Size: 682 Bytes

Versions: 7

Compression:

Stored size: 682 Bytes

Contents

pageflow.History = function(slideshow) {
  slideshow.on('slideshowchangepage', function() {
    if(pageflow.features.has('hashchange support')) {
      window.location.hash = '#' + slideshow.currentPage().attr('id');
    }
  });

  $(window).on('hashchange', function() {
    slideshow.goToByPermaId(getHash());
  });

  slideshow.goToByPermaId(getPermaId());

  function getHash() {
    var match = window.location.href.match(/#(.*)$/);
    return match ? match[1] : '';
  }

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pageflow-0.8.2 app/assets/javascripts/pageflow/history.js
pageflow-0.8.1 app/assets/javascripts/pageflow/history.js
pageflow-0.8.0 app/assets/javascripts/pageflow/history.js
pageflow-0.7.2 app/assets/javascripts/pageflow/history.js
pageflow-0.7.1 app/assets/javascripts/pageflow/history.js
pageflow-0.7.0 app/assets/javascripts/pageflow/history.js
pageflow-0.6.0 app/assets/javascripts/pageflow/history.js