summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager/provider/src/main/resources/elasticsearch/plugins/head/src/app/ui/selectMenuPanel/selectMenuPanel.js
blob: 8cbecc56c0614c4b482948f20bc0eb3e3a8cd5e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(function( app ) {

	var ui = app.ns("ui");

	ui.SelectMenuPanel = ui.MenuPanel.extend({
		defaults: {
			items: [],		// (required) an array of menu items
			value: null
		},
		_baseCls: "uiSelectMenuPanel uiMenuPanel",
		init: function() {
			this.value = this.config.value;
			this._super();
		},
		_getItems: function() {
			return this.config.items.map( function( item ) {
				return {
					text: item.text,
					selected: this.value === item.value,
					onclick: function( jEv ) {
						var el = $( jEv.target ).closest("LI");
						el.parent().children().removeClass("selected");
						el.addClass("selected");
						this.fire( "select", this, { value: item.value } );
						this.value = item.value;
					}.bind(this)
				};
			}, this );

		}
	});

})( this.app );