123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
"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,
_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));
this.addChildWidget(this._flowDecoratorWidget, {
noDOMInsert: true
});
},
_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');
}
},
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;
},
managePriorityKeyDown: function(keyString, domKeyEvent, repeat) {
let keyProcessed = false;
if (keyString === "esc") {
if (this._flowDecoratorWidget && this._flowDecoratorWidget.isDropDownOpen()) {
this._flowDecoratorWidget.closeDropDown();
keyProcessed = true;
}
}
return keyProcessed;
},
getDecoratorWidth: function() {
return this._flowDecoratorWidget.getLayoutInformation().getRawMeasure().getWidth();
},
getFlowDecoratorWidget: function() {
return this._flowDecoratorWidget;
},
setFormWidget: function(widget) {
this._formWidget = widget;
}
};
});
cls.WidgetFactory.registerBuilder('ToolBar', cls.ToolBarWidget);
});