SOURCE CODE: Bevel On Multiple Images
<!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>Bevel On Multiple Images | JavaScript Examples | UIZE JavaScript Framework</title>
<meta name="keywords" content="Uize.Widget.Bevel"/>
<meta name="description" content="See how bevel overlays can be created for multiple images, where the thickness and opacity of the bevel for all images can be controlled with sliders."/>
<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"/>
<link rel="stylesheet" href="css/labeled-horizontal-sliders.css"/>
<style type="text/css">
/*** labeled horizontal slider overrides ***/
.sliderPlaceholder {
width:480px;
}
.bevelThumb {
width:105px;
height:75px;
position:relative;
}
</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>
Bevel On Multiple Images
<div id="page-actions" class="pageActions">
<a href="source-code/bevel-on-multiple-images.html" class="buttonLink">SOURCE</a>
</div>
</h1>
<div class="main">
<!-- explanation copy -->
<div class="explanation">
<p>In this example, the <code>Uize.Widget.Bevel.spawn</code> method is being used to spawn multiple <a href="../reference/Uize.Widget.Bevel.html"><code>Uize.Widget.Bevel</code></a> widget instances. This widget simply adds a bevel effect to the edge of the node to which it attaches. Instances are spawned for all div elements with a CSS class string of "bevelThumb". This is done by specifying a find expression object when calling the <code>Uize.Widget.Bevel.spawn</code> static method. Additionally, two slider widgets of the <a href="../reference/Uize.Widget.Bar.Slider.html"><code>Uize.Widget.Bar.Slider</code></a> class are instantiated and are wired up to control the <code>thickness</code> and <code>opacity</code> state properties for all the bevel widget instances. Each time the value of either slider changes, all <code>Uize.Widget.Bevel</code> instances are updated. The batch update is accomplished using the <code>Uize.callOn</code> static method, which allows a specified instance method or function to be called on all the instances contained inside the specified array - a form of convenience iterator.</p>
</div>
<!-- page layout's "wireframe" with slots for wipe objects -->
<form>
<table border="0" cellspacing="2" cellpadding="0" style="margin:auto;">
<tr>
<td colspan="4">
<table border="0" cellspacing="6" cellpadding="0">
<tr>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228109666540948246&max_dim=105);" title="Braving the Onslaught"/></td>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228745103279879745&max_dim=105);" title="Companion to a Sunset"/></td>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228866001826566384&max_dim=105);" title="Concrete Eternity"/></td>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228321774790917687&max_dim=105);" title="Corrugate It"/></td>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228463251413365530&max_dim=105);" title="Crank It Up"/></td>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228507796122097730&max_dim=105);" title="Driving Through the Rain"/></td>
</tr>
<tr>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228267745724726415&max_dim=105);" title="Flock of Clouds"/></td>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228937676589416694&max_dim=105);" title="Hail to the Opening"/></td>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228483162492178759&max_dim=105);" title="Heavens Open Over Pedro"/></td>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228855435929294206&max_dim=105);" title="Hook in the Wall"/></td>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228496639998196479&max_dim=105);" title="Huddling Together"/></td>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228623703668130129&max_dim=105);" title="Just a Visitor"/></td>
</tr>
<tr>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228897217554746467&max_dim=105);" title="Out the Bus Window"/></td>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228554379238024970&max_dim=105);" title="Pacifica Pier From Milagra"/></td>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228550194293355740&max_dim=105);" title="Pier Before the Storm"/></td>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228234695931308619&max_dim=105);" title="Rain Fall"/></td>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228580091324147918&max_dim=105);" title="Retirement Home"/></td>
<td><div class="bevelThumb" style="background:url(http://rlv.zcache.com/isapi/designall.dll?action=realview&rvtype=pre&view=front&pid=228074575082103294&max_dim=105);" title="San Fran Sunset"/></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="4" style="height:8px;"></td>
</tr>
<tr>
<td class="sliderLabel">BEVEL THICKNESS</td>
<td class="sliderValueLabel slideMinValue">0</td>
<td id="page_bevelThickness"><img src="../images/blank.gif" class="sliderPlaceholder" alt=""/></td>
<td class="sliderValueLabel sliderMaxValue">30</td>
</tr>
<tr>
<td class="sliderLabel">BEVEL OPACITY</td>
<td class="sliderValueLabel slideMinValue">0</td>
<td id="page_bevelOpacity"><img src="../images/blank.gif" class="sliderPlaceholder" alt=""/></td>
<td class="sliderValueLabel sliderMaxValue">1</td>
</tr>
</table>
</form>
</div>
<!-- JavaScript code to make the static wipe HTML "come alive" -->
<script type="text/javascript">
Uize.module ({
required:[
'UizeSite.Page.Example.library',
'UizeSite.Page.Example',
'Uize.Widget.Bevel',
'Uize.Widget.Bar.Slider.xSkin'
],
builder:function () {
/*** create the example page widget ***/
var page = window.page = UizeSite.Page.Example ();
/*** spawn a batch of Uize.Widget.Bevel instances ***/
var bevels = Uize.Widget.Bevel.spawn ({idPrefix:{tagName:'DIV',className:'bevelThumb'}},page);
/*** code to update thickness and opacity for the bevel instances ***/
function updateBevelInstances () {
Uize.callOn (
bevels,
'set',
[{
thickness:+bevelThickness,
opacity:+bevelOpacity
}]
);
}
/*** set defaults for properties whose values are the same for most sliders ***/
Uize.Widget.Bar.Slider.set ({
fullTintColor:'#fff',
fullTintLevel:60,
emptyTintColor:'#9aa',
emptyTintLevel:40,
borderThickness:1,
borderTintColor:'#666',
borderTintLevel:100,
knobSize:18,
orientation:'horizontal'
});
/*** create the Uize.Widget.Bar.Slider object for the bevel thickness selector ***/
var bevelThickness = page.addChild (
'bevelThickness',
Uize.Widget.Bar.Slider,
{
minValue:1,
maxValue:10,
value:4,
built:false
}
);
bevelThickness.wire ('Changed.value',updateBevelInstances);
/*** create the Uize.Widget.Bar.Slider object for the bevel opacity selector ***/
var bevelOpacity = page.addChild (
'bevelOpacity',
Uize.Widget.Bar.Slider,
{
minValue:0,
maxValue:1,
value:.575,
increments:0,
built:false
}
);
bevelOpacity.wire ('Changed.value',updateBevelInstances);
/*** initialize the bevel instances to the slider values ***/
updateBevelInstances ();
/*** wire up the page widget ***/
page.wireUi ();
}
});
</script>
</body>
</html>