[PE] Add view settings to context menu
This commit is contained in:
parent
83c888729e
commit
f598a93033
|
@ -423,6 +423,8 @@ define([
|
|||
view.menuTableInsertText.menu.on('item:click', _.bind(me.tableInsertText, me));
|
||||
view.menuTableDeleteText.menu.on('item:click', _.bind(me.tableDeleteText, me));
|
||||
view.mnuGuides.menu.on('item:click', _.bind(me.onGuidesClick, me));
|
||||
view.mnuGridlines.menu.on('item:click', _.bind(me.onGridlinesClick, me));
|
||||
view.mnuRulers.on('click', _.bind(me.onRulersClick, me));
|
||||
},
|
||||
|
||||
getView: function (name) {
|
||||
|
@ -2126,6 +2128,21 @@ define([
|
|||
this.documentHolder.fireEvent('guides:show', [item.isChecked()]);
|
||||
},
|
||||
|
||||
onGridlinesClick: function(menu, item) {
|
||||
if (item.value === 'custom')
|
||||
this.documentHolder.fireEvent('gridlines:custom');
|
||||
else if (item.value === 'snap')
|
||||
this.documentHolder.fireEvent('gridlines:snap', [item.isChecked()]);
|
||||
else if (item.value === 'show')
|
||||
this.documentHolder.fireEvent('gridlines:show', [item.isChecked()]);
|
||||
else
|
||||
this.documentHolder.fireEvent('gridlines:spacing', [item.value]);
|
||||
},
|
||||
|
||||
onRulersClick: function(item) {
|
||||
this.documentHolder.fireEvent('rulers:change', [item.isChecked()]);
|
||||
},
|
||||
|
||||
SetDisabled: function(state) {
|
||||
this._isDisabled = state;
|
||||
this.documentHolder.SetDisabled(state);
|
||||
|
|
|
@ -119,7 +119,12 @@ define([
|
|||
'guides:show': _.bind(this.onGuidesShow, this),
|
||||
'guides:add': _.bind(this.onGuidesAdd, this),
|
||||
'guides:clear': _.bind(this.onGuidesClear, this),
|
||||
'guides:smart': _.bind(this.onGuidesSmartShow, this)
|
||||
'guides:smart': _.bind(this.onGuidesSmartShow, this),
|
||||
'gridlines:show': _.bind(this.onGridlinesShow, this),
|
||||
'gridlines:snap': _.bind(this.onGridlinesSnap, this),
|
||||
'gridlines:spacing': _.bind(this.onGridlinesSpacing, this),
|
||||
'gridlines:custom': _.bind(this.onGridlinesCustom, this),
|
||||
'rulers:change': _.bind(this.onChangeRulers, this)
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -172,8 +177,9 @@ define([
|
|||
Common.NotificationCenter.trigger('edit:complete', this.view);
|
||||
},
|
||||
|
||||
onChangeRulers: function (btn, checked) {
|
||||
onChangeRulers: function (checked) {
|
||||
this.api.asc_SetViewRulers(checked);
|
||||
this.view.chRulers.setValue(checked, true);
|
||||
Common.localStorage.setBool('pe-hidden-rulers', !checked);
|
||||
Common.Utils.InternalSettings.set("pe-hidden-rulers", !checked);
|
||||
Common.NotificationCenter.trigger('layout:changed', 'rulers');
|
||||
|
@ -234,6 +240,7 @@ define([
|
|||
|
||||
onGuidesShow: function(state) {
|
||||
this.api.asc_setShowGuides(state);
|
||||
this.view.btnGuides.toggle(state, true);
|
||||
Common.localStorage.setBool('pe-settings-showguides', state);
|
||||
Common.NotificationCenter.trigger('edit:complete', this.view);
|
||||
},
|
||||
|
@ -268,6 +275,7 @@ define([
|
|||
|
||||
onGridlinesShow: function(state) {
|
||||
this.api.asc_setShowGridlines(state);
|
||||
this.view.btnGridlines.toggle(state, true);
|
||||
Common.localStorage.setBool('pe-settings-showgrid', state);
|
||||
Common.NotificationCenter.trigger('edit:complete', this.view);
|
||||
},
|
||||
|
|
|
@ -975,6 +975,35 @@ define([
|
|||
})
|
||||
});
|
||||
|
||||
me.mnuGridlines = new Common.UI.MenuItem({
|
||||
caption : me.textGridlines,
|
||||
menu : new Common.UI.Menu({
|
||||
menuAlign: 'tl-tr',
|
||||
items: [
|
||||
{ caption: me.textShowGridlines, value: 'show', checkable: true },
|
||||
{ caption: me.textSnapObjects, value: 'snap', checkable: true },
|
||||
{ caption: '--'},
|
||||
{ caption: Common.Utils.String.format(me.textManyGrids, 8), value: 0.13, checkable: true, toggleGroup: 'tb-gridlines' },
|
||||
{ caption: Common.Utils.String.format(me.textManyGrids, 6), value: 0.17, checkable: true, toggleGroup: 'tb-gridlines' },
|
||||
{ caption: Common.Utils.String.format(me.textManyGrids, 5), value: 0.2, checkable: true, toggleGroup: 'tb-gridlines' },
|
||||
{ caption: Common.Utils.String.format(me.textFewGrids, 4), value: 0.25, checkable: true, toggleGroup: 'tb-gridlines' },
|
||||
{ caption: Common.Utils.String.format(me.textFewGrids, 3), value: 0.33, checkable: true, toggleGroup: 'tb-gridlines' },
|
||||
{ caption: Common.Utils.String.format(me.textFewGrids, 2), value: 0.5, checkable: true, toggleGroup: 'tb-gridlines' },
|
||||
{ caption: '1 ' + me.textCm, value: 1, checkable: true, toggleGroup: 'tb-gridlines' },
|
||||
{ caption: '2 ' + me.textCm, value: 2, checkable: true, toggleGroup: 'tb-gridlines' },
|
||||
{ caption: '3 ' + me.textCm, value: 3, checkable: true, toggleGroup: 'tb-gridlines' },
|
||||
{ caption: '4 ' + me.textCm, value: 4, checkable: true, toggleGroup: 'tb-gridlines' },
|
||||
{ caption: '5 ' + me.textCm, value: 5, checkable: true, toggleGroup: 'tb-gridlines' },
|
||||
{ caption: '--'},
|
||||
{ caption: me.textCustom, value: 'custom' }
|
||||
]
|
||||
})
|
||||
});
|
||||
me.mnuRulers = new Common.UI.MenuItem({
|
||||
caption : me.textRulers,
|
||||
checkable: true
|
||||
});
|
||||
|
||||
me.slideMenu = new Common.UI.Menu({
|
||||
cls: 'shifted-right',
|
||||
restoreHeightAndTop: true,
|
||||
|
@ -982,8 +1011,8 @@ define([
|
|||
var selectedLast = me.api.asc_IsLastSlideSelected(),
|
||||
selectedFirst = me.api.asc_IsFirstSlideSelected();
|
||||
me.menuSlidePaste.setVisible(value.fromThumbs!==true);
|
||||
me.slideMenu.items[1].setVisible(value.fromThumbs===true); // New Slide
|
||||
me.slideMenu.items[2].setVisible(value.isSlideSelect===true); // Duplicate Slide
|
||||
me.mnuNewSlide.setVisible(value.fromThumbs===true); // New Slide
|
||||
me.mnuDuplicateSlide.setVisible(value.isSlideSelect===true); // Duplicate Slide
|
||||
me.mnuDeleteSlide.setVisible(value.isSlideSelect===true);
|
||||
me.mnuSlideHide.setVisible(value.isSlideSelect===true);
|
||||
me.mnuSlideHide.setChecked(value.isSlideHidden===true);
|
||||
|
@ -994,21 +1023,41 @@ define([
|
|||
me.menuSlideSettings.setVisible(value.isSlideSelect===true || value.fromThumbs!==true);
|
||||
me.menuSlideSettings.options.value = null;
|
||||
|
||||
me.slideMenu.items[10].setVisible(!value.fromThumbs); // guides
|
||||
me.slideMenu.items[11].setVisible(!value.fromThumbs);
|
||||
me.slideMenu.items[12].setVisible(value.fromThumbs===true);
|
||||
me.slideMenu.items[13].setVisible(value.fromThumbs===true);
|
||||
me.slideMenu.items[10].setVisible(!value.fromThumbs); // guides separator
|
||||
me.mnuGuides.setVisible(!value.fromThumbs);
|
||||
me.mnuGridlines.setVisible(!value.fromThumbs);
|
||||
me.mnuRulers.setVisible(!value.fromThumbs);
|
||||
me.slideMenu.items[14].setVisible(value.fromThumbs===true);
|
||||
me.mnuSelectAll.setVisible(value.fromThumbs===true);
|
||||
|
||||
me.mnuPrintSelection.setVisible(me.mode.canPrint && value.fromThumbs===true);
|
||||
me.slideMenu.items[15].setVisible((!selectedLast || !selectedFirst) && value.isSlideSelect===true);
|
||||
me.slideMenu.items[17].setVisible((!selectedLast || !selectedFirst) && value.isSlideSelect===true);
|
||||
me.mnuMoveSlideToEnd.setVisible(!selectedLast && value.isSlideSelect===true);
|
||||
me.mnuMoveSlideToStart.setVisible(!selectedFirst && value.isSlideSelect===true);
|
||||
me.slideMenu.items[18].setVisible(value.fromThumbs===true);
|
||||
me.slideMenu.items[19].setVisible(value.fromThumbs===true);
|
||||
me.slideMenu.items[20].setVisible(value.fromThumbs===true);
|
||||
me.mnuPreview.setVisible(value.fromThumbs===true);
|
||||
|
||||
me.mnuGuides.menu.items[6].setDisabled(!me.api.asc_canClearGuides());
|
||||
me.mnuGuides.menu.items[0].setChecked(me.api.asc_getShowGuides(), true);
|
||||
me.mnuGuides.menu.items[5].setChecked(me.api.asc_getShowSmartGuides(), true);
|
||||
if (!value.fromThumbs) {
|
||||
me.mnuGuides.menu.items[6].setDisabled(!me.api.asc_canClearGuides());
|
||||
me.mnuGuides.menu.items[0].setChecked(me.api.asc_getShowGuides(), true);
|
||||
me.mnuGuides.menu.items[5].setChecked(me.api.asc_getShowSmartGuides(), true);
|
||||
|
||||
me.mnuGridlines.menu.items[0].setChecked(me.api.asc_getShowGridlines(), true);
|
||||
me.mnuGridlines.menu.items[1].setChecked(me.api.asc_getSnapToGrid(), true);
|
||||
|
||||
var spacing = me.api.asc_getGridSpacing()/360000,
|
||||
items = me.mnuGridlines.menu.items;
|
||||
for (var i=3; i<14; i++) {
|
||||
var item = items[i];
|
||||
if (item.value<1 && Math.abs(item.value - spacing)<0.005)
|
||||
item.setChecked(true);
|
||||
else if (item.value>=1 && Math.abs(item.value - spacing)<0.001)
|
||||
item.setChecked(true);
|
||||
else
|
||||
item.setChecked(false);
|
||||
}
|
||||
me.mnuRulers.setChecked(!Common.Utils.InternalSettings.get("pe-hidden-rulers"));
|
||||
}
|
||||
|
||||
var selectedElements = me.api.getSelectedElements(),
|
||||
locked = false,
|
||||
|
@ -1052,6 +1101,8 @@ define([
|
|||
me.menuSlideSettings,
|
||||
{caption: '--'},
|
||||
me.mnuGuides,
|
||||
me.mnuGridlines,
|
||||
me.mnuRulers,
|
||||
{caption: '--'},
|
||||
me.mnuSelectAll,
|
||||
me.mnuPrintSelection,
|
||||
|
@ -2481,7 +2532,15 @@ define([
|
|||
textAddVGuides: 'Add vertical guide',
|
||||
textAddHGuides: 'Add horizontal guide',
|
||||
textSmartGuides: 'Smart Guides',
|
||||
textClearGuides: 'Clear Guides'
|
||||
textClearGuides: 'Clear Guides',
|
||||
textGridlines: 'Gridlines',
|
||||
textShowGridlines: 'Show Gridlines',
|
||||
textSnapObjects: 'Snap object to grid',
|
||||
textCm: 'cm',
|
||||
textCustom: 'Custom',
|
||||
textManyGrids: '{0} grids per cm',
|
||||
textFewGrids: '{0} grids per cm',
|
||||
textRulers: 'Rulers'
|
||||
|
||||
}, PE.Views.DocumentHolder || {}));
|
||||
});
|
|
@ -109,7 +109,7 @@ define([
|
|||
me.fireEvent('statusbar:hide', [me.chStatusbar, state !== 'checked']);
|
||||
}, me));
|
||||
me.chRulers && me.chRulers.on('change', _.bind(function (checkbox, state) {
|
||||
me.fireEvent('rulers:change', [me.chRulers, state === 'checked']);
|
||||
me.fireEvent('rulers:change', [state === 'checked']);
|
||||
}, me));
|
||||
me.chNotes && me.chNotes.on('change', _.bind(function (checkbox, state) {
|
||||
me.fireEvent('notes:change', [me.chNotes, state === 'checked']);
|
||||
|
@ -136,7 +136,7 @@ define([
|
|||
else if (item.value === 'smart')
|
||||
me.fireEvent('guides:smart', [item.isChecked()]);
|
||||
else
|
||||
me.btnGuides.toggle(item.isChecked());
|
||||
me.fireEvent('guides:show', [item.isChecked()]);
|
||||
}, me));
|
||||
me.btnGuides.menu.on('show:after', _.bind(function(btn, state) {
|
||||
me.fireEvent('guides:aftershow');
|
||||
|
@ -151,7 +151,7 @@ define([
|
|||
else if (item.value === 'snap')
|
||||
me.fireEvent('gridlines:snap', [item.isChecked()]);
|
||||
else if (item.value === 'show')
|
||||
me.btnGridlines.toggle(item.isChecked());
|
||||
me.fireEvent('gridlines:show', [item.isChecked()]);
|
||||
else
|
||||
me.fireEvent('gridlines:spacing', [item.value]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue