Created
November 29, 2012 06:39
-
-
Save brendankowitz/4167197 to your computer and use it in GitHub Desktop.
Better than revealing module pattern?
This file contains 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
(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(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some tweaks https://gist.github.com/4167607