function modifyIFrameNavigation (hasher, History, HashChanger) {

		var oHashChanger = new HashChanger(),
			oHistory = new History(oHashChanger),
			fnOriginalSetHash = hasher.setHash,
			fnOriginalGetHash = hasher.getHash,
			sCurrentHash,
			bKnownHashChange = false,
			fnOriginalGo = oFrameWindow.history.go;

		// replace hash is only allowed if it is triggered within the inner window. Even if you trigger an event from the outer test, it will not work.
		// Therefore we have mock the behavior of replace hash. If an application uses the dom api to change the hash window.location.hash, this workaround will fail.
		hasher.replaceHash = function (sHash) {
			bKnownHashChange = true;
			var sOldHash = this.getHash();
			sCurrentHash = sHash;
			// fire the secret events for the local history so the recording is correct.
			// The hash changer is not the global singleton it is a local one only used in this scope for the history.
			oHashChanger.fireEvent("hashReplaced",{ sHash : sHash });
			this.changed.dispatch(sHash, sOldHash);
		};

		hasher.setHash = function (sHash) {
			bKnownHashChange = true;
			var sRealCurrentHash = fnOriginalGetHash.call(this);
			sCurrentHash = sHash;
			// fire the secret events for the local history so the recording is correct.
			// The hash changer is not the global singleton it is a local one only used in this scope for the history.
			oHashChanger.fireEvent("hashSet", { sHash : sHash });
			fnOriginalSetHash.apply(this, arguments);

			// Happens when setHash("a") back setHash("a") is called.
			// Then dispatch the previous hash as new one because hasher does not dispatch if the real hash stays the same
			if (sRealCurrentHash === this.getHash()) {
				// always dispatch the current position of the history, since this can only happen in the backwards / forwards direction
				this.changed.dispatch(sRealCurrentHash, oHistory.aHistory[oHistory.iHistoryPosition]);
			}

		};

		// This function also needs to be manipulated since hasher does not know about our intercepted replace
		hasher.getHash = function() {
			//initial hash
			if (sCurrentHash === undefined) {
				return fnOriginalGetHash.apply(this, arguments);
			}

			return sCurrentHash;
		};

		// when a link is clicked or the hash is directly set we only get a changed event.
		hasher.changed.add(function (sNewHash) {
			// only if the change does not come from the other known places it is likely to be a pressed link
			if (!bKnownHashChange) {
				// fire the secret events for the local history so the recording is correct.
				// The hash changer is not the global singleton it is a local one only used in this scope for the history.
				oHashChanger.fireEvent("hashSet", { sHash : sNewHash });
				sCurrentHash = sNewHash;
			}
			bKnownHashChange = false;
		});

		oHashChanger.init();

		function goBack () {
			bKnownHashChange = true;
			var sNewPreviousHash = oHistory.aHistory[oHistory.iHistoryPosition],
				sNewCurrentHash = oHistory.getPreviousHash();

			sCurrentHash = sNewCurrentHash;
			hasher.changed.dispatch(sNewCurrentHash, sNewPreviousHash);
		}

		function goForward () {
			bKnownHashChange = true;
			var sNewCurrentHash = oHistory.aHistory[oHistory.iHistoryPosition + 1],
				sNewPreviousHash = oHistory.aHistory[oHistory.iHistoryPosition];

			if (sNewCurrentHash === undefined) {
				Log.error("Could not navigate forwards, there is no history entry in the forwards direction", this);
				return;
			}

			sCurrentHash = sNewCurrentHash;
			hasher.changed.dispatch(sNewCurrentHash, sNewPreviousHash);
		}

		oFrameWindow.history.back = goBack;
		oFrameWindow.history.forward = goForward;

		oFrameWindow.history.go = function (iSteps) {
			if (iSteps === -1) {
				goBack();
				return;
			} else if (iSteps === 1) {
				goForward();
				return;
			}

			Log.error("Using history.go with a number greater than 1 is not supported by OPA5", this);
			return fnOriginalGo.apply(oFrameWindow.history, arguments);
		};
	}
/**
	 * Disables most of the navigation in an IFrame, only setHash has an effect on the real IFrame history after running this function.
	 * Reason: replace hash does not work in an IFrame so it may not be called at all.
	 * This makes it necessary to hook into all navigation methods
	 * @private
	 */
Disables most of the navigation in an IFrame, only setHash has an effect on the real IFrame history after running this function.
Reason: replace hash does not work in an IFrame so it may not be called at all.
This makes it necessary to hook into all navigation methods
@private
Disables most of the navigation in an IFrame only setHash has an effect on the real IFrame history after running this function . Reason : replace hash does not work in an IFrame so it may not be called at all . This makes it necessary to hook into all navigation methods @private
function modifyIFrameNavigation (hasher, History, HashChanger) {
		var oHashChanger = new HashChanger(),
			oHistory = new History(oHashChanger),
			fnOriginalSetHash = hasher.setHash,
			fnOriginalGetHash = hasher.getHash,
			sCurrentHash,
			bKnownHashChange = false,
			fnOriginalGo = oFrameWindow.history.go;
		hasher.replaceHash = function (sHash) {
			bKnownHashChange = true;
			var sOldHash = this.getHash();
			sCurrentHash = sHash;
			oHashChanger.fireEvent("hashReplaced",{ sHash : sHash });
			this.changed.dispatch(sHash, sOldHash);
		};
		hasher.setHash = function (sHash) {
			bKnownHashChange = true;
			var sRealCurrentHash = fnOriginalGetHash.call(this);
			sCurrentHash = sHash;
			oHashChanger.fireEvent("hashSet", { sHash : sHash });
			fnOriginalSetHash.apply(this, arguments);
			if (sRealCurrentHash === this.getHash()) {
				this.changed.dispatch(sRealCurrentHash, oHistory.aHistory[oHistory.iHistoryPosition]);
			}
		};
		hasher.getHash = function() {
			if (sCurrentHash === undefined) {
				return fnOriginalGetHash.apply(this, arguments);
			}
			return sCurrentHash;
		};
		hasher.changed.add(function (sNewHash) {
			if (!bKnownHashChange) {
				oHashChanger.fireEvent("hashSet", { sHash : sNewHash });
				sCurrentHash = sNewHash;
			}
			bKnownHashChange = false;
		});
		oHashChanger.init();
		function goBack () {
			bKnownHashChange = true;
			var sNewPreviousHash = oHistory.aHistory[oHistory.iHistoryPosition],
				sNewCurrentHash = oHistory.getPreviousHash();
			sCurrentHash = sNewCurrentHash;
			hasher.changed.dispatch(sNewCurrentHash, sNewPreviousHash);
		}
		function goForward () {
			bKnownHashChange = true;
			var sNewCurrentHash = oHistory.aHistory[oHistory.iHistoryPosition + 1],
				sNewPreviousHash = oHistory.aHistory[oHistory.iHistoryPosition];
			if (sNewCurrentHash === undefined) {
				Log.error("Could not navigate forwards, there is no history entry in the forwards direction", this);
				return;
			}
			sCurrentHash = sNewCurrentHash;
			hasher.changed.dispatch(sNewCurrentHash, sNewPreviousHash);
		}
		oFrameWindow.history.back = goBack;
		oFrameWindow.history.forward = goForward;
		oFrameWindow.history.go = function (iSteps) {
			if (iSteps === -1) {
				goBack();
				return;
			} else if (iSteps === 1) {
				goForward();
				return;
			}
			Log.error("Using history.go with a number greater than 1 is not supported by OPA5", this);
			return fnOriginalGo.apply(oFrameWindow.history, arguments);
		};
	}
function modifyIFrameNavigation ( hasher , History , HashChanger ) { var oHashChanger = new HashChanger ( ) , oHistory = new History ( oHashChanger ) , fnOriginalSetHash = hasher . setHash , fnOriginalGetHash = hasher . getHash , sCurrentHash , bKnownHashChange = false , fnOriginalGo = oFrameWindow . history . go ; hasher . replaceHash = function ( sHash ) { bKnownHashChange = true ; var sOldHash = this . getHash ( ) ; sCurrentHash = sHash ; oHashChanger . fireEvent ( "hashReplaced" , { sHash : sHash } ) ; this . changed . dispatch ( sHash , sOldHash ) ; } ; hasher . setHash = function ( sHash ) { bKnownHashChange = true ; var sRealCurrentHash = fnOriginalGetHash . call ( this ) ; sCurrentHash = sHash ; oHashChanger . fireEvent ( "hashSet" , { sHash : sHash } ) ; fnOriginalSetHash . apply ( this , arguments ) ; if ( sRealCurrentHash === this . getHash ( ) ) { this . changed . dispatch ( sRealCurrentHash , oHistory . aHistory [ oHistory . iHistoryPosition ] ) ; } } ; hasher . getHash = function ( ) { if ( sCurrentHash === undefined ) { return fnOriginalGetHash . apply ( this , arguments ) ; } return sCurrentHash ; } ; hasher . changed . add ( function ( sNewHash ) { if ( ! bKnownHashChange ) { oHashChanger . fireEvent ( "hashSet" , { sHash : sNewHash } ) ; sCurrentHash = sNewHash ; } bKnownHashChange = false ; } ) ; oHashChanger . init ( ) ; function goBack ( ) { bKnownHashChange = true ; var sNewPreviousHash = oHistory . aHistory [ oHistory . iHistoryPosition ] , sNewCurrentHash = oHistory . getPreviousHash ( ) ; sCurrentHash = sNewCurrentHash ; hasher . changed . dispatch ( sNewCurrentHash , sNewPreviousHash ) ; } function goForward ( ) { bKnownHashChange = true ; var sNewCurrentHash = oHistory . aHistory [ oHistory . iHistoryPosition + 1 ] , sNewPreviousHash = oHistory . aHistory [ oHistory . iHistoryPosition ] ; if ( sNewCurrentHash === undefined ) { Log . error ( "Could not navigate forwards, there is no history entry in the forwards direction" , this ) ; return ; } sCurrentHash = sNewCurrentHash ; hasher . changed . dispatch ( sNewCurrentHash , sNewPreviousHash ) ; } oFrameWindow . history . back = goBack ; oFrameWindow . history . forward = goForward ; oFrameWindow . history . go = function ( iSteps ) { if ( iSteps === - 1 ) { goBack ( ) ; return ; } else if ( iSteps === 1 ) { goForward ( ) ; return ; } Log . error ( "Using history.go with a number greater than 1 is not supported by OPA5" , this ) ; return fnOriginalGo . apply ( oFrameWindow . history , arguments ) ; } ; }
Disables most of the navigation in an IFrame, only setHash has an effect on the real IFrame history after running this function.
Disables most of the navigation in an IFrame only setHash has an effect on the real IFrame history after running this function .
// replace hash is only allowed if it is triggered within the inner window. Even if you trigger an event from the outer test, it will not work. // Therefore we have mock the behavior of replace hash. If an application uses the dom api to change the hash window.location.hash, this workaround will fail. // fire the secret events for the local history so the recording is correct. // The hash changer is not the global singleton it is a local one only used in this scope for the history. // fire the secret events for the local history so the recording is correct. // The hash changer is not the global singleton it is a local one only used in this scope for the history. // Happens when setHash("a") back setHash("a") is called. // Then dispatch the previous hash as new one because hasher does not dispatch if the real hash stays the same // always dispatch the current position of the history, since this can only happen in the backwards / forwards direction // This function also needs to be manipulated since hasher does not know about our intercepted replace //initial hash // when a link is clicked or the hash is directly set we only get a changed event. // only if the change does not come from the other known places it is likely to be a pressed link // fire the secret events for the local history so the recording is correct. // The hash changer is not the global singleton it is a local one only used in this scope for the history.