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
$('body').on('touchstart click', $staticSection, function(e) { | |
var $target = $(e.target); | |
if(!$target.closest($someSection).length) { | |
// do something... ex: $someSection.removeClass('open'); | |
} | |
}); | |
// conditional example | |
$('body').on('touchstart click', $staticSection, function(e) { |
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
var yourFunction = function(id) { | |
var _somePath, | |
_img, | |
conditionA = !! (window.someGlobalVar === 5), // if you need internal ternary conditions (path switching for example) | |
conditionB = !! (window.someGlobalVar === 10), | |
conditionC = !! (window.someGlobalVar === 15); | |
switch (id) { | |
case 'some-id-name-1': | |
// do something |
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
var someFn = function() { | |
$('<style></style>').appendTo($(document.body)).remove(); // force safari redraw | |
}; |
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
// Released under MIT license: http://www.opensource.org/licenses/mit-license.php | |
$('[placeholder]').focus(function() { | |
var input = $(this); | |
if (input.val() === input.attr('placeholder')) { | |
input.val(''); | |
input.removeClass('placeholder'); | |
} | |
}).blur(function() { | |
var input = $(this); |
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
// Var & Function Syntax // WIP | |
var someName; // a variable on the local scope | |
someName; // a variable on the global scope | |
window.someName; // a production friendly variable on the global scope | |
// note: when making a reference to any var with a specific namespace, | |
// make sure you specify it in the call | |
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
var cities = ["Melbourne", "Amman", "Helsinki", "NYC", "Tulsa", "Nome"]; | |
for (var i = 0; i < cities.length; i++) { | |
console.log("I would like to visit " + cities[i]); | |
} |
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
for (var i=1; i<26; i = i++) { // counting from 1 to 25 | |
console.log(i); | |
} | |
for (var i = 5; i < 51; i+=5) { // counting from 5 to 50 in increments of 5 | |
console.log(i); | |
} | |
for (var i=8; i<120; i+=12) { // counting from 8 to 119 in increments of 12 | |
console.log(i); |
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
var url = document.referrer, | |
urlsplit = url.split("/").pop(); | |
$('body').addClass(urlsplit); |
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
$('#element').click(function() { | |
if ($(this).data('clicked')) { | |
$(this).css({'display': 'block'}); | |
$(this).data('clicked', false); | |
} else { | |
$(this).css({'display': 'none'}); | |
$(this).data('clicked', true); | |
} | |
}); |