source: main/trunk/model-sites-dev/von-sparql/js/paper/examples/Interface/Palette.html@ 28914

Last change on this file since 28914 was 28914, checked in by ak19, 10 years ago

Supporting javascript libraries and bespoke code written by Steffan to support the von-sparql user interface

File size: 1.5 KB
Line 
1<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="UTF-8">
5 <title>Paelette</title>
6 <link rel="stylesheet" href="../css/style.css">
7 <script type="text/javascript" src="../../dist/paper.js"></script>
8 <script type="text/paperscript" canvas="canvas">
9 var values = {
10 number: 1,
11 string: 200,
12 checkbox: true,
13 list: 'Two',
14 text: 'Hello World!'
15 };
16 var components = {
17 number: {
18 type: 'number',
19 label: 'A Number',
20 step: 2.5
21 },
22 string: {
23 type: 'string',
24 label: 'A String'
25 },
26 checkbox: {
27 type: 'boolean',
28 label: 'A Checkbox',
29 onChange: function(value) {
30 values.list = value ? 'Two' : 'One';
31 }
32 },
33 list: {
34 type: 'list',
35 label: 'A List',
36 options: [ 'One', 'Two', 'Three' ]
37 },
38 text: {
39 type: 'text',
40 label: 'A Text'
41 },
42 button: {
43 type: 'button',
44 label: 'A Button',
45 value: 'Click Me!',
46 onClick: function() {
47 console.log('Resetting');
48 palette.reset();
49 values.text = 'You clicked!';
50 }
51 },
52 slider: {
53 type: 'slider',
54 label: 'A Slider',
55 value: 10,
56 range: [0, 50],
57 step: 10
58 }
59 };
60 var palette = new Palette('Values', components, values);
61 palette.onChange = function(component, name, value) {
62 console.log(name + ' = ' + value, component);
63 }
64 values.number = 10;
65 values.string = 'Woop woop';
66 values.list = 'Three';
67 console.log(JSON.stringify(values));
68 </script>
69</head>
70<body>
71 <canvas id="canvas" width="640" height="100"></canvas>
72</body>
73</html>
Note: See TracBrowser for help on using the repository browser.