Skip to content

Instantly share code, notes, and snippets.

<head>
<link rel="stylesheet" href="base.css" />
<link rel="stylesheet" href="mobile.css" media="max-width: 320px" />
<!-- OR -->
<style type="text/css">
/* base styles go here */
@media (max-width: 320px)
$.fn.disable = function() {
return this.filter(':input').each(function() {
$(this).attr('disabled', 'disabled');
});
};
(function($) {
$.fn.enable = function() {
// Enable each selected element by removing its 'disabled' attribute.
return this.each(function() {
$(this).removeAttr('disabled');
});
};
$.fn.disable = function() {
(function(m) {
m.doStuff = function() {
// TODO: Stuff
};
})(window.deeply.nested.module);
window.deeply.nested.module.doStuff();
(function(module, undefined) {
// Anything declared at this level is only accessible within this
// function. Efectively, they will be the module's private variables.
var _answer = 42;
// The module's public interface is then defined by declaring variables on
// the module variable that was passed in.
module.getAnswer = function(question) {
var createPerson = function(name) {
var _name = name;
return {
getName: function() {
return _name;
}
};
};
var message = 'Hello!';
(function () {
var message;
alert(message);
message = 'Hi!';
})();
var message = 'Hello!';
(function() {
alert(message);
var message = 'Hi!';
})();
var message = 'Hello!';
(function() {
var message = 'Hi!';
alert(message);
})();
var gistPrefix = 'http://gist.github.com/',
// Cache document.write so that it can be restored once all Gists have been
// embedded.
cachedWrite = document.write,
body = $('body'),
// Map each p.gist to an object that contains the paragraph to be replaced
// and the Gist's identifier.
gists = $('p.gist').map(function(n, p) {
p = $(p);