Merge pull request #1182 from ONLYOFFICE/feature/Bug_43485

Feature/bug 43485
This commit is contained in:
JuliaSvinareva 2021-09-17 20:11:56 +03:00 committed by GitHub
commit 637443b913
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 424 additions and 241 deletions

View file

@ -874,7 +874,8 @@ define([
this.cmpEl.html(this.template({ this.cmpEl.html(this.template({
items: me.store.toJSON(), items: me.store.toJSON(),
itemTemplate: me.itemTemplate, itemTemplate: me.itemTemplate,
style: me.style style: me.style,
options: me.options
})); }));
} }
var modalParents = this.cmpEl.closest('.asc-window'); var modalParents = this.cmpEl.closest('.asc-window');
@ -1088,6 +1089,8 @@ define([
if (data.keyCode==Common.UI.Keys.RETURN) { if (data.keyCode==Common.UI.Keys.RETURN) {
if (this.selectedBeforeHideRec) // only for ComboDataView menuPicker if (this.selectedBeforeHideRec) // only for ComboDataView menuPicker
rec = this.selectedBeforeHideRec; rec = this.selectedBeforeHideRec;
if (this.canAddRecents) // only for DaraViewShape
this.addRecentItem(rec);
this.trigger('item:click', this, this, rec, e); this.trigger('item:click', this, this, rec, e);
if (this.parentMenu) if (this.parentMenu)
this.parentMenu.hide(); this.parentMenu.hide();
@ -1257,4 +1260,229 @@ define([
} }
}, 100); }, 100);
}); });
Common.UI.DataViewShape = Common.UI.DataViewSimple.extend(_.extend({
template: _.template([
'<div class="dataview inner" style="<%= style %>">',
'<% _.each(options.groups, function(group, index) { %>',
'<div class="grouped-data <% if (index === 0) { %> recent-group <% } %> " id="<%= group.id %>" <% if (!options.recentShapes && index === 0) { %> style="display: none;" <% } %>>',
'<% if (!_.isEmpty(group.groupName)) { %>',
'<div class="group-description">',
'<span><%= group.groupName %></span>',
'</div>',
'<% } %>',
'<div class="group-items-container <% if (index === 0) { %> recent-items <% } %>">',
'<% _.each(group.groupStore.toJSON(), function(item) { %>',
'<% if (!item.id) item.id = Common.UI.getId(); %>',
'<div class="item" <% if(!!item.tip) { %> data-toggle="tooltip" <% } %> ><%= itemTemplate(item) %></div>',
'<% }); %>',
'</div>',
'</div>',
'<% }); %>',
'</div>'
].join('')),
initialize : function(options) {
var me = this;
this.canAddRecents = true;
var filter = Common.localStorage.getKeysFilter();
this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : '';
me.groups = options.groups;
if (options.isFromImage) {
var store = me.groups[0].groupStore.clone();
store.shift();
me.groups[0].groupStore = store;
}
// add recent shapes to store
var recentStore = new Common.UI.DataViewGroupStore,
recentArr = options.recentShapes || [],
cols = (recentArr.length) > 18 ? 7 : 6,
height = Math.ceil(recentArr.length/cols) * 35 + 3,
width = 30 * cols;
me.recentShapes = recentArr;
recentStore.add(recentArr);
me.groups.unshift({
groupName : options.textRecentlyUsed,
groupStore : recentStore,
groupWidth : width,
groupHeight : height
});
var store = new Common.UI.DataViewStore();
_.each(me.groups, function (group) {
store.add(group.groupStore.models);
});
options.store = store;
Common.UI.DataViewSimple.prototype.initialize.call(this, options);
me.parentMenu.on('show:before', function() { me.updateRecents(); });
if (me.recentShapes.length > 0 && !me.cmpEl.find('.recent-group').is(':visible')) {
me.cmpEl.find('.recent-group').show();
}
},
onAfterShowMenu: function(e) {
var me = this;
if (!me.dataViewItems) {
me.dataViewItems = [];
_.each(me.cmpEl.find('div.grouped-data'), function (group, indexGroup) {
_.each($(group).find('div.item'), function (item, index) {
var $item = $(item),
rec = me.options.groups.at(indexGroup).groupStore.at(index);
me.dataViewItems.push({el: $item, groupIndex: indexGroup, index: index});
var tip = rec.get('tip');
if (tip) {
$item.one('mouseenter', function(){ // hide tooltip when mouse is over menu
$item.attr('data-toggle', 'tooltip');
$item.tooltip({
title : tip,
placement : 'cursor',
zIndex : me.tipZIndex
});
$item.mouseenter();
});
}
});
});
}
if (me.updateDataViewItems && me.cmpEl.is(':visible')) {
// add recent item in dataViewItems
var recent = _.where(me.dataViewItems, {groupIndex: 0});
var len = recent ? recent.length : 0;
for (var i = 0; i < len; i++) {
var tip = me.dataViewItems[i].el.data('bs.tooltip');
if (tip) {
if (tip.dontShow===undefined)
tip.dontShow = true;
(tip.tip()).remove();
}
}
me.dataViewItems = me.dataViewItems.slice(len);
var recentViewItems = [];
_.each(me.cmpEl.find('.recent-group div.item'), function (item, index) {
var $item = $(item),
rec = me.recentShapes[index];
recentViewItems.push({el: $item, groupIndex: 0, index: index});
var tip = rec.tip;
if (tip) {
$item.one('mouseenter', function(){ // hide tooltip when mouse is over menu
$item.attr('data-toggle', 'tooltip');
$item.tooltip({
title: tip,
placement: 'cursor',
zIndex : me.tipZIndex
});
$item.mouseenter();
});
}
});
me.dataViewItems = recentViewItems.concat(me.dataViewItems);
me.fillIndexesArray();
if (me.recentShapes.length === 1) {
$('.recent-group').show();
}
me.updateDataViewItems = false;
}
},
onClickItem: function(e) {
if ( this.disabled ) return;
window._event = e; // for FireFox only
var groupIndex = $(e.currentTarget).closest('div.grouped-data').index(),
itemIndex = $(e.currentTarget).closest('div.item').index();
var index = _.findIndex(this.dataViewItems, function (item) {
return (item.groupIndex === groupIndex && item.index === itemIndex);
});
var record = (index>=0) ? this.store.at(index) : null,
view = (index>=0) ? this.dataViewItems[index] : null;
if (!record || !view) return;
record.set({selected: true});
var tip = view.el.data('bs.tooltip');
if (tip) (tip.tip()).remove();
if (!this.isSuspendEvents) {
this.trigger('item:click', this, view.el, record, e);
}
this.addRecentItem(record);
},
addRecentItem: function (rec) {
var me = this,
exist = false,
type = rec.get('data').shapeType;
for (var i = 0; i < me.recentShapes.length; i++) {
if (me.recentShapes[i].data.shapeType === type) {
exist = true;
break;
}
}
if (exist) return;
var item = rec.toJSON(),
model = {
data: item.data,
tip: item.tip,
allowSelected: item.allowSelected,
selected: false
};
me.recentShapes.unshift(model);
if (me.recentShapes.length > 14) {
me.recentShapes.splice(14, 1);
}
Common.localStorage.setItem(this.appPrefix + 'recent-shapes', JSON.stringify(me.recentShapes));
me.recentShapes = undefined;
},
updateRecents: function () {
var me = this,
recents = Common.localStorage.getItem(this.appPrefix + 'recent-shapes');
recents = recents ? JSON.parse(recents) : [];
var diff = false;
if (me.recentShapes) {
for (var i = 0; i < recents.length; i++) {
if (!me.recentShapes[i] || (me.recentShapes[i] && recents[i].tip !== me.recentShapes[i].tip)) {
diff = true;
}
}
} else {
diff = true;
}
if (recents.length > 0 && diff) {
me.recentShapes = recents;
me.groups.at(0).groupStore.reset(me.recentShapes);
var store = new Common.UI.DataViewStore();
_.each(me.groups, function (group) {
store.add(group.groupStore.models);
});
me.store = store;
var template = _.template([
'<% _.each(items, function(item) { %>',
'<% if (!item.id) item.id = Common.UI.getId(); %>',
'<div class="item" <% if(!!item.tip) { %> data-toggle="tooltip" <% } %> ><%= itemTemplate(item) %></div>',
'<% }) %>'
].join(''));
me.cmpEl && me.cmpEl.find('.recent-items').html(template({
items: me.recentShapes,
itemTemplate: this.itemTemplate,
style : this.style
}));
me.updateDataViewItems = true;
}
}
}));
}); });

View file

@ -88,4 +88,16 @@
border: @scaled-one-px-value solid @input-border; border: @scaled-one-px-value solid @input-border;
.border-radius(@border-radius-small); .border-radius(@border-radius-small);
} }
}
.menu-insert-shape, .menu-change-shape {
width: 362px;
padding: 10px 5px 10px 10px;
.group-description {
padding: 3px 0 3px 4px;
}
.dataview .grouped-data .group-items-container .item {
box-shadow: none;
margin: 2px 2px 2px;
}
} }

View file

@ -2641,50 +2641,39 @@ define([
var me = this, var me = this,
shapesStore = this.getApplication().getCollection('ShapeGroups'); shapesStore = this.getApplication().getCollection('ShapeGroups');
var onShowAfter = function(menu) { var menuitem = new Common.UI.MenuItem({
for (var i = 0; i < shapesStore.length; i++) { template: _.template('<div id="id-toolbar-menu-insertshape" class="menu-insertshape"></div>')
var shapePicker = new Common.UI.DataViewSimple({ });
el: $('#id-toolbar-menu-shapegroup' + i, menu.items[i].$el), me.toolbar.btnInsertShape.menu.addItem(menuitem);
store: shapesStore.at(i).get('groupStore'),
parentMenu: menu.items[i].menu,
itemTemplate: _.template('<div class="item-shape" id="<%= id %>"><svg width="20" height="20" class=\"icon\"><use xlink:href=\"#svg-icon-<%= data.shapeType %>\"></use></svg></div>')
});
shapePicker.on('item:click', function(picker, item, record, e) {
if (me.api) {
if (record) {
me._addAutoshape(true, record.get('data').shapeType);
me._isAddingShape = true;
}
if (me.toolbar.btnInsertText.pressed) { var recents = Common.localStorage.getItem('de-recent-shapes');
me.toolbar.btnInsertText.toggle(false, true);
}
if (e.type !== 'click') var shapePicker = new Common.UI.DataViewShape({
me.toolbar.btnInsertShape.menu.hide(); el: $('#id-toolbar-menu-insertshape'),
Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnInsertShape); itemTemplate: _.template('<div class="item-shape" id="<%= id %>"><svg width="20" height="20" class=\"icon\"><use xlink:href=\"#svg-icon-<%= data.shapeType %>\"></use></svg></div>'),
Common.component.Analytics.trackEvent('ToolBar', 'Add Shape'); groups: shapesStore.toJSON(),
} parentMenu: me.toolbar.btnInsertShape.menu,
}); restoreHeight: 640,
textRecentlyUsed: me.textRecentlyUsed,
recentShapes: recents ? JSON.parse(recents) : null
});
shapePicker.on('item:click', function(picker, item, record, e) {
if (me.api) {
if (record) {
me._addAutoshape(true, record.get('data').shapeType);
me._isAddingShape = true;
}
if (me.toolbar.btnInsertText.pressed) {
me.toolbar.btnInsertText.toggle(false, true);
}
if (e.type !== 'click')
me.toolbar.btnInsertShape.menu.hide();
Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnInsertShape);
Common.component.Analytics.trackEvent('ToolBar', 'Add Shape');
} }
menu.off('show:after', onShowAfter); });
};
me.toolbar.btnInsertShape.menu.on('show:after', onShowAfter);
for (var i = 0; i < shapesStore.length; i++) {
var shapeGroup = shapesStore.at(i);
var menuItem = new Common.UI.MenuItem({
caption: shapeGroup.get('groupName'),
menu: new Common.UI.Menu({
menuAlign: 'tl-tr',
items: [
{ template: _.template('<div id="id-toolbar-menu-shapegroup' + i + '" class="menu-shape" style="width: ' + (shapeGroup.get('groupWidth') - 8) + 'px; margin-left: 5px;"></div>') }
]
})
});
me.toolbar.btnInsertShape.menu.addItem(menuItem);
}
}, },
fillEquations: function() { fillEquations: function() {
@ -3670,7 +3659,8 @@ define([
textInsert: 'Insert', textInsert: 'Insert',
textTabForms: 'Forms', textTabForms: 'Forms',
textGroup: 'Group', textGroup: 'Group',
textEmptyMMergeUrl: 'You need to specify URL.' textEmptyMMergeUrl: 'You need to specify URL.',
textRecentlyUsed: 'Recently Used'
}, DE.Controllers.Toolbar || {})); }, DE.Controllers.Toolbar || {}));
}); });

View file

@ -1611,7 +1611,7 @@ define([
iconCls: 'btn-change-shape', iconCls: 'btn-change-shape',
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
menuAlign: 'tr-br', menuAlign: 'tr-br',
cls: 'menu-shapes', cls: 'menu-shapes menu-change-shape',
items: [] items: []
}), }),
dataHint: '1', dataHint: '1',
@ -1786,46 +1786,33 @@ define([
fillAutoShapes: function() { fillAutoShapes: function() {
var me = this, var me = this,
shapesStore = this.application.getCollection('ShapeGroups'), shapesStore = this.application.getCollection('ShapeGroups'),
count = shapesStore.length; recents = Common.localStorage.getItem('de-recent-shapes');
var onShowAfter = function(menu) { for (var i = 0; i < 2; i++) {
for (var i=-1; i<count-1 && count>0; i++) { var menuitem = new Common.UI.MenuItem({
var store = shapesStore.at(i > -1 ? i : 0).get('groupStore'); template: _.template('<div id="id-change-shape-menu-<%= options.index %>" class="menu-insertshape"></div>'),
if (i<0) { index: i
store = store.clone(); });
store.shift(); me.btnChangeShape.menu.addItem(menuitem);
}
var shapePicker = new Common.UI.DataViewSimple({ var shapePicker = new Common.UI.DataViewShape({
el: $('#id-shape-menu-shapegroup' + (i+1), menu.items[i+1].$el), el: $('#id-change-shape-menu-' + i),
store: store, itemTemplate: _.template('<div class="item-shape" id="<%= id %>"><svg width="20" height="20" class=\"icon\"><use xlink:href=\"#svg-icon-<%= data.shapeType %>\"></use></svg></div>'),
parentMenu: menu.items[i+1].menu, groups: shapesStore.toJSON(),
itemTemplate: _.template('<div class="item-shape" id="<%= id %>"><svg width="20" height="20" class=\"icon\"><use xlink:href=\"#svg-icon-<%= data.shapeType %>\"></use></svg></div>') parentMenu: me.btnChangeShape.menu,
}); restoreHeight: 640,
shapePicker.on('item:click', function(picker, item, record, e) { textRecentlyUsed: me.textRecentlyUsed,
if (me.api) { recentShapes: recents ? JSON.parse(recents) : null,
me.api.ChangeShapeType(record.get('data').shapeType); isFromImage: i === 0
me.fireEvent('editcomplete', me); });
} shapePicker.on('item:click', function(picker, item, record, e) {
if (e.type !== 'click') if (me.api) {
me.btnChangeShape.menu.hide(); me.api.ChangeShapeType(record.get('data').shapeType);
}); me.fireEvent('editcomplete', me);
} }
menu.off('show:after', onShowAfter); if (e.type !== 'click')
}; me.btnChangeShape.menu.hide();
me.btnChangeShape.menu.on('show:after', onShowAfter);
for (var i=-1; i<count-1 && count>0; i++) {
var shapeGroup = shapesStore.at(i > -1 ? i : i + 1);
var menuItem = new Common.UI.MenuItem({
caption: shapeGroup.get('groupName'),
menu: new Common.UI.Menu({
menuAlign: 'tr-tl',
items: [
{template: _.template('<div id="id-shape-menu-shapegroup' + (i + 1) + '" class="menu-shape" style="width: ' + (shapeGroup.get('groupWidth') - 8) + 'px; margin-left: 5px;"></div>')}
]
})
}); });
me.btnChangeShape.menu.addItem(menuItem);
} }
me.btnChangeShape.menu.items[0].setVisible(me._state.isFromImage); me.btnChangeShape.menu.items[0].setVisible(me._state.isFromImage);
me.btnChangeShape.menu.items[1].setVisible(!me._state.isFromImage); me.btnChangeShape.menu.items[1].setVisible(!me._state.isFromImage);
@ -2093,6 +2080,7 @@ define([
textPosition: 'Position', textPosition: 'Position',
tipAddGradientPoint: 'Add gradient point', tipAddGradientPoint: 'Add gradient point',
tipRemoveGradientPoint: 'Remove gradient point', tipRemoveGradientPoint: 'Remove gradient point',
textAngle: 'Angle' textAngle: 'Angle',
textRecentlyUsed: 'Recently Used'
}, DE.Views.ShapeSettings || {})); }, DE.Views.ShapeSettings || {}));
}); });

View file

@ -619,7 +619,7 @@ define([
iconCls: 'toolbar__icon btn-insertshape', iconCls: 'toolbar__icon btn-insertshape',
caption: me.capBtnInsShape, caption: me.capBtnInsShape,
enableToggle: true, enableToggle: true,
menu: new Common.UI.Menu({cls: 'menu-shapes'}), menu: new Common.UI.Menu({cls: 'menu-shapes menu-insert-shape'}),
dataHint: '1', dataHint: '1',
dataHintDirection: 'bottom', dataHintDirection: 'bottom',
dataHintOffset: 'small' dataHintOffset: 'small'

View file

@ -1224,6 +1224,7 @@
"DE.Controllers.Toolbar.txtSymbol_vdots": "Vertical ellipsis", "DE.Controllers.Toolbar.txtSymbol_vdots": "Vertical ellipsis",
"DE.Controllers.Toolbar.txtSymbol_xsi": "Xi", "DE.Controllers.Toolbar.txtSymbol_xsi": "Xi",
"DE.Controllers.Toolbar.txtSymbol_zeta": "Zeta", "DE.Controllers.Toolbar.txtSymbol_zeta": "Zeta",
"DE.Controllers.Toolbar.textRecentlyUsed": "Recently Used",
"DE.Controllers.Viewport.textFitPage": "Fit to Page", "DE.Controllers.Viewport.textFitPage": "Fit to Page",
"DE.Controllers.Viewport.textFitWidth": "Fit to Width", "DE.Controllers.Viewport.textFitWidth": "Fit to Width",
"DE.Views.AddNewCaptionLabelDialog.textLabel": "Label:", "DE.Views.AddNewCaptionLabelDialog.textLabel": "Label:",
@ -2311,6 +2312,7 @@
"DE.Views.ShapeSettings.txtTight": "Tight", "DE.Views.ShapeSettings.txtTight": "Tight",
"DE.Views.ShapeSettings.txtTopAndBottom": "Top and bottom", "DE.Views.ShapeSettings.txtTopAndBottom": "Top and bottom",
"DE.Views.ShapeSettings.txtWood": "Wood", "DE.Views.ShapeSettings.txtWood": "Wood",
"DE.Views.ShapeSettings.textRecentlyUsed": "Recently Used",
"DE.Views.SignatureSettings.notcriticalErrorTitle": "Warning", "DE.Views.SignatureSettings.notcriticalErrorTitle": "Warning",
"DE.Views.SignatureSettings.strDelete": "Remove Signature", "DE.Views.SignatureSettings.strDelete": "Remove Signature",
"DE.Views.SignatureSettings.strDetails": "Signature Details", "DE.Views.SignatureSettings.strDetails": "Signature Details",

View file

@ -1437,7 +1437,7 @@ define([
iconCls: 'btn-change-shape', iconCls: 'btn-change-shape',
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
menuAlign: 'tr-br', menuAlign: 'tr-br',
cls: 'menu-shapes', cls: 'menu-shapes menu-change-shape',
items: [] items: []
}), }),
dataHint: '1', dataHint: '1',
@ -1641,47 +1641,35 @@ define([
fillAutoShapes: function() { fillAutoShapes: function() {
var me = this, var me = this,
shapesStore = this.application.getCollection('ShapeGroups'), shapesStore = this.application.getCollection('ShapeGroups'),
count = shapesStore.length; recents = Common.localStorage.getItem('pe-recent-shapes');
var onShowAfter = function(menu) { for (var i = 0; i < 2; i++) {
for (var i=-1; i<count-1 && count>0; i++) { var menuitem = new Common.UI.MenuItem({
var store = shapesStore.at(i > -1 ? i : 0).get('groupStore'); template: _.template('<div id="id-change-shape-menu-<%= options.index %>" class="menu-insertshape"></div>'),
if (i<0) { index: i
store = store.clone(); });
store.shift(); me.btnChangeShape.menu.addItem(menuitem);
}
var shapePicker = new Common.UI.DataViewSimple({ var shapePicker = new Common.UI.DataViewShape({
el: $('#id-shape-menu-shapegroup' + (i+1), menu.items[i+1].$el), el: $('#id-change-shape-menu-' + i),
store: store, itemTemplate: _.template('<div class="item-shape" id="<%= id %>"><svg width="20" height="20" class=\"icon\"><use xlink:href=\"#svg-icon-<%= data.shapeType %>\"></use></svg></div>'),
parentMenu: menu.items[i+1].menu, groups: shapesStore.toJSON(),
itemTemplate: _.template('<div class="item-shape" id="<%= id %>"><svg width="20" height="20" class=\"icon\"><use xlink:href=\"#svg-icon-<%= data.shapeType %>\"></use></svg></div>') parentMenu: me.btnChangeShape.menu,
}); restoreHeight: 640,
shapePicker.on('item:click', function(picker, item, record, e) { textRecentlyUsed: me.textRecentlyUsed,
if (me.api) { recentShapes: recents ? JSON.parse(recents) : null,
me.api.ChangeShapeType(record.get('data').shapeType); isFromImage: i === 0
me.fireEvent('editcomplete', me); });
} shapePicker.on('item:click', function(picker, item, record, e) {
if (e.type !== 'click') if (me.api) {
me.btnChangeShape.menu.hide(); me.api.ChangeShapeType(record.get('data').shapeType);
}); me.fireEvent('editcomplete', me);
} }
menu.off('show:after', onShowAfter); if (e.type !== 'click')
}; me.btnChangeShape.menu.hide();
me.btnChangeShape.menu.on('show:after', onShowAfter);
for (var i=-1; i<count-1 && count>0; i++) {
var shapeGroup = shapesStore.at(i>-1 ? i : i+1);
var menuItem = new Common.UI.MenuItem({
caption: shapeGroup.get('groupName'),
menu: new Common.UI.Menu({
menuAlign: 'tr-tl',
items: [
{ template: _.template('<div id="id-shape-menu-shapegroup' + (i+1) + '" class="menu-shape" style="width: ' + (shapeGroup.get('groupWidth') - 8) + 'px; margin-left: 5px;"></div>') }
]
})
}); });
me.btnChangeShape.menu.addItem(menuItem);
} }
me.btnChangeShape.menu.items[0].setVisible(me._state.isFromImage); me.btnChangeShape.menu.items[0].setVisible(me._state.isFromImage);
me.btnChangeShape.menu.items[1].setVisible(!me._state.isFromImage); me.btnChangeShape.menu.items[1].setVisible(!me._state.isFromImage);
}, },
@ -1954,6 +1942,7 @@ define([
textPosition: 'Position', textPosition: 'Position',
tipAddGradientPoint: 'Add gradient point', tipAddGradientPoint: 'Add gradient point',
tipRemoveGradientPoint: 'Remove gradient point', tipRemoveGradientPoint: 'Remove gradient point',
textAngle: 'Angle' textAngle: 'Angle',
textRecentlyUsed: 'Recently Used'
}, PE.Views.ShapeSettings || {})); }, PE.Views.ShapeSettings || {}));
}); });

View file

@ -1249,7 +1249,7 @@ define([
btn.updateHint(me.tipInsertShape); btn.updateHint(me.tipInsertShape);
btn.setMenu( btn.setMenu(
new Common.UI.Menu({ new Common.UI.Menu({
cls: 'menu-shapes' cls: 'menu-shapes menu-insert-shape'
}).on('hide:after', function (e) { }).on('hide:after', function (e) {
me.fireEvent('insert:shape', ['menu:hide']); me.fireEvent('insert:shape', ['menu:hide']);
}) })
@ -1687,39 +1687,31 @@ define([
}, },
updateAutoshapeMenu: function (menuShape, collection) { updateAutoshapeMenu: function (menuShape, collection) {
var me = this; var me = this,
var onShowAfter = function(menu) { index = $(menuShape.el).prop('id').slice(-1);
for (var i = 0; i < collection.length; i++) {
var shapePicker = new Common.UI.DataViewSimple({
el: $('.shapegroup-' + i, menu.items[i].$el),
store: collection.at(i).get('groupStore'),
parentMenu: menu.items[i].menu,
itemTemplate: _.template('<div class="item-shape" id="<%= id %>"><svg width="20" height="20" class=\"icon\"><use xlink:href=\"#svg-icon-<%= data.shapeType %>\"></use></svg></div>')
});
shapePicker.on('item:click', function(picker, item, record, e) {
if (e.type !== 'click') Common.UI.Menu.Manager.hideAll();
if (record)
me.fireEvent('insert:shape', [record.get('data').shapeType]);
});
}
menu.off('show:after', onShowAfter);
};
menuShape.on('show:after', onShowAfter);
for (var i = 0; i < collection.size(); i++) { var menuitem = new Common.UI.MenuItem({
var group = collection.at(i); template: _.template('<div id="id-toolbar-menu-insertshape-<%= options.index %>" class="menu-insertshape"></div>'),
index: index
});
menuShape.addItem(menuitem);
var menuitem = new Common.UI.MenuItem({ var recents = Common.localStorage.getItem('pe-recent-shapes');
caption: group.get('groupName'),
menu: new Common.UI.Menu({ var shapePicker = new Common.UI.DataViewShape({
menuAlign: 'tl-tr', el: $('#id-toolbar-menu-insertshape-'+index),
items: [ itemTemplate: _.template('<div class="item-shape" id="<%= id %>"><svg width="20" height="20" class=\"icon\"><use xlink:href=\"#svg-icon-<%= data.shapeType %>\"></use></svg></div>'),
{template: _.template('<div class="shapegroup-' + i + '" class="menu-shape" style="width: ' + (group.get('groupWidth') - 8) + 'px; margin-left: 5px;"></div>')} groups: collection.toJSON(),
] parentMenu: menuShape,
}) restoreHeight: 640,
}); textRecentlyUsed: me.textRecentlyUsed,
menuShape.addItem(menuitem); recentShapes: recents ? JSON.parse(recents) : null
} });
shapePicker.on('item:click', function(picker, item, record, e) {
if (e.type !== 'click') Common.UI.Menu.Manager.hideAll();
if (record)
me.fireEvent('insert:shape', [record.get('data').shapeType]);
});
}, },
updateAddSlideMenu: function(collection) { updateAddSlideMenu: function(collection) {
@ -1926,7 +1918,8 @@ define([
strMenuNoFill: 'No Fill', strMenuNoFill: 'No Fill',
tipHighlightColor: 'Highlight color', tipHighlightColor: 'Highlight color',
txtScheme22: 'New Office', txtScheme22: 'New Office',
textTabTransitions: 'Transitions' textTabTransitions: 'Transitions',
textRecentlyUsed: 'Recently Used'
} }
}()), PE.Views.Toolbar || {})); }()), PE.Views.Toolbar || {}));
}); });

View file

@ -1592,6 +1592,7 @@
"PE.Views.ShapeSettings.txtNoBorders": "No Line", "PE.Views.ShapeSettings.txtNoBorders": "No Line",
"PE.Views.ShapeSettings.txtPapyrus": "Papyrus", "PE.Views.ShapeSettings.txtPapyrus": "Papyrus",
"PE.Views.ShapeSettings.txtWood": "Wood", "PE.Views.ShapeSettings.txtWood": "Wood",
"PE.Views.ShapeSettings.textRecentlyUsed": "Recently Used",
"PE.Views.ShapeSettingsAdvanced.strColumns": "Columns", "PE.Views.ShapeSettingsAdvanced.strColumns": "Columns",
"PE.Views.ShapeSettingsAdvanced.strMargins": "Text Padding", "PE.Views.ShapeSettingsAdvanced.strMargins": "Text Padding",
"PE.Views.ShapeSettingsAdvanced.textAlt": "Alternative Text", "PE.Views.ShapeSettingsAdvanced.textAlt": "Alternative Text",
@ -1984,6 +1985,7 @@
"PE.Views.Toolbar.txtScheme9": "Foundry", "PE.Views.Toolbar.txtScheme9": "Foundry",
"PE.Views.Toolbar.txtSlideAlign": "Align to Slide", "PE.Views.Toolbar.txtSlideAlign": "Align to Slide",
"PE.Views.Toolbar.txtUngroup": "Ungroup", "PE.Views.Toolbar.txtUngroup": "Ungroup",
"PE.Views.Toolbar.textRecentlyUsed": "Recently Used",
"PE.Views.Transitions.strDelay": "Delay", "PE.Views.Transitions.strDelay": "Delay",
"PE.Views.Transitions.strDuration": "Duration", "PE.Views.Transitions.strDuration": "Duration",
"PE.Views.Transitions.strStartOnClick": "Start On Click", "PE.Views.Transitions.strStartOnClick": "Start On Click",

View file

@ -3157,50 +3157,38 @@ define([
var me = this, var me = this,
shapesStore = this.getApplication().getCollection('ShapeGroups'); shapesStore = this.getApplication().getCollection('ShapeGroups');
var onShowAfter = function(menu) { var menuitem = new Common.UI.MenuItem({
for (var i = 0; i < shapesStore.length; i++) { template: _.template('<div id="id-toolbar-menu-insertshape" class="menu-insertshape"></div>')
var shapePicker = new Common.UI.DataViewSimple({ });
el: $('#id-toolbar-menu-shapegroup' + i, menu.items[i].$el), me.toolbar.btnInsertShape.menu.addItem(menuitem);
store: shapesStore.at(i).get('groupStore'),
parentMenu: menu.items[i].menu,
itemTemplate: _.template('<div class="item-shape" id="<%= id %>"><svg width="21" height="21" class=\"icon\"><use xlink:href=\"#svg-icon-<%= data.shapeType %>\"></use></svg></div>')
});
shapePicker.on('item:click', function(picker, item, record, e) {
if (me.api) {
if (record) {
me._addAutoshape(true, record.get('data').shapeType);
me._isAddingShape = true;
}
if (me.toolbar.btnInsertText.pressed) { var recents = Common.localStorage.getItem('sse-recent-shapes');
me.toolbar.btnInsertText.toggle(false, true);
} var shapePicker = new Common.UI.DataViewShape({
if (e.type !== 'click') el: $('#id-toolbar-menu-insertshape'),
me.toolbar.btnInsertShape.menu.hide(); itemTemplate: _.template('<div class="item-shape" id="<%= id %>"><svg width="20" height="20" class=\"icon\"><use xlink:href=\"#svg-icon-<%= data.shapeType %>\"></use></svg></div>'),
Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnInsertShape); groups: shapesStore.toJSON(),
Common.component.Analytics.trackEvent('ToolBar', 'Add Shape'); parentMenu: me.toolbar.btnInsertShape.menu,
} restoreHeight: 640,
}); textRecentlyUsed: me.textRecentlyUsed,
recentShapes: recents ? JSON.parse(recents) : null
});
shapePicker.on('item:click', function(picker, item, record, e) {
if (me.api) {
if (record) {
me._addAutoshape(true, record.get('data').shapeType);
me._isAddingShape = true;
}
if (me.toolbar.btnInsertText.pressed) {
me.toolbar.btnInsertText.toggle(false, true);
}
if (e.type !== 'click')
me.toolbar.btnInsertShape.menu.hide();
Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnInsertShape);
Common.component.Analytics.trackEvent('ToolBar', 'Add Shape');
} }
menu.off('show:after', onShowAfter); });
};
me.toolbar.btnInsertShape.menu.on('show:after', onShowAfter);
for (var i = 0; i < shapesStore.length; i++) {
var shapeGroup = shapesStore.at(i);
var menuItem = new Common.UI.MenuItem({
caption: shapeGroup.get('groupName'),
menu: new Common.UI.Menu({
menuAlign: 'tl-tr',
items: [
{ template: _.template('<div id="id-toolbar-menu-shapegroup' + i + '" class="menu-shape" style="width: ' + (shapeGroup.get('groupWidth') - 8) + 'px; margin-left: 5px;"></div>') }
]
})
});
me.toolbar.btnInsertShape.menu.addItem(menuItem);
}
}, },
fillEquations: function() { fillEquations: function() {
@ -4440,7 +4428,8 @@ define([
textShapes: 'Shapes', textShapes: 'Shapes',
textIndicator: 'Indicators', textIndicator: 'Indicators',
textRating: 'Ratings', textRating: 'Ratings',
txtLockSort: 'Data is found next to your selection, but you do not have sufficient permissions to change those cells.<br>Do you wish to continue with the current selection?' txtLockSort: 'Data is found next to your selection, but you do not have sufficient permissions to change those cells.<br>Do you wish to continue with the current selection?',
textRecentlyUsed: 'Recently Used'
}, SSE.Controllers.Toolbar || {})); }, SSE.Controllers.Toolbar || {}));
}); });

View file

@ -1463,7 +1463,7 @@ define([
iconCls: 'btn-change-shape', iconCls: 'btn-change-shape',
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
menuAlign: 'tr-br', menuAlign: 'tr-br',
cls: 'menu-shapes', cls: 'menu-shapes menu-change-shape',
items: [] items: []
}), }),
dataHint: '1', dataHint: '1',
@ -1659,46 +1659,33 @@ define([
fillAutoShapes: function() { fillAutoShapes: function() {
var me = this, var me = this,
shapesStore = this.application.getCollection('ShapeGroups'), shapesStore = this.application.getCollection('ShapeGroups'),
count = shapesStore.length; recents = Common.localStorage.getItem('sse-recent-shapes');
var onShowAfter = function(menu) { for (var i = 0; i < 2; i++) {
for (var i=-1; i<count-1 && count>0; i++) { var menuitem = new Common.UI.MenuItem({
var store = shapesStore.at(i > -1 ? i : 0).get('groupStore'); template: _.template('<div id="id-change-shape-menu-<%= options.index %>" class="menu-insertshape"></div>'),
if (i<0) { index: i
store = store.clone(); });
store.shift(); me.btnChangeShape.menu.addItem(menuitem);
}
var shapePicker = new Common.UI.DataViewSimple({ var shapePicker = new Common.UI.DataViewShape({
el: $('#id-shape-menu-shapegroup' + (i+1), menu.items[i+1].$el), el: $('#id-change-shape-menu-' + i),
store: store, itemTemplate: _.template('<div class="item-shape" id="<%= id %>"><svg width="20" height="20" class=\"icon\"><use xlink:href=\"#svg-icon-<%= data.shapeType %>\"></use></svg></div>'),
parentMenu: menu.items[i+1].menu, groups: shapesStore.toJSON(),
itemTemplate: _.template('<div class="item-shape" id="<%= id %>"><svg width="20" height="20" class=\"icon\"><use xlink:href=\"#svg-icon-<%= data.shapeType %>\"></use></svg></div>') parentMenu: me.btnChangeShape.menu,
}); restoreHeight: 640,
shapePicker.on('item:click', function(picker, item, record, e) { textRecentlyUsed: me.textRecentlyUsed,
if (me.api) { recentShapes: recents ? JSON.parse(recents) : null,
me.api.asc_changeShapeType(record.get('data').shapeType); isFromImage: i === 0
Common.NotificationCenter.trigger('edit:complete', me); });
} shapePicker.on('item:click', function(picker, item, record, e) {
if (e.type !== 'click') if (me.api) {
me.btnChangeShape.menu.hide(); me.api.asc_changeShapeType(record.get('data').shapeType);
}); Common.NotificationCenter.trigger('edit:complete', me);
} }
menu.off('show:after', onShowAfter); if (e.type !== 'click')
}; me.btnChangeShape.menu.hide();
me.btnChangeShape.menu.on('show:after', onShowAfter);
for (var i=-1; i<count-1 && count>0; i++) {
var shapeGroup = shapesStore.at(i>-1 ? i : i+1);
var menuItem = new Common.UI.MenuItem({
caption: shapeGroup.get('groupName'),
menu: new Common.UI.Menu({
menuAlign: 'tr-tl',
items: [
{ template: _.template('<div id="id-shape-menu-shapegroup' + (i+1) + '" class="menu-shape" style="width: ' + (shapeGroup.get('groupWidth') - 8) + 'px; margin-left: 5px;"></div>') }
]
})
}); });
me.btnChangeShape.menu.addItem(menuItem);
} }
me.btnChangeShape.menu.items[0].setVisible(me._state.isFromImage); me.btnChangeShape.menu.items[0].setVisible(me._state.isFromImage);
me.btnChangeShape.menu.items[1].setVisible(!me._state.isFromImage); me.btnChangeShape.menu.items[1].setVisible(!me._state.isFromImage);
@ -1986,6 +1973,7 @@ define([
textPosition: 'Position', textPosition: 'Position',
tipAddGradientPoint: 'Add gradient point', tipAddGradientPoint: 'Add gradient point',
tipRemoveGradientPoint: 'Remove gradient point', tipRemoveGradientPoint: 'Remove gradient point',
textAngle: 'Angle' textAngle: 'Angle',
textRecentlyUsed: 'Recently Used'
}, SSE.Views.ShapeSettings || {})); }, SSE.Views.ShapeSettings || {}));
}); });

View file

@ -803,7 +803,7 @@ define([
enableToggle: true, enableToggle: true,
caption : me.capInsertShape, caption : me.capInsertShape,
lock : [_set.editCell, _set.lostConnect, _set.coAuth, _set['Objects']], lock : [_set.editCell, _set.lostConnect, _set.coAuth, _set['Objects']],
menu : new Common.UI.Menu({cls: 'menu-shapes'}), menu : new Common.UI.Menu({cls: 'menu-shapes menu-insert-shape'}),
dataHint : '1', dataHint : '1',
dataHintDirection: 'bottom', dataHintDirection: 'bottom',
dataHintOffset: 'small' dataHintOffset: 'small'

View file

@ -1417,6 +1417,7 @@
"SSE.Controllers.Toolbar.txtTable_TableStyleMedium": "Table Style Medium", "SSE.Controllers.Toolbar.txtTable_TableStyleMedium": "Table Style Medium",
"SSE.Controllers.Toolbar.warnLongOperation": "The operation you are about to perform might take rather much time to complete.<br>Are you sure you want to continue?", "SSE.Controllers.Toolbar.warnLongOperation": "The operation you are about to perform might take rather much time to complete.<br>Are you sure you want to continue?",
"SSE.Controllers.Toolbar.warnMergeLostData": "Only the data from the upper-left cell will remain in the merged cell. <br>Are you sure you want to continue?", "SSE.Controllers.Toolbar.warnMergeLostData": "Only the data from the upper-left cell will remain in the merged cell. <br>Are you sure you want to continue?",
"SSE.Controllers.Toolbar.textRecentlyUsed": "Recently Used",
"SSE.Controllers.Viewport.textFreezePanes": "Freeze Panes", "SSE.Controllers.Viewport.textFreezePanes": "Freeze Panes",
"SSE.Controllers.Viewport.textFreezePanesShadow": "Show Frozen Panes Shadow", "SSE.Controllers.Viewport.textFreezePanesShadow": "Show Frozen Panes Shadow",
"SSE.Controllers.Viewport.textHideFBar": "Hide Formula Bar", "SSE.Controllers.Viewport.textHideFBar": "Hide Formula Bar",
@ -2856,6 +2857,7 @@
"SSE.Views.ShapeSettings.txtNoBorders": "No Line", "SSE.Views.ShapeSettings.txtNoBorders": "No Line",
"SSE.Views.ShapeSettings.txtPapyrus": "Papyrus", "SSE.Views.ShapeSettings.txtPapyrus": "Papyrus",
"SSE.Views.ShapeSettings.txtWood": "Wood", "SSE.Views.ShapeSettings.txtWood": "Wood",
"SSE.Views.ShapeSettings.textRecentlyUsed": "Recently Used",
"SSE.Views.ShapeSettingsAdvanced.strColumns": "Columns", "SSE.Views.ShapeSettingsAdvanced.strColumns": "Columns",
"SSE.Views.ShapeSettingsAdvanced.strMargins": "Text Padding", "SSE.Views.ShapeSettingsAdvanced.strMargins": "Text Padding",
"SSE.Views.ShapeSettingsAdvanced.textAbsolute": "Don't move or size with cells", "SSE.Views.ShapeSettingsAdvanced.textAbsolute": "Don't move or size with cells",