Skip to content

Instantly share code, notes, and snippets.

@RyoSugimoto
RyoSugimoto / is_checked.js
Last active August 29, 2015 13:58
ラジオボタンやチェックボックスが「checked」状態であるか調べる。
function isChecked (name) {
if (name instanceof Array) {
for (var i = name.length; 0 < i--;) {
if (!isChecked(name[i])) {
return false;
}
}
return true;
} else if (typeof name === 'string') {
var radios = document.getElementsByName(name);
@RyoSugimoto
RyoSugimoto / resize_end.js
Created April 12, 2014 15:17
ウィンドウのリサイズが終わったときに処理を実行する。
var timer = false;
$(window).resize(function() {
if (timer !== false) {
clearTimeout(timer);
}
timer = setTimeout(function() {
console.log('resized');
// 何らかの処理
}, 200);
});
@RyoSugimoto
RyoSugimoto / ie_min_height.css
Last active August 29, 2015 13:59
IE6のためのmin-height、min-width、max-height、max-width。
.foo {
min-height: 100px;
height: auto !important;
height: 100px;
}
.bar {
max-height: 200px;
width: expression(document.body.clientWidth > 202? "200px" : "auto");
}
@RyoSugimoto
RyoSugimoto / head.html
Last active August 29, 2015 13:59
<head>要素のテンプレート。
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Document</title>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<link rel="canonical" href="">
@RyoSugimoto
RyoSugimoto / remove_no_js.js
Created April 15, 2014 00:40
「no-js」クラスを<html>要素から取り除く。
// remove "no-js" class from <html>
;(function () {
setTimeout(function () {
var html = document.getElementsByTagName('html')[0],
htmlClass = html.className,
newClass = htmlClass.replace(/(^| )no-js( |$)/, ' ');
html.className = newClass;
}, 0);
}());
@RyoSugimoto
RyoSugimoto / google_map.html
Last active August 29, 2015 13:59
Google Maps APIの記述例。
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
function initialize() {
var latlng = new google.maps.LatLng(100, 100);
var mapOptions = {
center: latlng,
zoom: 17,
scaleControl: true,
scrollwheel: false
};
@RyoSugimoto
RyoSugimoto / css_calc.css
Created April 15, 2014 12:38
CSSのcalc()関数が使えるかどうかを調べる。
#css-calc {
width: 10px;
width: calc(10px + 10px);
width: -webkit-calc(10px + 10px);
display: none;
}
@RyoSugimoto
RyoSugimoto / cancel_scroll.js
Last active August 29, 2015 13:59
タッチデバイスでスクロールをキャンセルする。
$(window).on('touchmove.cancelScroll', function (e) { e.preventDefault(); })
@RyoSugimoto
RyoSugimoto / bugs.md
Last active August 29, 2015 13:59
ブラウザのバグ情報まとめ。

Browser Bugs

Android

  • position: relative にした要素を子要素に持つ要素を JavaScript で非表示の状態から表示させると、その子要素が見えなくなってしまうことがある。あとで JavaScript で position の値を static にしようが、何をしようが直らない。
@RyoSugimoto
RyoSugimoto / find_event_handler.js
Last active August 29, 2015 14:00
jQueryのイベントハンドラを調べる。
$._data($("#js_debug").get(0), "events");
$._data($0[0], "events");