website/pages/generator/generatorPage.js
function(msg) {
		if (!_firstPageLoaded) {
			if (msg.data.pageHash !== "generator-result") {
				_firstPage = msg.data.page;
			}
			_firstPageLoaded = true;
		}
		if (msg.data.page !== "generator") {
			return;
		}

		var pageHash = msg.data.pageHash;
		var tab = (_currentTab) ? _currentTab : "generator-start";
		if ($.inArray(pageHash, _tabs) !== -1) {
			tab = pageHash;
		}

		if (pageHash === "generator-result") {
			_sendDemoPieData();
			$("#sidebar,#pieChartDiv").addClass("fadeOut");
			setTimeout(function() {
				$("#sidebar,#pieChartDiv").addClass("hidden").removeClass("fadeOut");
				$("#generator-result").removeClass("hidden fadeOut").addClass("fadeIn");
			}, C.OTHER.PAGE_LOAD_SPEED);
		} else if (pageHash === "generator" && tab === "generator-result") {
			// do nothing. This happens when a user's on the generator-result tab, goes to
			// another page (not tab), then clicks back to the generator tab
		} else {
			// if the previous tab was generator-result
			if (_currentTab === "generator-result") {
				$("#generator-result").addClass("fadeOut");
				setTimeout(function() {
					$("#generator-result").addClass("hidden").removeClass("fadeOut");
					_renderWithNoAnimation();
					$("#sidebar,#pieChartDiv").removeClass("hidden fadeOut").addClass("fadeIn");
				}, C.OTHER.PAGE_LOAD_SPEED);
			}
		}

		if (msg.data.pageHash.match(/pie\d$/)) {
			var index = pageHelper.getDemoPieChartIndex(EXAMPLE_PIES);
			_loadDemoPie(EXAMPLE_PIES[index]);
		}

		var $generatorTabs = $("#generatorTabs");

		// now show the appropriate tab
		if (_currentTab === null) {
			$generatorTabs.find("a[href=#" + tab + "]").closest("li").addClass("active");
			$("#" + tab).removeClass("fadeOut hidden").addClass("fadeIn");
			_renderWithAnimation();
		} else {
			$generatorTabs.find("a[href=#" + _currentTab + "]").closest("li").removeClass("active");
			$generatorTabs.find("a[href=#" + tab + "]").closest("li").addClass("active");
			$("#" + _currentTab).removeClass("hidden fadeIn").addClass("fadeOut");

			// another klutzy workaround
			if (pageHash === "generator" && tab === "generator-result") {
				$("#" + tab).removeClass("hidden fadeOut");
			} else {
				(function(ct) {
					setTimeout(function() {
						$("#" + ct).addClass("hidden").removeClass("fadeOut");
						$("#" + tab).removeClass("hidden fadeOut").addClass("fadeIn");
					}, C.OTHER.PAGE_LOAD_SPEED);
				})(_currentTab);
			}
		}
		_currentTab = tab;
	}
function(msg) {
		if (!_firstPageLoaded) {
			if (msg.data.pageHash !== "generator-result") {
				_firstPage = msg.data.page;
			}
			_firstPageLoaded = true;
		}
		if (msg.data.page !== "generator") {
			return;
		}

		var pageHash = msg.data.pageHash;
		var tab = (_currentTab) ? _currentTab : "generator-start";
		if ($.inArray(pageHash, _tabs) !== -1) {
			tab = pageHash;
		}

		if (pageHash === "generator-result") {
			_sendDemoPieData();
			$("#sidebar,#pieChartDiv").addClass("fadeOut");
			setTimeout(function() {
				$("#sidebar,#pieChartDiv").addClass("hidden").removeClass("fadeOut");
				$("#generator-result").removeClass("hidden fadeOut").addClass("fadeIn");
			}, C.OTHER.PAGE_LOAD_SPEED);
		} else if (pageHash === "generator" && tab === "generator-result") {
			// do nothing. This happens when a user's on the generator-result tab, goes to
			// another page (not tab), then clicks back to the generator tab
		} else {
			// if the previous tab was generator-result
			if (_currentTab === "generator-result") {
				$("#generator-result").addClass("fadeOut");
				setTimeout(function() {
					$("#generator-result").addClass("hidden").removeClass("fadeOut");
					_renderWithNoAnimation();
					$("#sidebar,#pieChartDiv").removeClass("hidden fadeOut").addClass("fadeIn");
				}, C.OTHER.PAGE_LOAD_SPEED);
			}
		}

		if (msg.data.pageHash.match(/pie\d$/)) {
			var index = pageHelper.getDemoPieChartIndex(EXAMPLE_PIES);
			_loadDemoPie(EXAMPLE_PIES[index]);
		}

		var $generatorTabs = $("#generatorTabs");

		// now show the appropriate tab
		if (_currentTab === null) {
			$generatorTabs.find("a[href=#" + tab + "]").closest("li").addClass("active");
			$("#" + tab).removeClass("fadeOut hidden").addClass("fadeIn");
			_renderWithAnimation();
		} else {
			$generatorTabs.find("a[href=#" + _currentTab + "]").closest("li").removeClass("active");
			$generatorTabs.find("a[href=#" + tab + "]").closest("li").addClass("active");
			$("#" + _currentTab).removeClass("hidden fadeIn").addClass("fadeOut");

			// another klutzy workaround
			if (pageHash === "generator" && tab === "generator-result") {
				$("#" + tab).removeClass("hidden fadeOut");
			} else {
				(function(ct) {
					setTimeout(function() {
						$("#" + ct).addClass("hidden").removeClass("fadeOut");
						$("#" + tab).removeClass("hidden fadeOut").addClass("fadeIn");
					}, C.OTHER.PAGE_LOAD_SPEED);
				})(_currentTab);
			}
		}
		_currentTab = tab;
	}
function ( msg ) { if ( ! _firstPageLoaded ) { if ( msg . data . pageHash !== "generator-result" ) { _firstPage = msg . data . page ; } _firstPageLoaded = true ; } if ( msg . data . page !== "generator" ) { return ; } var pageHash = msg . data . pageHash ; var tab = ( _currentTab ) ? _currentTab : "generator-start" ; if ( $ . inArray ( pageHash , _tabs ) !== - 1 ) { tab = pageHash ; } if ( pageHash === "generator-result" ) { _sendDemoPieData ( ) ; $ ( "#sidebar,#pieChartDiv" ) . addClass ( "fadeOut" ) ; setTimeout ( function ( ) { $ ( "#sidebar,#pieChartDiv" ) . addClass ( "hidden" ) . removeClass ( "fadeOut" ) ; $ ( "#generator-result" ) . removeClass ( "hidden fadeOut" ) . addClass ( "fadeIn" ) ; } , C . OTHER . PAGE_LOAD_SPEED ) ; } else if ( pageHash === "generator" && tab === "generator-result" ) { // do nothing. This happens when a user's on the generator-result tab, goes to // another page (not tab), then clicks back to the generator tab } else { // if the previous tab was generator-result if ( _currentTab === "generator-result" ) { $ ( "#generator-result" ) . addClass ( "fadeOut" ) ; setTimeout ( function ( ) { $ ( "#generator-result" ) . addClass ( "hidden" ) . removeClass ( "fadeOut" ) ; _renderWithNoAnimation ( ) ; $ ( "#sidebar,#pieChartDiv" ) . removeClass ( "hidden fadeOut" ) . addClass ( "fadeIn" ) ; } , C . OTHER . PAGE_LOAD_SPEED ) ; } } if ( msg . data . pageHash . match ( / pie\d$ / ) ) { var index = pageHelper . getDemoPieChartIndex ( EXAMPLE_PIES ) ; _loadDemoPie ( EXAMPLE_PIES [ index ] ) ; } var $generatorTabs = $ ( "#generatorTabs" ) ; // now show the appropriate tab if ( _currentTab === null ) { $generatorTabs . find ( "a[href=#" + tab + "]" ) . closest ( "li" ) . addClass ( "active" ) ; $ ( "#" + tab ) . removeClass ( "fadeOut hidden" ) . addClass ( "fadeIn" ) ; _renderWithAnimation ( ) ; } else { $generatorTabs . find ( "a[href=#" + _currentTab + "]" ) . closest ( "li" ) . removeClass ( "active" ) ; $generatorTabs . find ( "a[href=#" + tab + "]" ) . closest ( "li" ) . addClass ( "active" ) ; $ ( "#" + _currentTab ) . removeClass ( "hidden fadeIn" ) . addClass ( "fadeOut" ) ; // another klutzy workaround if ( pageHash === "generator" && tab === "generator-result" ) { $ ( "#" + tab ) . removeClass ( "hidden fadeOut" ) ; } else { ( function ( ct ) { setTimeout ( function ( ) { $ ( "#" + ct ) . addClass ( "hidden" ) . removeClass ( "fadeOut" ) ; $ ( "#" + tab ) . removeClass ( "hidden fadeOut" ) . addClass ( "fadeIn" ) ; } , C . OTHER . PAGE_LOAD_SPEED ) ; } ) ( _currentTab ) ; } } _currentTab = tab ; }
Bloody awful function! This is called whenever the page/tab is changed. It got way out of control. Nav should
be moved to a single, top-level area.
@param msg
@private
Bloody awful function! This is called whenever the page / tab is changed . It got way out of control . Nav should be moved to a single top - level area .