Commit
…p and CSS based on Filament Group's awesome book 'Designing with Progressive Enhancement' Ch. 15
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Checkbox Static Test : Default</title> | ||
<link rel="stylesheet" href="../static.css" type="text/css" /> | ||
<link rel="stylesheet" href="../../../themes/base/jquery.ui.base.css" type="text/css" /> | ||
<link rel="stylesheet" href="../../../themes/base/jquery.ui.theme.css" type="text/css" title="ui-theme" /> | ||
<script type="text/javascript" src="../../../jquery-1.4.2.js"></script> | ||
<script type="text/javascript" src="../static.js"></script> | ||
</head> | ||
<body> | ||
|
||
<div class="ui-checkbox"> | ||
<input type="checkbox" id="check1"> | ||
<label for="check1">Unchecked</label> | ||
</div> | ||
|
||
<div class="ui-checkbox"> | ||
<input type="checkbox" id="check2" checked="checked"> | ||
<label for="check2">Checked</label> | ||
</div> | ||
|
||
<div class="ui-checkbox"> | ||
<input type="checkbox" id="check3" disabled="disabled"> | ||
<label for="check3">Disabled</label> | ||
</div> | ||
|
||
<div class="ui-checkbox"> | ||
<input type="checkbox" id="check4" checked="checked" disabled="disabled"> | ||
<label for="check4">Checked and disabled</label> | ||
</div> | ||
|
||
<script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> | ||
<script> | ||
$('<div/>').css({ | ||
position: "absolute", | ||
right: 10, | ||
top: 10 | ||
}).appendTo(document.body).themeswitcher(); | ||
</script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Checkbox Visual Test : Default</title> | ||
<link rel="stylesheet" href="../visual.css" type="text/css" /> | ||
<link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" /> | ||
<script type="text/javascript" src="../../../jquery-1.4.2.js"></script> | ||
<script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> | ||
<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> | ||
<script type="text/javascript" src="../../../ui/jquery.ui.checkbox.js"></script> | ||
<script type="text/javascript"> | ||
$(function() { | ||
$("#check1, #check2, #check3").checkbox(); | ||
|
||
}); | ||
</script> | ||
</head> | ||
<body> | ||
|
||
<form> | ||
|
||
<input type="checkbox" id="check1" /><label for="check1">Check 1</label> | ||
|
||
<input type="checkbox" id="check2" /><label for="check2">Check 2</label> | ||
|
||
<input type="checkbox" id="check3" /><label for="check3">Check 3</label> | ||
|
||
</form> | ||
|
||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* Checkbox | ||
----------------------------------*/ | ||
.ui-checkbox { position: relative; } | ||
.ui-checkbox input { position: absolute; left: 2px; top: 2px; margin: 0; } | ||
.ui-checkbox label { display: block; position: relative; padding-right: 1em; line-height: 1; padding: .5em 0 .5em 30px; margin: 0 0 .3em; cursor: pointer; z-index: 1; } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* jQuery UI Checkbox @VERSION | ||
* | ||
* Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) | ||
* Dual licensed under the MIT (MIT-LICENSE.txt) | ||
* and GPL (GPL-LICENSE.txt) licenses. | ||
* | ||
* {{TODO replace with docs link once plugin is released}} | ||
* http://wiki.jqueryui.com/Checkbox | ||
* {{/TODO}} | ||
* | ||
* Depends: | ||
* jquery.ui.core.js | ||
* jquery.ui.widget.js | ||
*/ | ||
(function( $ ) { | ||
|
||
$.widget( "ui.checkbox", { | ||
|
||
_create: function() { | ||
|
||
this.labelElement = $( this.element[0].ownerDocument ).find( "label[for=" + this.element.attr("id") + "]" ); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
scottgonzalez
Member
|
||
|
||
this.checkboxElement = this.element.wrap( "<div></div>" ).parent() | ||
.addClass("ui-checkbox") | ||
.append(this.labelElement); | ||
|
||
}, | ||
|
||
widget: function() { | ||
return this.checkboxElement; | ||
}, | ||
|
||
destroy: function() { | ||
this.checkboxElement | ||
.after( this.labelElement ).end() | ||
.unwrap( "<div></div>" ); | ||
|
||
$.Widget.prototype.destroy.apply( this, arguments ); | ||
}, | ||
|
||
_setOption: function( key, value ) { | ||
if ( key === "disabled" ) { | ||
this.element | ||
.attr( "disabled", value ); | ||
this.checkboxElement | ||
[ value ? "addClass" : "removeClass" ]( "ui-checkbox-disabled" ); | ||
} | ||
|
||
$.Widget.prototype._setOption.apply( this, arguments ); | ||
}, | ||
|
||
}); | ||
|
||
$.extend( $.ui.checkbox, { | ||
version: "@VERSION" | ||
}); | ||
|
||
}( jQuery )); |
Thinking: .siblings() is probably fine here. The danger exposed here is, say, a tab interface with the same control on more than one panel. .siblings() protects from that.