Skip to content

Commit

Permalink
Merge pull request #2625 from ONLYOFFICE/fix/smart-arts
Browse files Browse the repository at this point in the history
Fix/smart arts
  • Loading branch information
JuliaRadzhabova authored Oct 3, 2023
2 parents 8a6461c + 6d1843c commit 2a98767
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 21 deletions.
28 changes: 25 additions & 3 deletions apps/documenteditor/main/app/controller/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ define([
'home:open' : this.onHomeOpen,
'add:chart' : this.onSelectChart,
'insert:textart' : this.onInsertTextart,
'generate:smartart' : this.generateSmartArt,
'insert:smartart' : this.onInsertSmartArt
'insert:smartart' : this.onInsertSmartArt,
'smartart:mouseenter': this.mouseenterSmartArt,
'smartart:mouseleave': this.mouseleaveSmartArt,
},
'FileMenu': {
'menu:hide': this.onFileMenu.bind(this, 'hide'),
Expand Down Expand Up @@ -3494,11 +3495,26 @@ define([
})).show();
},

mouseenterSmartArt: function (groupName) {
if (this.smartArtGenerating === undefined) {
this.generateSmartArt(groupName);
} else {
this.delayedSmartArt = groupName;
}
},

mouseleaveSmartArt: function (groupName) {
if (this.delayedSmartArt === groupName) {
this.delayedSmartArt = undefined;
}
},

generateSmartArt: function (groupName) {
this.api.asc_generateSmartArtPreviews(groupName);
},

onApiBeginSmartArtPreview: function () {
onApiBeginSmartArtPreview: function (type) {
this.smartArtGenerating = type;
this.smartArtGroups = this.toolbar.btnInsertSmartArt.menu.items;
this.smartArtData = Common.define.smartArt.getSmartArtData();
},
Expand Down Expand Up @@ -3528,9 +3544,15 @@ define([
},

onApiEndSmartArtPreview: function () {
this.smartArtGenerating = undefined;
if (this.currentSmartArtMenu) {
this.currentSmartArtMenu.menu.alignPosition();
}
if (this.delayedSmartArt !== undefined) {
var delayedSmartArt = this.delayedSmartArt;
this.delayedSmartArt = undefined;
this.generateSmartArt(delayedSmartArt);
}
},

onInsertSmartArt: function (value) {
Expand Down
12 changes: 8 additions & 4 deletions apps/documenteditor/main/app/view/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2327,10 +2327,6 @@ define([
});
var onShowBeforeSmartArt = function (menu) { // + <% if(typeof imageUrl === "undefined" || imageUrl===null || imageUrl==="") { %> style="visibility: hidden;" <% } %>/>',
me.btnInsertSmartArt.menu.items.forEach(function (item, index) {
item.$el.one('mouseenter', function () {
me.fireEvent('generate:smartart', [item.value]);
item.$el.mouseenter();
});
item.menuPicker = new Common.UI.DataView({
el: $('#' + item.options.itemId),
parentMenu: me.btnInsertSmartArt.menu.items[index].menu,
Expand All @@ -2350,6 +2346,14 @@ define([
}
Common.NotificationCenter.trigger('edit:complete', me);
});
item.$el.on('mouseenter', function () {
if (item.menuPicker.store.length === 0) {
me.fireEvent('smartart:mouseenter', [item.value]);
}
});
item.$el.on('mouseleave', function () {
me.fireEvent('smartart:mouseleave', [item.value]);
});
});
menu.off('show:before', onShowBeforeSmartArt);
};
Expand Down
28 changes: 25 additions & 3 deletions apps/presentationeditor/main/app/controller/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ define([
'change:slide' : this.onChangeSlide.bind(this),
'change:compact' : this.onClickChangeCompact,
'add:chart' : this.onSelectChart,
'generate:smartart' : this.generateSmartArt,
'insert:smartart' : this.onInsertSmartArt
'insert:smartart' : this.onInsertSmartArt,
'smartart:mouseenter': this.mouseenterSmartArt,
'smartart:mouseleave': this.mouseleaveSmartArt,
},
'FileMenu': {
'menu:hide': this.onFileMenu.bind(this, 'hide'),
Expand Down Expand Up @@ -2787,11 +2788,26 @@ define([
}
},

mouseenterSmartArt: function (groupName) {
if (this.smartArtGenerating === undefined) {
this.generateSmartArt(groupName);
} else {
this.delayedSmartArt = groupName;
}
},

mouseleaveSmartArt: function (groupName) {
if (this.delayedSmartArt === groupName) {
this.delayedSmartArt = undefined;
}
},

generateSmartArt: function (groupName) {
this.api.asc_generateSmartArtPreviews(groupName);
},

onApiBeginSmartArtPreview: function () {
onApiBeginSmartArtPreview: function (type) {
this.smartArtGenerating = type;
this.smartArtGroups = this.toolbar.btnInsertSmartArt.menu.items;
this.smartArtData = Common.define.smartArt.getSmartArtData();
},
Expand Down Expand Up @@ -2821,9 +2837,15 @@ define([
},

onApiEndSmartArtPreview: function () {
this.smartArtGenerating = undefined;
if (this.currentSmartArtMenu) {
this.currentSmartArtMenu.menu.alignPosition();
}
if (this.delayedSmartArt !== undefined) {
var delayedSmartArt = this.delayedSmartArt;
this.delayedSmartArt = undefined;
this.generateSmartArt(delayedSmartArt);
}
},

onInsertSmartArt: function (value) {
Expand Down
12 changes: 8 additions & 4 deletions apps/presentationeditor/main/app/view/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1572,10 +1572,6 @@ define([
});
var onShowBeforeSmartArt = function (menu) { // + <% if(typeof imageUrl === "undefined" || imageUrl===null || imageUrl==="") { %> style="visibility: hidden;" <% } %>/>',
me.btnInsertSmartArt.menu.items.forEach(function (item, index) {
item.$el.one('mouseenter', function () {
me.fireEvent('generate:smartart', [item.value]);
item.$el.mouseenter();
});
item.menuPicker = new Common.UI.DataView({
el: $('#' + item.options.itemId),
parentMenu: me.btnInsertSmartArt.menu.items[index].menu,
Expand All @@ -1595,6 +1591,14 @@ define([
}
Common.NotificationCenter.trigger('edit:complete', me);
});
item.$el.on('mouseenter', function () {
if (item.menuPicker.store.length === 0) {
me.fireEvent('smartart:mouseenter', [item.value]);
}
});
item.$el.on('mouseleave', function () {
me.fireEvent('smartart:mouseleave', [item.value]);
});
});
menu.off('show:before', onShowBeforeSmartArt);
};
Expand Down
28 changes: 25 additions & 3 deletions apps/spreadsheeteditor/main/app/controller/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ define([
'change:scalespn': this.onClickChangeScaleInMenu.bind(me),
'click:customscale': this.onScaleClick.bind(me),
'home:open' : this.onHomeOpen,
'generate:smartart' : this.generateSmartArt,
'insert:smartart' : this.onInsertSmartArt
'insert:smartart' : this.onInsertSmartArt,
'smartart:mouseenter': this.mouseenterSmartArt,
'smartart:mouseleave': this.mouseleaveSmartArt,
},
'FileMenu': {
'menu:hide': me.onFileMenu.bind(me, 'hide'),
Expand Down Expand Up @@ -5019,11 +5020,26 @@ define([
Common.component.Analytics.trackEvent('ToolBar', 'Vertical align');
},

mouseenterSmartArt: function (groupName) {
if (this.smartArtGenerating === undefined) {
this.generateSmartArt(groupName);
} else {
this.delayedSmartArt = groupName;
}
},

mouseleaveSmartArt: function (groupName) {
if (this.delayedSmartArt === groupName) {
this.delayedSmartArt = undefined;
}
},

generateSmartArt: function (groupName) {
this.api.asc_generateSmartArtPreviews(groupName);
},

onApiBeginSmartArtPreview: function () {
onApiBeginSmartArtPreview: function (type) {
this.smartArtGenerating = type;
this.smartArtGroups = this.toolbar.btnInsertSmartArt.menu.items;
this.smartArtData = Common.define.smartArt.getSmartArtData();
},
Expand Down Expand Up @@ -5053,9 +5069,15 @@ define([
},

onApiEndSmartArtPreview: function () {
this.smartArtGenerating = undefined;
if (this.currentSmartArtMenu) {
this.currentSmartArtMenu.menu.alignPosition();
}
if (this.delayedSmartArt !== undefined) {
var delayedSmartArt = this.delayedSmartArt;
this.delayedSmartArt = undefined;
this.generateSmartArt(delayedSmartArt);
}
},

onInsertSmartArt: function (value) {
Expand Down
12 changes: 8 additions & 4 deletions apps/spreadsheeteditor/main/app/view/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2638,10 +2638,6 @@ define([
});
var onShowBeforeSmartArt = function (menu) { // + <% if(typeof imageUrl === "undefined" || imageUrl===null || imageUrl==="") { %> style="visibility: hidden;" <% } %>/>',
me.btnInsertSmartArt.menu.items.forEach(function (item, index) {
item.$el.one('mouseenter', function () {
me.fireEvent('generate:smartart', [item.value]);
item.$el.mouseenter();
});
item.menuPicker = new Common.UI.DataView({
el: $('#' + item.options.itemId),
parentMenu: me.btnInsertSmartArt.menu.items[index].menu,
Expand All @@ -2661,6 +2657,14 @@ define([
}
Common.NotificationCenter.trigger('edit:complete', me);
});
item.$el.on('mouseenter', function () {
if (item.menuPicker.store.length === 0) {
me.fireEvent('smartart:mouseenter', [item.value]);
}
});
item.$el.on('mouseleave', function () {
me.fireEvent('smartart:mouseleave', [item.value]);
});
});
menu.off('show:before', onShowBeforeSmartArt);
};
Expand Down

0 comments on commit 2a98767

Please sign in to comment.