Use ButtonsArray for group of buttons
This commit is contained in:
parent
e347b92a0f
commit
4321974f75
|
@ -846,30 +846,6 @@ Common.Utils.injectButtons = function($slots, id, iconCls, caption, lock, split,
|
|||
return btnsArr;
|
||||
};
|
||||
|
||||
Common.Utils.injectComponents = function ($slots, id, iconCls, caption, lock, split, menu, toggle) {
|
||||
var btnsArr = [];
|
||||
id = id || ("id-toolbar-" + iconCls);
|
||||
$slots.each(function(index, el) {
|
||||
var _cls = 'btn-toolbar';
|
||||
/x-huge/.test(el.className) && (_cls += ' x-huge icon-top');
|
||||
|
||||
var button = new Common.UI.Button({
|
||||
id: id + index,
|
||||
cls: _cls,
|
||||
iconCls: iconCls,
|
||||
caption: caption,
|
||||
split: split || false,
|
||||
menu: menu || false,
|
||||
enableToggle: toggle || false,
|
||||
lock: lock,
|
||||
disabled: true
|
||||
}).render( $slots.eq(index) );
|
||||
|
||||
btnsArr.push(button);
|
||||
});
|
||||
return btnsArr;
|
||||
};
|
||||
|
||||
Common.Utils.injectComponent = function ($slot, cmp) {
|
||||
if (cmp && $slot.length) {
|
||||
cmp.rendered ? $slot.append(cmp.$el) : cmp.render($slot);
|
||||
|
|
|
@ -149,22 +149,14 @@ define([
|
|||
control_plain = (control_props) ? (control_props.get_ContentControlType()==Asc.c_oAscSdtLevelType.Inline) : false;
|
||||
|
||||
var need_disable = paragraph_locked || in_equation || in_image || in_header || control_plain;
|
||||
_.each (this.view.btnsNotes, function(item){
|
||||
item.setDisabled(need_disable);
|
||||
}, this);
|
||||
this.view.btnsNotes.setDisabled(need_disable);
|
||||
|
||||
need_disable = paragraph_locked || header_locked || in_header || control_plain;
|
||||
this.view.btnBookmarks.setDisabled(need_disable);
|
||||
},
|
||||
|
||||
onApiCanAddHyperlink: function(value) {
|
||||
var need_disable = !value || this._state.prcontrolsdisable;
|
||||
|
||||
if ( this.toolbar.editMode ) {
|
||||
_.each (this.view.btnsHyperlink, function(item){
|
||||
item.setDisabled(need_disable);
|
||||
}, this);
|
||||
}
|
||||
this.toolbar.editMode && this.view.btnsHyperlink.setDisabled(!value || this._state.prcontrolsdisable);
|
||||
},
|
||||
|
||||
onHyperlinkClick: function(btn) {
|
||||
|
|
|
@ -122,10 +122,10 @@ define([
|
|||
var me = this,
|
||||
$host = me.toolbar.$el;
|
||||
|
||||
this.btnsContents = Common.Utils.injectComponents($host.find('.btn-slot.btn-contents'), '', 'btn-contents', me.capBtnInsContents );
|
||||
this.btnsNotes = Common.Utils.injectComponents($host.find('.btn-slot.slot-notes'), '', 'btn-notes', me.capBtnInsFootnote, undefined, true, true);
|
||||
this.btnsHyperlink = Common.Utils.injectComponents($host.find('.btn-slot.slot-inshyperlink'), '', 'btn-inserthyperlink', me.capBtnInsLink);
|
||||
this.paragraphControls = this.paragraphControls.concat(this.btnsContents, this.btnsNotes, this.btnsHyperlink);
|
||||
this.btnsContents = Common.Utils.injectButtons($host.find('.btn-slot.btn-contents'), '', 'btn-contents', me.capBtnInsContents );
|
||||
this.btnsNotes = Common.Utils.injectButtons($host.find('.btn-slot.slot-notes'), '', 'btn-notes', me.capBtnInsFootnote, undefined, true, true);
|
||||
this.btnsHyperlink = Common.Utils.injectButtons($host.find('.btn-slot.slot-inshyperlink'), '', 'btn-inserthyperlink', me.capBtnInsLink);
|
||||
Array.prototype.push.apply(this.paragraphControls, this.btnsContents.concat(this.btnsNotes, this.btnsHyperlink));
|
||||
|
||||
this.btnContentsUpdate = new Common.UI.Button({
|
||||
cls: 'btn-toolbar x-huge icon-top',
|
||||
|
|
|
@ -2185,14 +2185,12 @@ define([
|
|||
|
||||
val = (filterInfo) ? filterInfo.asc_getIsAutoFilter() : null;
|
||||
if (this._state.filter !== val) {
|
||||
toolbar.btnsSetAutofilter.forEach(function(button) {
|
||||
button.toggle(val===true, true);
|
||||
});
|
||||
toolbar.btnsSetAutofilter.toggle(val===true, true);
|
||||
this._state.filter = val;
|
||||
}
|
||||
need_disable = this._state.controlsdisabled.filters || (val===null);
|
||||
toolbar.lockToolbar(SSE.enumLock.ruleFilter, need_disable,
|
||||
{ array: [toolbar.btnTableTemplate].concat(toolbar.btnsSetAutofilter, toolbar.btnsSortDown, toolbar.btnsSortUp) });
|
||||
{ array: toolbar.btnsSetAutofilter.concat(toolbar.btnsSortDown, toolbar.btnsSortUp, toolbar.btnTableTemplate) });
|
||||
|
||||
val = (formatTableInfo) ? formatTableInfo.asc_getTableStyleName() : null;
|
||||
if (this._state.tablestylename !== val && this.toolbar.mnuTableTemplatePicker) {
|
||||
|
@ -2222,10 +2220,10 @@ define([
|
|||
toolbar.lockToolbar(SSE.enumLock.multiselect, this._state.multiselect, { array: [toolbar.btnTableTemplate, toolbar.btnInsertHyperlink]});
|
||||
|
||||
this._state.inpivot = !!info.asc_getPivotTableInfo();
|
||||
toolbar.lockToolbar(SSE.enumLock.editPivot, this._state.inpivot, { array: [toolbar.btnMerge, toolbar.btnInsertHyperlink].concat(toolbar.btnsSetAutofilter, toolbar.btnsClearAutofilter, toolbar.btnsSortDown, toolbar.btnsSortUp)});
|
||||
toolbar.lockToolbar(SSE.enumLock.editPivot, this._state.inpivot, { array: toolbar.btnsSetAutofilter.concat(toolbar.btnsClearAutofilter, toolbar.btnsSortDown, toolbar.btnsSortUp, toolbar.btnMerge, toolbar.btnInsertHyperlink)});
|
||||
|
||||
need_disable = !this.appConfig.canModifyFilter;
|
||||
toolbar.lockToolbar(SSE.enumLock.cantModifyFilter, need_disable, { array: [toolbar.btnTableTemplate, toolbar.btnClearStyle.menu.items[0], toolbar.btnClearStyle.menu.items[2] ].concat(toolbar.btnsSetAutofilter, toolbar.btnsSortDown, toolbar.btnsSortUp)});
|
||||
toolbar.lockToolbar(SSE.enumLock.cantModifyFilter, need_disable, { array: toolbar.btnsSetAutofilter.concat(toolbar.btnsSortDown, toolbar.btnsSortUp, toolbar.btnTableTemplate, toolbar.btnClearStyle.menu.items[0], toolbar.btnClearStyle.menu.items[2])});
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -96,10 +96,6 @@ define([
|
|||
this.toolbar = options.toolbar;
|
||||
|
||||
this.lockedControls = [];
|
||||
this.btnsSortDown = [];
|
||||
this.btnsSortUp = [];
|
||||
this.btnsSetAutofilter = [];
|
||||
this.btnsClearAutofilter = [];
|
||||
|
||||
var me = this,
|
||||
$host = me.toolbar.$el,
|
||||
|
@ -159,19 +155,20 @@ define([
|
|||
Common.Utils.injectComponent($host.find('#slot-btn-hide-details'), this.btnHide);
|
||||
this.lockedControls.push(this.btnHide);
|
||||
|
||||
this.btnsSortDown = Common.Utils.injectComponents($host.find('.slot-sortdesc'), '', 'btn-sort-down', '',
|
||||
this.btnsSortDown = Common.Utils.injectButtons($host.find('.slot-sortdesc'), '', 'btn-sort-down', '',
|
||||
[_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter]);
|
||||
|
||||
this.btnsSortUp = Common.Utils.injectComponents($host.find('.slot-sortasc'), '', 'btn-sort-up', '',
|
||||
this.btnsSortUp = Common.Utils.injectButtons($host.find('.slot-sortasc'), '', 'btn-sort-up', '',
|
||||
[_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter]);
|
||||
|
||||
this.btnsSetAutofilter = Common.Utils.injectComponents($host.find('.slot-btn-setfilter'), '', 'btn-autofilter', '',
|
||||
this.btnsSetAutofilter = Common.Utils.injectButtons($host.find('.slot-btn-setfilter'), '', 'btn-autofilter', '',
|
||||
[_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter],
|
||||
false, false, true);
|
||||
|
||||
this.btnsClearAutofilter = Common.Utils.injectComponents($host.find('.slot-btn-clear-filter'), '', 'btn-clear-filter', '',
|
||||
this.btnsClearAutofilter = Common.Utils.injectButtons($host.find('.slot-btn-clear-filter'), '', 'btn-clear-filter', '',
|
||||
[_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleDelFilter, _set.editPivot]);
|
||||
this.lockedControls = this.lockedControls.concat(this.btnsSortDown, this.btnsSortUp, this.btnsSetAutofilter,this.btnsClearAutofilter);
|
||||
|
||||
Array.prototype.push.apply(this.lockedControls, this.btnsSortDown.concat(this.btnsSortUp, this.btnsSetAutofilter,this.btnsClearAutofilter));
|
||||
|
||||
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue