blob: 4f2e12defbed327bab570c16e9f89340ab972108 [file] [log] [blame]
Nils Diewald0e6992a2015-04-14 20:13:52 +00001requirejs.config({
2 baseUrl: '../js/src',
3 paths : {
4 'lib': '../lib'
5 }
6});
7
Akron308db382016-05-30 22:34:07 +02008var hint = undefined;
9
Akron2d0d96d2019-11-18 19:49:50 +010010require(['plugin/server','panel/query', 'hint','hint/foundries/cnx','lib/domReady'], function (pluginClass, queryPanelClass, hintClass, hintArray, domReady) {
Nils Diewald0e6992a2015-04-14 20:13:52 +000011 KorAP.hintArray = hintArray;
Akron72f73572017-12-05 12:31:09 +010012 KorAP.Hint = null;
Akron2d0d96d2019-11-18 19:49:50 +010013
Nils Diewald0e6992a2015-04-14 20:13:52 +000014 domReady(function() {
Akron2d0d96d2019-11-18 19:49:50 +010015
Akron72f73572017-12-05 12:31:09 +010016 KorAP.Hint = hintClass.create();
Akron2d0d96d2019-11-18 19:49:50 +010017
Leo Repp8e21cbe2021-08-18 16:37:52 +020018 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
Akron2d0d96d2019-11-18 19:49:50 +010026 /**
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' : {
Akrondbf7bae2020-10-07 10:44:24 +020060 "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",
Akron2d0d96d2019-11-18 19:49:50 +010076 "template" : "http://localhost:3003/demo/plugin-client.html"
77 }
78 }]
79 });
Leo Repp8e21cbe2021-08-18 16:37:52 +020080
81 console.log(KorAP.Hint);
Nils Diewald0e6992a2015-04-14 20:13:52 +000082 });
83});
Akron308db382016-05-30 22:34:07 +020084
85function demoAlert (pos, msg) {
Akron72f73572017-12-05 12:31:09 +010086 if (KorAP.hint !== undefined)
87 KorAP.Hint.alert(pos, msg);
Leo Repp8e21cbe2021-08-18 16:37:52 +020088 console.log(KorAP.Hint);
Akron308db382016-05-30 22:34:07 +020089}