View jquery.notextSelector.js
/*
jQuery's ':empty' selector only returns true if the element contains no text node, or whose text node consists exclusively of zero or more spaces and tabs. This ':notext' selector will return true for elements whose text nodes can also contain line breaks (any whitespace character) and HTML comments.
*/
$.expr[':'].notext = function detectNoText(x){
return x.innerHTML && x.innerHTML.replace(/(<!--.*(?!-->))|\s+/g, '').length === 0
}
View html.loading.snippet.html
<script>
// add a class of 'loading' to the HTML, then remove it once the page has finished loading
(function(c){
c('scripted loading')
window.onload = function(){setTimeout(function(){
c(c().replace('loading',''))
},30)}
}(function(c){
var h = document.lastChild
return c ? h.className = c : h.className
View uriQueryObj.js
/* Return an object model of a URI query (search or hash) */
function uriQueryObj(str){
if(!str) return false;
var str = decodeURIComponent(str),
str = /(^#)|(^$)/.test(str) ? str.substr(1) : str,
arr = str.substr(1).split('&'),
hash = {};
while(arr.length && arr[0]){
var bits = arr.pop().split('=')
View detectCSS.js
// Is the passed CSS property supported?
// eg. detectCSS('transition')
function detectCSS(prop){
var
prop = prop.replace(/-(\w)/g,function(s,g){return g.toUpperCase()}),
pre = ',Icab,Khtml,Moz,Ms,O,Webkit'.split(',');
for (var i = 0; i < pre.length; ++i){
if(i==1)
prop = prop.slice(0,1).toUpperCase() + prop.slice(1);
View fixText.css
.background {
background: rgb(247,247,247);
}
.fixText {
text-shadow: 0 0 1px rgba(247,247,247,.5);
}
View onload.js
// Stack window.onload functions
function addLoad(func){
var old = window.onload;
func instanceof Function
&& (window.onload =
old instanceof Function
? function(){func();old()}
: func);
};
View asyncFrames.js
// iframes delay page load: cut them out and in to reduce synchronous dependency
function asyncFrames(){
$('iframe').each(function(){
var
markup = $(this).clone(),
guide = $('<b>').replaceAll(this);
// addLoad: https://gist.github.com/1226302
addLoad(function(){
guide.replaceWith(markup)
View writeStyle.js
function writeStyle(rules){
var head = document.getElementsByTagName('head')[0],
el = this.el || document.createElement('style'),
rules = rules || '';
if(!this.el)
el.type = 'text/css';
if(el.styleSheet){
el.styleSheet.cssText = rules;
View attrs.js
// Return all attributes, optionally filtered by RegExp
$.fn.attrs = function(expr){
var
el = this[0],
$el = this,
attrArray = [];
for(var i=0, attrs = el.attributes; i<attrs.length; ++i){
var attrKey = [
attrs.item(i).nodeName,
View $.outerHTML.js
// Cross-browser outerHTML: return it, or if an argument was passed, replace the element.
$.fn.outerHTML = function(arg){
var $el = this;
return arg
? $el.replaceWith(arg)
: $el.clone().wrap('<b>').parent().html();
};