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
* | |
jQuery array utils - 0.1 | |
http://code.google.com/p/jquery-utils/ | |
(c) Maxime Haineault <[email protected]> | |
http://haineault.com | |
MIT License (http://www.opensource.org/licenses/mit-license.php | |
*/ |
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
/** | |
* 版本1 | |
* Throttles a call to a method based on the time between calls. | |
* @param {Function} fn The function call to throttle. | |
* @param {Object} [context] context fn to run | |
* @param {Number} [ms] The number of milliseconds to throttle the method call. | |
* Passing a -1 will disable the throttle. Defaults to 150. | |
* @return {Function} Returns a wrapped function that calls fn throttled. | |
* @member KISSY | |
*/ |
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
/** | |
* web 浏览器有这样的一类问题: | |
* 当某些内容被隐藏, 过一段时间需要被显示 显示出来, 这个时候可能导致浏览器不会渲染被隐藏 | |
* 的内容, 可以通过旋转屏幕等方式强制浏览器重新渲染页面, 下面是一个比较笨的解决方法。 求更好的解决方法 | |
*/ | |
function reRender(){ | |
document.body.style.display = 'none'; | |
setTimeout(function(){ | |
document.body.style.display = 'block'; | |
}, 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
/** | |
* Module dependencies. | |
*/ | |
var express = require('express'); | |
var routes = require('./routes'); | |
var user = require('./routes/user'); | |
var http = require('http'); | |
var path = require('path'); |
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
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
/** | |
*--livescripts | |
*/ | |
livescript: { | |
src: { |
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 html_encode(str) | |
{ | |
var s = ""; | |
if (str.length == 0) return ""; | |
s = str.replace(/&/g, ">"); | |
s = s.replace(/</g, "<"); | |
s = s.replace(/>/g, ">"); | |
s = s.replace(/ /g, " "); | |
s = s.replace(/\'/g, "'"); | |
s = s.replace(/\"/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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
<script> | |
window.onload=function (){ | |
function getCommandList(){ | |
return {'2D-Position':true, | |
'absolutePosition':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 isArrayLike(obj) { | |
if (obj && typeof obj === "object") { | |
var n = obj.length | |
if (+n === n && !(n % 1) && n >= 0) {//检测length属性是否为非负整数 | |
try { | |
if ({}.propertyIsEnumerable.call(obj, 'length') === false) {//如果是原生对象 | |
return Array.isArray(obj) || /^\s?function/.test(obj.item || obj.callee) | |
} | |
return true; | |
} catch (e) {//IE的NodeList直接抛错 |
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 whichTransitionEvent(){ | |
var t; | |
var el = document.createElement('fakeelement'); | |
var transitions = { | |
'transition':'transitionend', | |
'OTransition':'oTransitionEnd', | |
'MozTransition':'transitionend', | |
'WebkitTransition':'webkitTransitionEnd' | |
} |
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 api | |
document.contains(someReferenceToADomElement); | |
//from job | |
var elementInDocument = function(element) { | |
while (element = element.parentNode) { | |
if (element == document) { | |
return true; | |
} | |
} |