Add sdnr wt devicemanager
[ccsdk/features.git] / sdnr / wt / devicemanager / provider / src / main / resources / elasticsearch / plugins / head / src / app / ui / splitButton / splitButton.js
1 (function( $, app ) {
2
3         var ui = app.ns("ui");
4
5         ui.SplitButton = ui.AbstractWidget.extend({
6                 defaults: {
7                         items: [],
8                         label: ""
9                 },
10                 _baseCls: "uiSplitButton",
11                 init: function( parent ) {
12                         this._super( parent );
13                         this.value = null;
14                         this.button = new ui.Button({
15                                 label: this.config.label,
16                                 onclick: this._click_handler
17                         });
18                         this.menu = new ui.SelectMenuPanel({
19                                 value: this.config.value,
20                                 items: this._getItems(),
21                                 onSelect: this._select_handler
22                         });
23                         this.menuButton = new ui.MenuButton({
24                                 label: "\u00a0",
25                                 menu: this.menu
26                         });
27                         this.el = $.joey(this._main_template());
28                 },
29                 remove: function() {
30                         this.menu.remove();
31                 },
32                 disable: function() {
33                         this.button.disable();
34                 },
35                 enable: function() {
36                         this.button.enable();
37                 },
38                 _click_handler: function() {
39                         this.fire("click", this, { value: this.value } );
40                 },
41                 _select_handler: function( panel, event ) {
42                         this.fire( "select", this, event );
43                 },
44                 _getItems: function() {
45                         return this.config.items;
46                 },
47                 _main_template: function() {
48                         return { tag: "DIV", cls: this._baseCls, children: [
49                                 this.button, this.menuButton
50                         ] };
51                 }
52         });
53
54 })( this.jQuery, this.app );