Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flash time #231

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ tooltip-speed="" | String('fast', 'slow', 'medium') | 'medium' | Set your toolti
tooltip-hidden="" | String(Boolean) | false | Hide (at all) the tooltip
tooltip-append-to-body="" | String(Boolean) | false | This attribute clones the tooltip and append this directly on body. This enables the tooltip position also, for instance, if you have an scrolling area. **This option does heavy javascript calculation.**
tooltip-show="" | String(Boolean) | false | Show/Hide the tooltip "manually"

tooltip-flash-time="" | String(Integer) | null | Number of milliseconds before the tooltip automatically dissapears

## Globals
Sometimes you may need to set all of your tooltips options in one place, you can achieve this using `tooltipsConfProvider` like this:
Expand All @@ -110,6 +110,7 @@ Sometimes you may need to set all of your tooltips options in one place, you can
'size': 'large',
'speed': 'slow',
'tooltipTemplateUrlCache': true
'flashTime': '2000'
//etc...
});
}])
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-tooltips.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* http://720kb.github.io/angular-tooltips
*
* MIT license
* Tue Jun 20 2017
* Fri Jul 06 2018
*/
@-webkit-keyframes animate-tooltip {
0% {
Expand Down
1 change: 0 additions & 1 deletion dist/angular-tooltips.css.map

This file was deleted.

49 changes: 36 additions & 13 deletions dist/angular-tooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* http://720kb.github.io/angular-tooltips
*
* MIT license
* Tue Jun 20 2017
* Fri Jul 06 2018
*/
/*global angular,window*/
(function withAngular(angular, window) {
Expand Down Expand Up @@ -145,6 +145,12 @@
element.removeAttr('tooltip-speed');
}

if (element.attr('tooltip-flash-time') !== undefined) {

attributesToAdd['tooltip-flash-time'] = element.attr('tooltip-flash-time');
element.removeAttr('tooltip-flash-time');
}

return attributesToAdd;
}
, getStyle = function getStyle(anElement) {
Expand Down Expand Up @@ -251,7 +257,8 @@
'size': '',
'speed': 'steady',
'tooltipTemplateUrlCache': false,
'show': null
'show': null,
'flashTime': null
};

return {
Expand Down Expand Up @@ -312,6 +319,7 @@
$attrs.tooltipSize = $attrs.tooltipSize || tooltipsConf.size;
$attrs.tooltipSpeed = $attrs.tooltipSpeed || tooltipsConf.speed;
$attrs.tooltipAppendToBody = $attrs.tooltipAppendToBody === 'true';
$attrs.tooltipFlashTime = $attrs.tooltipFlashTime || tooltipsConf.flashTime;

$transcludeFunc($scope, function onTransclusionDone(element, scope) {
var attributes = getAttributesToAdd(element)
Expand All @@ -321,6 +329,7 @@
, tipTipElement = angular.element(window.document.createElement('tip-tip'))
, closeButtonElement = angular.element(window.document.createElement('span'))
, tipArrowElement = angular.element(window.document.createElement('tip-arrow'))
, flashTimer
, whenActivateMultilineCalculation = function whenActivateMultilineCalculation() {

return tipContElement.html();
Expand All @@ -336,8 +345,22 @@
tooltipElement.removeClass('_multiline');
}
}
, onTooltipShow = function onTooltipShow(event) {
, onTooltipHide = function onTooltipHide(event) {

if (event && tooltipElement.hasClass('active')) {

event.stopImmediatePropagation();
}

if ($attrs.tooltipAppendToBody) {

removeAppendedTip(tooltipElement);
} else {

tooltipElement.removeClass('active');
}
}
, onTooltipShow = function onTooltipShow(event) {
if (event && !tooltipElement.hasClass('active')) {

event.stopImmediatePropagation();
Expand Down Expand Up @@ -462,20 +485,20 @@
tooltipElement.addClass('active');
}
}
}
, onTooltipHide = function onTooltipHide(event) {

if (event && tooltipElement.hasClass('active')) {

event.stopImmediatePropagation();
}
if ($attrs.tooltipFlashTime) {

if ($attrs.tooltipAppendToBody) {
if (flashTimer) {

removeAppendedTip(tooltipElement);
} else {
$timeout.cancel(flashTimer);
}

flashTimer = $timeout(function hideTooltip() {

onTooltipHide(event);

}, parseInt($attrs.tooltipFlashTime, 10));

tooltipElement.removeClass('active');
}
}
, registerOnScrollFrom = function registerOnScrollFrom(theElement) {
Expand Down
1 change: 0 additions & 1 deletion dist/angular-tooltips.js.map

This file was deleted.

Loading