実行結果
設置サンプルのソース
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="ja" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="imagetoolbar" content="no" />
<title>設置サンプル</title>
<link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
<!-- JS -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="/content/lib/jquery/iphone-style-checkboxes.js"></script>
<script type="text/javascript">
$(function(){
$('.on_off :checkbox').iphoneStyle();
$('.disabled :checkbox').iphoneStyle();
$('.css_sized_container :checkbox').iphoneStyle({ resizeContainer: false, resizeHandle: false });
$('.long_tiny :checkbox').iphoneStyle({ checkedLabel: 'Very Long Text', uncheckedLabel: 'Tiny' });
var onchange_checkbox = $('.onchange :checkbox').iphoneStyle();
setInterval(function toggleCheckbox() {
onchange_checkbox.attr('checked', !onchange_checkbox.is(':checked')).change();
$('span#status').html(onchange_checkbox.is(':checked').toString());
}, 2500);
});
</script>
<!-- CSS -->
<style type="text/css">
.iPhoneCheckContainer,
.iPhoneCheckContainer label {
user-select: none;
-moz-user-select: none;
-khtml-user-select: none;
}
.iPhoneCheckDisabled {
filter: alpha(opacity=50);
-moz-opacity: 0.5;
-khtml-opacity: 0.5;
opacity: 0.5;
}
.iPhoneCheckContainer {
position: relative;
height: 27px;
cursor: pointer;
overflow: hidden;
}
.iPhoneCheckContainer input {
position: absolute;
top: 5px; left: 30px;
filter: alpha(opacity=0);
-moz-opacity: 0;
-khtml-opacity: 0;
opacity: 0;
}
.iPhoneCheckContainer label {
white-space: nowrap;
font-weight: bold;
font-family: Helvetica Neue, Arial, Helvetica, sans-serif;
text-transform: uppercase;
cursor: pointer;
display: block;
position: absolute;
width: auto; height: 27px;
top: 0;
padding-top: 5px;
overflow: hidden;
}
label.iPhoneCheckLabelOn {
color: #fff;
background: url("/content/img/ajax/iphone-style-checkboxes/on.png") no-repeat;
text-shadow: 0px 0px 2px rgba(0, 0, 0, 0.6);
left: 0;
padding-top: 5px;
}
label.iPhoneCheckLabelOn span {
padding-left: 8px;
}
label.iPhoneCheckLabelOff {
color: #8B8B8B;
background: url("/content/img/ajax/iphone-style-checkboxes/off.png") no-repeat right 0;
text-shadow: 0px 0px 2px rgba(255, 255, 255, 0.6);
text-align: right;
right: 0;
}
label.iPhoneCheckLabelOff span {
padding-right: 8px;
}
.iPhoneCheckHandle {
display: block;
cursor: pointer;
position: absolute;
top: 0; left: 0;
width: 0; height: 27px;
background: url("/content/img/ajax/iphone-style-checkboxes/slider_left.png") no-repeat;
padding-left: 3px;
}
.iPhoneCheckHandleRight {
width: 100%; height:100%;
padding-right: 3px;
background: url("/content/img/ajax/iphone-style-checkboxes/slider_right.png") no-repeat right 0;
}
.iPhoneCheckHandleCenter {
width: 100%; height: 100%;
background: url("/content/img/ajax/iphone-style-checkboxes/slider_center.png");
}
th {
text-align: right;
padding: 4px;
padding-right: 15px;
vertical-align: top;
}
.css_sized_container .iPhoneCheckContainer {
width: 250px;
}
</style>
<link rel="stylesheet" type="text/css" href="/common/css/example.css"></head>
<body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP & JavaScript Room</a> :: 設置サンプル</h1>
<h3 class='h'>実行結果</h3>
<div id="wrap">
<h1>設置サンプル</h1>
<p>参照: <a href='http://tdreyno.github.com/iphone-style-checkboxes/'>iphone-style-checkboxes</a></p>
<!-- CODE -->
<table>
<tr class="disabled">
<th><label for="disabled">無効化</label></th>
<td>
<input type="checkbox" id="disabled" disabled="disabled" />
</td>
</tr>
<tr class="on_off">
<th><label for="on_off">デフォルト</label></th>
<td>
<input type="checkbox" id="on_off" />
</td>
</tr>
<tr class="on_off">
<th><label for="on_off_on">デフォルトON</label></th>
<td>
<input type="checkbox" checked="checked" id="on_off_on"/>
</td>
</tr>
<tr class="css_sized_container">
<th><label for="css_sized_container">CSSでサイズ変更</label></th>
<td>
<input type="checkbox" id="css_sized_container" />
</td>
</tr>
<tr class="long_tiny">
<th><label class="left" for="long_tiny">長短ラベル</label></th>
<td>
<input type="checkbox" id="long_tiny" />
</td>
</tr>
<tr class="onchange">
<th>イベントトラッキング</th>
<td>
<input type="checkbox" id="onchange" />
<p>チェックボックスの状態:<strong><span id="status">...</span></strong>.</p>
</td>
</tr>
</table>
<!-- / CODE -->
</div>
</body>
</html>