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
.spinner { | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
margin: -25px 0px 0px -25px; | |
width: 50px; | |
height: 50px; | |
background: url('loading.png') no-repeat center center; | |
-moz-animation-name: spin; | |
-moz-animation-duration: 1s; |
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
_unique: function (arr) { //判断数组值唯一 | |
var i,len = arr.length,a = [],o = {}; | |
for (i = 0; i < len; i++) { | |
o[arr[i]] = 0; | |
} | |
for (i in o) { | |
a.push(i); | |
} | |
return a; | |
} |
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 validateEmail(email) { | |
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | |
return re.test(email); | |
} |
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
_fullDate: function(time){ //转换成类似 2012-12-20 的时间格式 | |
var date = new Date(time); | |
return date.getFullYear() + '-' + (date.getMonth() >= 9 ? '' : '0') + (date.getMonth() + 1) + '-' + (date.getDate() > 9 ? '' : '0') + date.getDate(); | |
}, |
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
/** | |
* IE9表格渲染bug修复,表格数据量大时,ie9下莫名其妙出现空的td | |
*/ | |
IE9TabelRenderFixed: function(str){ | |
var reg = new RegExp('>[ \t\r\n\v\f]*<', 'g'); | |
return str.replace(reg, '><'); | |
} |
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 http://snipplr.com/view/43542/ | |
function hex2rgb(hex, opacity) { | |
var rgb = hex.replace('#', '').match(/(.{2})/g); | |
var i = 3; | |
while (i--) { | |
rgb[i] = parseInt(rgb[i], 16); | |
} | |
if (typeof opacity == 'undefined') { |
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/979256/how-to-sort-an-array-of-javascript-objects | |
// demo http://jsfiddle.net/dFNva/1/ | |
var sort_by = function(field, reverse, primer){ | |
var key = function (x) {return primer ? primer(x[field]) : x[field]}; | |
return function (a,b) { | |
var A = key(a), B = key(b); | |
return ((A < B) ? -1 : | |
(A > B) ? +1 : 0)) * [-1,1][+!!reverse]; | |
} | |
} |
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 http://stackoverflow.com/questions/5786186/javascript-age-count-from-date-of-birth | |
function date2Age(str){ // 根据年月日计算年龄str 格式为yyyy-mm-dd | |
var diff = new Date - new Date(parseISO8601(str)); | |
var diffdays = diff / 1000 / (60 * 60 * 24); | |
return Math.floor(diffdays / 365.25) | |
} | |
//form http://stackoverflow.com/questions/2182246/javascript-dates-in-ie-nan-firefox-chrome-ok | |
function parseISO8601(dateStringInRange) { // fixed IE8 NaN | |
var isoExp = /^\s*(\d{4})-(\d\d)-(\d\d)\s*$/, | |
date = new Date(NaN), |
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
_encodeHTML: function(source){ //转换特殊字符 | |
return source.replace(/&/g, '&') | |
.replace(/</g, '<') | |
.replace(/>/g, '>') | |
.replace(/"/g, """) | |
.replace(/\(/g, "(") | |
.replace(/\)/g, ")") | |
.replace(/\$/g, "$") | |
.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
(function($){ | |
$.extend($.fn,{ | |
pluginName: function(options){ | |
return this.each(function(){ | |
var pluginName = $.data(this, "pluginName"); | |
if(!pluginName){ | |
pluginName = new $.pluginName(options, this); | |
$.data(this, "pluginName", pluginName); |