From 4a408e0d3a3aa380e14670e0c9201d4ad16c49c3 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 20 Mar 2017 16:37:20 +0300 Subject: [PATCH 01/23] Change markers for the gradient slider. --- .../main/lib/component/MultiSliderGradient.js | 12 ++++++ apps/common/main/lib/component/Slider.js | 42 +++++++++++++++---- .../main/app/view/ShapeSettings.js | 12 ++++++ .../main/app/view/TextArtSettings.js | 12 ++++++ .../main/app/view/ShapeSettings.js | 12 ++++++ .../main/app/view/SlideSettings.js | 12 ++++++ .../main/app/view/TextArtSettings.js | 12 ++++++ .../main/app/view/ShapeSettings.js | 12 ++++++ .../main/app/view/TextArtSettings.js | 12 ++++++ 9 files changed, 130 insertions(+), 8 deletions(-) diff --git a/apps/common/main/lib/component/MultiSliderGradient.js b/apps/common/main/lib/component/MultiSliderGradient.js index c738bb976..bba8fde46 100644 --- a/apps/common/main/lib/component/MultiSliderGradient.js +++ b/apps/common/main/lib/component/MultiSliderGradient.js @@ -150,6 +150,18 @@ define([ } style = Common.Utils.String.format('linear-gradient(to right, {0} {1}%, {2} {3}%)', this.colorValues[0], this.getValue(0), this.colorValues[1], this.getValue(1)); this.trackEl.css('background', style); + }, + + sortThumbs: function() { + var recalc_indexes = Common.UI.MultiSlider.prototype.sortThumbs.call(this); + var colors = [], + me = this; + _.each (this.colorValues, function(color, index) { + colors[index] = me.colorValues[recalc_indexes[index]]; + }); + this.colorValues = colors; + this.trigger('sortthumbs', me, recalc_indexes); + return recalc_indexes; } }); }); diff --git a/apps/common/main/lib/component/Slider.js b/apps/common/main/lib/component/Slider.js index 2d34c85e0..bdfe5ac3b 100644 --- a/apps/common/main/lib/component/Slider.js +++ b/apps/common/main/lib/component/Slider.js @@ -338,16 +338,21 @@ define([ e.preventDefault(); e.stopPropagation(); - var index = e.data, + var index = e.data.index, lastValue = me.thumbs[index].value, minValue = (index-1<0) ? 0 : me.thumbs[index-1].position, maxValue = (index+1 maxValue, + pos = Math.max(0, Math.min(100, position)), value = pos/me.delta + me.minValue; me.setThumbPosition(index, pos); me.thumbs[index].value = value; + if (need_sort) + me.sortThumbs(); + $(document).off('mouseup', onMouseUp); $(document).off('mousemove', onMouseMove); @@ -362,16 +367,21 @@ define([ e.preventDefault(); e.stopPropagation(); - var index = e.data, + var index = e.data.index, lastValue = me.thumbs[index].value, minValue = (index-1<0) ? 0 : me.thumbs[index-1].position, maxValue = (index+1 maxValue, + pos = Math.max(0, Math.min(100, position)), value = pos/me.delta + me.minValue; me.setThumbPosition(index, pos); me.thumbs[index].value = value; + if (need_sort) + me.sortThumbs(); + if (Math.abs(value-lastValue)>0.001) me.trigger('change', me, value, lastValue); }; @@ -379,7 +389,7 @@ define([ var onMouseDown = function (e) { if ( me.disabled ) return; - var index = e.data, + var index = e.data.index, thumb = me.thumbs[index].thumb; me._dragstart = e.pageX*Common.Utils.zoom() - thumb.offset().left - thumb.width()/2; @@ -389,8 +399,8 @@ define([ (index == idx) ? item.thumb.css('z-index', 500) : item.thumb.css('z-index', ''); }); - $(document).on('mouseup', null, index, onMouseUp); - $(document).on('mousemove', null, index, onMouseMove); + $(document).on('mouseup', null, e.data, onMouseUp); + $(document).on('mousemove', null, e.data, onMouseMove); }; var onTrackMouseDown = function (e) { @@ -441,7 +451,7 @@ define([ index: index }); me.setValue(index, me.options.values[index]); - thumb.on('mousedown', null, index, onMouseDown); + thumb.on('mousedown', null, me.thumbs[index], onMouseDown); }); me.setActiveThumb(0, true); @@ -489,6 +499,22 @@ define([ if (disabled !== this.disabled) this.cmpEl.toggleClass('disabled', disabled); this.disabled = disabled; + }, + + sortThumbs: function() { + this.thumbs.sort(function(a, b) { + if (a.position < b.position) + return -1; + if (a.position > b.position) + return 1; + return 0; + }); + var recalc_indexes = []; + _.each (this.thumbs, function(thumb, index) { + recalc_indexes[index] = thumb.index; + thumb.index = index; + }); + return recalc_indexes; } }); }); diff --git a/apps/documenteditor/main/app/view/ShapeSettings.js b/apps/documenteditor/main/app/view/ShapeSettings.js index 2d131a7ad..326e1e2c6 100644 --- a/apps/documenteditor/main/app/view/ShapeSettings.js +++ b/apps/documenteditor/main/app/view/ShapeSettings.js @@ -1341,6 +1341,18 @@ define([ this.sldrGradient.on('thumbdblclick', function(cmp){ me.btnGradColor.cmpEl.find('button').dropdown('toggle'); }); + this.sldrGradient.on('sortthumbs', function(cmp, indexes){ + var colors = [], + currentIdx; + _.each (me.GradColor.colors, function(color, index) { + colors[index] = me.GradColor.colors[indexes[index]]; + if (me.GradColor.currentIdx == indexes[index]) + currentIdx = index; + }); + me.OriginalFillType = null; + me.GradColor.colors = colors; + me.GradColor.currentIdx = currentIdx; + }); this.fillControls.push(this.sldrGradient); this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({ diff --git a/apps/documenteditor/main/app/view/TextArtSettings.js b/apps/documenteditor/main/app/view/TextArtSettings.js index 4a8259e87..c10773795 100644 --- a/apps/documenteditor/main/app/view/TextArtSettings.js +++ b/apps/documenteditor/main/app/view/TextArtSettings.js @@ -916,6 +916,18 @@ define([ this.sldrGradient.on('thumbdblclick', function(cmp){ me.btnGradColor.cmpEl.find('button').dropdown('toggle'); }); + this.sldrGradient.on('sortthumbs', function(cmp, indexes){ + var colors = [], + currentIdx; + _.each (me.GradColor.colors, function(color, index) { + colors[index] = me.GradColor.colors[indexes[index]]; + if (me.GradColor.currentIdx == indexes[index]) + currentIdx = index; + }); + me.OriginalFillType = null; + me.GradColor.colors = colors; + me.GradColor.currentIdx = currentIdx; + }); this.lockedControls.push(this.sldrGradient); this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({ diff --git a/apps/presentationeditor/main/app/view/ShapeSettings.js b/apps/presentationeditor/main/app/view/ShapeSettings.js index f06f575a6..4fbefbef2 100644 --- a/apps/presentationeditor/main/app/view/ShapeSettings.js +++ b/apps/presentationeditor/main/app/view/ShapeSettings.js @@ -1234,6 +1234,18 @@ define([ this.sldrGradient.on('thumbdblclick', function(cmp){ me.btnGradColor.cmpEl.find('button').dropdown('toggle'); }); + this.sldrGradient.on('sortthumbs', function(cmp, indexes){ + var colors = [], + currentIdx; + _.each (me.GradColor.colors, function(color, index) { + colors[index] = me.GradColor.colors[indexes[index]]; + if (me.GradColor.currentIdx == indexes[index]) + currentIdx = index; + }); + me.OriginalFillType = null; + me.GradColor.colors = colors; + me.GradColor.currentIdx = currentIdx; + }); this.fillControls.push(this.sldrGradient); this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({ diff --git a/apps/presentationeditor/main/app/view/SlideSettings.js b/apps/presentationeditor/main/app/view/SlideSettings.js index faf85e79a..dbb3975a8 100644 --- a/apps/presentationeditor/main/app/view/SlideSettings.js +++ b/apps/presentationeditor/main/app/view/SlideSettings.js @@ -755,6 +755,18 @@ define([ this.sldrGradient.on('thumbdblclick', function(cmp){ me.btnGradColor.cmpEl.find('button').dropdown('toggle'); }); + this.sldrGradient.on('sortthumbs', function(cmp, indexes){ + var colors = [], + currentIdx; + _.each (me.GradColor.colors, function(color, index) { + colors[index] = me.GradColor.colors[indexes[index]]; + if (me.GradColor.currentIdx == indexes[index]) + currentIdx = index; + }); + me.OriginalFillType = null; + me.GradColor.colors = colors; + me.GradColor.currentIdx = currentIdx; + }); this.FillItems.push(this.sldrGradient); }, diff --git a/apps/presentationeditor/main/app/view/TextArtSettings.js b/apps/presentationeditor/main/app/view/TextArtSettings.js index 7aee796d9..084345427 100644 --- a/apps/presentationeditor/main/app/view/TextArtSettings.js +++ b/apps/presentationeditor/main/app/view/TextArtSettings.js @@ -1224,6 +1224,18 @@ define([ this.sldrGradient.on('thumbdblclick', function(cmp){ me.btnGradColor.cmpEl.find('button').dropdown('toggle'); }); + this.sldrGradient.on('sortthumbs', function(cmp, indexes){ + var colors = [], + currentIdx; + _.each (me.GradColor.colors, function(color, index) { + colors[index] = me.GradColor.colors[indexes[index]]; + if (me.GradColor.currentIdx == indexes[index]) + currentIdx = index; + }); + me.OriginalFillType = null; + me.GradColor.colors = colors; + me.GradColor.currentIdx = currentIdx; + }); this.lockedControls.push(this.sldrGradient); this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({ diff --git a/apps/spreadsheeteditor/main/app/view/ShapeSettings.js b/apps/spreadsheeteditor/main/app/view/ShapeSettings.js index a43b106db..b296197eb 100644 --- a/apps/spreadsheeteditor/main/app/view/ShapeSettings.js +++ b/apps/spreadsheeteditor/main/app/view/ShapeSettings.js @@ -1258,6 +1258,18 @@ define([ this.sldrGradient.on('thumbdblclick', function(cmp){ me.btnGradColor.cmpEl.find('button').dropdown('toggle'); }); + this.sldrGradient.on('sortthumbs', function(cmp, indexes){ + var colors = [], + currentIdx; + _.each (me.GradColor.colors, function(color, index) { + colors[index] = me.GradColor.colors[indexes[index]]; + if (me.GradColor.currentIdx == indexes[index]) + currentIdx = index; + }); + me.OriginalFillType = null; + me.GradColor.colors = colors; + me.GradColor.currentIdx = currentIdx; + }); this.fillControls.push(this.sldrGradient); this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({ diff --git a/apps/spreadsheeteditor/main/app/view/TextArtSettings.js b/apps/spreadsheeteditor/main/app/view/TextArtSettings.js index 4a26f7699..cef2d8b24 100644 --- a/apps/spreadsheeteditor/main/app/view/TextArtSettings.js +++ b/apps/spreadsheeteditor/main/app/view/TextArtSettings.js @@ -1228,6 +1228,18 @@ define([ this.sldrGradient.on('thumbdblclick', function(cmp){ me.btnGradColor.cmpEl.find('button').dropdown('toggle'); }); + this.sldrGradient.on('sortthumbs', function(cmp, indexes){ + var colors = [], + currentIdx; + _.each (me.GradColor.colors, function(color, index) { + colors[index] = me.GradColor.colors[indexes[index]]; + if (me.GradColor.currentIdx == indexes[index]) + currentIdx = index; + }); + me.OriginalFillType = null; + me.GradColor.colors = colors; + me.GradColor.currentIdx = currentIdx; + }); this.lockedControls.push(this.sldrGradient); this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({ From 4ffa3c5a9244578d3568e76e03baa596baa9115a Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 21 Mar 2017 11:03:02 +0300 Subject: [PATCH 02/23] Gradient Slider - refactoring. --- apps/common/main/lib/component/MultiSliderGradient.js | 10 +++++----- apps/common/main/lib/component/Slider.js | 8 ++------ apps/documenteditor/main/app/view/ShapeSettings.js | 8 ++++---- apps/documenteditor/main/app/view/TextArtSettings.js | 8 ++++---- apps/presentationeditor/main/app/view/ShapeSettings.js | 8 ++++---- apps/presentationeditor/main/app/view/SlideSettings.js | 8 ++++---- .../main/app/view/TextArtSettings.js | 8 ++++---- apps/spreadsheeteditor/main/app/view/ShapeSettings.js | 8 ++++---- .../spreadsheeteditor/main/app/view/TextArtSettings.js | 8 ++++---- 9 files changed, 35 insertions(+), 39 deletions(-) diff --git a/apps/common/main/lib/component/MultiSliderGradient.js b/apps/common/main/lib/component/MultiSliderGradient.js index bba8fde46..86290981b 100644 --- a/apps/common/main/lib/component/MultiSliderGradient.js +++ b/apps/common/main/lib/component/MultiSliderGradient.js @@ -153,13 +153,13 @@ define([ }, sortThumbs: function() { - var recalc_indexes = Common.UI.MultiSlider.prototype.sortThumbs.call(this); - var colors = [], + var recalc_indexes = Common.UI.MultiSlider.prototype.sortThumbs.call(this), + new_colors = [], me = this; - _.each (this.colorValues, function(color, index) { - colors[index] = me.colorValues[recalc_indexes[index]]; + _.each (recalc_indexes, function(recalc_index) { + new_colors.push(me.colorValues[recalc_index]); }); - this.colorValues = colors; + this.colorValues = new_colors; this.trigger('sortthumbs', me, recalc_indexes); return recalc_indexes; } diff --git a/apps/common/main/lib/component/Slider.js b/apps/common/main/lib/component/Slider.js index bdfe5ac3b..67a86d2d2 100644 --- a/apps/common/main/lib/component/Slider.js +++ b/apps/common/main/lib/component/Slider.js @@ -503,15 +503,11 @@ define([ sortThumbs: function() { this.thumbs.sort(function(a, b) { - if (a.position < b.position) - return -1; - if (a.position > b.position) - return 1; - return 0; + return (a.position - b.position); }); var recalc_indexes = []; _.each (this.thumbs, function(thumb, index) { - recalc_indexes[index] = thumb.index; + recalc_indexes.push(thumb.index); thumb.index = index; }); return recalc_indexes; diff --git a/apps/documenteditor/main/app/view/ShapeSettings.js b/apps/documenteditor/main/app/view/ShapeSettings.js index 326e1e2c6..d33dec7d0 100644 --- a/apps/documenteditor/main/app/view/ShapeSettings.js +++ b/apps/documenteditor/main/app/view/ShapeSettings.js @@ -1341,12 +1341,12 @@ define([ this.sldrGradient.on('thumbdblclick', function(cmp){ me.btnGradColor.cmpEl.find('button').dropdown('toggle'); }); - this.sldrGradient.on('sortthumbs', function(cmp, indexes){ + this.sldrGradient.on('sortthumbs', function(cmp, recalc_indexes){ var colors = [], currentIdx; - _.each (me.GradColor.colors, function(color, index) { - colors[index] = me.GradColor.colors[indexes[index]]; - if (me.GradColor.currentIdx == indexes[index]) + _.each (recalc_indexes, function(recalc_index, index) { + colors.push(me.GradColor.colors[recalc_index]); + if (me.GradColor.currentIdx == recalc_index) currentIdx = index; }); me.OriginalFillType = null; diff --git a/apps/documenteditor/main/app/view/TextArtSettings.js b/apps/documenteditor/main/app/view/TextArtSettings.js index c10773795..479909abb 100644 --- a/apps/documenteditor/main/app/view/TextArtSettings.js +++ b/apps/documenteditor/main/app/view/TextArtSettings.js @@ -916,12 +916,12 @@ define([ this.sldrGradient.on('thumbdblclick', function(cmp){ me.btnGradColor.cmpEl.find('button').dropdown('toggle'); }); - this.sldrGradient.on('sortthumbs', function(cmp, indexes){ + this.sldrGradient.on('sortthumbs', function(cmp, recalc_indexes){ var colors = [], currentIdx; - _.each (me.GradColor.colors, function(color, index) { - colors[index] = me.GradColor.colors[indexes[index]]; - if (me.GradColor.currentIdx == indexes[index]) + _.each (recalc_indexes, function(recalc_index, index) { + colors.push(me.GradColor.colors[recalc_index]); + if (me.GradColor.currentIdx == recalc_index) currentIdx = index; }); me.OriginalFillType = null; diff --git a/apps/presentationeditor/main/app/view/ShapeSettings.js b/apps/presentationeditor/main/app/view/ShapeSettings.js index 4fbefbef2..dadf43a91 100644 --- a/apps/presentationeditor/main/app/view/ShapeSettings.js +++ b/apps/presentationeditor/main/app/view/ShapeSettings.js @@ -1234,12 +1234,12 @@ define([ this.sldrGradient.on('thumbdblclick', function(cmp){ me.btnGradColor.cmpEl.find('button').dropdown('toggle'); }); - this.sldrGradient.on('sortthumbs', function(cmp, indexes){ + this.sldrGradient.on('sortthumbs', function(cmp, recalc_indexes){ var colors = [], currentIdx; - _.each (me.GradColor.colors, function(color, index) { - colors[index] = me.GradColor.colors[indexes[index]]; - if (me.GradColor.currentIdx == indexes[index]) + _.each (recalc_indexes, function(recalc_index, index) { + colors.push(me.GradColor.colors[recalc_index]); + if (me.GradColor.currentIdx == recalc_index) currentIdx = index; }); me.OriginalFillType = null; diff --git a/apps/presentationeditor/main/app/view/SlideSettings.js b/apps/presentationeditor/main/app/view/SlideSettings.js index dbb3975a8..0c8f54bf0 100644 --- a/apps/presentationeditor/main/app/view/SlideSettings.js +++ b/apps/presentationeditor/main/app/view/SlideSettings.js @@ -755,12 +755,12 @@ define([ this.sldrGradient.on('thumbdblclick', function(cmp){ me.btnGradColor.cmpEl.find('button').dropdown('toggle'); }); - this.sldrGradient.on('sortthumbs', function(cmp, indexes){ + this.sldrGradient.on('sortthumbs', function(cmp, recalc_indexes){ var colors = [], currentIdx; - _.each (me.GradColor.colors, function(color, index) { - colors[index] = me.GradColor.colors[indexes[index]]; - if (me.GradColor.currentIdx == indexes[index]) + _.each (recalc_indexes, function(recalc_index, index) { + colors.push(me.GradColor.colors[recalc_index]); + if (me.GradColor.currentIdx == recalc_index) currentIdx = index; }); me.OriginalFillType = null; diff --git a/apps/presentationeditor/main/app/view/TextArtSettings.js b/apps/presentationeditor/main/app/view/TextArtSettings.js index 084345427..a51b3d261 100644 --- a/apps/presentationeditor/main/app/view/TextArtSettings.js +++ b/apps/presentationeditor/main/app/view/TextArtSettings.js @@ -1224,12 +1224,12 @@ define([ this.sldrGradient.on('thumbdblclick', function(cmp){ me.btnGradColor.cmpEl.find('button').dropdown('toggle'); }); - this.sldrGradient.on('sortthumbs', function(cmp, indexes){ + this.sldrGradient.on('sortthumbs', function(cmp, recalc_indexes){ var colors = [], currentIdx; - _.each (me.GradColor.colors, function(color, index) { - colors[index] = me.GradColor.colors[indexes[index]]; - if (me.GradColor.currentIdx == indexes[index]) + _.each (recalc_indexes, function(recalc_index, index) { + colors.push(me.GradColor.colors[recalc_index]); + if (me.GradColor.currentIdx == recalc_index) currentIdx = index; }); me.OriginalFillType = null; diff --git a/apps/spreadsheeteditor/main/app/view/ShapeSettings.js b/apps/spreadsheeteditor/main/app/view/ShapeSettings.js index b296197eb..f11030b49 100644 --- a/apps/spreadsheeteditor/main/app/view/ShapeSettings.js +++ b/apps/spreadsheeteditor/main/app/view/ShapeSettings.js @@ -1258,12 +1258,12 @@ define([ this.sldrGradient.on('thumbdblclick', function(cmp){ me.btnGradColor.cmpEl.find('button').dropdown('toggle'); }); - this.sldrGradient.on('sortthumbs', function(cmp, indexes){ + this.sldrGradient.on('sortthumbs', function(cmp, recalc_indexes){ var colors = [], currentIdx; - _.each (me.GradColor.colors, function(color, index) { - colors[index] = me.GradColor.colors[indexes[index]]; - if (me.GradColor.currentIdx == indexes[index]) + _.each (recalc_indexes, function(recalc_index, index) { + colors.push(me.GradColor.colors[recalc_index]); + if (me.GradColor.currentIdx == recalc_index) currentIdx = index; }); me.OriginalFillType = null; diff --git a/apps/spreadsheeteditor/main/app/view/TextArtSettings.js b/apps/spreadsheeteditor/main/app/view/TextArtSettings.js index cef2d8b24..f31ebef90 100644 --- a/apps/spreadsheeteditor/main/app/view/TextArtSettings.js +++ b/apps/spreadsheeteditor/main/app/view/TextArtSettings.js @@ -1228,12 +1228,12 @@ define([ this.sldrGradient.on('thumbdblclick', function(cmp){ me.btnGradColor.cmpEl.find('button').dropdown('toggle'); }); - this.sldrGradient.on('sortthumbs', function(cmp, indexes){ + this.sldrGradient.on('sortthumbs', function(cmp, recalc_indexes){ var colors = [], currentIdx; - _.each (me.GradColor.colors, function(color, index) { - colors[index] = me.GradColor.colors[indexes[index]]; - if (me.GradColor.currentIdx == indexes[index]) + _.each (recalc_indexes, function(recalc_index, index) { + colors.push(me.GradColor.colors[recalc_index]); + if (me.GradColor.currentIdx == recalc_index) currentIdx = index; }); me.OriginalFillType = null; From 538b7ff031d59a1b5b9b8569d6cea0c8a4a6c16a Mon Sep 17 00:00:00 2001 From: Alexander Yuzhin Date: Mon, 3 Apr 2017 10:33:25 +0300 Subject: [PATCH 03/23] [mobile] Fix bug 33939 --- apps/documenteditor/mobile/app/template/AddImage.template | 3 ++- apps/presentationeditor/mobile/app/template/AddImage.template | 3 ++- apps/spreadsheeteditor/mobile/app/template/AddOther.template | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/documenteditor/mobile/app/template/AddImage.template b/apps/documenteditor/mobile/app/template/AddImage.template index 0ac3570e4..f5bbcb0c8 100644 --- a/apps/documenteditor/mobile/app/template/AddImage.template +++ b/apps/documenteditor/mobile/app/template/AddImage.template @@ -40,12 +40,13 @@
-
<%= scope.textAddress %>
+ <% if (!android) { %>
<%= scope.textAddress %>
<% } %>