Akron | 52ed22d | 2018-07-11 17:05:19 +0200 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
Akron | 537bc52 | 2018-07-13 19:06:27 +0200 | [diff] [blame] | 4 | <title>Panel and ButtonGroup demo</title> |
Akron | 52ed22d | 2018-07-11 17:05:19 +0200 | [diff] [blame] | 5 | <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> |
Akron | 537bc52 | 2018-07-13 19:06:27 +0200 | [diff] [blame] | 10 | <nav id="mainButton" style="position: absolute; width: 100%; top: 150px"></nav> |
Akron | 52ed22d | 2018-07-11 17:05:19 +0200 | [diff] [blame] | 11 | </body> |
| 12 | <script> |
| 13 | requirejs.config({ |
| 14 | baseUrl: '../js/src', |
| 15 | paths : { |
| 16 | 'lib': '../lib' |
| 17 | } |
| 18 | }); |
| 19 | |
| 20 | |
Akron | 858cbc8 | 2019-12-05 16:53:13 +0100 | [diff] [blame^] | 21 | require(['buttongroup', 'panel', 'view/result/koralquery', 'state'], function (btnClass, panelClass, kqClass, stateClass) { |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 22 | KorAP.koralQuery = { |
| 23 | '@type' : "https://beispiel", |
| 24 | 'key' : 'Cool' |
| 25 | }; |
| 26 | |
Akron | 858cbc8 | 2019-12-05 16:53:13 +0100 | [diff] [blame^] | 27 | let panel = panelClass.create(); |
| 28 | let actions = panel.actions; |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 29 | |
Akron | 858cbc8 | 2019-12-05 16:53:13 +0100 | [diff] [blame^] | 30 | // Add simple button |
Akron | 537bc52 | 2018-07-13 19:06:27 +0200 | [diff] [blame] | 31 | actions.add('Meta',['meta'], function () { |
Akron | 52ed22d | 2018-07-11 17:05:19 +0200 | [diff] [blame] | 32 | console.log(this.button.classList.contains('meta')); |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 33 | view = kqClass.create(); |
Akron | 537bc52 | 2018-07-13 19:06:27 +0200 | [diff] [blame] | 34 | panel.add(view); |
Akron | 52ed22d | 2018-07-11 17:05:19 +0200 | [diff] [blame] | 35 | }); |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 36 | |
Akron | 858cbc8 | 2019-12-05 16:53:13 +0100 | [diff] [blame^] | 37 | // Add list button |
Akron | 537bc52 | 2018-07-13 19:06:27 +0200 | [diff] [blame] | 38 | var list = actions.addList('More', ['list']); |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 39 | |
Akron | 52ed22d | 2018-07-11 17:05:19 +0200 | [diff] [blame] | 40 | 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 | ]); |
Akron | 537bc52 | 2018-07-13 19:06:27 +0200 | [diff] [blame] | 44 | |
Akron | 858cbc8 | 2019-12-05 16:53:13 +0100 | [diff] [blame^] | 45 | // 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 | |
Akron | 537bc52 | 2018-07-13 19:06:27 +0200 | [diff] [blame] | 62 | document.getElementById('mainButton').appendChild(panel.element()); |
Akron | 52ed22d | 2018-07-11 17:05:19 +0200 | [diff] [blame] | 63 | }); |
| 64 | |
| 65 | |
| 66 | </script> |
| 67 | </html> |