Created
April 28, 2016 12:41
-
-
Save shabanovtg/c084aaf2afb0e42e811b3439917efdbf to your computer and use it in GitHub Desktop.
tooltip-ui
This file contains hidden or 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
| t = { | |
| initTooltip: function() { | |
| var $tooltipsCircles = $('.js-tooltip-circles'); | |
| $tooltipsCircles.tooltip({ | |
| show: 'fold', | |
| position: { | |
| my: 'center bottom-20', | |
| at: 'center top', | |
| using: function(position, feedback) { | |
| $(this).css(position); | |
| $('<div>') | |
| .addClass('ui-tooltip-arrow') | |
| .addClass(feedback.vertical) | |
| .addClass(feedback.horizontal) | |
| .appendTo(this); | |
| } | |
| }, | |
| close: function(event, ui) { | |
| var $target = $(this); | |
| $target.data('topen', false); | |
| ui.tooltip.hover(function() { | |
| $target.data('topen', Number(new Date())); | |
| $(this).stop(true).fadeTo(500, 1); | |
| }, function() { | |
| $(this).fadeOut('500', function() { | |
| $target.data('topen', false); | |
| $(this).remove(); | |
| }); | |
| }); | |
| }, | |
| open: function(event, ui) { | |
| console.log('open'); | |
| $(this).data('topen', Number(new Date())); | |
| } | |
| }); | |
| $tooltipsCircles.on('click', function(ev) { | |
| ev.preventDefault(); | |
| var $target = $(ev.currentTarget), | |
| topen = $target.data('topen'), | |
| abs = topen ? Math.abs(Number(new Date()) - topen) : 0; | |
| if (topen && abs > 250) { | |
| $target.tooltip('close'); | |
| } | |
| if (!topen) { | |
| $target.tooltip('open'); | |
| } | |
| }); | |
| function refresh() { | |
| $tooltipsCircles.tooltip('close'); | |
| $tooltipsPyramid.tooltip('close'); | |
| } | |
| if (window.addEventListener) { | |
| window.addEventListener('resize', refresh, false); | |
| } else if (window.attachEvent) { | |
| window.attachEvent('onresize', refresh); | |
| } | |
| } | |
| } | |
| //////////////// | |
| (function($) { | |
| $(function() { | |
| $('.js-tooltip-method-unavailable').tooltip({ | |
| tooltipClass: 'tooltip-method-unavailable', | |
| position: { | |
| my: "center top", | |
| at: "center bottom+10", | |
| using: function(position, feedback) { | |
| $(this).css(position); | |
| $('<div>') | |
| .addClass('ui-tooltip-arrow') | |
| .addClass(feedback.vertical) | |
| .addClass(feedback.horizontal) | |
| .appendTo(this); | |
| } | |
| } | |
| }); | |
| }); | |
| })(jQuery); |
This file contains hidden or 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
| .tooltip-method-unavailable { | |
| min-width: 150px; | |
| .ui-tooltip-content { | |
| position: relative; | |
| padding: 10px; | |
| border: 1px solid #cccccc; | |
| border-radius: 6px; | |
| color: #000000; | |
| font-size: 14px; | |
| background: #ffffff; | |
| &:before, | |
| &:after { | |
| display: none; | |
| } | |
| } | |
| .ui-tooltip-arrow { | |
| &:before, | |
| &:after { | |
| content: ''; | |
| position: absolute; | |
| top: -20px; | |
| left: 50%; | |
| margin-left: -10px; | |
| border: 10px solid transparent; | |
| border-bottom: 10px solid #cccccc; | |
| } | |
| &:after { | |
| top: -19px; | |
| border-bottom: 10px solid #ffffff; | |
| } | |
| &.bottom { | |
| &:before, | |
| &:after { | |
| top: auto; | |
| bottom: -20px; | |
| border: 10px solid transparent; | |
| border-top: 10px solid #cccccc; | |
| } | |
| &:after { | |
| top: auto; | |
| bottom: -19px; | |
| border-top: 10px solid #ffffff; | |
| } | |
| } | |
| &.left { | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment