Skip to content

Instantly share code, notes, and snippets.

View keelii's full-sized avatar
🎯
Focusing

kily zhou keelii

🎯
Focusing
View GitHub Profile
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@keelii
keelii / position-fixed.css
Created March 30, 2012 08:55 — forked from subtleGradient/position-fixed.css
Make position:fixed work in IE6
/*Make position:fixed work in IE6!*/
.fixed-top /* position fixed Top */{position:fixed;bottom:auto;top:0;}
.fixed-bottom /* position fixed Bottom */{position:fixed;bottom:0;top:auto;}
.fixed-left /* position fixed Left */{position:fixed;right:auto;left:0;}
.fixed-right /* position fixed right */{position:fixed;right:0;left:auto;}
* html,* html body /* IE6 Fixed Position Jitter Fix */{background-image:url(about:blank);background-attachment:fixed;}
* html .fixed-top /* IE6 position fixed Top */{position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop));}
* html .fixed-right /* IE6 position fixed right */{position:absolute;right:auto;left:expression(eval(document.documentElement.scrollLeft+document.documentElement.clientWidth-this.offsetWidth)-(parseInt(this.currentStyle.marginLeft,10)||0)-(parseInt(this.currentStyle.marginRight,10)||0));}
@keelii
keelii / js-array-remove.js
Created April 5, 2012 07:33 — forked from danro/js-array-remove.js
JavaScript Array Remove - By John Resig
// Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
@keelii
keelii / jQuery Plugin Design Pattern
Created August 1, 2012 05:11
The Best jQuery Plugin Design Pattern ...
/*!
* from: http://stackoverflow.com/questions/7127600/which-jquery-plugin-design-pattern-should-i-use
*/
(function ($) {
// the constructor
var MyClass = function (node, options) {
// node is the target
this.node = node;
@keelii
keelii / IE userData storage
Created September 12, 2012 10:11
IE userData storage solution!
var store = function(days) {
if ( typeof localStorage == 'undefined' ) {
var obj = document.createElement('q'),
days = days || 365;
obj.style.display = 'none';
obj.addBehavior('#default#userData');
var exp = new Date();
exp.setDate(exp.getDate() + days)
@keelii
keelii / jQuery Plugin Design Pattern for us
Created January 31, 2013 05:25
jQuery Plugin Design Pattern for us
(function ($) {
/**
* pluginName插件
*/
var pluginName = function (that, options, callback) {
this.opts = $.extend({
content: that.title || '',
options: 'you want to set'
@keelii
keelii / random link
Created February 25, 2013 05:36
链接添加随机数
@keelii
keelii / define
Created June 19, 2013 01:18
AMD define
/*
https://github.com/gruntjs/grunt-contrib-jshint
Copyright (c) 2013 John Urberg
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@keelii
keelii / formatSeconds
Created June 21, 2013 06:05
把秒数转换成 「天:时:分:秒」
var formatSecounds = function(seconds, callback) {
var rDays, rHours, rMinutes, rSeconds;
if (!seconds || seconds < 0) {
return;
} else {
seconds = Math.round(seconds);
}
//剩余天
@keelii
keelii / Jshare
Created August 28, 2013 07:01
Jshare
(function ($) {
/**
* Jshare插件
*/
var Jshare = function (that, options, callback) {
this.opts = $.extend({
title: '我在 @京东 发现了一个非常不错的商品',
url: location.href,
pic: 'http://misc.360buyimg.com/lib/img/e/logo-201305.png',