/* * Widget to configure an autocompletion widget with suggestions from a skos vocabulary */ YUI.add('skosautocomplete', function(Y) { function SkosAutoComplete(config) { SkosAutoComplete.superclass.constructor.apply(this, arguments); } SkosAutoComplete.NAME = "aclist"; // use same name as Y.Plugin.AutoComplete to inherit css SkosAutoComplete.NS = "skosautocomplete"; SkosAutoComplete.ATTRS = { handler: { value: null }, // on select we call handler ... caller: { value: null }, // with caller and context: { value: {} }, // context as parameters }; Y.extend(SkosAutoComplete, Y.Plugin.AutoComplete, { initializer: function(args) { var parentNode = this.DEF_PARENT_NODE; // handler to call when item selected from autocompletion suggestions: var caller = this.get('caller'); var handler = this.get('handler'); var context = this.get('context'); this.on("select", handler, caller, context); // infoNode is the overlay with tooltips when hovering over suggested terms this.infoNode = new Y.Overlay({}).render(parentNode); this.on("activeItemChange", this.onSuggestionHover, this); this.on("hoveredItemChange", this.onSuggestionHover, this); }, onSuggestionHover : function(ev) { var infoNode = this.infoNode, active = ev.newVal, body = ''; if(active && active.getData().result.raw.info) { var scope = active.getData().result.raw.info.scopeNotes[0]; var defin = active.getData().result.raw.info.definitions[0]; var alts = active.getData().result.raw.info.altLabels; var img = active.getData().result.raw.info.images[0]; if (scope && scope.en) { body += "