Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>Menu demo</title> |
| 5 | <meta charset="utf-8" /> |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame^] | 6 | <script src="../js/src/menu.js"></script> |
| 7 | <link type="text/css" rel="stylesheet" href="../css/kalamar.css" /> |
Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 8 | <style type="text/css" rel="stylesheet"> |
| 9 | .info { |
| 10 | background-color: #ddd; |
| 11 | color: black; |
| 12 | padding: 1em; |
| 13 | font-family: mono; |
| 14 | } |
| 15 | body { |
| 16 | margin: 0; |
| 17 | background-color: #ddd; |
| 18 | } |
| 19 | </style> |
| 20 | </head> |
| 21 | <body> |
| 22 | <div style="position: absolute; background-color: #7ba400; height: 50px; width: 100%;"></div> |
| 23 | |
| 24 | <div id="menu" class="vc"></div> |
| 25 | |
| 26 | <main> |
| 27 | <div> |
| 28 | <div id="pagination"><a rel="prev"><span><i class="fa fa-caret-left"></i></span></a><a rel="self"><span>1</span></a><a href="/kalamar?q=der+%5Bmate/m%3Dnumber:sg%5D&ql=poliqarp&p=2"><span>2</span></a><a href="/kalamar?q=der+%5Bmate/m%3Dnumber:sg%5D&ql=poliqarp&p=3"><span>3</span></a><span><i class="fa fa-ellipsis-h"></i></span><a href="/kalamar?q=der+%5Bmate/m%3Dnumber:sg%5D&ql=poliqarp&p=52230"><span>52230</span></a><a rel="next" href="/kalamar?q=der+%5Bmate/m%3Dnumber:sg%5D&ql=poliqarp&p=2"><span><i class="fa fa-caret-right"></i></span></a></div> |
| 29 | </div> |
| 30 | </main> |
| 31 | |
| 32 | <script> |
| 33 | KorAP.OwnMenuItem = { |
| 34 | create : function (params) { |
| 35 | return Object.create(KorAP.MenuItem).upgradeTo(KorAP.OwnMenuItem)._init(params); |
| 36 | }, |
| 37 | content : function (content) { |
| 38 | if (arguments.length === 1) { |
| 39 | this._content = content; |
| 40 | }; |
| 41 | return this._content; |
| 42 | }, |
| 43 | |
| 44 | // enter or click |
| 45 | onclick : function () { |
| 46 | console.log(this._name); |
| 47 | }, |
| 48 | |
| 49 | // right arrow |
| 50 | further : function () { |
| 51 | console.log("Further: " + this._name); |
| 52 | }, |
| 53 | _init : function (params) { |
| 54 | if (params[0] === undefined) |
| 55 | throw new Error("Missing parameters"); |
| 56 | |
| 57 | this._name = params[0]; |
| 58 | this._content = document.createTextNode(this._name); |
| 59 | this._lcField = ' ' + this.content().textContent.toLowerCase(); |
| 60 | |
| 61 | return this; |
| 62 | } |
| 63 | }; |
| 64 | |
| 65 | KorAP.OwnPrefix = { |
| 66 | create : function () { |
| 67 | return Object.create(KorAP.MenuPrefix) |
| 68 | .upgradeTo(KorAP.OwnPrefix) |
| 69 | ._init(); |
| 70 | }, |
| 71 | onclick : function () { |
| 72 | console.log('Prefix: ' + this.value()); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | KorAP.OwnMenu = { |
| 77 | create : function (params) { |
| 78 | return Object.create(KorAP.Menu) |
| 79 | .upgradeTo(KorAP.OwnMenu) |
| 80 | ._init(KorAP.OwnMenuItem, KorAP.OwnPrefix, params); |
| 81 | } |
| 82 | }; |
| 83 | |
| 84 | var menu = KorAP.OwnMenu.create([ |
| 85 | ['Titel', 'title', 'string'], |
| 86 | ['Untertitel', 'subTitle', 'string'], |
| 87 | ['Veröffentlichungsdatum', 'pubDate', 'date'], |
| 88 | ['Länge', 'length', 'integer'], |
| 89 | ['Autor', 'author', 'string'], |
| 90 | ['Genre', 'genre', 'string'], |
| 91 | ['corpusID', 'corpusID', 'string'], |
| 92 | ['docID', 'docID', 'string'], |
| 93 | ['textID', 'textID', 'string'] |
| 94 | ]); |
| 95 | |
| 96 | document.getElementById('menu').appendChild(menu.element()); |
| 97 | |
| 98 | menu.limit(3); |
| 99 | menu.show(''); |
| 100 | menu.focus(); |
| 101 | |
| 102 | </script> |
| 103 | </body> |
| 104 | </html> |