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({
items: me.store.toJSON(),
itemTemplate: me.itemTemplate,
style: me.style
style: me.style,
options: me.options
}));
}
var modalParents = this.cmpEl.closest('.asc-window');
@ -1088,6 +1089,8 @@ define([
if (data.keyCode==Common.UI.Keys.RETURN) {
if (this.selectedBeforeHideRec) // only for ComboDataView menuPicker
rec = this.selectedBeforeHideRec;
if (this.canAddRecents) // only for DaraViewShape
this.addRecentItem(rec);
this.trigger('item:click', this, this, rec, e);
if (this.parentMenu)
this.parentMenu.hide();
@ -1257,4 +1260,229 @@ define([
}
}, 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

@ -89,3 +89,15 @@
.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,13 +2641,21 @@ define([
var me = this,
shapesStore = this.getApplication().getCollection('ShapeGroups');
var onShowAfter = function(menu) {
for (var i = 0; i < shapesStore.length; i++) {
var shapePicker = new Common.UI.DataViewSimple({
el: $('#id-toolbar-menu-shapegroup' + i, menu.items[i].$el),
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>')
var menuitem = new Common.UI.MenuItem({
template: _.template('<div id="id-toolbar-menu-insertshape" class="menu-insertshape"></div>')
});
me.toolbar.btnInsertShape.menu.addItem(menuitem);
var recents = Common.localStorage.getItem('de-recent-shapes');
var shapePicker = new Common.UI.DataViewShape({
el: $('#id-toolbar-menu-insertshape'),
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>'),
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) {
@ -2666,25 +2674,6 @@ define([
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() {
@ -3670,7 +3659,8 @@ define([
textInsert: 'Insert',
textTabForms: 'Forms',
textGroup: 'Group',
textEmptyMMergeUrl: 'You need to specify URL.'
textEmptyMMergeUrl: 'You need to specify URL.',
textRecentlyUsed: 'Recently Used'
}, DE.Controllers.Toolbar || {}));
});

View file

@ -1611,7 +1611,7 @@ define([
iconCls: 'btn-change-shape',
menu : new Common.UI.Menu({
menuAlign: 'tr-br',
cls: 'menu-shapes',
cls: 'menu-shapes menu-change-shape',
items: []
}),
dataHint: '1',
@ -1786,20 +1786,24 @@ define([
fillAutoShapes: function() {
var me = this,
shapesStore = this.application.getCollection('ShapeGroups'),
count = shapesStore.length;
recents = Common.localStorage.getItem('de-recent-shapes');
var onShowAfter = function(menu) {
for (var i=-1; i<count-1 && count>0; i++) {
var store = shapesStore.at(i > -1 ? i : 0).get('groupStore');
if (i<0) {
store = store.clone();
store.shift();
}
var shapePicker = new Common.UI.DataViewSimple({
el: $('#id-shape-menu-shapegroup' + (i+1), menu.items[i+1].$el),
store: store,
parentMenu: menu.items[i+1].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>')
for (var i = 0; i < 2; i++) {
var menuitem = new Common.UI.MenuItem({
template: _.template('<div id="id-change-shape-menu-<%= options.index %>" class="menu-insertshape"></div>'),
index: i
});
me.btnChangeShape.menu.addItem(menuitem);
var shapePicker = new Common.UI.DataViewShape({
el: $('#id-change-shape-menu-' + i),
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>'),
groups: shapesStore.toJSON(),
parentMenu: me.btnChangeShape.menu,
restoreHeight: 640,
textRecentlyUsed: me.textRecentlyUsed,
recentShapes: recents ? JSON.parse(recents) : null,
isFromImage: i === 0
});
shapePicker.on('item:click', function(picker, item, record, e) {
if (me.api) {
@ -1810,23 +1814,6 @@ define([
me.btnChangeShape.menu.hide();
});
}
menu.off('show:after', onShowAfter);
};
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[1].setVisible(!me._state.isFromImage);
},
@ -2093,6 +2080,7 @@ define([
textPosition: 'Position',
tipAddGradientPoint: 'Add gradient point',
tipRemoveGradientPoint: 'Remove gradient point',
textAngle: 'Angle'
textAngle: 'Angle',
textRecentlyUsed: 'Recently Used'
}, DE.Views.ShapeSettings || {}));
});

View file

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

View file

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

View file

@ -1437,7 +1437,7 @@ define([
iconCls: 'btn-change-shape',
menu : new Common.UI.Menu({
menuAlign: 'tr-br',
cls: 'menu-shapes',
cls: 'menu-shapes menu-change-shape',
items: []
}),
dataHint: '1',
@ -1641,20 +1641,24 @@ define([
fillAutoShapes: function() {
var me = this,
shapesStore = this.application.getCollection('ShapeGroups'),
count = shapesStore.length;
recents = Common.localStorage.getItem('pe-recent-shapes');
var onShowAfter = function(menu) {
for (var i=-1; i<count-1 && count>0; i++) {
var store = shapesStore.at(i > -1 ? i : 0).get('groupStore');
if (i<0) {
store = store.clone();
store.shift();
}
var shapePicker = new Common.UI.DataViewSimple({
el: $('#id-shape-menu-shapegroup' + (i+1), menu.items[i+1].$el),
store: store,
parentMenu: menu.items[i+1].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>')
for (var i = 0; i < 2; i++) {
var menuitem = new Common.UI.MenuItem({
template: _.template('<div id="id-change-shape-menu-<%= options.index %>" class="menu-insertshape"></div>'),
index: i
});
me.btnChangeShape.menu.addItem(menuitem);
var shapePicker = new Common.UI.DataViewShape({
el: $('#id-change-shape-menu-' + i),
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>'),
groups: shapesStore.toJSON(),
parentMenu: me.btnChangeShape.menu,
restoreHeight: 640,
textRecentlyUsed: me.textRecentlyUsed,
recentShapes: recents ? JSON.parse(recents) : null,
isFromImage: i === 0
});
shapePicker.on('item:click', function(picker, item, record, e) {
if (me.api) {
@ -1665,23 +1669,7 @@ define([
me.btnChangeShape.menu.hide();
});
}
menu.off('show:after', onShowAfter);
};
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[1].setVisible(!me._state.isFromImage);
},
@ -1954,6 +1942,7 @@ define([
textPosition: 'Position',
tipAddGradientPoint: 'Add gradient point',
tipRemoveGradientPoint: 'Remove gradient point',
textAngle: 'Angle'
textAngle: 'Angle',
textRecentlyUsed: 'Recently Used'
}, PE.Views.ShapeSettings || {}));
});

View file

@ -1249,7 +1249,7 @@ define([
btn.updateHint(me.tipInsertShape);
btn.setMenu(
new Common.UI.Menu({
cls: 'menu-shapes'
cls: 'menu-shapes menu-insert-shape'
}).on('hide:after', function (e) {
me.fireEvent('insert:shape', ['menu:hide']);
})
@ -1687,39 +1687,31 @@ define([
},
updateAutoshapeMenu: function (menuShape, collection) {
var me = this;
var onShowAfter = function(menu) {
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>')
var me = this,
index = $(menuShape.el).prop('id').slice(-1);
var menuitem = new Common.UI.MenuItem({
template: _.template('<div id="id-toolbar-menu-insertshape-<%= options.index %>" class="menu-insertshape"></div>'),
index: index
});
menuShape.addItem(menuitem);
var recents = Common.localStorage.getItem('pe-recent-shapes');
var shapePicker = new Common.UI.DataViewShape({
el: $('#id-toolbar-menu-insertshape-'+index),
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>'),
groups: collection.toJSON(),
parentMenu: menuShape,
restoreHeight: 640,
textRecentlyUsed: me.textRecentlyUsed,
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]);
});
}
menu.off('show:after', onShowAfter);
};
menuShape.on('show:after', onShowAfter);
for (var i = 0; i < collection.size(); i++) {
var group = collection.at(i);
var menuitem = new Common.UI.MenuItem({
caption: group.get('groupName'),
menu: new Common.UI.Menu({
menuAlign: 'tl-tr',
items: [
{template: _.template('<div class="shapegroup-' + i + '" class="menu-shape" style="width: ' + (group.get('groupWidth') - 8) + 'px; margin-left: 5px;"></div>')}
]
})
});
menuShape.addItem(menuitem);
}
},
updateAddSlideMenu: function(collection) {
@ -1926,7 +1918,8 @@ define([
strMenuNoFill: 'No Fill',
tipHighlightColor: 'Highlight color',
txtScheme22: 'New Office',
textTabTransitions: 'Transitions'
textTabTransitions: 'Transitions',
textRecentlyUsed: 'Recently Used'
}
}()), PE.Views.Toolbar || {}));
});

View file

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

View file

@ -3157,13 +3157,21 @@ define([
var me = this,
shapesStore = this.getApplication().getCollection('ShapeGroups');
var onShowAfter = function(menu) {
for (var i = 0; i < shapesStore.length; i++) {
var shapePicker = new Common.UI.DataViewSimple({
el: $('#id-toolbar-menu-shapegroup' + i, menu.items[i].$el),
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>')
var menuitem = new Common.UI.MenuItem({
template: _.template('<div id="id-toolbar-menu-insertshape" class="menu-insertshape"></div>')
});
me.toolbar.btnInsertShape.menu.addItem(menuitem);
var recents = Common.localStorage.getItem('sse-recent-shapes');
var shapePicker = new Common.UI.DataViewShape({
el: $('#id-toolbar-menu-insertshape'),
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>'),
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) {
@ -3181,26 +3189,6 @@ define([
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() {
@ -4440,7 +4428,8 @@ define([
textShapes: 'Shapes',
textIndicator: 'Indicators',
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 || {}));
});

View file

@ -1463,7 +1463,7 @@ define([
iconCls: 'btn-change-shape',
menu : new Common.UI.Menu({
menuAlign: 'tr-br',
cls: 'menu-shapes',
cls: 'menu-shapes menu-change-shape',
items: []
}),
dataHint: '1',
@ -1659,20 +1659,24 @@ define([
fillAutoShapes: function() {
var me = this,
shapesStore = this.application.getCollection('ShapeGroups'),
count = shapesStore.length;
recents = Common.localStorage.getItem('sse-recent-shapes');
var onShowAfter = function(menu) {
for (var i=-1; i<count-1 && count>0; i++) {
var store = shapesStore.at(i > -1 ? i : 0).get('groupStore');
if (i<0) {
store = store.clone();
store.shift();
}
var shapePicker = new Common.UI.DataViewSimple({
el: $('#id-shape-menu-shapegroup' + (i+1), menu.items[i+1].$el),
store: store,
parentMenu: menu.items[i+1].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>')
for (var i = 0; i < 2; i++) {
var menuitem = new Common.UI.MenuItem({
template: _.template('<div id="id-change-shape-menu-<%= options.index %>" class="menu-insertshape"></div>'),
index: i
});
me.btnChangeShape.menu.addItem(menuitem);
var shapePicker = new Common.UI.DataViewShape({
el: $('#id-change-shape-menu-' + i),
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>'),
groups: shapesStore.toJSON(),
parentMenu: me.btnChangeShape.menu,
restoreHeight: 640,
textRecentlyUsed: me.textRecentlyUsed,
recentShapes: recents ? JSON.parse(recents) : null,
isFromImage: i === 0
});
shapePicker.on('item:click', function(picker, item, record, e) {
if (me.api) {
@ -1683,23 +1687,6 @@ define([
me.btnChangeShape.menu.hide();
});
}
menu.off('show:after', onShowAfter);
};
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[1].setVisible(!me._state.isFromImage);
},
@ -1986,6 +1973,7 @@ define([
textPosition: 'Position',
tipAddGradientPoint: 'Add gradient point',
tipRemoveGradientPoint: 'Remove gradient point',
textAngle: 'Angle'
textAngle: 'Angle',
textRecentlyUsed: 'Recently Used'
}, SSE.Views.ShapeSettings || {}));
});

View file

@ -803,7 +803,7 @@ define([
enableToggle: true,
caption : me.capInsertShape,
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',
dataHintDirection: 'bottom',
dataHintOffset: 'small'

View file

@ -1417,6 +1417,7 @@
"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.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.textFreezePanesShadow": "Show Frozen Panes Shadow",
"SSE.Controllers.Viewport.textHideFBar": "Hide Formula Bar",
@ -2856,6 +2857,7 @@
"SSE.Views.ShapeSettings.txtNoBorders": "No Line",
"SSE.Views.ShapeSettings.txtPapyrus": "Papyrus",
"SSE.Views.ShapeSettings.txtWood": "Wood",
"SSE.Views.ShapeSettings.textRecentlyUsed": "Recently Used",
"SSE.Views.ShapeSettingsAdvanced.strColumns": "Columns",
"SSE.Views.ShapeSettingsAdvanced.strMargins": "Text Padding",
"SSE.Views.ShapeSettingsAdvanced.textAbsolute": "Don't move or size with cells",