Change synchronize tip component: add new placements

This commit is contained in:
Julia Radzhabova 2021-02-17 20:25:30 +03:00
parent 2ba6fdd351
commit 17a1ec78e4
9 changed files with 296 additions and 40 deletions

View file

@ -43,7 +43,7 @@ define([
options : {
target : $(document.body),
text : '',
placement: 'right',
placement: 'right-bottom',
showLink: true
},
@ -53,7 +53,7 @@ define([
'<div class="tip-arrow <%= scope.placement %>"></div>',
'<div>',
'<div class="tip-text"><%= scope.text %></div>',
'<div class="close img-commonctrl"></div>',
'<div class="close"></div>',
'</div>',
'<% if ( scope.showLink ) { %>',
'<div class="show-link"><label><%= scope.textLink %></label></div>',
@ -103,27 +103,45 @@ define([
},
applyPlacement: function () {
var showxy = this.target.offset(),
innerHeight = Common.Utils.innerHeight();
var showxy = this.target.offset();
if (this.placement=='target') {
this.cmpEl.css({top : showxy.top + 5 + 'px', left: showxy.left + 5 + 'px'});
return;
}
if (this.placement == 'document') {
// this.cmpEl.css('top', $('#editor_sdk').offset().top);
} else
if (this.placement == 'top')
this.cmpEl.css({bottom : innerHeight - showxy.top + 'px', right: Common.Utils.innerWidth() - showxy.left - this.target.width()/2 + 'px'});
else if (this.placement == 'bottom')
this.cmpEl.css({top : (showxy.top+5) + this.target.height() + 'px', left: showxy.left + (this.target.width() - this.cmpEl.width())/2 + 'px'});
else if (this.placement == 'target') {
this.cmpEl.css({top : (showxy.top+5) + 'px', left: (showxy.left+5) + 'px'});
} else {// left or right
var top = showxy.top + this.target.height()/2,
height = this.cmpEl.height();
if (top+height>innerHeight)
top = innerHeight - height;
if (this.placement == 'left')
this.cmpEl.css({top : top + 'px', right: Common.Utils.innerWidth() - showxy.left - 5 + 'px'});
var placement = this.placement.split('-');
if (placement.length>0) {
var top, left, bottom, right;
var pos = placement[0];
if (pos=='top') {
bottom = Common.Utils.innerHeight() - showxy.top;
} else if (pos == 'bottom') {
top = showxy.top + this.target.height();
} else if (pos == 'left') {
right = Common.Utils.innerWidth() - showxy.left;
} else if (pos == 'right') {
left = showxy.left + this.target.width();
}
pos = placement[1];
if (pos=='top') {
bottom = Common.Utils.innerHeight() - showxy.top - this.target.height()/2;
} else if (pos == 'bottom') {
top = showxy.top + this.target.height()/2;
} else if (pos == 'left') {
right = Common.Utils.innerWidth() - showxy.left - this.target.width()/2;
} else if (pos == 'right') {
left = showxy.left + this.target.width()/2;
} else {
if (bottom!==undefined || top!==undefined)
left = showxy.left + (this.target.width() - this.cmpEl.width())/2;
else
this.cmpEl.css({top : top + 'px', left: showxy.left + this.target.width() + 'px'});
top = showxy.top + (this.target.height() - this.cmpEl.height())/2;
}
top = (top!==undefined) ? (top + 'px') : 'auto';
bottom = (bottom!==undefined) ? (bottom + 'px') : 'auto';
left = (left!==undefined) ? (left + 'px') : 'auto';
right = (right!==undefined) ? (right + 'px') : 'auto';
this.cmpEl.css({top : top, left: left, right: right, bottom: bottom});
}
},

View file

@ -33,6 +33,40 @@
}
}
&.theme-color {
.asc-synchronizetip {
background-color: @header-background-color-ie;
background-color: @header-background-color;
color: @text-toolbar-header-ie;
color: @text-toolbar-header;
.close {
&:before, &:after {
background-color: @text-toolbar-header-ie;
background-color: @text-toolbar-header;
}
}
}
.tip-arrow:after {
background-color: @header-background-color-ie;
background-color: @header-background-color;
}
}
&.toolbar-color {
.asc-synchronizetip {
background-color: @background-toolbar-ie;
background-color: @background-toolbar;
}
.tip-arrow:after {
background-color: @background-toolbar-ie;
background-color: @background-toolbar;
}
}
&.inc-index {
z-index: @zindex-navbar + 4;
}
@ -42,9 +76,103 @@
overflow: hidden;
}
&.right-top,
&.right-bottom,
&.right {
margin: 0 0 0 15px;
}
&.left-top,
&.left-bottom,
&.left {
margin: 0 15px 0 0;
}
&.top-left,
&.top-right,
&.top {
margin: 0 0 15px 0;
}
&.bottom-left,
&.bottom-right,
&.bottom {
margin: 15px 0 0 0;
}
&.right-top,
&.right-bottom {
margin: 0 0 0 15px;
}
&.right {
.tip-arrow {
left: -13px;
top: 50%;
margin-top: -7px;
width: 16px;
height: 15px;
.box-shadow(0 0 8px -5px rgba(0, 0, 0, 0.2));
&:after {
top: 0;
left: 8px;
width: 16px;
.box-shadow(0 0 8px -1px rgba(0, 0, 0, 0.2));
}
}
}
&.left {
.tip-arrow {
right: -13px;
top: 50%;
margin-top: -7px;
width: 16px;
height: 15px;
.box-shadow(0 0 8px -5px rgba(0, 0, 0, 0.2));
&:after {
top: 0;
left: -8px;
width: 16px;
.box-shadow(0 4px 8px -1px rgba(0, 0, 0, 0.2));
}
}
}
&.top {
.tip-arrow {
left: 50%;
bottom: -12px;
margin-left: -6px;
width: 16px;
height: 16px;
.box-shadow(0 0 8px -5px rgba(0, 0, 0, 0.2));
&:after {
top: -6px;
left: 0;
width: 16px;
}
}
}
&.bottom {
.tip-arrow {
left: 50%;
top: -12px;
margin-left: -7px;
width: 16px;
height: 15px;
.box-shadow(0 0 8px -5px rgba(0, 0, 0, 0.2));
&:after {
top: 7px;
left: 0;
width: 16px;
}
}
}
&.right-bottom {
.tip-arrow {
left: -15px;
top: 0;
@ -60,9 +188,7 @@
}
}
&.left {
margin: 0 15px 0 0;
&.left-bottom {
.tip-arrow {
right: -15px;
top: 0;
@ -73,14 +199,11 @@
&:after {
top: -7px;
left: -7px;
width: 15px;
}
}
}
&.top {
margin: 0 0 15px 0;
&.top-left {
.tip-arrow {
right: 0;
bottom: -15px;
@ -94,6 +217,87 @@
}
}
}
&.top-right {
.tip-arrow {
left: 0;
bottom: -15px;
width: 15px;
height: 15px;
.box-shadow(-5px 0 8px -5px rgba(0, 0, 0, 0.2));
&:after {
top: -8px;
left: -8px;
.box-shadow(2px 2px 8px -1px rgba(0, 0, 0, 0.2));
}
}
}
&.bottom-left {
.tip-arrow {
right: 0;
top: -15px;
width: 15px;
height: 15px;
.box-shadow(8px 5px 8px -5px rgba(0, 0, 0, 0.2));
&:after {
top: 8px;
left: 8px;
.box-shadow(0 0 8px -1px rgba(0, 0, 0, 0.2));
}
}
}
&.bottom-right {
.tip-arrow {
left: 0;
top: -15px;
width: 15px;
height: 15px;
.box-shadow(-8px 0 8px -5px rgba(0, 0, 0, 0.2));
&:after {
top: 8px;
left: -8px;
.box-shadow(0 0 8px -1px rgba(0, 0, 0, 0.2));
}
}
}
&.right-top {
.tip-arrow {
left: -15px;
bottom: 0;
width: 15px;
height: 15px;
.box-shadow(0 5px 8px -5px rgba(0, 0, 0, 0.2));
&:after {
top: 7px;
left: 7px;
width: 16px;
}
}
}
&.left-top {
.tip-arrow {
right: -15px;
bottom: 0;
width: 15px;
height: 13px;
.box-shadow(-5px 8px 8px -5px rgba(0, 0, 0, 0.2));
&:after {
bottom: -7px;
left: -7px;
//width: 15px;
.box-shadow(0 0 8px -1px rgba(0, 0, 0, 0.2));
}
}
}
}
.asc-synchronizetip {
@ -103,15 +307,23 @@
background-color: @background-notification-popover;
overflow: visible;
.right & {
.bottom-right &,
.right-bottom & {
border-top-left-radius: 0;
}
.left & {
.bottom-left &,
.left-bottom & {
border-top-right-radius: 0;
}
.top & {
.top-right &,
.right-top & {
border-bottom-left-radius: 0;
}
.top-left &,
.left-top & {
border-bottom-right-radius: 0;
}
@ -159,10 +371,33 @@
margin: 8px;
cursor: pointer;
background-position: @but-close-offset-x @but-close-offset-y;
opacity: 0.7;
transition: transform .3s;
&.over,
&:hover {
background-position: @but-close-offset-x @but-close-offset-y - 16px;
transform: scale(1.1);
opacity: 1;
}
&:before, &:after {
content: ' ';
position: absolute;
left: 7px;
left: calc(7px/@pixel-ratio-factor);
top: @scaled-one-px-value-ie;
top: @scaled-one-px-value;
height: 14px;
width: @scaled-one-px-value-ie;
width: @scaled-one-px-value;
background-color: @icon-normal-ie;
background-color: @icon-normal;
}
&:before {
transform: rotate(45deg);
}
&:after {
transform: rotate(-45deg);
}
}

View file

@ -257,7 +257,7 @@ define([
var tip = new Common.UI.SynchronizeTip({
target : me.btnTurnReview.$el,
text : text,
placement: 'top'
placement: 'top-left'
});
tip.on({
'dontshowclick': function() {

View file

@ -348,7 +348,7 @@ define([
text : tipText,
showLink: showLink,
textLink: this.txtContinueEditing,
placement: 'left'
placement: 'left-bottom'
});
tip.on({
'dontshowclick': function() {

View file

@ -2123,6 +2123,7 @@ define([
createSynchTip: function () {
this.synchTooltip = new Common.UI.SynchronizeTip({
extCls: (this.mode.customization && !!this.mode.customization.compactHeader) ? undefined : 'inc-index',
placement: 'right-bottom',
target: this.btnCollabChanges.$el
});
this.synchTooltip.on('dontshowclick', function () {

View file

@ -302,7 +302,7 @@ define([
text : tipText,
showLink: showLink,
textLink: this.txtContinueEditing,
placement: 'left'
placement: 'left-bottom'
});
tip.on({
'dontshowclick': function() {

View file

@ -1495,6 +1495,7 @@ define([
createSynchTip: function () {
this.synchTooltip = new Common.UI.SynchronizeTip({
extCls: (this.mode.customization && !!this.mode.customization.compactHeader) ? undefined : 'inc-index',
placement: 'right-bottom',
target: this.btnCollabChanges.$el
});
this.synchTooltip.on('dontshowclick', function () {

View file

@ -348,7 +348,7 @@ define([
text : tipText,
showLink: showLink,
textLink: this.txtContinueEditing,
placement: 'left'
placement: 'left-bottom'
});
tip.on({
'dontshowclick': function() {

View file

@ -2093,6 +2093,7 @@ define([
createSynchTip: function () {
this.synchTooltip = new Common.UI.SynchronizeTip({
extCls: (this.mode.customization && !!this.mode.customization.compactHeader) ? undefined : 'inc-index',
placement: 'right-bottom',
target: this.btnCollabChanges.$el
});
this.synchTooltip.on('dontshowclick', function() {