diff --git a/apps/common/main/lib/component/DataView.js b/apps/common/main/lib/component/DataView.js
index 1fc31a77f..5813da8f0 100644
--- a/apps/common/main/lib/component/DataView.js
+++ b/apps/common/main/lib/component/DataView.js
@@ -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([
+ '
',
+ '<% _.each(options.groups, function(group, index) { %>',
+ '
style="display: none;" <% } %>>',
+ '<% if (!_.isEmpty(group.groupName)) { %>',
+ '
',
+ '<%= group.groupName %>',
+ '
',
+ '<% } %>',
+ '
',
+ '<% _.each(group.groupStore.toJSON(), function(item) { %>',
+ '<% if (!item.id) item.id = Common.UI.getId(); %>',
+ '
data-toggle="tooltip" <% } %> ><%= itemTemplate(item) %>
',
+ '<% }); %>',
+ '
',
+ '
',
+ '<% }); %>',
+ '
'
+ ].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(); %>',
+ ' data-toggle="tooltip" <% } %> ><%= itemTemplate(item) %>
',
+ '<% }) %>'
+ ].join(''));
+ me.cmpEl && me.cmpEl.find('.recent-items').html(template({
+ items: me.recentShapes,
+ itemTemplate: this.itemTemplate,
+ style : this.style
+ }));
+
+ me.updateDataViewItems = true;
+ }
+ }
+ }));
+
});
\ No newline at end of file
diff --git a/apps/common/main/resources/less/dataview.less b/apps/common/main/resources/less/dataview.less
index 29eb93dc9..7acb0bcdb 100644
--- a/apps/common/main/resources/less/dataview.less
+++ b/apps/common/main/resources/less/dataview.less
@@ -88,4 +88,16 @@
border: @scaled-one-px-value solid @input-border;
.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;
+ }
}
\ No newline at end of file
diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js
index 9c9a1d09f..83ead42f7 100644
--- a/apps/documenteditor/main/app/controller/Toolbar.js
+++ b/apps/documenteditor/main/app/controller/Toolbar.js
@@ -2641,50 +2641,39 @@ 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('')
- });
- shapePicker.on('item:click', function(picker, item, record, e) {
- if (me.api) {
- if (record) {
- me._addAutoshape(true, record.get('data').shapeType);
- me._isAddingShape = true;
- }
+ var menuitem = new Common.UI.MenuItem({
+ template: _.template('')
+ });
+ me.toolbar.btnInsertShape.menu.addItem(menuitem);
- if (me.toolbar.btnInsertText.pressed) {
- me.toolbar.btnInsertText.toggle(false, true);
- }
+ var recents = Common.localStorage.getItem('de-recent-shapes');
- 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');
- }
- });
+ var shapePicker = new Common.UI.DataViewShape({
+ el: $('#id-toolbar-menu-insertshape'),
+ itemTemplate: _.template(''),
+ 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('') }
- ]
- })
- });
- 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 || {}));
});
diff --git a/apps/documenteditor/main/app/view/ShapeSettings.js b/apps/documenteditor/main/app/view/ShapeSettings.js
index 6bd98fb15..c5b09976d 100644
--- a/apps/documenteditor/main/app/view/ShapeSettings.js
+++ b/apps/documenteditor/main/app/view/ShapeSettings.js
@@ -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,46 +1786,33 @@ 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; i0; 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('')
- });
- shapePicker.on('item:click', function(picker, item, record, e) {
- if (me.api) {
- me.api.ChangeShapeType(record.get('data').shapeType);
- me.fireEvent('editcomplete', me);
- }
- if (e.type !== 'click')
- me.btnChangeShape.menu.hide();
- });
- }
- menu.off('show:after', onShowAfter);
- };
- me.btnChangeShape.menu.on('show:after', onShowAfter);
-
- for (var i=-1; i0; 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('')}
- ]
- })
+ for (var i = 0; i < 2; i++) {
+ var menuitem = new Common.UI.MenuItem({
+ template: _.template(''),
+ index: i
+ });
+ me.btnChangeShape.menu.addItem(menuitem);
+
+ var shapePicker = new Common.UI.DataViewShape({
+ el: $('#id-change-shape-menu-' + i),
+ itemTemplate: _.template(''),
+ 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) {
+ me.api.ChangeShapeType(record.get('data').shapeType);
+ me.fireEvent('editcomplete', me);
+ }
+ if (e.type !== 'click')
+ me.btnChangeShape.menu.hide();
});
- 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 || {}));
});
diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js
index 89b39e1e5..8146cfab3 100644
--- a/apps/documenteditor/main/app/view/Toolbar.js
+++ b/apps/documenteditor/main/app/view/Toolbar.js
@@ -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'
diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json
index 5595dfb36..395ce4de2 100644
--- a/apps/documenteditor/main/locale/en.json
+++ b/apps/documenteditor/main/locale/en.json
@@ -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",
diff --git a/apps/presentationeditor/main/app/view/ShapeSettings.js b/apps/presentationeditor/main/app/view/ShapeSettings.js
index 97404aec3..5ecb19a7d 100644
--- a/apps/presentationeditor/main/app/view/ShapeSettings.js
+++ b/apps/presentationeditor/main/app/view/ShapeSettings.js
@@ -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,47 +1641,35 @@ 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; i0; 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('')
- });
- shapePicker.on('item:click', function(picker, item, record, e) {
- if (me.api) {
- me.api.ChangeShapeType(record.get('data').shapeType);
- me.fireEvent('editcomplete', me);
- }
- if (e.type !== 'click')
- me.btnChangeShape.menu.hide();
- });
- }
- menu.off('show:after', onShowAfter);
- };
- me.btnChangeShape.menu.on('show:after', onShowAfter);
-
- for (var i=-1; i0; 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('') }
- ]
- })
+ for (var i = 0; i < 2; i++) {
+ var menuitem = new Common.UI.MenuItem({
+ template: _.template(''),
+ index: i
+ });
+ me.btnChangeShape.menu.addItem(menuitem);
+
+ var shapePicker = new Common.UI.DataViewShape({
+ el: $('#id-change-shape-menu-' + i),
+ itemTemplate: _.template(''),
+ 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) {
+ me.api.ChangeShapeType(record.get('data').shapeType);
+ me.fireEvent('editcomplete', me);
+ }
+ if (e.type !== 'click')
+ me.btnChangeShape.menu.hide();
});
- 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 || {}));
});
diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js
index b6db11ec8..e5c0ce2ae 100644
--- a/apps/presentationeditor/main/app/view/Toolbar.js
+++ b/apps/presentationeditor/main/app/view/Toolbar.js
@@ -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('')
- });
- 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);
+ var me = this,
+ index = $(menuShape.el).prop('id').slice(-1);
- for (var i = 0; i < collection.size(); i++) {
- var group = collection.at(i);
+ var menuitem = new Common.UI.MenuItem({
+ template: _.template(''),
+ index: index
+ });
+ menuShape.addItem(menuitem);
- var menuitem = new Common.UI.MenuItem({
- caption: group.get('groupName'),
- menu: new Common.UI.Menu({
- menuAlign: 'tl-tr',
- items: [
- {template: _.template('')}
- ]
- })
- });
- 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(''),
+ 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]);
+ });
},
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 || {}));
});
\ No newline at end of file
diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json
index 268c79a7c..b91f928d6 100644
--- a/apps/presentationeditor/main/locale/en.json
+++ b/apps/presentationeditor/main/locale/en.json
@@ -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",
diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js
index cc434b41b..1cd814b66 100644
--- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js
+++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js
@@ -3157,50 +3157,38 @@ 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('')
- });
- shapePicker.on('item:click', function(picker, item, record, e) {
- if (me.api) {
- if (record) {
- me._addAutoshape(true, record.get('data').shapeType);
- me._isAddingShape = true;
- }
+ var menuitem = new Common.UI.MenuItem({
+ template: _.template('')
+ });
+ me.toolbar.btnInsertShape.menu.addItem(menuitem);
- 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');
- }
- });
+ var recents = Common.localStorage.getItem('sse-recent-shapes');
+
+ var shapePicker = new Common.UI.DataViewShape({
+ el: $('#id-toolbar-menu-insertshape'),
+ itemTemplate: _.template(''),
+ 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('') }
- ]
- })
- });
-
- 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.
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.
Do you wish to continue with the current selection?',
+ textRecentlyUsed: 'Recently Used'
}, SSE.Controllers.Toolbar || {}));
});
\ No newline at end of file
diff --git a/apps/spreadsheeteditor/main/app/view/ShapeSettings.js b/apps/spreadsheeteditor/main/app/view/ShapeSettings.js
index fb9c26e30..909df6986 100644
--- a/apps/spreadsheeteditor/main/app/view/ShapeSettings.js
+++ b/apps/spreadsheeteditor/main/app/view/ShapeSettings.js
@@ -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,46 +1659,33 @@ 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; i0; 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('')
- });
- shapePicker.on('item:click', function(picker, item, record, e) {
- if (me.api) {
- me.api.asc_changeShapeType(record.get('data').shapeType);
- Common.NotificationCenter.trigger('edit:complete', me);
- }
- if (e.type !== 'click')
- me.btnChangeShape.menu.hide();
- });
- }
- menu.off('show:after', onShowAfter);
- };
- me.btnChangeShape.menu.on('show:after', onShowAfter);
-
- for (var i=-1; i0; 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('') }
- ]
- })
+ for (var i = 0; i < 2; i++) {
+ var menuitem = new Common.UI.MenuItem({
+ template: _.template(''),
+ index: i
+ });
+ me.btnChangeShape.menu.addItem(menuitem);
+
+ var shapePicker = new Common.UI.DataViewShape({
+ el: $('#id-change-shape-menu-' + i),
+ itemTemplate: _.template(''),
+ 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) {
+ me.api.asc_changeShapeType(record.get('data').shapeType);
+ Common.NotificationCenter.trigger('edit:complete', me);
+ }
+ if (e.type !== 'click')
+ me.btnChangeShape.menu.hide();
});
- 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 || {}));
});
diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js
index 7a25f45e5..673e50227 100644
--- a/apps/spreadsheeteditor/main/app/view/Toolbar.js
+++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js
@@ -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'
diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json
index 75aabddfc..2bb10c13c 100644
--- a/apps/spreadsheeteditor/main/locale/en.json
+++ b/apps/spreadsheeteditor/main/locale/en.json
@@ -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.
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.
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",