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() { | |
if (!Event.prototype.preventDefault) { | |
Event.prototype.preventDefault=function() { | |
this.returnValue=false; | |
}; | |
} | |
if (!Event.prototype.stopPropagation) { | |
Event.prototype.stopPropagation=function() { | |
this.cancelBubble=true; | |
}; |
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 $(sel) { | |
if (!sel) { | |
return document.body; | |
} | |
var r = document.querySelectorAll(sel); | |
return r.length == 1 ? r[0] : Array.prototype.slice.call(r); | |
} | |
$.matches = function(el, sel) { | |
var matchesSelector = el.webkitMatchesSelector || el.mozMatchesSelector || |
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
// Evento - v1.0.0 | |
// by Erik Royall <erikroyalL@hotmail.com> (http://erikroyall.github.io) | |
// Dual licensed under MIT and GPL | |
// Array.prototype.indexOf shim | |
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf | |
if (!Array.prototype.indexOf) { | |
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { | |
'use strict'; |
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 test_jQuery() { jQuery(""); } | |
function success_jQuery() { alert("jQuery is loaded!"); | |
var successfully_loaded = false; | |
function loadOrFallback(scripts,idx) { | |
function testAndFallback() { | |
clearTimeout(fallback_timeout); | |
if (successfully_loaded) return; // already loaded successfully, so just bail | |
try { | |
scripts[idx].test(); |
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
/** | |
* Loads javascript file by url and saves reference to it by name, so it's not loaded again | |
* @param {string} name Name of js library | |
* @param {string} url Url to js library | |
* @return {promise} Resolves when library is loaded | |
* | |
* Based on example by Brad Berger: https://bradb.net/blog/promise-based-js-script-loader/ | |
* Extended w/ global variable to keep track of previously loaded scripts. | |
* Removed support for loading several independent scripts at once via Promise.all() | |
* |
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() { | |
if (!Event.prototype.preventDefault) { | |
Event.prototype.preventDefault=function() { | |
this.returnValue=false; | |
}; | |
} | |
if (!Event.prototype.stopPropagation) { | |
Event.prototype.stopPropagation=function() { | |
this.cancelBubble=true; | |
}; |
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
/* | |
* Trying to feature-detect (very naive) | |
* CSS Flexbox support. | |
* - Only most modern syntax | |
* | |
* Is this nonsense? | |
*/ | |
(function NaiveFlexBoxSupport(d){ | |
var f = "flex", e = d.createElement('b'); |
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
'use strict'; | |
// Add ECMA262-5 method binding if not supported natively | |
// | |
if (!('bind' in Function.prototype)) { | |
Function.prototype.bind= function(owner) { | |
var that= this; | |
if (arguments.length<=1) { | |
return function() { | |
return that.apply(owner, arguments); |
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
// document.ready | |
document.addEventListener("DOMContentLoaded", function() { | |
// your code | |
}, false); | |
// select div | |
var element = document.querySelector("div"); |
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
// long version | |
function loadExt(files, after) { | |
var _this=this; | |
_this.files = files; | |
_this.js = []; | |
_this.head = document.getElementsByTagName("head")[0]; | |
_this.after = after || function(){}; | |
_this.loadStyle = function(file) { | |
var link = document.createElement("link"); | |
link.rel = "stylesheet"; |
OlderNewer