mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-20 00:10:26 +00:00
the flag must be in all src and test files so that we get the benefit of running in the strict mode even in jstd the following script was used to modify all files: for file in `find src test -name "*.js"`; do echo -e "'use strict';\n" > temp.txt cat $file >> temp.txt mv temp.txt $file done
58 lines
2 KiB
JavaScript
58 lines
2 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* @workInProgress
|
|
* @ngdoc service
|
|
* @name angular.service.$hover
|
|
* @requires $browser
|
|
* @requires $document
|
|
*
|
|
* @description
|
|
*
|
|
* @example
|
|
*/
|
|
angularServiceInject("$hover", function(browser, document) {
|
|
var tooltip, self = this, error, width = 300, arrowWidth = 10, body = jqLite(document[0].body);
|
|
browser.hover(function(element, show){
|
|
if (show && (error = element.attr(NG_EXCEPTION) || element.attr(NG_VALIDATION_ERROR))) {
|
|
if (!tooltip) {
|
|
tooltip = {
|
|
callout: jqLite('<div id="ng-callout"></div>'),
|
|
arrow: jqLite('<div></div>'),
|
|
title: jqLite('<div class="ng-title"></div>'),
|
|
content: jqLite('<div class="ng-content"></div>')
|
|
};
|
|
tooltip.callout.append(tooltip.arrow);
|
|
tooltip.callout.append(tooltip.title);
|
|
tooltip.callout.append(tooltip.content);
|
|
body.append(tooltip.callout);
|
|
}
|
|
var docRect = body[0].getBoundingClientRect(),
|
|
elementRect = element[0].getBoundingClientRect(),
|
|
leftSpace = docRect.right - elementRect.right - arrowWidth;
|
|
tooltip.title.text(element.hasClass("ng-exception") ? "EXCEPTION:" : "Validation error...");
|
|
tooltip.content.text(error);
|
|
if (leftSpace < width) {
|
|
tooltip.arrow.addClass('ng-arrow-right');
|
|
tooltip.arrow.css({left: (width + 1)+'px'});
|
|
tooltip.callout.css({
|
|
position: 'fixed',
|
|
left: (elementRect.left - arrowWidth - width - 4) + "px",
|
|
top: (elementRect.top - 3) + "px",
|
|
width: width + "px"
|
|
});
|
|
} else {
|
|
tooltip.arrow.addClass('ng-arrow-left');
|
|
tooltip.callout.css({
|
|
position: 'fixed',
|
|
left: (elementRect.right + arrowWidth) + "px",
|
|
top: (elementRect.top - 3) + "px",
|
|
width: width + "px"
|
|
});
|
|
}
|
|
} else if (tooltip) {
|
|
tooltip.callout.remove();
|
|
tooltip = null;
|
|
}
|
|
});
|
|
}, ['$browser', '$document'], true);
|