Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bower_components
node_modules
.tmp
.DS_Store
1 change: 0 additions & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
}
</style>

<script src="../bower_components/jquery/jquery.js"></script>
<script src="../bower_components/angular/angular.js"></script>
<script src="../bower_components/angular-animate/angular-animate.js"></script>
<script src="../bower_components/tether/tether.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Expand Down Expand Up @@ -61,7 +61,7 @@ module.exports = function(config) {
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['Firefox'],
browsers: ['PhantomJS'],


// Continuous Integration mode
Expand Down
31 changes: 6 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
33 changes: 22 additions & 11 deletions src/angular-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -42,7 +42,7 @@
function attachTether() {
tether = new Tether(extend({
element: elem,
target: target
target: target[0]
}, options.tether));
}

Expand All @@ -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();
}
}
}

Expand All @@ -69,16 +74,21 @@
}
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);
}

/**
* Close the tooltip
*/
function close() {
delete result.elem;
$animate.leave(elem);
if (elem !== undefined && elem != null)
$animate.leave(angular.element(elem));
detachTether();
}

Expand Down Expand Up @@ -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());
});
}
};
Expand Down