| Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 1 | define(['menu/item'], function (itemClass) { | 
|  | 2 | /** | 
|  | 3 | * Menu item for tree view choice. | 
|  | 4 | */ | 
|  | 5 |  | 
|  | 6 | return { | 
|  | 7 | create : function (params) { | 
|  | 8 | return Object.create(itemClass) | 
|  | 9 | .upgradeTo(this)._init(params); | 
|  | 10 | }, | 
|  | 11 | content : function (content) { | 
|  | 12 | if (arguments.length === 1) { | 
|  | 13 | this._content = content; | 
|  | 14 | }; | 
|  | 15 | return this._content; | 
|  | 16 | }, | 
|  | 17 |  | 
|  | 18 | // The foundry attribute | 
|  | 19 | foundry : function () { | 
|  | 20 | return this._foundry; | 
|  | 21 | }, | 
|  | 22 |  | 
|  | 23 | // The layer attribute | 
|  | 24 | layer : function () { | 
|  | 25 | return this._layer; | 
|  | 26 | }, | 
|  | 27 |  | 
|  | 28 | // enter or click | 
|  | 29 | onclick : function (e) { | 
|  | 30 | var menu = this.menu(); | 
|  | 31 | menu.hide(); | 
|  | 32 | e.halt(); | 
|  | 33 | if (menu.info() !== undefined) | 
|  | 34 | menu.info().addTree(this._foundry, this._layer); | 
|  | 35 | }, | 
|  | 36 |  | 
|  | 37 | _init : function (params) { | 
|  | 38 | if (params[0] === undefined) | 
|  | 39 | throw new Error("Missing parameters"); | 
|  | 40 |  | 
|  | 41 | this._name    = params[0]; | 
|  | 42 | this._foundry = params[1]; | 
|  | 43 | this._layer   = params[2]; | 
|  | 44 | this._content = document.createTextNode(this._name); | 
|  | 45 | this._lcField = ' ' + this.content().textContent.toLowerCase(); | 
|  | 46 | return this; | 
|  | 47 | } | 
|  | 48 | }; | 
|  | 49 | }); |