blob: 0b4d6c4058b88ca9a10b3830d1490760b8acdc7f [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();
Akron6333dd12024-07-29 15:24:06 +020028 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
Akron6333dd12024-07-29 15:24:06 +020040 list.list.readItems([
Akron52ed22d2018-07-11 17:05:19 +020041 ['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>