Skip to content

Instantly share code, notes, and snippets.

@hdragomir
hdragomir / $.fn.redraw.js
Created December 14, 2010 09:45
Quick jQuery plugin to force element redraws
(function($){
$.fn.redraw = function(){
return $(this).each(function(){
var n = document.createTextNode(' ');
$(this).append(n);
setTimeout(function(){n.parentNode.removeChild(n)}, 0);
});
}
})(jQuery)
@msaspence
msaspence / gist:11032254
Created April 18, 2014 08:47
Chosen with absolute positioning
// Chosen, a Select Box Enhancer for jQuery and Prototype
// by Patrick Filler for Harvest, http://getharvest.com
//
// Version 0.9.15
// Full source at https://github.com/harvesthq/chosen
// Copyright (c) 2011 Harvest http://getharvest.com
// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
// This file is generated by `cake build`, do not edit it by hand.
(function() {
@qhm123
qhm123 / gist:3087415
Created July 11, 2012 01:43
js relative path to absolute
// If it's a relative path, we need to make it absolute, using the
// reader's location (not the active component's location).
if (!url.match(/^\//)) {
var link = document.createElement('a');
link.setAttribute('href', url);
url = link.href;
delete(link);
}
@wintercn
wintercn / gist:5918272
Created July 3, 2013 14:18
CSS3 标准和属性对应数据
[
{
"spec name": "CSS Animations",
"uri": "http://www.w3.org/TR/css3-animations",
"category": "css-property",
"Name": "animation-name",
"Value": "<single-animation-name> [\n ‘,’ <single-animation-name> ]*",
"Initial": "‘none’",
"Applies To": "all elements, ::before and ::after pseudo-elements",
"Inherited": "no",
@fatso83
fatso83 / app.js
Last active December 31, 2015 07:29
This feature detects the actual event name used by the browser for transitionEnd . This might differ from Modernizr.prefixed('transition'). Known browsers+device affected by this: Chrome 27.0.1453.93 on Desktop/OS X, Android 4.1.2 browser running on Samsung Note II
// Defines prefixed versions of the
// transitionEnd event handler
transitionFinishedEvents = {
'WebkitTransition' : 'webkitTransitionEnd',
'MozTransition' : 'transitionend',
'OTransition' : 'oTransitionEnd',
'msTransition' : 'msTransitionEnd',
'transition' : 'transitionEnd'
};
// Define the correct transition event for this UA
@jed
jed / LICENSE.txt
Created May 25, 2011 14:15 — forked from 140bytes/LICENSE.txt
select DOM elements by ID, tag name, or class name
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@wintercn
wintercn / showboxes.js
Created May 21, 2013 06:34
显示页面的盒结构
function randomColor(){
return "rgb("+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+")";
}
function showBoxes(window) {
var rects = [];
function getRects(node){
var range = window.document.createRange();
range.setStartBefore(node);
range.setEndAfter(node);
@Justineo
Justineo / createStyle.js
Last active November 24, 2016 09:05
Correct way to create stylesheets dynamically
function createStyle(styleText) {
var style = document.createElement('style');
style.type = 'text/css';
// <style> element must be appended into DOM before setting `cssText`
// otherwise IE8 will interpret the text in IE7 mode.
document.body.appendChild(style);
if (style.styleSheet) {
style.styleSheet.cssText = styleText;
} else {
@benplum
benplum / matchMedia - IE8
Last active February 1, 2017 21:37
matchMedia Polyfill w/ Listeners - IE8
// Modernizr style test
if (!(window.webkitMatchMedia || window.mozMatchMedia || window.oMatchMedia || window.msMatchMedia || window.matchMedia)) {
var root = document.getElementsByTagName( 'html' )[0];
root.className += ' no-matchmedia';
}
/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license - IE8 VERSION! */
window.matchMedia = window.matchMedia || (function(doc, undefined){
var docElem = doc.documentElement,
@wintercn
wintercn / h5g
Last active May 19, 2017 06:50
HTML5 Canvas Game Template
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<!--允许全屏-->
<meta content="yes" name="apple-mobile-web-app-capable"/>
<meta content="yes" name="apple-touch-fullscreen"/>
<!--禁止电话号码和邮箱识别-->