Skip to content

Instantly share code, notes, and snippets.

@mboudreau
Created May 30, 2012 15:24
Show Gist options
  • Save mboudreau/2836991 to your computer and use it in GitHub Desktop.
Save mboudreau/2836991 to your computer and use it in GitHub Desktop.
// Enable Strict Mode and remove errors relating to global vars
/*global $:false, jQuery:false, google:false, _gaq:false, _:false */
"use strict";
goog.provide('com.tivity.Main');
goog.require('goog.ui.Component');
goog.require('goog.dom');
// Composites
goog.require('com.tivity.Header');
goog.require('com.tivity.Footer');
// Templates
goog.require('com.tivity.templates.main');
com.tivity.Main = function(domHelper) {
goog.ui.Component.call(this, domHelper);
this.header_ = new com.tivity.Header();
this.footer_ = new com.tivity.Footer();
/**
* Event handler for this object.
* @type goog.events.EventHandler
* @private
*/
this.eh_ = new goog.events.EventHandler(this);
/**
* Keyboard handler for this object. This object is created once the
* component's DOM element is known.
*
* @type goog.events.KeyHandler|Null
* @private
*/
this.kh_ = null;
goog.base(this);
};
goog.inherits(com.tivity.Main, goog.ui.Component);
goog.addSingletonGetter(com.tivity.Main);
com.tivity.Main.prototype.createDom = function() {
this.header_.render();
this.decorateInternal(com.tivity.templates.main());
this.footer_.render();
};
com.tivity.Main.prototype.enterDocument = function() {
com.tivity.Main.superClass_.enterDocument.call(this);
// Add event listener
/* this.eh_.listen(this.getContentElement(), goog.events.EventType.CLICK,
this.onDivClicked_);*/
};
com.tivity.Main.prototype.exitDocument = function() {
// Remove all event listeners/ui elements
};
com.tivity.Main.prototype.dispose = function() {
// Remove all remaining elements that are being cached
if (!this.isDisposed()) {
com.tivity.Main.superClass_.dispose.call(this);
this.eh_.dispose();
if (this.kh_) {
this.kh_.dispose();
}
}
};
/*
com.tivity.Main.prototype.initHistory = function() {
var h;
try {
h = new goog.history.Html5History();
} catch (e) {
document.write(e.message);
}
if (h) {
var cur = 'kittens';
goog.events.listen(h, goog.history.EventType.NAVIGATE, function(e) {
var token = e.token || 'kittens';
var next = document.getElementById(token);
if (next) {
document.getElementById(cur).className = 'section';
next.className = 'section active';
cur = token;
}
});
h.setUseFragment(false);
h.setPathPrefix(new goog.Uri(document.location.href).getPath() + '/');
h.setEnabled(true);
goog.events.listen(
document.getElementById('links'), 'click', function(e) {
if (e.target.tagName == 'A') {
h.setToken(e.target.getAttribute('token'), e.target.title);
e.preventDefault();
}
});
}
}*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment