diff --git a/.gitignore b/.gitignore
index fd3a1c2..35118cb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
bower_components
node_modules
.tmp
+.DS_Store
diff --git a/examples/index.html b/examples/index.html
index a062c38..2b14a74 100644
--- a/examples/index.html
+++ b/examples/index.html
@@ -24,7 +24,6 @@
}
-
diff --git a/karma.conf.js b/karma.conf.js
index 2b03fbf..31f5eef 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -17,7 +17,7 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
files: [
- 'bower_components/jquery/jquery.js',
+ 'bower_components/jquery/dist/jquery.js',
'bower_components/angular/angular.js',
'bower_components/tether/tether.js',
@@ -61,7 +61,7 @@ module.exports = function(config) {
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
- browsers: ['Firefox'],
+ browsers: ['PhantomJS'],
// Continuous Integration mode
diff --git a/package.json b/package.json
index be28983..4ea8ddd 100644
--- a/package.json
+++ b/package.json
@@ -1,28 +1,9 @@
{
- "name": "remind101.js",
- "description": "Restangular client for the Remind101 API",
- "devDependencies": {
- "grunt": "~0.4.1",
- "grunt-contrib-uglify": "~0.2.0",
- "grunt-contrib-copy": "~0.4.1",
- "grunt-contrib-concat": "~0.3.0",
- "grunt-ngmin": "~0.0.3",
- "load-grunt-tasks": "~0.2.0",
- "karma": "latest",
- "karma-mocha": "latest",
- "karma-phantomjs-launcher": "~0.1.0",
- "chai": "latest",
- "sinon": "latest",
- "sinon-chai": "latest",
- "chai-jquery": "~1.2.1"
- },
- "engines": {
- "node": ">=0.8.0"
- },
- "scripts": {
- "test": "grunt test"
- },
- "dependencies": {
- "grunt-karma": "^0.10.1"
+ "name": "@chinchilla-software/angular-tooltip",
+ "version": "1.2.2",
+ "description": "Simple and extensible tooltips for angularjs",
+ "repository": "https://github.com/Chinchilla-Software-Com/angular-tooltip",
+ "dependencies": {
+ "angular": "1.8.2"
}
}
diff --git a/src/angular-tooltip.js b/src/angular-tooltip.js
index 7940af7..471b3bd 100644
--- a/src/angular-tooltip.js
+++ b/src/angular-tooltip.js
@@ -25,7 +25,7 @@
options = extend({ templateUrl: defaultTemplateUrl }, options);
options.tether = extend({}, defaultTetherOptions, options.tether || {});
- var template = options.template || ( $templateCache.get(options.templateUrl) ? $templateCache.get(options.templateUrl)[1] : undefined ),
+ var template = options.template || ( $templateCache.get(options.templateUrl) ? $templateCache.get(options.templateUrl) : undefined ),
scope = options.scope || $rootScope.$new(),
target = options.target,
tether, elem;
@@ -42,7 +42,7 @@
function attachTether() {
tether = new Tether(extend({
element: elem,
- target: target
+ target: target[0]
}, options.tether));
}
@@ -53,8 +53,13 @@
if (tether) {
tether.destroy();
tether = undefined;
- angular.element(elem).scope().$destroy();
- angular.element(elem).remove();
+ var ae = angular.element(elem);
+ if (ae !== undefined){
+ var aes = ae.scope();
+ if (aes !== undefined)
+ aes.$destroy();
+ ae.remove();
+ }
}
}
@@ -69,8 +74,12 @@
}
result.elem = elem;
$animate.enter(elem, null, target);
- attachTether();
- tether.position();
+ // without a timeout, an ng-repeat won't have finished, thus the height won't be calculated for attachment, and only top based alignment will work
+ // bottom base or variable width, right based alignment will be flakey.
+ $timeout(function(){
+ attachTether();
+ tether.position();
+ }, 0);
}
/**
@@ -78,7 +87,8 @@
*/
function close() {
delete result.elem;
- $animate.leave(elem);
+ if (elem !== undefined && elem != null)
+ $animate.leave(angular.element(elem));
detachTether();
}
@@ -119,10 +129,11 @@
/**
* Toggle the tooltip.
*/
- elem.hover(function() {
- scope.$apply(tooltip.open);
- }, function() {
- scope.$apply(tooltip.close);
+ elem.on('mouseover', function() {
+ scope.$apply(tooltip.open());
+ });
+ elem.on('mouseout', function() {
+ scope.$apply(tooltip.close());
});
}
};