Skip to content

Commit

Permalink
Merge pull request #74 from louisameline/master
Browse files Browse the repository at this point in the history
Fixed functionInit, changed version to 2.2.3
  • Loading branch information
louisameline committed Oct 31, 2013
2 parents c2229f3 + c14eab9 commit fa45184
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 85 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tooltipster",
"version": "2.2.1",
"version": "2.2.3",
"main": ["js/jquery.tooltipster.min.js", "css/tooltipster.css"],
"dependencies": {
"jquery": ">=1.4"
Expand Down
157 changes: 75 additions & 82 deletions js/jquery.tooltipster.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Tooltipster 2.2.1 | 10/29/13
Tooltipster 2.2.3 | 10/29/13
A rockin' custom tooltip jQuery plugin
Developed by Caleb Jacob uner the MIT license http://opensource.org/licenses/MIT
Expand All @@ -20,9 +20,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
delay: 200,
fixedWidth: 0,
maxWidth: 0,
functionInit: function(origin, content, continueInit) {
continueInit();
},
functionInit: function(origin, content) {},
functionBefore: function(origin, continueTooltip) {
continueTooltip();
},
Expand Down Expand Up @@ -111,6 +109,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
if (run) {
// first, strip the title off of the element and set it as a data attribute to prevent the default tooltips from popping up
var tooltipsterContent = $.trim(object.options.content).length > 0 ? object.options.content : $this.attr('title');

var c = object.options.functionInit($this, tooltipsterContent);
if(c) tooltipsterContent = c;

$this.data('tooltipsterContent', tooltipsterContent);
$this.removeAttr('title');

Expand All @@ -126,99 +128,90 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
$this = icon;
}

// fire our init function before moving on
object.options.functionInit($this, tooltipsterContent, function(newContent) {
// if we're changing the content
if (newContent) {
tooltipsterContent = newContent;
$this.data('tooltipsterContent', newContent);
}

// if this is a touch device, add some touch events to launch the tooltip
if ((object.options.touchDevices) && (touchDevice) && ((object.options.trigger == 'click') || (object.options.trigger == 'hover'))) {
$this.on('touchstart.tooltipster', function(element, options) {
// if this is a touch device, add some touch events to launch the tooltip
if ((object.options.touchDevices) && (touchDevice) && ((object.options.trigger == 'click') || (object.options.trigger == 'hover'))) {
$this.on('touchstart.tooltipster', function(element, options) {
object.showTooltip();
});
}

// if this is a desktop, deal with adding regular mouse events
else {

// if hover events are set to show and hide the tooltip, attach those events respectively
if (object.options.trigger == 'hover') {
$this.on('mouseenter.tooltipster', function() {
object.showTooltip();
});
}

// if this is a desktop, deal with adding regular mouse events
else {

// if hover events are set to show and hide the tooltip, attach those events respectively
if (object.options.trigger == 'hover') {
$this.on('mouseenter.tooltipster', function() {
object.showTooltip();
});

// if this is an interactive tooltip, delay getting rid of the tooltip right away so you have a chance to hover on the tooltip
if (object.options.interactive) {
$this.on('mouseleave.tooltipster', function() {
var tooltipster = $this.data('tooltipster');
var keepAlive = false;

// if this is an interactive tooltip, delay getting rid of the tooltip right away so you have a chance to hover on the tooltip
if (object.options.interactive) {
$this.on('mouseleave.tooltipster', function() {
var tooltipster = $this.data('tooltipster');
var keepAlive = false;

if ((tooltipster !== undefined) && (tooltipster !== '')) {
tooltipster.mouseenter(function() {
keepAlive = true;
});
tooltipster.mouseleave(function() {
keepAlive = false;
});

if ((tooltipster !== undefined) && (tooltipster !== '')) {
tooltipster.mouseenter(function() {
keepAlive = true;
});
tooltipster.mouseleave(function() {
keepAlive = false;
});

var tolerance = setTimeout(function() {
var tolerance = setTimeout(function() {

if (keepAlive) {
if (object.options.interactiveAutoClose) {
tooltipster.find('select').on('change', function() {
object.hideTooltip();
});
if (keepAlive) {
if (object.options.interactiveAutoClose) {
tooltipster.find('select').on('change', function() {
object.hideTooltip();
});

tooltipster.mouseleave(function(e) {
var $target = $(e.target);
tooltipster.mouseleave(function(e) {
var $target = $(e.target);

if ($target.parents('.tooltipster-base').length === 0 || $target.hasClass('tooltipster-base')) {
object.hideTooltip();
}
if ($target.parents('.tooltipster-base').length === 0 || $target.hasClass('tooltipster-base')) {
object.hideTooltip();
}

else {
$target.on('mouseleave', function(e) {
object.hideTooltip();
});
}
});
}
}
else {
object.hideTooltip();
else {
$target.on('mouseleave', function(e) {
object.hideTooltip();
});
}
});
}
}, object.options.interactiveTolerance);
}
else {
object.hideTooltip();
}
});
}

// if this is a dumb tooltip, just get rid of it on mouseleave
else {
$this.on('mouseleave.tooltipster', function() {
object.hideTooltip();
});
}
}

// if click events are set to show and hide the tooltip, attach those events respectively
if (object.options.trigger == 'click') {
$this.on('click.tooltipster', function() {
if (($this.data('tooltipster') === '') || ($this.data('tooltipster') === undefined)) {
object.showTooltip();
}
else {
object.hideTooltip();
}
}, object.options.interactiveTolerance);
}
else {
object.hideTooltip();
}
});
}

// if this is a dumb tooltip, just get rid of it on mouseleave
else {
$this.on('mouseleave.tooltipster', function() {
object.hideTooltip();
});
}
}
});

// if click events are set to show and hide the tooltip, attach those events respectively
if (object.options.trigger == 'click') {
$this.on('click.tooltipster', function() {
if (($this.data('tooltipster') === '') || ($this.data('tooltipster') === undefined)) {
object.showTooltip();
}
else {
object.hideTooltip();
}
});
}
}
}
},

Expand Down
Loading

0 comments on commit fa45184

Please sign in to comment.