blob: 0d36724f5ffa2de9e723f1969f6a90f9d06bae71 [file] [log] [blame]
Akrone51eaa32020-11-10 09:35:53 +01001"use strict";
2
Nils Diewald0e6992a2015-04-14 20:13:52 +00003define(['menu/item'], function (itemClass) {
Akron671fdb92017-09-12 18:09:46 +02004
Nils Diewald0e6992a2015-04-14 20:13:52 +00005 /**
6 * Menu item for tree view choice.
7 */
8
9 return {
Nils Diewald7148c6f2015-05-04 15:07:53 +000010
11 /**
12 * Create new menu item
13 * for tree views.
14 */
Nils Diewald0e6992a2015-04-14 20:13:52 +000015 create : function (params) {
16 return Object.create(itemClass)
Akrond67d45b2017-05-18 21:47:38 +020017 .upgradeTo(this)._init(params);
Nils Diewald0e6992a2015-04-14 20:13:52 +000018 },
Nils Diewald7148c6f2015-05-04 15:07:53 +000019
20 /**
21 * Get or set the content of the
22 * menu item.
23 */
Nils Diewald0e6992a2015-04-14 20:13:52 +000024 content : function (content) {
25 if (arguments.length === 1) {
Akrond67d45b2017-05-18 21:47:38 +020026 this._content = content;
Nils Diewald0e6992a2015-04-14 20:13:52 +000027 };
28 return this._content;
29 },
30
Akronff1b1f32020-10-18 11:41:29 +020031
Nils Diewald7148c6f2015-05-04 15:07:53 +000032 /**
33 * The foundry attribute of the menu item.
34 */
Nils Diewald0e6992a2015-04-14 20:13:52 +000035 foundry : function () {
36 return this._foundry;
37 },
38
Akronff1b1f32020-10-18 11:41:29 +020039
Nils Diewald7148c6f2015-05-04 15:07:53 +000040 /**
41 * The layer attribute of the menu item.
42 */
Nils Diewald0e6992a2015-04-14 20:13:52 +000043 layer : function () {
44 return this._layer;
45 },
46
Akronff1b1f32020-10-18 11:41:29 +020047
Nils Diewald7148c6f2015-05-04 15:07:53 +000048 /**
Akron0988d882017-11-10 16:13:12 +010049 * The type attribute of the menu item.
50 * Is either "spans" or "rels".
51 */
52 type : function () {
53 return this._type;
54 },
55
Akronff1b1f32020-10-18 11:41:29 +020056
Akron0988d882017-11-10 16:13:12 +010057 /**
Nils Diewald7148c6f2015-05-04 15:07:53 +000058 * Override click action of the menu item.
59 */
Nils Diewald0e6992a2015-04-14 20:13:52 +000060 onclick : function (e) {
Akronff1b1f32020-10-18 11:41:29 +020061 const menu = this.menu();
Nils Diewald0e6992a2015-04-14 20:13:52 +000062 menu.hide();
63 e.halt();
Akronff1b1f32020-10-18 11:41:29 +020064
Akron7f9a6a32018-07-18 15:05:23 +020065 if (menu.panel() !== undefined) {
66 menu.panel().addTree(this._foundry, this._layer, this._type);
Akron0988d882017-11-10 16:13:12 +010067 };
Nils Diewald0e6992a2015-04-14 20:13:52 +000068 },
Nils Diewald7148c6f2015-05-04 15:07:53 +000069
Akronff1b1f32020-10-18 11:41:29 +020070
Nils Diewald7148c6f2015-05-04 15:07:53 +000071 // Initialize tree menu item.
Nils Diewald0e6992a2015-04-14 20:13:52 +000072 _init : function (params) {
73 if (params[0] === undefined)
Akrond67d45b2017-05-18 21:47:38 +020074 throw new Error("Missing parameters");
Nils Diewald0e6992a2015-04-14 20:13:52 +000075
Akronff1b1f32020-10-18 11:41:29 +020076 const t = this;
77
78 t._name = params[0];
79 t._foundry = params[1];
80 t._layer = params[2];
81 t._type = params[3];
82 t._content = document.createTextNode(t._name);
83 t._lcField = ' ' + t.content().textContent.toLowerCase();
84 return t;
Nils Diewald0e6992a2015-04-14 20:13:52 +000085 }
86 };
87});