JavaScript Events: OnResizeStart, OnResize, and OnResizeComplete
SplitterBar Events: This example demonstrates the use of
the VwdCms.SplitterBar event handler
properties OnResizeStart, OnResize, and OnResizeComplete.
See the JavaScipt code below in for details about custom coding with the OnResizeStart,
OnResize, and OnResizeComplete event handlers.
Move the SplitterBar to see what the custom JavaScript event handlers do
!! RESIZING !!
SplitterBar Event Handler Code Examples:
var _timerID = 0;
var _prevWidth = 0;
function splitterOnResizeStart(splitterBar)
{
// Arguments:
// splitterBar is a VwdCmsSplitterBar object
// ** the actual div element that you see on the
// screen can be accessed by using splitterBar.splitterBar
// or by document.getElementById('splitterBarID')
// where 'splitterBarID' is the ID of the server control
// in your ASPX code.
// check to see which splitterBar fired this event
if ( splitterBar splitterBar.id == "vwdSplitter1" )
{
setupTimer("divAlert");
document.getElementById("divDirection").style.display = "block";
}
}
function splitterOnResize(splitterBar, width)
{
// Arguments:
// splitterBar is a VwdCmsSplitterBar object
// width is a string like "250px
// ** the actual div element that you see on the
// screen can be accessed by using splitterBar.splitterBar
// or by document.getElementById('splitterBarID')
// where 'splitterBarID' is the ID of the server control
// in your ASPX code.
// do any other work that needs to happen when the
// splitter resizes. this is a good place to handle
// any complex resizing rules, etc.
// make sure the width is in number format
if (typeof width == "string")
{
width = new Number(width.replace("px",""));
}
// check to see which splitterBar fired this event
if ( splitterBar splitterBar.id == "vwdSplitter1" )
{
var div = document.getElementById("divDirection");
if ( _prevWidth != 0 )
{
if ( width _prevWidth )
{
div.innerHTML = ">> MOVING TO THE RIGHT >>";
}
else
{
div.innerHTML = "<< MOVING TO THE LEFT <<";
}
}
_prevWidth = width;
}
}
function splitterOnResizeComplete(splitterBar, width)
{
// Arguments:
// splitterBar is a VwdCmsSplitterBar object
// width is a string like "250px
// ** the actual div element that you see on the
// screen can be accessed by using splitterBar.splitterBar
// or by document.getElementById('splitterBarID')
// where 'splitterBarID' is the ID of the server control
// in your ASPX code.
// check to see which splitterBar fired this event
if ( splitterBar splitterBar.id == "vwdSplitter1" )
{
cancelTimer("divAlert");
var div = document.getElementById("divDirection");
div.style.display = "none";
div.innerHTML = "";
_prevWidth = 0;
}
}
function setupTimer(controlId)
{
cancelTimer(controlId);
_timerID = setInterval("showAlert('" + controlId + "');", 300);
}
function cancelTimer(controlId)
{
if ( _timerID != 0 )
{
hideAlert(controlId);
clearInterval(_timerID);
_timerID = 0;
}
}
function showAlert(controlId)
{
var element = document.getElementById(controlId);
if ( element element.style )
{
element.style.display = "block";
if (element.style.fontWeight == "bold")
{
element.style.fontWeight = "normal";
}
else
{
element.style.fontWeight = "bold";
}
}
}
function hideAlert(controlId)
{
var element = document.getElementById(controlId);
if ( element element.style )
{
element.style.display = "none";
element.style.fontWeight = "normal";
}
}
This code sample has been automatically colorized by the
VwdCms.CodeViewer
control, an ASP.NET server control code colorizer that supports
HTML, ASPX, XML, C#, and JavaScript code formats.
All SplitterBar examples presented here are using a Master Page with the following DOCTYPE declaration:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">