From 8119c6a7b7e82296adb3ad0c909a84648b1fab65 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Tue, 14 Jul 2020 17:22:00 +0300 Subject: [PATCH] [DE][PE][SSE] Change active gradient point after removal of point --- apps/documenteditor/main/app/view/ShapeSettings.js | 11 ++++++++++- apps/documenteditor/main/app/view/TextArtSettings.js | 11 ++++++++++- .../presentationeditor/main/app/view/ShapeSettings.js | 11 ++++++++++- .../presentationeditor/main/app/view/SlideSettings.js | 11 ++++++++++- .../main/app/view/TextArtSettings.js | 11 ++++++++++- apps/spreadsheeteditor/main/app/view/CellSettings.js | 11 ++++++++++- apps/spreadsheeteditor/main/app/view/ShapeSettings.js | 11 ++++++++++- .../main/app/view/TextArtSettings.js | 11 ++++++++++- 8 files changed, 80 insertions(+), 8 deletions(-) diff --git a/apps/documenteditor/main/app/view/ShapeSettings.js b/apps/documenteditor/main/app/view/ShapeSettings.js index ecaa59708..0d1052bde 100644 --- a/apps/documenteditor/main/app/view/ShapeSettings.js +++ b/apps/documenteditor/main/app/view/ShapeSettings.js @@ -1390,6 +1390,12 @@ define([ me.sldrGradient.removeThumb(index); me.GradColor.values.splice(index, 1); me.sldrGradient.changeGradientStyle(); + if (_.isUndefined(me.GradColor.currentIdx) || me.GradColor.currentIdx >= me.GradColor.colors.length) { + var newIndex = index > 0 ? index - 1 : index; + newIndex = (newIndex === 0 && me.GradColor.values.length > 2) ? me.GradColor.values.length - 2 : newIndex; + me.GradColor.currentIdx = newIndex; + } + me.sldrGradient.setActiveThumb(me.GradColor.currentIdx); }); this.fillControls.push(this.sldrGradient); @@ -1902,10 +1908,13 @@ define([ onRemoveGradientStep: function() { if (this.GradColor.values.length < 3) return; + var index = this.GradColor.currentIdx; this.GradColor.values.splice(this.GradColor.currentIdx, 1); this.sldrGradient.removeThumb(this.GradColor.currentIdx); if (_.isUndefined(this.GradColor.currentIdx) || this.GradColor.currentIdx >= this.GradColor.colors.length) { - this.GradColor.currentIdx = 0; + var newIndex = index > 0 ? index - 1 : index; + newIndex = (newIndex === 0 && this.GradColor.values.length > 2) ? this.GradColor.values.length - 2 : newIndex; + this.GradColor.currentIdx = newIndex; } this.sldrGradient.setActiveThumb(this.GradColor.currentIdx); this.sldrGradient.trigger('change', this.sldrGradient); diff --git a/apps/documenteditor/main/app/view/TextArtSettings.js b/apps/documenteditor/main/app/view/TextArtSettings.js index 32e00e1c1..c982851df 100644 --- a/apps/documenteditor/main/app/view/TextArtSettings.js +++ b/apps/documenteditor/main/app/view/TextArtSettings.js @@ -955,6 +955,12 @@ define([ me.sldrGradient.removeThumb(index); me.GradColor.values.splice(index, 1); me.sldrGradient.changeGradientStyle(); + if (_.isUndefined(me.GradColor.currentIdx) || me.GradColor.currentIdx >= me.GradColor.colors.length) { + var newIndex = index > 0 ? index - 1 : index; + newIndex = (newIndex === 0 && me.GradColor.values.length > 2) ? me.GradColor.values.length - 2 : newIndex; + me.GradColor.currentIdx = newIndex; + } + me.sldrGradient.setActiveThumb(me.GradColor.currentIdx); }); this.lockedControls.push(this.sldrGradient); @@ -1236,10 +1242,13 @@ define([ onRemoveGradientStep: function() { if (this.GradColor.values.length < 3) return; + var index = this.GradColor.currentIdx; this.GradColor.values.splice(this.GradColor.currentIdx, 1); this.sldrGradient.removeThumb(this.GradColor.currentIdx); if (_.isUndefined(this.GradColor.currentIdx) || this.GradColor.currentIdx >= this.GradColor.colors.length) { - this.GradColor.currentIdx = 0; + var newIndex = index > 0 ? index - 1 : index; + newIndex = (newIndex === 0 && this.GradColor.values.length > 2) ? this.GradColor.values.length - 2 : newIndex; + this.GradColor.currentIdx = newIndex; } this.sldrGradient.setActiveThumb(this.GradColor.currentIdx); this.sldrGradient.trigger('change', this.sldrGradient); diff --git a/apps/presentationeditor/main/app/view/ShapeSettings.js b/apps/presentationeditor/main/app/view/ShapeSettings.js index eff763f08..ad3f325d6 100644 --- a/apps/presentationeditor/main/app/view/ShapeSettings.js +++ b/apps/presentationeditor/main/app/view/ShapeSettings.js @@ -1302,6 +1302,12 @@ define([ me.sldrGradient.removeThumb(index); me.GradColor.values.splice(index, 1); me.sldrGradient.changeGradientStyle(); + if (_.isUndefined(me.GradColor.currentIdx) || me.GradColor.currentIdx >= me.GradColor.colors.length) { + var newIndex = index > 0 ? index - 1 : index; + newIndex = (newIndex === 0 && me.GradColor.values.length > 2) ? me.GradColor.values.length - 2 : newIndex; + me.GradColor.currentIdx = newIndex; + } + me.sldrGradient.setActiveThumb(me.GradColor.currentIdx); }); this.fillControls.push(this.sldrGradient); @@ -1773,10 +1779,13 @@ define([ onRemoveGradientStep: function() { if (this.GradColor.values.length < 3) return; + var index = this.GradColor.currentIdx; this.GradColor.values.splice(this.GradColor.currentIdx, 1); this.sldrGradient.removeThumb(this.GradColor.currentIdx); if (_.isUndefined(this.GradColor.currentIdx) || this.GradColor.currentIdx >= this.GradColor.colors.length) { - this.GradColor.currentIdx = 0; + var newIndex = index > 0 ? index - 1 : index; + newIndex = (newIndex === 0 && this.GradColor.values.length > 2) ? this.GradColor.values.length - 2 : newIndex; + this.GradColor.currentIdx = newIndex; } this.sldrGradient.setActiveThumb(this.GradColor.currentIdx); this.sldrGradient.trigger('change', this.sldrGradient); diff --git a/apps/presentationeditor/main/app/view/SlideSettings.js b/apps/presentationeditor/main/app/view/SlideSettings.js index d88b075d1..f55e5e1d5 100644 --- a/apps/presentationeditor/main/app/view/SlideSettings.js +++ b/apps/presentationeditor/main/app/view/SlideSettings.js @@ -847,6 +847,12 @@ define([ me.sldrGradient.removeThumb(index); me.GradColor.values.splice(index, 1); me.sldrGradient.changeGradientStyle(); + if (_.isUndefined(me.GradColor.currentIdx) || me.GradColor.currentIdx >= me.GradColor.colors.length) { + var newIndex = index > 0 ? index - 1 : index; + newIndex = (newIndex === 0 && me.GradColor.values.length > 2) ? me.GradColor.values.length - 2 : newIndex; + me.GradColor.currentIdx = newIndex; + } + me.sldrGradient.setActiveThumb(me.GradColor.currentIdx); }); this.FillItems.push(this.sldrGradient); @@ -1573,10 +1579,13 @@ define([ onRemoveGradientStep: function() { if (this.GradColor.values.length < 3) return; + var index = this.GradColor.currentIdx; this.GradColor.values.splice(this.GradColor.currentIdx, 1); this.sldrGradient.removeThumb(this.GradColor.currentIdx); if (_.isUndefined(this.GradColor.currentIdx) || this.GradColor.currentIdx >= this.GradColor.colors.length) { - this.GradColor.currentIdx = 0; + var newIndex = index > 0 ? index - 1 : index; + newIndex = (newIndex === 0 && this.GradColor.values.length > 2) ? this.GradColor.values.length - 2 : newIndex; + this.GradColor.currentIdx = newIndex; } this.sldrGradient.setActiveThumb(this.GradColor.currentIdx); this.sldrGradient.trigger('change', this.sldrGradient); diff --git a/apps/presentationeditor/main/app/view/TextArtSettings.js b/apps/presentationeditor/main/app/view/TextArtSettings.js index 1eb97c4b2..4e0d7b53c 100644 --- a/apps/presentationeditor/main/app/view/TextArtSettings.js +++ b/apps/presentationeditor/main/app/view/TextArtSettings.js @@ -1262,6 +1262,12 @@ define([ me.sldrGradient.removeThumb(index); me.GradColor.values.splice(index, 1); me.sldrGradient.changeGradientStyle(); + if (_.isUndefined(me.GradColor.currentIdx) || me.GradColor.currentIdx >= me.GradColor.colors.length) { + var newIndex = index > 0 ? index - 1 : index; + newIndex = (newIndex === 0 && me.GradColor.values.length > 2) ? me.GradColor.values.length - 2 : newIndex; + me.GradColor.currentIdx = newIndex; + } + me.sldrGradient.setActiveThumb(me.GradColor.currentIdx); }); this.lockedControls.push(this.sldrGradient); @@ -1667,10 +1673,13 @@ define([ onRemoveGradientStep: function() { if (this.GradColor.values.length < 3) return; + var index = this.GradColor.currentIdx; this.GradColor.values.splice(this.GradColor.currentIdx, 1); this.sldrGradient.removeThumb(this.GradColor.currentIdx); if (_.isUndefined(this.GradColor.currentIdx) || this.GradColor.currentIdx >= this.GradColor.colors.length) { - this.GradColor.currentIdx = 0; + var newIndex = index > 0 ? index - 1 : index; + newIndex = (newIndex === 0 && this.GradColor.values.length > 2) ? this.GradColor.values.length - 2 : newIndex; + this.GradColor.currentIdx = newIndex; } this.sldrGradient.setActiveThumb(this.GradColor.currentIdx); this.sldrGradient.trigger('change', this.sldrGradient); diff --git a/apps/spreadsheeteditor/main/app/view/CellSettings.js b/apps/spreadsheeteditor/main/app/view/CellSettings.js index 8eef682fb..a260cbb7f 100644 --- a/apps/spreadsheeteditor/main/app/view/CellSettings.js +++ b/apps/spreadsheeteditor/main/app/view/CellSettings.js @@ -288,6 +288,12 @@ define([ me.sldrGradient.removeThumb(index); me.GradColor.values.splice(index, 1); me.sldrGradient.changeGradientStyle(); + if (_.isUndefined(me.GradColor.currentIdx) || me.GradColor.currentIdx >= me.GradColor.colors.length) { + var newIndex = index > 0 ? index - 1 : index; + newIndex = (newIndex === 0 && me.GradColor.values.length > 2) ? me.GradColor.values.length - 2 : newIndex; + me.GradColor.currentIdx = newIndex; + } + me.sldrGradient.setActiveThumb(me.GradColor.currentIdx); }); this.fillControls.push(this.sldrGradient); @@ -1260,10 +1266,13 @@ define([ onRemoveGradientStep: function() { if (this.GradColor.values.length < 3) return; + var index = this.GradColor.currentIdx; this.GradColor.values.splice(this.GradColor.currentIdx, 1); this.sldrGradient.removeThumb(this.GradColor.currentIdx); if (_.isUndefined(this.GradColor.currentIdx) || this.GradColor.currentIdx >= this.GradColor.colors.length) { - this.GradColor.currentIdx = 0; + var newIndex = index > 0 ? index - 1 : index; + newIndex = (newIndex === 0 && this.GradColor.values.length > 2) ? this.GradColor.values.length - 2 : newIndex; + this.GradColor.currentIdx = newIndex; } this.sldrGradient.setActiveThumb(this.GradColor.currentIdx); }, diff --git a/apps/spreadsheeteditor/main/app/view/ShapeSettings.js b/apps/spreadsheeteditor/main/app/view/ShapeSettings.js index 18ea5de33..d382468e5 100644 --- a/apps/spreadsheeteditor/main/app/view/ShapeSettings.js +++ b/apps/spreadsheeteditor/main/app/view/ShapeSettings.js @@ -1328,6 +1328,12 @@ define([ me.sldrGradient.removeThumb(index); me.GradColor.values.splice(index, 1); me.sldrGradient.changeGradientStyle(); + if (_.isUndefined(me.GradColor.currentIdx) || me.GradColor.currentIdx >= me.GradColor.colors.length) { + var newIndex = index > 0 ? index - 1 : index; + newIndex = (newIndex === 0 && me.GradColor.values.length > 2) ? me.GradColor.values.length - 2 : newIndex; + me.GradColor.currentIdx = newIndex; + } + me.sldrGradient.setActiveThumb(me.GradColor.currentIdx); }); this.fillControls.push(this.sldrGradient); @@ -1804,10 +1810,13 @@ define([ onRemoveGradientStep: function() { if (this.GradColor.values.length < 3) return; + var index = this.GradColor.currentIdx; this.GradColor.values.splice(this.GradColor.currentIdx, 1); this.sldrGradient.removeThumb(this.GradColor.currentIdx); if (_.isUndefined(this.GradColor.currentIdx) || this.GradColor.currentIdx >= this.GradColor.colors.length) { - this.GradColor.currentIdx = 0; + var newIndex = index > 0 ? index - 1 : index; + newIndex = (newIndex === 0 && this.GradColor.values.length > 2) ? this.GradColor.values.length - 2 : newIndex; + this.GradColor.currentIdx = newIndex; } this.sldrGradient.setActiveThumb(this.GradColor.currentIdx); this.sldrGradient.trigger('change', this.sldrGradient); diff --git a/apps/spreadsheeteditor/main/app/view/TextArtSettings.js b/apps/spreadsheeteditor/main/app/view/TextArtSettings.js index f5416e3bf..4413045a5 100644 --- a/apps/spreadsheeteditor/main/app/view/TextArtSettings.js +++ b/apps/spreadsheeteditor/main/app/view/TextArtSettings.js @@ -1266,6 +1266,12 @@ define([ me.sldrGradient.removeThumb(index); me.GradColor.values.splice(index, 1); me.sldrGradient.changeGradientStyle(); + if (_.isUndefined(me.GradColor.currentIdx) || me.GradColor.currentIdx >= me.GradColor.colors.length) { + var newIndex = index > 0 ? index - 1 : index; + newIndex = (newIndex === 0 && me.GradColor.values.length > 2) ? me.GradColor.values.length - 2 : newIndex; + me.GradColor.currentIdx = newIndex; + } + me.sldrGradient.setActiveThumb(me.GradColor.currentIdx); }); this.lockedControls.push(this.sldrGradient); @@ -1670,10 +1676,13 @@ define([ onRemoveGradientStep: function() { if (this.GradColor.values.length < 3) return; + var index = this.GradColor.currentIdx; this.GradColor.values.splice(this.GradColor.currentIdx, 1); this.sldrGradient.removeThumb(this.GradColor.currentIdx); if (_.isUndefined(this.GradColor.currentIdx) || this.GradColor.currentIdx >= this.GradColor.colors.length) { - this.GradColor.currentIdx = 0; + var newIndex = index > 0 ? index - 1 : index; + newIndex = (newIndex === 0 && this.GradColor.values.length > 2) ? this.GradColor.values.length - 2 : newIndex; + this.GradColor.currentIdx = newIndex; } this.sldrGradient.setActiveThumb(this.GradColor.currentIdx); this.sldrGradient.trigger('change', this.sldrGradient);