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
/*! | |
* remove all children of parent element | |
* gist.github.com/englishextra/da26bf39bc90fd29435e8ae0b409ddc3 | |
* @param {Object} e parent HTML Element | |
* removeChildren(e) | |
*/ | |
var removeChildren=function(e){if(e&&e.firstChild)for(;e.firstChild;)e.removeChild(e.firstChild)}; |
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
/*! | |
* remove element from DOM | |
* gist.github.com/englishextra/d2a286f64d404052fbbdac1e416ab808 | |
* @param {Object} e an Element to remove | |
* removeElement(e) | |
*/ | |
var removeElement=function(e){var r="remove",pN="parentNode";if(e){if("undefined"!==typeof e[r]){return e[r]();}else{return e[pN]&&e[pN].removeChild(e);};}}; |
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
/*! | |
* Create Fragment from string/element | |
* gist.github.com/englishextra/974922256540c9570e969096a00765bc | |
* @param {String|object} e a text string or HTML Element to convert to fragment | |
* createFragment(e) | |
*/ | |
var createFragment=function(e){"string"===typeof e&&(e=document.createTextNode(e));var df=document.createDocumentFragment();df.appendChild(e);return df;}; |
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
/*! | |
* append node into other with fragment | |
* gist.github.com/englishextra/0ff3204d5fb285ef058d72f31e3af766 | |
* @param {String|object} e an HTML Element to append | |
* @param {Object} a target HTML Element | |
* appendFragment(e,a) | |
*/ | |
var appendFragment=function(e,a){"use strict";a=a||d.getElementsByTagNames("body")[0]||"";var g=function(){if(e){var d=document,df=d.createDocumentFragment()||"",aC="appendChild";if("string"===typeof e){e=d.createTextNode(e);};df[aC](e);a[aC](df);}};return g();}; |
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
/*! | |
* insert text response as fragment into element | |
* gist.github.com/englishextra/4e13afb8ce184ad28d77f6b5eed71d1f | |
* @param {String} t text/response to insert | |
* @param {Object} c target HTML Element | |
* @param {Object} [cb] callback function | |
* insertTextAsFragment(t,c,cb) | |
*/ | |
var insertTextAsFragment = function (t, c, cb) { | |
"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
/*! | |
* modified github.com/englishextra/deepclone | |
* gist.github.com/englishextra/806a8d0c8a2ca5cceaa2651044331cf1 | |
* performs deep clone. Not able to deep clone closures, enclosed values | |
* still point to original reference, so this is not full deep clone in all situations. | |
* Anyway it is able to detect circular references | |
*/ | |
var DeepClone = function () { | |
function clone(x) { | |
if (isArray(x)) { |
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
/*! | |
* if element is in viewport | |
* gist.github.com/englishextra/2e9322e5eea9412f5086f7427009b903 | |
* stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport | |
* jsfiddle.net/englishextra/9mwdxgez/ | |
* @param e an HTML element | |
* var p = document.getElementById("h1") || ""; | |
* if(p){var g=function(_that){if(isInViewport(p)) | |
* {window.removeEventListener("scroll",_that);alert(1);}}; | |
* window.addEventListener("scroll",function h_w(){g(h_w);});} |
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
/*! | |
* modified for babel ToProgress v0.1.1 | |
* http://github.com/djyde/ToProgress | |
* gist.github.com/englishextra/6a8c79c9efbf1f2f50523d46a918b785 | |
* jsfiddle.net/englishextra/z5xhjde8/ | |
* arguments.callee changed to TP, a local wrapper function, | |
* so that public function name is now customizable; | |
* wrapped in curly brackets: | |
* else{document.body.appendChild(this.progressBar);}; | |
* removed AMD, CommonJS support |
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
/*! | |
* Plain javascript replacement for jQuery's .ready() | |
* so code can be scheduled to run when the document is ready | |
* github.com/jfriend00/docReady | |
* gist.github.com/englishextra/7c22a9a9cae3320318e9c9eab6777c84 | |
* docReady(function(){}); | |
* simple substitute by Christoph at stackoverflow.com/questions/8100576/how-to-check-if-dom-is-ready-without-a-framework | |
* (function(){var a=document.readyState;"interactive"===a||"complete"===a?(function(){}()):setTimeout(arguments.callee,100)})(); | |
*/ | |
(function(funcName,baseObj){"use strict";funcName=funcName||"docReady";baseObj=baseObj||window;var readyList=[];var readyFired=false;var readyEventHandlersInstalled=false;function ready(){if(!readyFired){readyFired=true;for(var i=0;i<readyList.length;i++){readyList[i].fn.call(window,readyList[i].ctx);}readyList=[];}}function readyStateChange(){if(document.readyState==="complete"){ready();}}baseObj[funcName]=function(callback,context){if(readyFired){setTimeout(function(){callback(context);},1);return;}else{readyList.pu |
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
/*! | |
* modified JavaScript image preloader with callback | |
* gist.github.com/eikes/3925183 | |
* gist.github.com/englishextra/bcaca065f3fbd6d29841f9e970dcdb73 | |
* jsfiddle.net/englishextra/r6rf51mL/ | |
* @param {String|object} a string/array of paths | |
* @param {Object} [cb] callback function | |
* preloadImages(["//farm2.staticflickr.com/1698/24651691653_41661b1f59_z.jpg", | |
* "//farm2.staticflickr.com/1575/24651691753_40fc6fdc5e_z.jpg"], | |
* function(a){for(var j=0,l=a.length;j<l;j+=1){alert(a[j].src);};}); |