Cheat sheet extracted from https://www.youtube.com/watch?v=2zmUSoVMyRU by That JS Dude.
If you pass any of the CSS selectors to $(<identifier>)
you get the first element.
> $('a')
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
(function ($, window, document, undefined) { | |
var pluginName = "elementInView", | |
defaults = { | |
visibleWhenRatio: 0, | |
cb: $.noop, | |
outsideViewCallback: $.noop, | |
debounce: 100, | |
onlyOnce: true | |
}; |
window.ikiThemes.Utils = (function ($) { | |
return { | |
//http://nodejs.org/docs/latest/api/util.html#util_util_inherits_constructor_superconstructor | |
inherits: function inherits(ctor, superCtor) { | |
ctor.super_ = superCtor; | |
ctor.prototype = Object.create(superCtor.prototype); | |
}, | |
inheritsOLOO: function (superCtor) { | |
var o = Object.create(superCtor); |
Cheat sheet extracted from https://www.youtube.com/watch?v=2zmUSoVMyRU by That JS Dude.
If you pass any of the CSS selectors to $(<identifier>)
you get the first element.
> $('a')
angular.module('uiElements', []).directive('ikiLadda', [function () { | |
if (typeof Ladda === 'undefined') { | |
throw new Error('Ladda Library Missing'); | |
// Ladda also depends on Spinner and it will throw error if that library is not present. | |
} | |
return { |
var bob = new MyClass(); | |
bob.set_name('Bob'); | |
bob.announce(); // id is 1, name shows as "Bob" | |
var john = new MyChildClass('Doe'); | |
john.set_name('John'); | |
john.announce(); // id is 2, name shows as "John Doe" | |
alert(john instanceof MyClass); // true |
/ antipattern | |
// for illustration only | |
// global functions | |
function foo() { | |
alert('global foo'); | |
} | |
function bar() { | |
alert('global bar'); | |
} | |
function hoistMe() { |
// this is a function expression, | |
// pased as an argument to the function `callMe` | |
callMe(function () { | |
// I am an unnamed function expression | |
// also known as an anonymous function | |
}); | |
Background | 59 | |
// this is a named function expression | |
callMe(function me() { | |
// I am a named function expression |
var myFunc = function (param) { | |
if (!myFunc.cache[param]) { | |
var result = {}; | |
// ... expensive operation ... | |
myFunc.cache[param] = result; | |
} | |
return myFunc.cache[param]; | |
}; | |
// cache storage | |
myFunc.cache = {} |
add_action('after_setup_theme','theme_setup'); | |
function theme_setup() | |
{ | |
add_theme_support('prefix-someCPT'); | |
} |