Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 1 | requirejs.config({ |
| 2 | baseUrl: '../js/src', |
| 3 | paths : { |
| 4 | 'lib': '../lib' |
| 5 | } |
| 6 | }); |
| 7 | |
Akron | 308db38 | 2016-05-30 22:34:07 +0200 | [diff] [blame] | 8 | var hint = undefined; |
| 9 | |
Akron | 2d0d96d | 2019-11-18 19:49:50 +0100 | [diff] [blame] | 10 | require(['plugin/server','panel/query', 'hint','hint/foundries/cnx','lib/domReady'], function (pluginClass, queryPanelClass, hintClass, hintArray, domReady) { |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 11 | KorAP.hintArray = hintArray; |
Akron | 72f7357 | 2017-12-05 12:31:09 +0100 | [diff] [blame] | 12 | KorAP.Hint = null; |
Akron | 2d0d96d | 2019-11-18 19:49:50 +0100 | [diff] [blame] | 13 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 14 | domReady(function() { |
Akron | 2d0d96d | 2019-11-18 19:49:50 +0100 | [diff] [blame] | 15 | |
Akron | 72f7357 | 2017-12-05 12:31:09 +0100 | [diff] [blame] | 16 | KorAP.Hint = hintClass.create(); |
Akron | 2d0d96d | 2019-11-18 19:49:50 +0100 | [diff] [blame] | 17 | |
Leo Repp | 5799740 | 2021-08-18 16:37:52 +0200 | [diff] [blame^] | 18 | var newItem = { |
| 19 | onclick : function (e) { console.log("CI click"); console.log(this.element()); console.log("'" + this._menu.prefix() + "'" + " <-- If this returns the empty string when\ |
| 20 | it should not, we know that the click event listener in container.js gets called too early and overwrites the prefix before we can read it.");}, |
| 21 | chop : function () { console.log("chop"); }, |
| 22 | defaultTextValue : "Text Example" |
| 23 | }; |
| 24 | KorAP.Hint.menu("-").container().addItem(newItem); //must be added to a specific context menu. |
| 25 | |
Akron | 2d0d96d | 2019-11-18 19:49:50 +0100 | [diff] [blame] | 26 | /** |
| 27 | * Add query panel |
| 28 | */ |
| 29 | var queryPanel = queryPanelClass.create(); |
| 30 | |
| 31 | // Get input field |
| 32 | var sform = document.getElementById("searchform"); |
| 33 | var vcView = document.getElementById('vc-view') |
| 34 | if (sform && vcView) { |
| 35 | // The views are below the query bar |
| 36 | sform.insertBefore(queryPanel.element(),vcView); |
| 37 | KorAP.Panel = KorAP.Panel || {}; |
| 38 | KorAP.Panel['query'] = queryPanel; |
| 39 | } |
| 40 | |
| 41 | // Load plugin server |
| 42 | KorAP.Plugin = pluginClass.create(); |
| 43 | |
| 44 | // Register match plugin |
| 45 | KorAP.Plugin.register({ |
| 46 | 'name' : 'Example New', |
| 47 | 'desc' : 'Some content about cats', |
| 48 | 'embed' : [{ |
| 49 | 'panel' : 'query', |
| 50 | 'title' : 'Translate', |
| 51 | 'classes' : ['translate'], |
| 52 | 'onClick' : { |
| 53 | "template" : "http://localhost:3003/demo/plugin-client.html" |
| 54 | } |
| 55 | },{ |
| 56 | 'panel' : 'query', |
| 57 | 'title' : 'Glemm', |
| 58 | 'classes' : ['glemm'], |
| 59 | 'onClick' : { |
Akron | dbf7bae | 2020-10-07 10:44:24 +0200 | [diff] [blame] | 60 | "action":"toggle", |
| 61 | "template" : "http://localhost:3003/demo/plugin-client.html" |
| 62 | } |
| 63 | }] |
| 64 | }); |
| 65 | |
| 66 | // Register match plugin |
| 67 | KorAP.Plugin.register({ |
| 68 | 'name' : 'Glimpse', |
| 69 | 'desc' : 'Shorten all queries', |
| 70 | 'embed' : [{ |
| 71 | 'panel' : 'query', |
| 72 | 'title' : 'Glimpse', |
| 73 | 'classes' : ['glimpse'], |
| 74 | 'onClick' : { |
| 75 | "action" : "toggle", |
Akron | 2d0d96d | 2019-11-18 19:49:50 +0100 | [diff] [blame] | 76 | "template" : "http://localhost:3003/demo/plugin-client.html" |
| 77 | } |
| 78 | }] |
| 79 | }); |
Leo Repp | 5799740 | 2021-08-18 16:37:52 +0200 | [diff] [blame^] | 80 | |
| 81 | console.log(KorAP.Hint); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 82 | }); |
| 83 | }); |
Akron | 308db38 | 2016-05-30 22:34:07 +0200 | [diff] [blame] | 84 | |
| 85 | function demoAlert (pos, msg) { |
Akron | 72f7357 | 2017-12-05 12:31:09 +0100 | [diff] [blame] | 86 | if (KorAP.hint !== undefined) |
| 87 | KorAP.Hint.alert(pos, msg); |
Leo Repp | 5799740 | 2021-08-18 16:37:52 +0200 | [diff] [blame^] | 88 | console.log(KorAP.Hint); |
Akron | 308db38 | 2016-05-30 22:34:07 +0200 | [diff] [blame] | 89 | } |