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