Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
* moved `tooltipTouchHandler` into the prototype to solve #430 (comment)
  • Loading branch information
thednp committed Feb 14, 2022
1 parent 8da3acb commit ba090ff
Show file tree
Hide file tree
Showing 36 changed files with 203 additions and 193 deletions.
4 changes: 2 additions & 2 deletions dist/bootstrap-native-v4-esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Native JavaScript for Bootstrap v4.1.0alpha5 (https://thednp.github.io/bootstrap.native/)
* Native JavaScript for Bootstrap v4.1.0alpha6 (https://thednp.github.io/bootstrap.native/)
* Copyright 2015-2022 © dnp_theme
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -2577,7 +2577,7 @@ function removeDataAPI(context) {
});
}

var version = "4.1.0alpha5";
var version = "4.1.0alpha6";

var Version = version;

Expand Down
4 changes: 2 additions & 2 deletions dist/bootstrap-native-v4-esm.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/bootstrap-native-v4.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Native JavaScript for Bootstrap v4.1.0alpha5 (https://thednp.github.io/bootstrap.native/)
* Native JavaScript for Bootstrap v4.1.0alpha6 (https://thednp.github.io/bootstrap.native/)
* Copyright 2015-2022 © dnp_theme
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -2583,7 +2583,7 @@
});
}

var version = "4.1.0alpha5";
var version = "4.1.0alpha6";

var Version = version;

Expand Down
4 changes: 2 additions & 2 deletions dist/bootstrap-native-v4.min.js

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions dist/bootstrap-native.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Native JavaScript for Bootstrap v4.1.0alpha5 (https://thednp.github.io/bootstrap.native/)
* Native JavaScript for Bootstrap v4.1.0alpha6 (https://thednp.github.io/bootstrap.native/)
* Copyright 2015-2022 © dnp_theme
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -539,7 +539,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) {
return normalOps;
}

var version = "4.1.0alpha5";
var version = "4.1.0alpha6";

const Version = version;

Expand Down Expand Up @@ -4288,7 +4288,7 @@ function toggleTooltipAction(self, add) {
const action = add ? addListener : removeListener;
const { element } = self;

action(getDocument(element), touchstartEvent, tooltipTouchHandler, passiveHandler);
action(getDocument(element), touchstartEvent, self.handleTouch, passiveHandler);

if (!isMedia(element)) {
[scrollEvent, resizeEvent].forEach((ev) => {
Expand Down Expand Up @@ -4360,7 +4360,7 @@ function toggleTooltipHandlers(self, add) {
action(btn, mouseclickEvent, self.hide);
} else {
action(element, mouseleaveEvent, self.hide);
action(getDocument(element), touchstartEvent, tooltipTouchHandler, passiveHandler);
action(getDocument(element), touchstartEvent, self.handleTouch, passiveHandler);
}
} else if (tr === mouseclickEvent) {
action(element, tr, (!dismissible ? self.toggle : self.show));
Expand Down Expand Up @@ -4417,21 +4417,6 @@ function toggleTooltipTitle(self, content) {
removeAttribute(element, titleAtt[content ? 1 : 0]);
}

// TOOLTIP EVENT HANDLERS
// ======================
/**
* Handles the `touchstart` event listener for `Tooltip`
* @this {Tooltip}
* @param {TouchEvent} e the `Event` object
*/
function tooltipTouchHandler({ target }) {
const { tooltip, element } = this;
// @ts-ignore
if (tooltip.contains(target) || target === element || element.contains(target)) ; else {
this.hide();
}
}

// TOOLTIP DEFINITION
// ==================
/** Creates a new `Tooltip` instance. */
Expand Down Expand Up @@ -4488,7 +4473,7 @@ class Tooltip extends BaseComponent {
tooltipDefaults[titleAttr] = null;

// all functions bind
tooltipTouchHandler.bind(self);
self.handleTouch = self.handleTouch.bind(self);
self.update = self.update.bind(self);
self.show = self.show.bind(self);
self.hide = self.hide.bind(self);
Expand Down Expand Up @@ -4652,6 +4637,21 @@ class Tooltip extends BaseComponent {
else self.disable();
}

/**
* Handles the `touchstart` event listener for `Tooltip`
* @this {Tooltip}
* @param {TouchEvent} e the `Event` object
*/
handleTouch({ target }) {
const { tooltip, element } = this;

if (tooltip.contains(target) || target === element
// @ts-ignore
|| (target && element.contains(target))) ; else {
this.hide();
}
}

/** Removes the `Tooltip` from the target element. */
dispose() {
const self = this;
Expand Down
4 changes: 2 additions & 2 deletions dist/bootstrap-native.esm.min.js

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions dist/bootstrap-native.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Native JavaScript for Bootstrap v4.1.0alpha5 (https://thednp.github.io/bootstrap.native/)
* Native JavaScript for Bootstrap v4.1.0alpha6 (https://thednp.github.io/bootstrap.native/)
* Copyright 2015-2022 © dnp_theme
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -545,7 +545,7 @@
return normalOps;
}

var version = "4.1.0alpha5";
var version = "4.1.0alpha6";

const Version = version;

Expand Down Expand Up @@ -4294,7 +4294,7 @@
const action = add ? addListener : removeListener;
const { element } = self;

action(getDocument(element), touchstartEvent, tooltipTouchHandler, passiveHandler);
action(getDocument(element), touchstartEvent, self.handleTouch, passiveHandler);

if (!isMedia(element)) {
[scrollEvent, resizeEvent].forEach((ev) => {
Expand Down Expand Up @@ -4366,7 +4366,7 @@
action(btn, mouseclickEvent, self.hide);
} else {
action(element, mouseleaveEvent, self.hide);
action(getDocument(element), touchstartEvent, tooltipTouchHandler, passiveHandler);
action(getDocument(element), touchstartEvent, self.handleTouch, passiveHandler);
}
} else if (tr === mouseclickEvent) {
action(element, tr, (!dismissible ? self.toggle : self.show));
Expand Down Expand Up @@ -4423,21 +4423,6 @@
removeAttribute(element, titleAtt[content ? 1 : 0]);
}

// TOOLTIP EVENT HANDLERS
// ======================
/**
* Handles the `touchstart` event listener for `Tooltip`
* @this {Tooltip}
* @param {TouchEvent} e the `Event` object
*/
function tooltipTouchHandler({ target }) {
const { tooltip, element } = this;
// @ts-ignore
if (tooltip.contains(target) || target === element || element.contains(target)) ; else {
this.hide();
}
}

// TOOLTIP DEFINITION
// ==================
/** Creates a new `Tooltip` instance. */
Expand Down Expand Up @@ -4494,7 +4479,7 @@
tooltipDefaults[titleAttr] = null;

// all functions bind
tooltipTouchHandler.bind(self);
self.handleTouch = self.handleTouch.bind(self);
self.update = self.update.bind(self);
self.show = self.show.bind(self);
self.hide = self.hide.bind(self);
Expand Down Expand Up @@ -4658,6 +4643,21 @@
else self.disable();
}

/**
* Handles the `touchstart` event listener for `Tooltip`
* @this {Tooltip}
* @param {TouchEvent} e the `Event` object
*/
handleTouch({ target }) {
const { tooltip, element } = this;

if (tooltip.contains(target) || target === element
// @ts-ignore
|| (target && element.contains(target))) ; else {
this.hide();
}
}

/** Removes the `Tooltip` from the target element. */
dispose() {
const self = this;
Expand Down
4 changes: 2 additions & 2 deletions dist/bootstrap-native.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/components/alert-native.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Native JavaScript for Bootstrap - Alert v4.1.0alpha5 (https://thednp.github.io/bootstrap.native/)
* Native JavaScript for Bootstrap - Alert v4.1.0alpha6 (https://thednp.github.io/bootstrap.native/)
* Copyright 2015-2022 © dnp_theme
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -526,7 +526,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) {
return normalOps;
}

var version = "4.1.0alpha5";
var version = "4.1.0alpha6";

const Version = version;

Expand Down
4 changes: 2 additions & 2 deletions dist/components/alert-native.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Native JavaScript for Bootstrap - Alert v4.1.0alpha5 (https://thednp.github.io/bootstrap.native/)
* Native JavaScript for Bootstrap - Alert v4.1.0alpha6 (https://thednp.github.io/bootstrap.native/)
* Copyright 2015-2022 © dnp_theme
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -532,7 +532,7 @@
return normalOps;
}

var version = "4.1.0alpha5";
var version = "4.1.0alpha6";

const Version = version;

Expand Down
4 changes: 2 additions & 2 deletions dist/components/button-native.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Native JavaScript for Bootstrap - Button v4.1.0alpha5 (https://thednp.github.io/bootstrap.native/)
* Native JavaScript for Bootstrap - Button v4.1.0alpha6 (https://thednp.github.io/bootstrap.native/)
* Copyright 2015-2022 © dnp_theme
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -388,7 +388,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) {
return normalOps;
}

var version = "4.1.0alpha5";
var version = "4.1.0alpha6";

const Version = version;

Expand Down
4 changes: 2 additions & 2 deletions dist/components/button-native.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Native JavaScript for Bootstrap - Button v4.1.0alpha5 (https://thednp.github.io/bootstrap.native/)
* Native JavaScript for Bootstrap - Button v4.1.0alpha6 (https://thednp.github.io/bootstrap.native/)
* Copyright 2015-2022 © dnp_theme
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -394,7 +394,7 @@
return normalOps;
}

var version = "4.1.0alpha5";
var version = "4.1.0alpha6";

const Version = version;

Expand Down
4 changes: 2 additions & 2 deletions dist/components/carousel-native.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Native JavaScript for Bootstrap - Carousel v4.1.0alpha5 (https://thednp.github.io/bootstrap.native/)
* Native JavaScript for Bootstrap - Carousel v4.1.0alpha6 (https://thednp.github.io/bootstrap.native/)
* Copyright 2015-2022 © dnp_theme
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -813,7 +813,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) {
return normalOps;
}

var version = "4.1.0alpha5";
var version = "4.1.0alpha6";

const Version = version;

Expand Down
4 changes: 2 additions & 2 deletions dist/components/carousel-native.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Native JavaScript for Bootstrap - Carousel v4.1.0alpha5 (https://thednp.github.io/bootstrap.native/)
* Native JavaScript for Bootstrap - Carousel v4.1.0alpha6 (https://thednp.github.io/bootstrap.native/)
* Copyright 2015-2022 © dnp_theme
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -819,7 +819,7 @@
return normalOps;
}

var version = "4.1.0alpha5";
var version = "4.1.0alpha6";

const Version = version;

Expand Down
4 changes: 2 additions & 2 deletions dist/components/collapse-native.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Native JavaScript for Bootstrap - Collapse v4.1.0alpha5 (https://thednp.github.io/bootstrap.native/)
* Native JavaScript for Bootstrap - Collapse v4.1.0alpha6 (https://thednp.github.io/bootstrap.native/)
* Copyright 2015-2022 © dnp_theme
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -684,7 +684,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) {
return normalOps;
}

var version = "4.1.0alpha5";
var version = "4.1.0alpha6";

const Version = version;

Expand Down
4 changes: 2 additions & 2 deletions dist/components/collapse-native.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Native JavaScript for Bootstrap - Collapse v4.1.0alpha5 (https://thednp.github.io/bootstrap.native/)
* Native JavaScript for Bootstrap - Collapse v4.1.0alpha6 (https://thednp.github.io/bootstrap.native/)
* Copyright 2015-2022 © dnp_theme
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -690,7 +690,7 @@
return normalOps;
}

var version = "4.1.0alpha5";
var version = "4.1.0alpha6";

const Version = version;

Expand Down
4 changes: 2 additions & 2 deletions dist/components/dropdown-native.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Native JavaScript for Bootstrap - Dropdown v4.1.0alpha5 (https://thednp.github.io/bootstrap.native/)
* Native JavaScript for Bootstrap - Dropdown v4.1.0alpha6 (https://thednp.github.io/bootstrap.native/)
* Copyright 2015-2022 © dnp_theme
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -635,7 +635,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) {
return normalOps;
}

var version = "4.1.0alpha5";
var version = "4.1.0alpha6";

const Version = version;

Expand Down
4 changes: 2 additions & 2 deletions dist/components/dropdown-native.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Native JavaScript for Bootstrap - Dropdown v4.1.0alpha5 (https://thednp.github.io/bootstrap.native/)
* Native JavaScript for Bootstrap - Dropdown v4.1.0alpha6 (https://thednp.github.io/bootstrap.native/)
* Copyright 2015-2022 © dnp_theme
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -641,7 +641,7 @@
return normalOps;
}

var version = "4.1.0alpha5";
var version = "4.1.0alpha6";

const Version = version;

Expand Down
4 changes: 2 additions & 2 deletions dist/components/modal-native.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Native JavaScript for Bootstrap - Modal v4.1.0alpha5 (https://thednp.github.io/bootstrap.native/)
* Native JavaScript for Bootstrap - Modal v4.1.0alpha6 (https://thednp.github.io/bootstrap.native/)
* Copyright 2015-2022 © dnp_theme
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -1091,7 +1091,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) {
return normalOps;
}

var version = "4.1.0alpha5";
var version = "4.1.0alpha6";

const Version = version;

Expand Down
4 changes: 2 additions & 2 deletions dist/components/modal-native.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Native JavaScript for Bootstrap - Modal v4.1.0alpha5 (https://thednp.github.io/bootstrap.native/)
* Native JavaScript for Bootstrap - Modal v4.1.0alpha6 (https://thednp.github.io/bootstrap.native/)
* Copyright 2015-2022 © dnp_theme
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -1097,7 +1097,7 @@
return normalOps;
}

var version = "4.1.0alpha5";
var version = "4.1.0alpha6";

const Version = version;

Expand Down
Loading

0 comments on commit ba090ff

Please sign in to comment.