Sha256: 61ff6997d1e7945e17e5ea1e2365fa1958a7e76e54f30dd1cd2f07bcfdcc1121

Contents?: true

Size: 852 Bytes

Versions: 7

Compression:

Stored size: 852 Bytes

Contents

/*
---

name: History.handleInitialState

description: Provides a helper method to handle the initial state of your application.

authors: Christoph Pojer (@cpojer)

license: MIT-style license.

requires: [History]

provides: History.handleInitialState

...
*/

History.handleInitialState = function(base){
	if (!base) base = '';
	var location = window.location,
		pathname = location.pathname.substr(base.length),
		hash = location.hash,
		hasPushState = History.hasPushState();

	if (!hasPushState && pathname.length > 1){
		window.location = (base || '/') + '#' + pathname;
		return true;
	}

	if (!hash || hash.length <= 1) return false;
	if (hasPushState){
		(function(){
			History.push(hash.substr(1));
		}).delay(1);
		return false;
	}

	if (!pathname || pathname == '/') return false;
	window.location = (base || '/') + hash;
	return true;
};

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lsd_rails-0.1.6 Packages/mootools-history/Source/History.handleInitialState.js
lsd_rails-0.1.5 Packages/mootools-history/Source/History.handleInitialState.js
lsd_rails-0.1.4 Packages/mootools-history/Source/History.handleInitialState.js
lsd_rails-0.1.3 Packages/mootools-history/Source/History.handleInitialState.js
lsd_rails-0.1.2 Packages/mootools-history/Source/History.handleInitialState.js
lsd_rails-0.1.1 Packages/mootools-history/Source/History.handleInitialState.js
lsd_rails-0.1 Packages/mootools-history/Source/History.handleInitialState.js