SOURCE CODE: Color Picker
<!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">
<head>
<title>Color Picker | JavaScript Examples | UIZE JavaScript Framework</title>
<meta name="keywords" content="color touch ipad Uize.Widget.ColorPicker"/>
<meta name="description" content="See how three RGB color picker widgets - with sliders for red, green, and blue - can be used to tweak text color, background color, and border color."/>
<link rel="alternate" type="application/rss+xml" title="UIZE JavaScript Framework - Latest News" href="http://www.uize.com/latest-news.rss"/>
<link rel="stylesheet" href="../css/page.css"/>
<link rel="stylesheet" href="../css/page.example.css"/>
<style>
.pickerSpacer {
width:15px;
}
</style>
</head>
<body>
<script type="text/javascript" src="../js/Uize.js"></script>
<h1 class="document-title">
<a id="page-homeLink" href="../index.html" title="UIZE JavaScript Framework home"></a>
<a href="../javascript-examples.html" class="breadcrumb breadcrumbWithArrow">JAVASCRIPT EXAMPLES</a>
Color Picker
<div id="page-actions" class="pageActions">
<a href="source-code/color-picker.html" class="buttonLink">SOURCE</a>
</div>
</h1>
<div class="main">
<!-- explanation copy -->
<div class="explanation">
<p>In this example, three instances of <a href="../reference/Uize.Widget.ColorPicker.html"><code>Uize.Widget.ColorPicker</code></a> are created, to control the text color, background color, and border color of the sample text to the left. Each color picker has a color swatch above the sliders, representing the current color selected by it.</p>
</div>
<!-- "wireframe" for the UI -->
<table border="0" cellspacing="0" cellpadding="0" style="margin:auto;">
<tr>
<td class="heading">Sample Area</td>
<td class="pickerSpacer"></td>
<td class="heading">Text</td>
<td class="pickerSpacer"></td>
<td class="heading">Background</td>
<td class="pickerSpacer"></td>
<td class="heading">Border</td>
</tr>
<tr>
<td id="page-sampleNode" style="width:300px; border:10px solid; padding:10px;">
I'd like to see the companies that make up the <b>new energy economy</b> gang up on the bloated fossil fuel giants like a bunch of vicious attack dogs and <b>rip</b> their corporate throats out.<br/>
<br/>
Then, once the kill is complete, may they rip through the <b>bloated bellies</b> of the fallen giants, to feast upon their oily entrails.<br/>
<br/>
And from feeding upon these fattened pigs, let the <b>age of renewable energy</b> truly dawn.<br/>
<br/>
We have seen a Silicon Valley giant born in this way, and advertising will never be the same again.<br/>
<br/>
May the same <b>fate</b> befall the entrenched and recalcitrant fossil energy giants.<br/>
</td>
<td></td>
<td id="page_colorPicker"></td>
<td></td>
<td id="page_backgroundColorPicker"></td>
<td></td>
<td id="page_borderColorPicker"></td>
</tr>
</table>
</div>
<!-- JavaScript code to make the static HTML "come alive" -->
<script type="text/javascript">
Uize.module ({
required:[
'UizeSite.Page.Example.library',
'UizeSite.Page.Example',
'Uize.Widget.ColorPicker'
],
builder:function () {
/*** create the example page widget ***/
var page = window.page = UizeSite.Page.Example ();
/*** set up the color pickers for text color, background color, and border color ***/
function setupColorPicker (styleProperty,initialValue) {
function syncStylePropertyToPicker (_event) {
page.getNode ('sampleNode').style [styleProperty] = '#' + colorPicker;
}
var colorPicker = page.addChild (
styleProperty + 'Picker',Uize.Widget.ColorPicker,{value:initialValue,built:false}
);
colorPicker.wire ('Changed.value',syncStylePropertyToPicker);
syncStylePropertyToPicker ();
}
setupColorPicker ('color','000000');
setupColorPicker ('backgroundColor','cccccc');
setupColorPicker ('borderColor','aaaaaa');
/*** wire up the page widget ***/
page.wireUi ();
}
});
</script>
</body>
</html>