A Pen by James Daly on CodePen.
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
// with this you can write .end(3) instead of .end().end().end() | |
(function(){ | |
// Define overriding method. | |
jQuery.fn.end = function(no_of_times){ | |
var prevObject = this.prevObject; | |
if (!(arguments.length) || (typeof no_of_times !== "number")) { | |
return this.prevObject || this.constructor(null); | |
} else { |
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
var myBooze = { | |
booze:['wine', 'beer', 'liquor'], | |
chosenBooze:[], | |
getBooze: function (type) { | |
var booze_length = this.booze.length | |
for (i=0; i < booze_length; i++) { | |
if (type === this.booze[i]) { | |
this.chosenBooze.push(this.booze[i]); | |
return this | |
} else { |
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
//drinking will call chooseWisely and will look for it's liquor property | |
//within the liquor property is a wine property that will get output | |
var drinking = function (who) { | |
var which_spirit = this.liquor.wine; | |
console.log(which_spirit) // this will output malbec | |
return true | |
}; | |
var chooseWisely = function (ohdeliciouswine, brewski, whiskey) { |
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
//polyfill for Object.create | |
if (!Object.create) { | |
Object.create = function (o) { | |
if (arguments.length > 1) { | |
throw new Error('Object.create implementation only accepts the first parameter.'); | |
} | |
function F() {} | |
F.prototype = o; | |
return new F(); | |
}; |
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
var beverages = ['juice', 'soda', 'beer'] | |
var func = function (thirsty, array, callback) { | |
array.push(thirsty); | |
var first = array[array.length - 1] | |
return callback(first); | |
} | |
func('water', beverages, function (param) { | |
return param |
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 inherit(C, P) { | |
var F = function () {}; | |
F.prototype = P.prototype; | |
C.prototype = new F(); | |
C.uber = P.prototype; | |
C.prototype.constructor = C; | |
} | |
function Parent () {} |
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
<script> | |
//this should probably be added to an external file | |
setTimeout(function () { | |
(function (w, d) { | |
var smallerScreen = "(max-width:990px)"; // this is set in movies.scss as part of media query | |
var removedTextArray = []; | |
var removedTextArrayone = []; | |
var relatedProductsContainer = $("#relatedProducts"); //normally set in ini | |
var $ul = $('div.btn-dropdown ul'); | |
var liFirstChild = $('div.product_content ul.product_description_list li:first-child'); |
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
var relatedProductsContainer = $("#relatedProducts"); | |
relatedProductsContainer.find('article').each(function(index, element) { | |
var containerHeight = [] | |
var $element = $(element); | |
var liFirstChild = $element.find('div.product_content ul.product_description_list li:first-child'); | |
var liLastChild = $element.find('div.product_content ul.product_description_list li:last-child'); | |
var liOnlyChild = $element.find('div.product_content ul.product_description_list li:only-child'); | |
var liSpanElement = liFirstChild.children('span:first-child'); | |
var lastLiSpanElement = liLastChild.children('span'); | |
var more = $('<a class="more_or_less more" style="cursor:pointer">more</a>'); //more trigger |
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
/* Word Game jQuery plugin | |
* | |
* @param {object} options | |
* @returns {settings object that override default} | |
* jQuery plugin | |
* current dependencies are jQuery ... duh | |
*/ | |
(function ($) { | |
$.fn.WordGame = function (options) { | |
var $container = $(this), |
OlderNewer