-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a451e6
commit 4953424
Showing
5 changed files
with
96 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* This file belongs to Kreta. | ||
* The source code of application includes a LICENSE file | ||
* with all information about license. | ||
* | ||
* @author benatespina <benatespina@gmail.com> | ||
* @author gorkalaucirica <gorka.lauzirika@gmail.com> | ||
*/ | ||
|
||
export class TooltipView { | ||
constructor() { | ||
$(document.body).on('mouseenter', '[data-tooltip-text]', this.onMouseEnter); | ||
$(document.body).on('mouseleave', '[data-tooltip-text]', this.onMouseLeave); | ||
} | ||
|
||
onMouseEnter() { | ||
if($(this).children('.tooltip').length == 0) { | ||
var tooltipPos = $(this).attr('data-tooltip-position') ? $(this).attr('data-tooltip-position') : 'left'; | ||
$(this).append('<span class="tooltip ' + tooltipPos + '">' + $(this).attr('data-tooltip-text') + '</span>'); | ||
} | ||
|
||
$(this).find('.tooltip').addClass('visible'); | ||
} | ||
|
||
onMouseLeave() { | ||
$(this).find('.tooltip').removeClass('visible'); | ||
} | ||
} |
67 changes: 58 additions & 9 deletions
67
src/Kreta/Bundle/WebBundle/Resources/public/scss/components/_tooltip.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,70 @@ | ||
$tooltip-arrow-height: 10px; | ||
|
||
[data-tooltip-text] { | ||
position: relative; | ||
} | ||
|
||
.tooltip { | ||
display: none; | ||
position: absolute; | ||
bottom: -30px; | ||
width: 50px; | ||
background: $main-black; | ||
border-radius: 3px; | ||
color: $white; | ||
font-size: .7em; | ||
padding: .3em; | ||
top: -4px; | ||
left: -65px; | ||
font-size: 12px; | ||
height: 20px; | ||
margin-top: -10px; | ||
padding: .3em .6em; | ||
position: absolute; | ||
top: 50%; | ||
transition-duration: .5s; | ||
opacity: 0; | ||
visibility: hidden; | ||
white-space: nowrap; | ||
|
||
&.visible { | ||
display: block; | ||
visibility: visible; | ||
opacity: 1; | ||
} | ||
|
||
&:after { | ||
content: " "; | ||
height: 0; | ||
width: 0; | ||
position: absolute; | ||
pointer-events: none; | ||
border: solid transparent; | ||
border-color: rgba($main-black, 0); | ||
border-width: $tooltip-arrow-height / 2; | ||
} | ||
|
||
//Position modifiers | ||
&.left { | ||
right: 100%; | ||
|
||
&:after { | ||
top: 50%; | ||
left: 100%; | ||
|
||
border-left-color: $main-black; | ||
border-width: $tooltip-arrow-height / 2; | ||
margin-top: -$tooltip-arrow-height / 2; | ||
} | ||
|
||
&.visible { | ||
right: calc(100% + 10px); | ||
} | ||
} | ||
|
||
&.right { | ||
left: 100%; | ||
|
||
&:after { | ||
top: 50%; | ||
right: 100%; | ||
border-right-color: $main-black; | ||
margin-top: -$tooltip-arrow-height / 2; | ||
} | ||
|
||
&.visible { | ||
left: calc(100% + 10px); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters