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
86937 isset | |
43159 echo | |
31697 empty | |
29252 substr | |
26146 count | |
24248 is_array | |
22572 strlen | |
19365 sprintf | |
18090 unset | |
16584 str_replace |
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
src: http://stackoverflow.com/a/11978996 | |
Firstly, use an IMG tag in your HTML to embed an SVG graphic. I used Adobe Illustrator to make the graphic. | |
<img id="facebook-logo" class="svg social-link" src="/images/logo-facebook.svg"/> | |
This is just like how you'd embed a normal image. Note that you need to set the IMG to have a class of svg. The 'social-link' class is just for examples sake. The ID is not required, but is useful. | |
Then use this jQuery code (in a separate file or inline in the HEAD). | |
/* | |
* Replace all SVG images with inline SVG |
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
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating | |
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel | |
// MIT license | |
(function() { | |
var lastTime = 0; | |
var vendors = ['ms', 'moz', 'webkit', 'o']; | |
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; x++) { | |
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; | |
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame']; |
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
// a simple facade that masks the various browser-specific methods | |
function addEvent( element, event, callback ) { | |
if( window.addEventListener ) { | |
element.addEventListener( event, callback, false ); | |
} else if( document.attachEvent ) { | |
element.attachEvent( 'on' + event, callback ); | |
} else { | |
element[ 'on' + event ] = callback; | |
} |
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 MyModule = ( function( window, undefined ) { | |
// revealing module pattern ftw | |
function MyModule() { | |
function someMethod() { | |
alert( 'some method' ); | |
} | |
function someOtherMethod() { |
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
// Example 1 | |
mediator.name = 'Doug'; | |
mediator.subscribe('nameChange', function(arg){ | |
console.log(this.name); | |
this.name = arg; | |
console.log(this.name); | |
}); | |
mediator.publish('nameChange', 'Jorn'); |
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
// array utils | |
// ================================================================================================= | |
const combine = (...arrays) => [].concat(...arrays); | |
const compact = arr => arr.filter(Boolean); | |
const contains = (() => Array.prototype.includes | |
? (arr, value) => arr.includes(value) | |
: (arr, value) => arr.some(el => el === value) |
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(){ | |
var parse = JSON.parse; | |
JSON = { | |
stringify: JSON.stringify, | |
validate: function(str){ | |
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
// 4. Conditionally load the webcomponents polyfill if needed by the browser | |
function finishLazyLoading() { | |
window.Polymer = window.Polymer || { | |
dom: 'shady' //'shadow' | |
}; | |
// 6. Fade splash screen, then remove. | |
var onImportLoaded = function() { | |
var loadEl = document.getElementById('splash'); |
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'; | |
function foo() {} | |
// Node.js|CommonJS / AMD / Default to window as global | |
if (typeof module !== 'undefined' && module.exports) { | |
module.exports = exports = foo; | |
} else if (typeof define === 'function' && define.amd) { | |
define(function() { |
OlderNewer