Skip to content

Instantly share code, notes, and snippets.

@kotarok
kotarok / gist:1035044
Created June 20, 2011 02:47
iOS style scrollbar sass snippet
/* iOS style scrollbar */
&::-webkit-scrollbar {
width: 12px;
height: 12px;
}
&::-webkit-scrollbar-thumb {
background: #ddd;
border: 3px solid #fff;
@include radius(6px);
@kotarok
kotarok / $.fn.fixFxTableMargin
Created February 23, 2011 12:56
Fix the Firefox's bug that vertical margins of table elements don't collapse.
$.fn.fixFxTableMargin = function(conf){
if(!$.browser.mozilla) return this;
this.each(function(){
var elem = $(this);
elem.wrap('<div class="fixFxTableMargin" />');
var mt = elem.css('margin-top'),
mb = elem.css('margin-bottom');
elem.css({'margin-top':0,'margin-bottom':0})
@kotarok
kotarok / jquery.stickyfooter.js
Created January 16, 2011 12:22
Make footer stick to the bottom edge. Cares not to overlap upper content. Make sure that base ancestor element's position is 'relative.' I believe that mostly its 'body' element.
/*!
* jquery.stickyfooter.js
*
* Copyright 2011, Kotaro Kokubo
* [email protected]
* Dual licensed under the MIT or GPL Version 2 licenses.
*/
// In jQuery1.4.4, .outerHeight() or .height doesn't work collecly sometimes.
$.fn.stickyfooter = function(){
html {
/*to remove all comment nodes on IE*/
behavior: expression(this.behavior || ((function(a){
a=document.getElementsByTagName('!');
try{for(var i=0,l=a.length;i<l;i++){a[i].parentNode.removeChild(a[i])}}catch(e){};
})(),1));
}
.whatever slector {
/*run behaviour only one time*/
behavior: expression(this.behavior || (function(that){try{
/*do something here*/
}catch(e){};})(this),1);
}
@kotarok
kotarok / give 'first-child' class in
Created December 4, 2010 00:37
In this gist, add 'first-child' class for first-child element. This runs expression only one time. So browser doesn't get slow.
.someClass{
behavior: expression(this.style.behavior || ((function(a,b,c){
c=a.parentNode.getElementsByTagName('!');
try{for(var i=0,l=c.length;i<l;i++){c[i].parentNode.removeChild(c[i])}}catch(e){};
if(a.parentNode.firstChild==a){a.className+=' '+b}
})(this,"lu.first-child"),1));
}
@kotarok
kotarok / my clearfix
Created November 28, 2010 10:28
the clearfix I'm currently using
.clearfix {
*zoom: 1;
}
.clearfix:after {
content: '';
display: block;
clear : both;
height: 0;
}
/**
* $.require('foo.js');
* $.require(['foo.js','baa.js','moo/muu.js]);
*/
jQuery.require= (function(){
var jspath = $('script[src]:last').attr('src');
var dirpath = /.+\//.exec(jspath)[0]
return function(jsfiles){
@kotarok
kotarok / jQuery.lang.js
Created February 9, 2010 09:33
get the language of target element
/**
* @param langid {String} optional
* @return {jQuery} when langid is given.
* @return langid {String} when langid is not given.
**/
$.fn.lang = function(langid) {
var elem = $(this);
var lang;
@kotarok
kotarok / gist:299050
Created February 9, 2010 09:32
mark part of string with given jQuery element by RegExp
/**
* @param query {RegExp} required
* @param wrapElement {jQuery} required
**/
$.fn.markTextByRegExp = function(query,wrapElement){
var REtag = '<\\/?[^>]+?\\/?>';
var REtagDivider = new RegExp(REtag+'|[^<>]*','gi');
return this.each(function(){
var elem = $(this);