w/resources/lib/oojs-router/oojs-router.js
/**
 * Provides navigation routing and location information
 *
 * @class Router
 * @mixins OO.EventEmitter
 */
Provides navigation routing and location information
@class Router
@mixins OO.EventEmitter
Provides navigation routing and location information @class Router @mixins OO . EventEmitter
function Router() {
	var self = this;
	OO.EventEmitter.call( this );
	this.routes = {};
	this.enabled = true;
	this.oldHash = this.getPath();
	$( window ).on( 'popstate', function () {
		self.emit( 'popstate' );
	} );
	$( window ).on( 'hashchange', function () {
		self.emit( 'hashchange' );
	} );
	this.on( 'hashchange', function () {
		var routeEv;
		if ( self.enabled ) {
			routeEv = $.Event( 'route', {
				path: self.getPath()
			} );
			self.emit( 'route', routeEv );
			if ( !routeEv.isDefaultPrevented() ) {
				self.checkRoute();
			} else {
				self.enabled = false;
				self.navigate( self.oldHash );
			}
		} else {
			self.enabled = true;
		}
		self.oldHash = self.getPath();
	} );
}
function Router ( ) { var self = this ; OO . EventEmitter . call ( this ) ; this . routes = { } ; this . enabled = true ; this . oldHash = this . getPath ( ) ; $ ( window ) . on ( 'popstate' , function ( ) { self . emit ( 'popstate' ) ; } ) ; $ ( window ) . on ( 'hashchange' , function ( ) { self . emit ( 'hashchange' ) ; } ) ; this . on ( 'hashchange' , function ( ) { var routeEv ; if ( self . enabled ) { routeEv = $ . Event ( 'route' , { path : self . getPath ( ) } ) ; self . emit ( 'route' , routeEv ) ; if ( ! routeEv . isDefaultPrevented ( ) ) { self . checkRoute ( ) ; } else { self . enabled = false ; self . navigate ( self . oldHash ) ; } } else { self . enabled = true ; } self . oldHash = self . getPath ( ) ; } ) ; }
Provides navigation routing and location information
 @class Router
 @mixins OO.EventEmitter
Provides navigation routing and location information @class Router @mixins OO . EventEmitter
// use an object instead of an array for routes so that we don't // duplicate entries that already exist // ev.originalEvent.newURL is undefined on Android 2.x // if route was prevented, ignore the next hash change and revert the // hash to its old value