Skip to content

Instantly share code, notes, and snippets.

@Takazudo
Takazudo / ieopacity.css
Created December 16, 2010 17:43
opacity style for fucking IE
.ui-thumbVideo:hover{
opacity:.8;
}
html.no-opacity .ui-thumbVideo:hover{
filter: alpha(opacity=80); /* ie */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)"; /* ie 8 */
}
@Takazudo
Takazudo / jquery.normalizeAnchor.js
Created December 22, 2010 09:41
$.fn.normalizeAnchor changes all anchors' href which referes the id in the page.
/**
* $.fn.normalizeAnchor
* changes anchor's href which referes the id in the page.
* ex: change <a href="/foobar/#hogehoge">...</a> to <a href="#hogehoge">...</a>
* if your location is http://somewhere/foobar/.
*/
$.fn.normalizeAnchor = function(){
var l = location;
var pathWoHash = l.protocol + '//' + l.host + l.pathname;
return this.each(function(){
@Takazudo
Takazudo / androidViewport.js
Created January 10, 2011 08:09
some androids can't handle meta viewport width=number.
/*
There's <meta name="viewport" content="width=480" /> in html then...
*/
// handle Android's viewport
(function($, undefined){
$.browser.android = /android/i.test(navigator.userAgent);
if(!$.browser.android){
@Takazudo
Takazudo / detectLegacyAndroid.js
Created January 12, 2011 12:12
detect legacy android
$.browser.android = /android/i.test(ua);
$.browser.legacyAndroid = function(){
if(!$.browser.android){
return false;
}
var threshold = 2.2;
var res = ua.match(/android\s?([^;^-]+)/i);
if(!res || res.length<2){
return false;
@Takazudo
Takazudo / lazyPreload.html
Created February 3, 2011 08:30
do preload using custom data attr.
<img
src="hogehoge_on.png"
data-srcoff="hogehoge_off.png"
data-preloadattr="srcoff"
alt=""
/>
@Takazudo
Takazudo / jQueryCDNFallbackLoad.html
Created February 6, 2011 18:20
load local file in case of offline.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/libs/jquery-1.5.min.js"%3E%3C/script%3E'))</script>
@Takazudo
Takazudo / detectIPhoneLT4.js
Created February 9, 2011 07:00
detect iPhone version less than 4.
var ua = navigator.userAgent;
$.browser.iPhone = /iphone/i.test(ua);
$.browser.iPhoneLt4 = function(){
if(!$.browser.iPhone){
return false;
}
if(window.devicePixelRatio >= 2){
return false;
}
@Takazudo
Takazudo / banRightClick.css
Created February 10, 2011 10:56
disable user right click
img{
-webkit-touch-callout:none; /* iOS Safari */
-webkit-user-select:none; /* iOS Safari */
touch-callout:none;
user-select:none;
}
@Takazudo
Takazudo / writeLastCode.js
Created March 5, 2011 15:09
put the code of the very last script element into pre element.
function writeLastCode(){
var $s = $('script');
document.write('<pre></pre>');
var $pre = $('pre').last();
$pre.last().text($($s[$s.length-2]).text().replace(/\t/g,' ').replace(/\n/,''));
}
/*
use like following
@Takazudo
Takazudo / jQueryUiWidget-factoryMethod.js
Created March 6, 2011 19:07
add factory method to jQuery UI's widget.
/* === jQuery UI widget way === */
$.widget('ui.dashboard', {
_create: function(){
alert('hey widget was created!');
console.log(this.element); // this is what you attached.
}
});
$('#div1').dashboard(options);