Skip to content

Commit

Permalink
use window.document.body instead of
Browse files Browse the repository at this point in the history
  • Loading branch information
louisameline committed Feb 12, 2017
1 parent 608bf70 commit 0d0127a
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/js/tooltipster.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ var defaults = {
IEmin: 6,
interactive: false,
multiple: false,
// must be 'body' for now, or an element positioned at (0, 0)
// must be 'body' for now (default), or an element positioned at (0, 0)
// in the document, typically like the very top views of an app.
parent: 'body',
parent: null,
plugins: ['sideTip'],
repositionOnScroll: false,
restoration: 'none',
Expand Down Expand Up @@ -546,7 +546,7 @@ $.Tooltipster.prototype = {

// to detect swiping
if (env.hasTouchCapability) {
$('body').on('touchmove.'+ self.__namespace +'-triggerOpen', function(event) {
$(env.window.document.body).on('touchmove.'+ self.__namespace +'-triggerOpen', function(event) {
self._touchRecordEvent(event);
});
}
Expand Down Expand Up @@ -941,7 +941,10 @@ $.Tooltipster.prototype = {
}

// determine the future parent
if (typeof this.__options.parent == 'string') {
if (this.__options.parent === null) {
this.__options.parent = $(env.window.document.body);
}
else if (typeof this.__options.parent == 'string') {
this.__options.parent = $(this.__options.parent);
}

Expand Down Expand Up @@ -1519,7 +1522,7 @@ $.Tooltipster.prototype = {
// clear the array to prevent memory leaks
self.__$originParents = null;

$('body').off('.'+ self.__namespace +'-triggerClose');
$(env.window.document.body).off('.'+ self.__namespace +'-triggerClose');

self._$origin.off('.'+ self.__namespace +'-triggerClose');

Expand Down Expand Up @@ -1971,7 +1974,7 @@ $.Tooltipster.prototype = {
eventNames += 'touchend.'+ self.__namespace +'-triggerClose';
}

$('body').on(eventNames, function(event) {
$(env.window.document.body).on(eventNames, function(event) {

if (self._touchIsMeaningfulEvent(event)) {

Expand All @@ -1986,7 +1989,7 @@ $.Tooltipster.prototype = {
// needed to detect and ignore swiping
if (self.__options.triggerClose.tap && env.hasTouchCapability) {

$('body').on('touchstart.'+ self.__namespace +'-triggerClose', function(event) {
$(env.window.document.body).on('touchstart.'+ self.__namespace +'-triggerClose', function(event) {
self._touchRecordEvent(event);
});
}
Expand Down Expand Up @@ -2485,7 +2488,7 @@ $.Tooltipster.prototype = {
.off('.'+ self.__namespace +'-triggerOpen');

// remove the touch listener
$('body').off('.' + self.__namespace +'-triggerOpen');
$(env.window.document.body).off('.' + self.__namespace +'-triggerOpen');

var ns = self._$origin.data('tooltipster-ns');

Expand Down Expand Up @@ -3070,7 +3073,7 @@ Ruler.prototype = {

this.$container = $('<div class="tooltipster-ruler"></div>')
.append(this.__$tooltip)
.appendTo('body');
.appendTo(env.window.document.body);
},

/**
Expand Down

0 comments on commit 0d0127a

Please sign in to comment.