Created
May 20, 2012 16:54
-
-
Save Amitesh/2758752 to your computer and use it in GitHub Desktop.
Sample js class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Description | |
* Author: Amitesh Kumar ([email protected]) | |
* Date: 20th May, 2012 | |
* | |
*/ | |
/** | |
* Module to display social info about a place | |
*/ | |
// create the namespace | |
window.App = {}; | |
// sub namespaces | |
App.Widget = {}; | |
( function ( App, document, $) { | |
var Widget = function () { | |
this.setup(); | |
}; | |
Widget.prototype = { | |
// DOM id of the widget container | |
ID: 'announceit-widget-container', | |
/** | |
* Initializes the Widget container and makes a initial | |
* request to get the necessary view HTML code. | |
*/ | |
setup: function () { | |
var element = $( '<div></div>', { id: this.ID } ); | |
this.getHTML( element ); | |
}, | |
/** | |
* Add event handlers, be sure to use 'namespaced' events | |
* in order to unbind easily | |
*/ | |
attachEventHandlers: function () { | |
var me = this; | |
// close dialog handler | |
this.element.on( 'click.ait', 'a.close', function ( e ) { | |
e.preventDefault(); | |
me.hide(); | |
} ); | |
}, | |
/** | |
* Destroys the widget view | |
*/ | |
destroy: function () { | |
} | |
}; | |
// export | |
App.Widget = new Widget(); | |
} )( App, document, jQuery ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment