SOURCE CODE: Sliders as RGB Selectors
VIEW EXAMPLE

<!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>Sliders as RGB Selectors | JavaScript Examples | UIZE JavaScript Framework</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="keywords" content="color widget Uize.Color Uize.Widgets.Slider.Widget"/>
  <meta name="description" content="Get three sliders in the same room together and you've got yourself an RGB color selector. See how to get sliders to cooperate for the greater good."/>
  <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"/>
</head>

<body>

<script type="text/javascript" src="../js/Uize.js"></script>

<h1 class="header">
  <a id="page-homeLink" href="../index.html" title="UIZE JavaScript Framework home"></a>
  <a href="../index.html" class="homeLinkText" title="UIZE JavaScript Framework home">UIZE JavaScript Framework</a>
</h1>

<div class="main">
  <h1 class="document-title">
    <a href="../javascript-examples.html" class="breadcrumb breadcrumbWithArrow">JAVASCRIPT EXAMPLES</a>
    Sliders as RGB Selectors
    <div class="pageActionsShell">
      <div id="page-actions" class="pageActions"><a href="source-code/sliders-as-rgb-selectors.html" class="buttonLink">SOURCE</a></div>
    </div>
  </h1>

  <!-- explanation copy -->

  <div class="explanation">
    <p>In this simple example, three instances of <a href="../reference/Uize.Widgets.Slider.Widget.html"><code>Uize.Widgets.Slider.Widget</code></a> are wired up and used together by some simple logic to control the values of the red, green, and blue channels of an RGB color. As you drag the individual sliders, a color swatch above the sliders is updated to the current color.</p>
  </div>

  <!-- page layout's "wireframe" with slots for sliders' HTML -->

  <table cellspacing="0" cellpadding="0" style="margin:auto;">
    <tr>
      <td id="page-colorSwatch" colspan="5" height="45">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="5" height="6"></td>
    </tr>
    <tr>
      <td id="page-redSlider" style="height: 340px;"></td>
      <td width="6"></td>
      <td id="page-greenSlider" style="height: 340px;"></td>
      <td width="6"></td>
      <td id="page-blueSlider" style="height: 340px;"></td>
    </tr>
    <tr>
      <td colspan="5" height="6"></td>
    </tr>
    <tr>
      <td height="25" style="background:#f00">&nbsp;</td>
      <td width="6"></td>
      <td height="25" style="background:#0f0">&nbsp;</td>
      <td width="6"></td>
      <td height="25" style="background:#00f">&nbsp;</td>
    </tr>
  </table>
</div>

<script type="text/javascript">

Uize.require (
  [
    'UizeSite.Page.Example.library',
    'UizeSite.Page.Example',
    'Uize.Color',
    'Uize.Widgets.Slider.Widget'
  ],
  function () {
    'use strict';

    /*** create the example page widget ***/
      var page = window.page = UizeSite.Page.Example ();

    /*** code for updating the color swatch ***/
      function updateColorSwatch () {
        page.setNodeStyle ('colorSwatch',{background:Uize.Color.to (rgbSliders,'#hex')});
      }

    /*** add the slider child widgets for red, green, and blue color channels ***/
      function createChannelSlider (channel,color) {
        page.addChild (
          channel + 'Slider',
          Uize.Widgets.Slider.Widget,
          {
            fullColor:color,
            minValue:0,
            maxValue:255,
            size:'large',
            orientation:'vertical',
            trackLength:'100%',
            built:false
          }
        ).wire ('Changed.value',updateColorSwatch);
      }
      createChannelSlider ('red','#f00');
      createChannelSlider ('green','#0f0');
      createChannelSlider ('blue','#00f');
      var rgbSliders = [page.children.redSlider,page.children.greenSlider,page.children.blueSlider];

    /*** wire up the page widget ***/
      page.wireUi ();

    /*** initialize the color swatch ***/
      updateColorSwatch ();
  }
);

</script>

</body>
</html>