Files
2022-11-04 13:24:24 +02:00

195 lines
6.9 KiB
HTML
Executable File

<!DOCTYPE html>
<html>
<head>
<title>Style binding</title>
<meta charset="utf-8">
<link href="../content/shared/styles/examples-offline.css" rel="stylesheet">
<link href="../../styles/kendo.common.min.css" rel="stylesheet">
<link href="../../styles/kendo.rtl.min.css" rel="stylesheet">
<link href="../../styles/kendo.default.min.css" rel="stylesheet">
<link href="../../styles/kendo.default.mobile.min.css" rel="stylesheet">
<script src="../../js/jquery.min.js"></script>
<script src="../../js/jszip.min.js"></script>
<script src="../../js/kendo.all.min.js"></script>
<script src="../content/shared/js/console.js"></script>
<script>
</script>
</head>
<body>
<a class="offline-button" href="../index.html">Back</a>
<div id="example">
<div class="demo-section k-content">
<div id="target" data-bind="style: {
backgroundColor: selectedBackground,
color: selectedColor,
borderStyle: selectedBorderStyle,
borderColor: selectedBorderColor,
webkitBorderRadius: selectedBorderRadius,
mozBorderRadius: selectedBorderRadius,
borderRadius: selectedBorderRadius
}">
One Big Orange Spot.
</div>
<ul class="fieldlist">
<li>
<label>Color:</label> <select data-text-field="name" data-value-field="hex" data-bind="source: colors, value: selectedColor"></select>
</li>
<li>
<label>Background color:</label> <select data-text-field="name" data-value-field="hex" data-bind="source: colors, value: selectedBackground"></select>
</li>
<li>
<label>Border color:</label> <select data-text-field="name" data-value-field="hex" data-bind="source: colors, value: selectedBorderColor"></select>
</li>
<li>
<label>Border style:</label> <select data-text-field="name" data-value-field="value" data-bind="source: borders, value: selectedBorderStyle"></select>
</li>
<li>
<label>Border radius:</label> <select data-bind="source: radii, value: selectedBorderRadius"></select>
</li>
</ul>
</div>
<script>
$(document).ready(function() {
var viewModel = kendo.observable({
selectedColor: "#8b0000",
selectedBorderRadius: "20px",
selectedBackground: "#ffd700",
selectedBorderStyle: "solid",
selectedBorderColor: "#ff8c00",
radii: [
"0px",
"5px",
"10px",
"20px"
],
colors: [
{ name: "Dark Red", hex: "#8b0000" },
{ name: "Orange Red", hex: "#ff4500" },
{ name: "Dark Orange", hex: "#ff8c00" },
{ name: "Gold", hex: "#ffd700" }
],
borders: [
{ name: "Solid", value: "solid" },
{ name: "Dashed", value: "dashed" },
{ name: "Double", value: "double" },
{ name: "Dotted", value: "dotted" },
{ name: "Ridge", value: "ridge" },
{ name: "None", value: "none" }
]
});
kendo.bind($("#example"), viewModel);
});
</script>
<div class="box wide">
<h4>View source code:</h4>
<pre class="prettyprint">
&lt;div id=&quot;target&quot; data-bind=&quot;style: {
backgroundColor: selectedBackground,
color: selectedColor,
borderStyle: selectedBorderStyle,
borderColor: selectedBorderColor,
webkitBorderRadius: selectedBorderRadius,
mozBorderRadius: selectedBorderRadius,
borderRadius: selectedBorderRadius
}&quot;&gt;
One Big Orange Spot.
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
Color: &lt;select data-text-field=&quot;name&quot; data-value-field=&quot;hex&quot; data-bind=&quot;source: colors, value: selectedColor&quot;&gt;&lt;/select&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;label&gt;Background color: &lt;select data-text-field=&quot;name&quot;
data-value-field=&quot;hex&quot; data-bind=&quot;source: colors, value: selectedBackground&quot;&gt;&lt;/select&gt;&lt;/label&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;label&gt;Border color: &lt;select data-text-field=&quot;name&quot;
data-value-field=&quot;hex&quot; data-bind=&quot;source: colors, value: selectedBorderColor&quot;&gt;&lt;/select&gt;&lt;/label&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;label&gt;Border style: &lt;select data-text-field=&quot;name&quot;
data-value-field=&quot;value&quot; data-bind=&quot;source: borders, value: selectedBorderStyle&quot;&gt;&lt;/select&gt;&lt;/label&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;label&gt;Border radius: &lt;select data-bind=&quot;source: radii, value: selectedBorderRadius&quot;&gt;&lt;/select&gt;&lt;/label&gt;
&lt;/li&gt;
&lt;/ul&gt;
</pre>
<h4 style="padding-top: 2em;">View model source code:</h4>
<pre class="prettyprint">
var viewModel = kendo.observable({
selectedColor: "#8b0000",
selectedBorderRadius: "20px",
selectedBackground: "#ffd700",
selectedBorderStyle: "solid",
selectedBorderColor: "#ff8c00",
radii: [ "0px", "5px", "10px", "20px" ],
colors: [
{ name: "Dark Red", hex: "#8b0000" },
{ name: "Orange Red", hex: "#ff4500" },
{ name: "Dark Orange", hex: "#ff8c00" },
{ name: "Gold", hex: "#ffd700" }
],
borders: [
{ name: "Solid", value: "solid" },
{ name: "Dashed", value: "dashed" },
{ name: "Double", value: "double" },
{ name: "Dotted", value: "dotted" },
{ name: "Ridge", value: "ridge" },
{ name: "None", value: "none" }
]
});
kendo.bind($("#example"), viewModel);
</pre>
</div>
<style>
.demo-section label {
display: block;
float: left;
clear: left;
width: 120px;
margin: .5em 0;
}
.demo-section select {
float: left;
width: 120px;
margin: .5em 0;
}
#target {
width: 100%;
border-width: 4px;
padding: 2em;
display: block;
box-sizing: border-box;
margin: 0 auto 30px;
-webkit-transition: all 500ms;
-moz-transition: all 500ms;
transition: all 500ms;
text-align: center;
vertical-align: middle;
}
.prettyprint {
background-color: #fff;
border: 1px solid #ccc;
overflow: auto;
padding: 5px;
}
</style>
</div>
</body>
</html>