blob: 10bbe06b3a34c172ae597863040c9a221b971c16 [file] [log] [blame]
requirejs.config({
baseUrl: '../js/src'
});
require(['menu','menu/item', 'menu/prefix', 'menu/lengthField'], function (menuClass, itemClass, prefixClass, lengthFieldClass) {
var OwnMenuItemClass = {
create : function (params) {
return Object.create(itemClass).upgradeTo(this)._init(params);
},
content : function (content) {
if (arguments.length === 1) {
this._content = content;
};
return this._content;
},
// enter or click
onclick : function () {
console.log(this._name);
},
// right arrow
further : function () {
console.log("Further: " + this._name);
},
_init : function (params) {
if (params[0] === undefined)
throw new Error("Missing parameters");
this._name = params[0];
this._content = document.createTextNode(this._name);
this._lcField = ' ' + this.content().textContent.toLowerCase();
return this;
}
};
var OwnPrefixClass = {
create : function () {
return Object.create(prefixClass)
.upgradeTo(this)
._init();
},
onclick : function () {
console.log('Prefix: ' + this.value());
}
};
var OwnMenu = {
create : function (params) {
var obj = Object.create(menuClass)
.upgradeTo(this)
._init(OwnMenuItemClass, OwnPrefixClass, lengthFieldClass, params);
obj._firstActive = true;
return obj;
}
};
var menu = OwnMenu.create([
['Titel', 'title', 'string'],
['Untertitel', 'subTitle', 'string'],
['Beschreibung', 'desc', 'string'],
['Veröffentlichungsdatum', 'pubDate', 'date'],
['Länge', 'length', 'integer'],
['Autor', 'author', 'string'],
['Genre', 'genre', 'string'],
['corpusID', 'corpusID', 'string'],
['docID', 'docID', 'string'],
['textID', 'textID', 'string']
]);
document.getElementById('menu').appendChild(menu.element());
menu._active = 2;
menu.limit(3);
menu.show('');
menu.focus();
});