Slider creation
Position | |
Width | |
Tooltip Template | |
Min Text/Value | |
Max Text/Value | |
Init Value | |
Add? |
</> Source
<!DOCTYPE html>
<html>
<head>
<title>Slider creation</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/fonts/font_roboto/roboto.css"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
<script src="../../../codebase/dhtmlx.js"></script>
<style>
div#toolbarObj {
margin-top: 30px;
}
</style>
<script>
var sel;
var myToolbar;
function doOnLoad() {
sel = document.getElementById("sel");
myToolbar = new dhtmlXToolbarObject({
parent: "toolbarObj",
icons_path: "../common/imgs/",
xml: "../common/dhxtoolbar_slider.xml",
onload: updateList
});
}
function add() {
var id = String(new Date().getTime());
var pos = Number(document.getElementById("txt1").value);
var len = String(document.getElementById("txt2").value);
var valueMin = Number(document.getElementById("txt5").value);
var valueMax = Number(document.getElementById("txt7").value);
var valueNow = Number(document.getElementById("txt8").value);
var textMin = String(document.getElementById("txt4").value);
var textMax = String(document.getElementById("txt6").value);
var tip = String(document.getElementById("txt3").value);
myToolbar.addSlider(id, pos, len, valueMin, valueMax, valueNow, textMin, textMax, tip);
updateList();
}
function getId() {
var id = sel.options[sel.selectedIndex].value;
return id;
}
function removeItem() {
if (sel.options.length == 0) { return; }
myToolbar.removeItem(getId());
updateList();
}
function updateList() {
sel.options.length = 0;
myToolbar.forEachItem(function(itemId){
if (myToolbar.getType(itemId) == "slider") {
sel.options.add(new Option(itemId, itemId));
}
});
}
</script>
</head>
<body onload="doOnLoad()">
<div id="toolbarObj"></div>
<div style="margin-top: 30px;">
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td style="padding-right: 5px;">Position</td>
<td><input id="txt1" type="text" value="1" style="width: 30px;"></td>
</tr>
<tr>
<td style="padding-right: 5px;">Width</td>
<td><input id="txt2" type="text" value="60" style="width: 50px;"></td>
</tr>
<tr>
<td style="padding-right: 5px;">Tooltip Template</td>
<td><input id="txt3" type="text" value="Current value: %v"></td>
</tr>
<tr>
<td style="padding-right: 5px;">Min Text/Value</td>
<td>
<input id="txt4" type="text" value="Min" style="width: 50px;">
<input id="txt5" type="text" value="100" style="width: 30px;">
</td>
</tr>
<tr>
<td style="padding-right: 5px;">Max Text/Value</td>
<td>
<input id="txt6" type="text" value="Max" style="width: 50px;">
<input id="txt7" type="text" value="200" style="width: 30px;">
</td>
</tr>
<tr>
<td style="padding-right: 5px;">Init Value</td>
<td><input id="txt8" type="text" value="150" style="width: 30px;"></td>
</tr>
<tr>
<td style="padding-right: 5px;">Add?</td>
<td><input type="button" value="Add" onclick="add();"></td>
</tr>
</table>
<table cellspacing="0" cellpadding="2" border="0" style="margin-top: 10px;">
<tr>
<td style="padding-right: 5px;"><select id="sel"></select></td>
<td><input type="button" value="Remove" onclick="removeItem();"></td>
</tr>
</table>
</div>
</body>
</html>
Documentation
Check documentation to learn how to use the components and easily implement them in your applications.