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://css-tricks.com/media-query-change-detection-in-javascript-through-css-animations/?utm_source=feedly*/ | |
body { | |
animation-duration: 0.001s; | |
} | |
@media screen and (min-width: 1000px) { | |
body { | |
animation-name: min-width-1000px; | |
} | |
} | |
@media screen and (min-width: 700px) { |
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
/* set up the keyframes */ | |
@keyframes nodeInserted { | |
from { clip: rect(1px, auto, auto, auto); } | |
to { clip: rect(0px, auto, auto, auto); } | |
} | |
@-moz-keyframes nodeInserted { | |
from { clip: rect(1px, auto, auto, auto); } | |
to { clip: rect(0px, auto, auto, auto); } | |
} |
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 DetectJSEnv() { | |
if (typeof environment === 'object' && ({}).toString.call(environment) === '[object Environment]') { | |
// Rhino | |
// Details on how to detect Rhino: https://github.com/ringo/ringojs/issues/88 | |
return 'rhino'; | |
} else if (typeof(window) === 'undefined') { | |
// Node.js | |
return 'node'; | |
} else { | |
// Browser |
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 getChineseUnit = function(number) { | |
var integer = Math.floor(number); | |
var digit = 0; | |
while (integer >= 1) { | |
digit++; | |
integer = integer / 10; | |
} | |
digit--; | |
integer = Math.floor(number); | |
var chineseUnit = ['个', '十', '百', '千', '万', '十万', '百万', '千万']; |
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
/** | |
* 为数字加上单位:万或亿 | |
* | |
* 例如: | |
* 1000.01 => 1000.01 | |
* 10000 => 1万 | |
* 99000 => 9.9万 | |
* 566000 => 56.6万 | |
* 5660000 => 566万 | |
* 44440000 => 4444万 |
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
// from https://github.com/neoziro/less-hidpi/blob/master/hidpi.less | |
// Configuration | |
@hidpi_min_ratio: 1.5; | |
@hidpi_suffix: "@2x"; | |
// Mixin | |
@hidpi_query: ~"(-webkit-min-device-pixel-ratio: @{hidpi_min_ratio}), (min--moz-device-pixel-ratio: @{hidpi_min_ratio}), (-o-min-device-pixel-ratio: @{hidpi_min_ratio}), (min-resolution: @{hidpi_min_ratio}dppx)"; | |
.hidpi(@path, @w: auto, @h: auto) { |
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
<div class="fluid-wrap"> | |
<img src="http://placehold.it/800x600" alt="" /> | |
</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
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 | |
var PIXEL = /^\d+(px)?$/i; | |
function getPixelValue(element, value) { | |
if (PIXEL.test(value)) { | |
return parseInt(value); | |
} | |
var style = element.style.left; | |
var runtimeStyle = element.runtimeStyle.left; | |
element.runtimeStyle.left = element.currentStyle.left; | |
element.style.left = value || 0; |
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 drawInlineBox(el) { | |
el = typeof el === 'string' ? | |
document.getElementById(el) : | |
el; | |
var lines = document.createElement('lines'); | |
lines.style.display = 'inline'; | |
var children = []; | |
for (var i = 0, l = el.childNodes.length; i < l; i++) { | |
children[i] = el.childNodes[i]; |