Skip to content

Instantly share code, notes, and snippets.

@brendankowitz
Created November 29, 2012 06:39
Show Gist options
  • Save brendankowitz/4167197 to your computer and use it in GitHub Desktop.
Save brendankowitz/4167197 to your computer and use it in GitHub Desktop.
Better than revealing module pattern?
(function ($, exports) {
'use strict';
exports.Site = function (el) {
this.el = el;
/* Private Methods */
function initSearch() {
el.find("#site-search-form").submit(function (e) {
var searchInput = $(this).find("input[type='text']");
var query = searchInput.val();
if (query.length > 0) {
window.location = $(this).find("select").val() + "?q=" + query;
} else {
el.find("#searchTerm").effect("highlight", {}, 3000);
}
return false;
});
}
function init3Col() {
if (el.find("#rightContentContainer").length > 0) {
el.find("#pageContainer").addClass("content3Col");
}
}
/* Public Methods */
this.init = function () {
initSearch();
init3Col();
};
};
}(jQuery, window));
$(function () {
var siteInstance = new Site(jQuery("body"));
siteInstance.init();
});
@liammclennan
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment