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
for (var method in jQuery.fn)(function (method) { | |
if (method == "init") return; | |
var old = jQuery.fn[method]; | |
jQuery.fn[method] = function () { | |
if (!internal && curEvent) { | |
internal = true; | |
var m = curEvent.methods[curEvent.methods.length] = { | |
name: method, |
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://stackoverflow.com/questions/1449666/create-a-jquery-special-event-for-content-changed | |
(function(){ | |
var interval; | |
jQuery.event.special.contentchange = { | |
setup: function(){ | |
var self = this, | |
$this = $(this), |
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; | |
} | |
} |
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
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
<!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 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
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
/** | |
* 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
/** | |
* web 浏览器有这样的一类问题: | |
* 当某些内容被隐藏, 过一段时间需要被显示 显示出来, 这个时候可能导致浏览器不会渲染被隐藏 | |
* 的内容, 可以通过旋转屏幕等方式强制浏览器重新渲染页面, 下面是一个比较笨的解决方法。 求更好的解决方法 | |
*/ | |
function reRender(){ | |
document.body.style.display = 'none'; | |
setTimeout(function(){ | |
document.body.style.display = 'block'; | |
}, 0); |