123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
"use strict";
modulum('ToolBarWidget', ['WidgetGroupBase', 'WidgetFactory'],
function(context, cls) {
cls.ToolBarWidget = context.oo.Class(cls.WidgetGroupBase, function($super) {
return {
__name: 'ToolBarWidget',
_flowDecoratorWidget: null,
_flowDecoratorContainer: null,
_chromeBar: null,
_resizeHandler: null,
_formWidget: null,
toolbarAspectChange: "g_toolbarAspectChange",
_initContainerElement: function() {
$super._initContainerElement.call(this);
this._flowDecoratorWidget = cls.WidgetFactory.createWidget("FlowDecorator", this.getBuildParameters());
this._flowDecoratorWidget.setParentWidget(this);
this._flowDecoratorWidget.setOrientation("vertical");
this._flowDecoratorWidget.setRendering("list");
this._flowDecoratorContainer = this.getElement().querySelector(".mt-tab-flow");
this._flowDecoratorContainer.appendChild(this._flowDecoratorWidget.getElement());
this._resizeHandler = context.HostService.onScreenResize(this._onResize.bind(this));
},
_initLayout: function() {
this._layoutInformation = new cls.LayoutInformation(this);
this._layoutEngine = new cls.FlowLayoutEngine(this);
this._layoutEngine.setFlowDecoratorWidget(this._flowDecoratorWidget);
},
_onResize: function() {
this._layoutEngine.forceMeasurement();
this._layoutEngine.invalidateMeasure();
},
setOrder: function(order) {
this.setStyle({
order: order
});
},
getOrder: function() {
return this.getStyle('order');
},
setButtonTextHidden: function(state) {
if (state) {
this.getElement().addClass('buttonTextHidden');
} else {
this.getElement().removeClass('buttonTextHidden');
}
},
setButtonSize: function(buttonSize) {
this.removeClass("button-small");
this.removeClass("button-large");
this.addClass("button-" + buttonSize);
this.getChildren().slice(1).forEach(item => {
item.getLayoutEngine().forceMeasurement();
item.getLayoutEngine().invalidateMeasure();
});
this._layoutEngine._refresh();
},
destroy: function() {
if (this._flowDecoratorWidget) {
this._flowDecoratorWidget.destroy();
this._flowDecoratorWidget = null;
}
if (this._resizeHandler) {
this._resizeHandler();
this._resizeHandler = null;
}
if (this.isChromeBar()) {
this._chromeBar = null;
}
$super.destroy.call(this);
},
setAsChromeBar: function(chromeBar) {
this._chromeBar = chromeBar;
},
isChromeBar: function() {
return Boolean(this._chromeBar);
},
manageMouseClick: function(domEvent) {
if (!domEvent.target.hasClass("gbc_FlowDecoratorWidget")) {
this._flowDecoratorWidget.closeDropDown();
}
return true;
},
getDecoratorWidth: function() {
return this._flowDecoratorWidget.getLayoutInformation().getRawMeasure().getWidth();
},
getFlowDecoratorWidget: function() {
return this._flowDecoratorWidget;
},
setFormWidget: function(widget) {
this._formWidget = widget;
},
setAspect: function(mode) {
this._aspect = mode;
this._element.setAttribute("gbc_toolbaraspect", mode);
this.emit(this.toolbarAspectChange, mode);
},
setItemSize: function(size) {
},
setToolBarItemsAlignment: function(alignment) {
if (this._itemsAlignment !== alignment) {
if (this._itemsAlignment) {
this.getContainerElement().removeClass(this._itemsAlignment);
}
this._itemsAlignment = alignment;
if (this.getContainerElement()) {
this.getContainerElement().addClass(alignment);
}
}
},
addChildWidget: function(widget, options) {
$super.addChildWidget.call(this, widget, options);
if (this._chromeBar) {
this._chromeBar.addItemWidget(widget, options);
}
}
};
});
cls.WidgetFactory.registerBuilder('ToolBar', cls.ToolBarWidget);
});