Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bootstrap-dropdown-hover

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bootstrap-dropdown-hover - npm Package Compare versions

Comparing version 4.1.1 to 4.2.0

2

bootstrap-dropdown-hover.jquery.json

@@ -11,3 +11,3 @@ {

],
"version": "4.1.1",
"version": "4.2.0",
"author": {

@@ -14,0 +14,0 @@ "name": "István Ujj-Mészáros",

{
"name": "bootstrap-dropdown-hover",
"version": "4.1.1",
"version": "4.2.0",
"homepage": "https://www.virtuosoft.eu/code/bootstrap-dropdown-hover/",

@@ -5,0 +5,0 @@ "authors": [

@@ -7,3 +7,3 @@ {

"homepage": "https://www.virtuosoft.eu/code/bootstrap-dropdown-hover/",
"version": "4.1.1",
"version": "4.2.0",
"authors": [

@@ -10,0 +10,0 @@ {

/*
* Bootstrap Dropdown Hover - v4.1.1
* Bootstrap Dropdown Hover - v4.2.0
* Open dropdown menus on mouse hover, the proper way.

@@ -41,4 +41,3 @@ * http://www.virtuosoft.eu/code/bootstrap-dropdown-hover/

_hardOpened = false,
_touchstartDetected = false,
_mouseDetected = false;
_isTouchDevice = false;

@@ -54,23 +53,42 @@ // The actual plugin constructor

function bindEvents(dropdown) {
var $body = $('body');
// https://stackoverflow.com/a/4819886/504270
function isTouchDevice() {
var prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
var mq = function(query) {
return window.matchMedia(query).matches;
};
$body.one('touchstart.dropdownhover', function() {
_touchstartDetected = true;
});
if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
return true;
}
$body.one('mousemove.dropdownhover', function() {
// touchstart fires before mousemove on touch devices
if (!_touchstartDetected) {
_mouseDetected = true;
}
});
// include the 'heartz' as a way to have a non matching MQ to help terminate the join
// https://git.io/vznFH
var query = ['(', prefixes.join('touch-enabled),('), 'heartz', ')'].join('');
return mq(query);
}
$('.dropdown-toggle, .dropdown-menu', dropdown.element.parent()).on('mouseenter.dropdownhover', function () {
// seems to be a touch device
if(_mouseDetected && !$(this.hover)) {
_mouseDetected = false;
}
_isTouchDevice = isTouchDevice();
if (!_mouseDetected) {
function getParent($this) {
var selector = $this.attr('data-target');
var $parent;
if (!selector) {
selector = $this.attr('href');
selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, ''); //strip for ie7
}
$parent = selector && $(selector);
if (!$parent || !$parent.length) {$parent = $this.parent();}
return $parent;
}
function bindEvents(dropdown) {
var $parent = getParent(dropdown.element);
$('.dropdown-toggle, .dropdown-menu', $parent).on('mouseenter.dropdownhover', function () {
if (_isTouchDevice) {
return;

@@ -80,3 +98,3 @@ }

clearTimeout(_hideTimeoutHandler);
if (!dropdown.element.parent().is('.open, .show')) {
if (!$parent.is('.open, .show')) {
_hardOpened = false;

@@ -87,4 +105,4 @@ dropdown.element.dropdown('toggle');

$('.dropdown-toggle, .dropdown-menu', dropdown.element.parent()).on('mouseleave.dropdownhover', function () {
if (!_mouseDetected) {
$('.dropdown-toggle, .dropdown-menu', $parent).on('mouseleave.dropdownhover', function () {
if (_isTouchDevice) {
return;

@@ -97,3 +115,3 @@ }

_hideTimeoutHandler = setTimeout(function () {
if (dropdown.element.parent().is('.open, .show')) {
if ($parent.is('.open, .show')) {
dropdown.element.dropdown('toggle');

@@ -105,3 +123,3 @@ }

dropdown.element.on('click.dropdownhover', function (e) {
if (dropdown.settings.clickBehavior !== 'link' && !_mouseDetected) {
if (dropdown.settings.clickBehavior !== 'link' && _isTouchDevice) {
return;

@@ -126,3 +144,3 @@ }

_hardOpened = true;
if (dropdown.element.parent().is('.open, .show')) {
if ($parent.is('.open, .show')) {
e.stopImmediatePropagation();

@@ -138,5 +156,6 @@ e.preventDefault();

function removeEvents(dropdown) {
$('.dropdown-toggle, .dropdown-menu', dropdown.element.parent()).off('.dropdownhover');
var $parent = getParent(dropdown.element);
$('.dropdown-toggle, .dropdown-menu', $parent).off('.dropdownhover');
// seems that bootstrap binds the click handler twice after we reinitializing the plugin after a destroy...
$('.dropdown-toggle, .dropdown-menu', dropdown.element.parent()).off('.dropdown');
$('.dropdown-toggle, .dropdown-menu', $parent).off('.dropdown');
dropdown.element.off('.dropdownhover');

@@ -143,0 +162,0 @@ $('body').off('.dropdownhover');

/*
* Bootstrap Dropdown Hover - v4.1.1
* Bootstrap Dropdown Hover - v4.2.0
* Open dropdown menus on mouse hover, the proper way.

@@ -10,2 +10,2 @@ * http://www.virtuosoft.eu/code/bootstrap-dropdown-hover/

!function(o){"function"==typeof define&&define.amd?define(["jquery"],o):"object"==typeof module&&module.exports?module.exports=function(e,t){return void 0===t&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),o(t),t}:o(jQuery)}(function(i){var o,r="bootstrapDropdownHover",n={clickBehavior:"sticky",hideTimeout:200},d=!1,s=!1,a=!1;function u(e,t){this.element=i(e),this.settings=i.extend({},n,t,this.element.data()),this._defaults=n,this._name=r,this.init()}u.prototype={init:function(){var t,e;return this.setClickBehavior(this.settings.clickBehavior),this.setHideTimeout(this.settings.hideTimeout),t=this,(e=i("body")).one("touchstart.dropdownhover",function(){s=!0}),e.one("mousemove.dropdownhover",function(){s||(a=!0)}),i(".dropdown-toggle, .dropdown-menu",t.element.parent()).on("mouseenter.dropdownhover",function(){a&&!i(this.hover)&&(a=!1),a&&(clearTimeout(o),t.element.parent().is(".open, .show")||(d=!1,t.element.dropdown("toggle")))}),i(".dropdown-toggle, .dropdown-menu",t.element.parent()).on("mouseleave.dropdownhover",function(){a&&(d||(o=setTimeout(function(){t.element.parent().is(".open, .show")&&t.element.dropdown("toggle")},t.settings.hideTimeout)))}),t.element.on("click.dropdownhover",function(e){if("link"===t.settings.clickBehavior||a)switch(t.settings.clickBehavior){case"default":return;case"disable":return e.preventDefault(),void e.stopImmediatePropagation();case"link":return void e.stopImmediatePropagation();case"sticky":return void(d?d=!1:(d=!0,t.element.parent().is(".open, .show")&&(e.stopImmediatePropagation(),e.preventDefault())))}}),this.element},setClickBehavior:function(e){return this.settings.clickBehavior=e,this.element},setHideTimeout:function(e){return this.settings.hideTimeout=e,this.element},destroy:function(){var e;return clearTimeout(o),i(".dropdown-toggle, .dropdown-menu",(e=this).element.parent()).off(".dropdownhover"),i(".dropdown-toggle, .dropdown-menu",e.element.parent()).off(".dropdown"),e.element.off(".dropdownhover"),i("body").off(".dropdownhover"),this.element.data("plugin_"+r,null),this.element}},i.fn[r]=function(o){var t,n=arguments;return void 0===o||"object"==typeof o?(i.contains(document,i(this)[0])||i('[data-toggle="dropdown"]').each(function(e,t){i(t).bootstrapDropdownHover(o)}),this.each(function(){i(this).hasClass("dropdown-toggle")&&"dropdown"===i(this).data("toggle")?i.data(this,"plugin_"+r)||i.data(this,"plugin_"+r,new u(this,o)):i('[data-toggle="dropdown"]',this).each(function(e,t){i(t).bootstrapDropdownHover(o)})})):"string"==typeof o&&"_"!==o[0]&&"init"!==o?(this.each(function(){var e=i.data(this,"plugin_"+r);e instanceof u&&"function"==typeof e[o]&&(t=e[o].apply(e,Array.prototype.slice.call(n,1)))}),void 0!==t?t:this):void 0}});
!function(o){"function"==typeof define&&define.amd?define(["jquery"],o):"object"==typeof module&&module.exports?module.exports=function(e,t){return void 0===t&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),o(t),t}:o(jQuery)}(function(i){var n,r,d="bootstrapDropdownHover",o={clickBehavior:"sticky",hideTimeout:200},s=!1;function a(e,t){this.element=i(e),this.settings=i.extend({},o,t,this.element.data()),this._defaults=o,this._name=d,this.init()}function u(e){var t,o=e.attr("data-target");return o||(o=(o=e.attr("href"))&&/#[A-Za-z]/.test(o)&&o.replace(/.*(?=#[^\s]*$)/,"")),(t=o&&i(o))&&t.length||(t=e.parent()),t}r=function(){var e=" -webkit- -moz- -o- -ms- ".split(" ");if("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)return!0;var t,o=["(",e.join("touch-enabled),("),"heartz",")"].join("");return t=o,window.matchMedia(t).matches}(),a.prototype={init:function(){var t,o;return this.setClickBehavior(this.settings.clickBehavior),this.setHideTimeout(this.settings.hideTimeout),o=u((t=this).element),i(".dropdown-toggle, .dropdown-menu",o).on("mouseenter.dropdownhover",function(){r||(clearTimeout(n),o.is(".open, .show")||(s=!1,t.element.dropdown("toggle")))}),i(".dropdown-toggle, .dropdown-menu",o).on("mouseleave.dropdownhover",function(){r||s||(n=setTimeout(function(){o.is(".open, .show")&&t.element.dropdown("toggle")},t.settings.hideTimeout))}),t.element.on("click.dropdownhover",function(e){if("link"===t.settings.clickBehavior||!r)switch(t.settings.clickBehavior){case"default":return;case"disable":return e.preventDefault(),void e.stopImmediatePropagation();case"link":return void e.stopImmediatePropagation();case"sticky":return void(s?s=!1:(s=!0,o.is(".open, .show")&&(e.stopImmediatePropagation(),e.preventDefault())))}}),this.element},setClickBehavior:function(e){return this.settings.clickBehavior=e,this.element},setHideTimeout:function(e){return this.settings.hideTimeout=e,this.element},destroy:function(){var e,t;return clearTimeout(n),t=u((e=this).element),i(".dropdown-toggle, .dropdown-menu",t).off(".dropdownhover"),i(".dropdown-toggle, .dropdown-menu",t).off(".dropdown"),e.element.off(".dropdownhover"),i("body").off(".dropdownhover"),this.element.data("plugin_"+d,null),this.element}},i.fn[d]=function(o){var t,n=arguments;return void 0===o||"object"==typeof o?(i.contains(document,i(this)[0])||i('[data-toggle="dropdown"]').each(function(e,t){i(t).bootstrapDropdownHover(o)}),this.each(function(){i(this).hasClass("dropdown-toggle")&&"dropdown"===i(this).data("toggle")?i.data(this,"plugin_"+d)||i.data(this,"plugin_"+d,new a(this,o)):i('[data-toggle="dropdown"]',this).each(function(e,t){i(t).bootstrapDropdownHover(o)})})):"string"==typeof o&&"_"!==o[0]&&"init"!==o?(this.each(function(){var e=i.data(this,"plugin_"+d);e instanceof a&&"function"==typeof e[o]&&(t=e[o].apply(e,Array.prototype.slice.call(n,1)))}),void 0!==t?t:this):void 0}});

@@ -12,9 +12,9 @@ {

"homepage": "https://www.virtuosoft.eu/code/bootstrap-dropdown-hover/",
"version": "4.1.1",
"version": "4.2.0",
"devDependencies": {
"grunt": "^1.0.2",
"grunt-cli": "^1.2.0",
"grunt": "^1.0.3",
"grunt-cli": "^1.3.1",
"grunt-contrib-jshint": "^1.1.0",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-uglify": "^3.3.0"
"grunt-contrib-uglify": "^3.4.0"
},

@@ -21,0 +21,0 @@ "scripts": {

@@ -33,4 +33,3 @@ (function(factory) {

_hardOpened = false,
_touchstartDetected = false,
_mouseDetected = false;
_isTouchDevice = false;

@@ -46,23 +45,42 @@ // The actual plugin constructor

function bindEvents(dropdown) {
var $body = $('body');
// https://stackoverflow.com/a/4819886/504270
function isTouchDevice() {
var prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
var mq = function(query) {
return window.matchMedia(query).matches;
};
$body.one('touchstart.dropdownhover', function() {
_touchstartDetected = true;
});
if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
return true;
}
$body.one('mousemove.dropdownhover', function() {
// touchstart fires before mousemove on touch devices
if (!_touchstartDetected) {
_mouseDetected = true;
}
});
// include the 'heartz' as a way to have a non matching MQ to help terminate the join
// https://git.io/vznFH
var query = ['(', prefixes.join('touch-enabled),('), 'heartz', ')'].join('');
return mq(query);
}
$('.dropdown-toggle, .dropdown-menu', dropdown.element.parent()).on('mouseenter.dropdownhover', function () {
// seems to be a touch device
if(_mouseDetected && !$(this.hover)) {
_mouseDetected = false;
}
_isTouchDevice = isTouchDevice();
if (!_mouseDetected) {
function getParent($this) {
var selector = $this.attr('data-target');
var $parent;
if (!selector) {
selector = $this.attr('href');
selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, ''); //strip for ie7
}
$parent = selector && $(selector);
if (!$parent || !$parent.length) {$parent = $this.parent();}
return $parent;
}
function bindEvents(dropdown) {
var $parent = getParent(dropdown.element);
$('.dropdown-toggle, .dropdown-menu', $parent).on('mouseenter.dropdownhover', function () {
if (_isTouchDevice) {
return;

@@ -72,3 +90,3 @@ }

clearTimeout(_hideTimeoutHandler);
if (!dropdown.element.parent().is('.open, .show')) {
if (!$parent.is('.open, .show')) {
_hardOpened = false;

@@ -79,4 +97,4 @@ dropdown.element.dropdown('toggle');

$('.dropdown-toggle, .dropdown-menu', dropdown.element.parent()).on('mouseleave.dropdownhover', function () {
if (!_mouseDetected) {
$('.dropdown-toggle, .dropdown-menu', $parent).on('mouseleave.dropdownhover', function () {
if (_isTouchDevice) {
return;

@@ -89,3 +107,3 @@ }

_hideTimeoutHandler = setTimeout(function () {
if (dropdown.element.parent().is('.open, .show')) {
if ($parent.is('.open, .show')) {
dropdown.element.dropdown('toggle');

@@ -97,3 +115,3 @@ }

dropdown.element.on('click.dropdownhover', function (e) {
if (dropdown.settings.clickBehavior !== 'link' && !_mouseDetected) {
if (dropdown.settings.clickBehavior !== 'link' && _isTouchDevice) {
return;

@@ -118,3 +136,3 @@ }

_hardOpened = true;
if (dropdown.element.parent().is('.open, .show')) {
if ($parent.is('.open, .show')) {
e.stopImmediatePropagation();

@@ -130,5 +148,6 @@ e.preventDefault();

function removeEvents(dropdown) {
$('.dropdown-toggle, .dropdown-menu', dropdown.element.parent()).off('.dropdownhover');
var $parent = getParent(dropdown.element);
$('.dropdown-toggle, .dropdown-menu', $parent).off('.dropdownhover');
// seems that bootstrap binds the click handler twice after we reinitializing the plugin after a destroy...
$('.dropdown-toggle, .dropdown-menu', dropdown.element.parent()).off('.dropdown');
$('.dropdown-toggle, .dropdown-menu', $parent).off('.dropdown');
dropdown.element.off('.dropdownhover');

@@ -135,0 +154,0 @@ $('body').off('.dropdownhover');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc