blob: ea8f57d6db5dd461cb9dc27a9c3b24f74f64bc83 [file] [log] [blame]
Akron52ed22d2018-07-11 17:05:19 +02001<!DOCTYPE html>
2<html>
3 <head>
Akron537bc522018-07-13 19:06:27 +02004 <title>Panel and ButtonGroup demo</title>
Akron52ed22d2018-07-11 17:05:19 +02005 <meta charset="utf-8" />
6 <script src="../js/lib/require.js" async="async"></script>
7 <link type="text/css" rel="stylesheet" href="../css/kalamar.css" />
8 </head>
9 <body>
Akron537bc522018-07-13 19:06:27 +020010 <nav id="mainButton" style="position: absolute; width: 100%; top: 150px"></nav>
Akron52ed22d2018-07-11 17:05:19 +020011 </body>
12 <script>
13requirejs.config({
14 baseUrl: '../js/src',
15 paths : {
16 'lib': '../lib'
17 }
18});
19
20
Akron858cbc82019-12-05 16:53:13 +010021require(['buttongroup', 'panel', 'view/result/koralquery', 'state'], function (btnClass, panelClass, kqClass, stateClass) {
Akron4d926f12018-07-16 15:30:25 +020022 KorAP.koralQuery = {
23 '@type' : "https://beispiel",
24 'key' : 'Cool'
25 };
26
Akron858cbc82019-12-05 16:53:13 +010027 let panel = panelClass.create();
28 let actions = panel.actions;
Akron4d926f12018-07-16 15:30:25 +020029
Akron858cbc82019-12-05 16:53:13 +010030 // Add simple button
Akron792b1a42020-09-14 18:56:38 +020031 actions.add('Meta',{'cls':['meta']}, function () {
Akron52ed22d2018-07-11 17:05:19 +020032 console.log(this.button.classList.contains('meta'));
Akron4d926f12018-07-16 15:30:25 +020033 view = kqClass.create();
Akron537bc522018-07-13 19:06:27 +020034 panel.add(view);
Akron52ed22d2018-07-11 17:05:19 +020035 });
Akron4d926f12018-07-16 15:30:25 +020036
Akron858cbc82019-12-05 16:53:13 +010037 // Add list button
Akron537bc522018-07-13 19:06:27 +020038 var list = actions.addList('More', ['list']);
Akron4d926f12018-07-16 15:30:25 +020039
Akron52ed22d2018-07-11 17:05:19 +020040 list.readItems([
41 ['cool', 'cool', function (e, action) { console.log('really' + this.action()) }],
42 ['very cool', 'veryCool', function (e, action) { console.log('very cool') }]
43 ]);
Akron537bc522018-07-13 19:06:27 +020044
Akron858cbc82019-12-05 16:53:13 +010045 // Add toggle button
46 let s = stateClass.create(true);
47
48 let bgChange = {
49 setState : function (val) {
50 if (val) {
51 document.body.style.backgroundColor = 'red';
52 } else {
53 document.body.style.backgroundColor = 'transparent';
54 }
55 }
56 };
57
58 s.associate(bgChange);
59
60 actions.addToggle('Background',['bg'], s);
61
Akron537bc522018-07-13 19:06:27 +020062 document.getElementById('mainButton').appendChild(panel.element());
Akron52ed22d2018-07-11 17:05:19 +020063});
64
65
66 </script>
67</html>