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

tether-drop

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tether-drop - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

2

bower.json
{
"name": "tether-drop",
"version": "1.1.2",
"version": "1.2.0",
"homepage": "https://github.com/HubSpot/drop",

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

@@ -1,2 +0,2 @@

/*! tether-drop 1.1.2 */
/*! tether-drop 1.2.0 */

@@ -119,2 +119,3 @@ (function(root, factory) {

openOn: 'click',
beforeClose: null,
constrainToScrollParent: true,

@@ -433,2 +434,10 @@ constrainToWindow: true,

var _options = this.options;
var remove = _options.remove;
var beforeClose = _options.beforeClose;
if (typeof beforeClose === 'function' && beforeClose() === false) {
return;
}
removeClass(this.drop, '' + drop.classPrefix + '-open');

@@ -447,3 +456,3 @@ removeClass(this.drop, '' + drop.classPrefix + '-after-open');

if (this.options.remove) {
if (remove) {
this.remove();

@@ -450,0 +459,0 @@ }

@@ -1,1 +0,1 @@

!function(t,e){"function"==typeof define&&define.amd?define(["tether"],e):"object"==typeof exports?module.exports=e(require("tether")):t.Drop=e(t.Tether)}(this,function(t){"use strict";function e(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t)){var n=[],o=!0,i=!1,s=void 0;try{for(var r,a=t[Symbol.iterator]();!(o=(r=a.next()).done)&&(n.push(r.value),!e||n.length!==e);o=!0);}catch(d){i=!0,s=d}finally{try{!o&&a["return"]&&a["return"]()}finally{if(i)throw s}}return n}throw new TypeError("Invalid attempt to destructure non-iterable instance")}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)}function i(t){var n=t.split(" "),o=e(n,2),i=o[0],s=o[1];if(["left","right"].indexOf(i)>=0){var r=[s,i];i=r[0],s=r[1]}return[i,s].join(" ")}function s(t,e){for(var n=void 0,o=[];-1!==(n=t.indexOf(e));)o.push(t.splice(n,1));return o}function r(){var e=void 0===arguments[0]?{}:arguments[0],h=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return new(p.apply(b,[null].concat(e)))};l(h,{createContext:r,drops:[],defaults:{}});var m={classPrefix:"drop",defaults:{position:"bottom left",openOn:"click",constrainToScrollParent:!0,constrainToWindow:!0,classes:"",remove:!1,tetherOptions:{}}};l(h,m,e),l(h.defaults,m.defaults,e.defaults),"undefined"==typeof x[h.classPrefix]&&(x[h.classPrefix]=[]),h.updateBodyClasses=function(){for(var t=!1,e=x[h.classPrefix],n=e.length,o=0;n>o;++o)if(e[o].isOpened()){t=!0;break}t?u(document.body,""+h.classPrefix+"-open"):c(document.body,""+h.classPrefix+"-open")};var b=function(e){function r(t){if(n(this,r),d(Object.getPrototypeOf(r.prototype),"constructor",this).call(this),this.options=l({},h.defaults,t),this.target=this.options.target,"undefined"==typeof this.target)throw new Error("Drop Error: You must provide a target.");this.options.classes&&this.options.addTargetClasses!==!1&&u(this.target,this.options.classes),h.drops.push(this),x[h.classPrefix].push(this),this._boundEvents=[],this.bindMethods(),this.setupElements(),this.setupEvents(),this.setupTether()}return o(r,e),a(r,[{key:"_on",value:function(t,e,n){this._boundEvents.push({element:t,event:e,handler:n}),t.addEventListener(e,n)}},{key:"bindMethods",value:function(){this.transitionEndHandler=this._transitionEndHandler.bind(this)}},{key:"setupElements",value:function(){var t=this;if(this.drop=document.createElement("div"),u(this.drop,h.classPrefix),this.options.classes&&u(this.drop,this.options.classes),this.content=document.createElement("div"),u(this.content,""+h.classPrefix+"-content"),"function"==typeof this.options.content){var e=function(){var e=t.options.content.call(t,t);if("string"==typeof e)t.content.innerHTML=e;else{if("object"!=typeof e)throw new Error("Drop Error: Content function should return a string or HTMLElement.");t.content.innerHTML="",t.content.appendChild(e)}};e(),this.on("open",e.bind(this))}else"object"==typeof this.options.content?this.content.appendChild(this.options.content):this.content.innerHTML=this.options.content;this.drop.appendChild(this.content)}},{key:"setupTether",value:function(){var e=this.options.position.split(" ");e[0]=O[e[0]],e=e.join(" ");var n=[];n.push(this.options.constrainToScrollParent?{to:"scrollParent",pin:"top, bottom",attachment:"together none"}:{to:"scrollParent"}),n.push(this.options.constrainToWindow!==!1?{to:"window",attachment:"together"}:{to:"window"});var o={element:this.drop,target:this.target,attachment:i(e),targetAttachment:i(this.options.position),classPrefix:h.classPrefix,offset:"0 0",targetOffset:"0 0",enabled:!1,constraints:n,addTargetClasses:this.options.addTargetClasses};this.options.tetherOptions!==!1&&(this.tether=new t(l({},o,this.options.tetherOptions)))}},{key:"setupEvents",value:function(){var t=this;if(this.options.openOn){if("always"===this.options.openOn)return void setTimeout(this.open.bind(this));var e=this.options.openOn.split(" ");if(e.indexOf("click")>=0)for(var n=function(e){t.toggle(),e.preventDefault()},o=function(e){t.isOpened()&&(e.target===t.drop||t.drop.contains(e.target)||e.target===t.target||t.target.contains(e.target)||t.close())},i=0;i<y.length;++i){var s=y[i];this._on(this.target,s,n),this._on(document,s,o)}e.indexOf("hover")>=0&&!function(){var e=!1,n=function(){e=!0,t.open()},o=null,i=function(){e=!1,"undefined"!=typeof o&&clearTimeout(o),o=setTimeout(function(){e||t.close(),o=null},50)};t._on(t.target,"mouseover",n),t._on(t.drop,"mouseover",n),t._on(t.target,"mouseout",i),t._on(t.drop,"mouseout",i)}()}}},{key:"isOpened",value:function(){return this.drop?f(this.drop,""+h.classPrefix+"-open"):void 0}},{key:"toggle",value:function(){this.isOpened()?this.close():this.open()}},{key:"open",value:function(){var t=this;this.isOpened()||(this.drop.parentNode||document.body.appendChild(this.drop),"undefined"!=typeof this.tether&&this.tether.enable(),u(this.drop,""+h.classPrefix+"-open"),u(this.drop,""+h.classPrefix+"-open-transitionend"),setTimeout(function(){t.drop&&u(t.drop,""+h.classPrefix+"-after-open")}),"undefined"!=typeof this.tether&&this.tether.position(),this.trigger("open"),h.updateBodyClasses())}},{key:"_transitionEndHandler",value:function(){f(this.drop,""+h.classPrefix+"-open")||c(this.drop,""+h.classPrefix+"-open-transitionend"),this.drop.removeEventListener(g,this.transitionEndHandler)}},{key:"close",value:function(){this.isOpened()&&(c(this.drop,""+h.classPrefix+"-open"),c(this.drop,""+h.classPrefix+"-after-open"),this.drop.addEventListener(g,this.transitionEndHandler),this.trigger("close"),"undefined"!=typeof this.tether&&this.tether.disable(),h.updateBodyClasses(),this.options.remove&&this.remove())}},{key:"remove",value:function(){this.close(),this.drop.parentNode&&this.drop.parentNode.removeChild(this.drop)}},{key:"position",value:function(){this.isOpened()&&"undefined"!=typeof this.tether&&this.tether.position()}},{key:"destroy",value:function(){this.remove(),"undefined"!=typeof this.tether&&this.tether.destroy();for(var t=0;t<this._boundEvents.length;++t){var e=this._boundEvents[t],n=e.element,o=e.event,i=e.handler;n.removeEventListener(o,i)}this._boundEvents=[],this.tether=null,this.drop=null,this.content=null,this.target=null,s(x[h.classPrefix],this),s(h.drops,this)}}]),r}(v);return h}var a=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),d=function(t,e,n){for(var o=!0;o;){var i=t,s=e,r=n;a=p=d=void 0,o=!1;var a=Object.getOwnPropertyDescriptor(i,s);if(void 0!==a){if("value"in a)return a.value;var d=a.get;return void 0===d?void 0:d.call(r)}var p=Object.getPrototypeOf(i);if(null===p)return void 0;t=p,e=s,n=r,o=!0}},p=Function.prototype.bind,h=t.Utils,l=h.extend,u=h.addClass,c=h.removeClass,f=h.hasClass,v=h.Evented,y=["click"];"ontouchstart"in document.documentElement&&y.push("touchstart");var m={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"otransitionend",transition:"transitionend"},g="";for(var b in m)if({}.hasOwnProperty.call(m,b)){var E=document.createElement("p");"undefined"!=typeof E.style[b]&&(g=m[b])}var O={left:"right",right:"left",top:"bottom",bottom:"top",middle:"middle",center:"center"},x={},P=r();return document.addEventListener("DOMContentLoaded",function(){P.updateBodyClasses()}),P});
!function(t,e){"function"==typeof define&&define.amd?define(["tether"],e):"object"==typeof exports?module.exports=e(require("tether")):t.Drop=e(t.Tether)}(this,function(t){"use strict";function e(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t)){var n=[],o=!0,i=!1,s=void 0;try{for(var r,a=t[Symbol.iterator]();!(o=(r=a.next()).done)&&(n.push(r.value),!e||n.length!==e);o=!0);}catch(d){i=!0,s=d}finally{try{!o&&a["return"]&&a["return"]()}finally{if(i)throw s}}return n}throw new TypeError("Invalid attempt to destructure non-iterable instance")}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)}function i(t){var n=t.split(" "),o=e(n,2),i=o[0],s=o[1];if(["left","right"].indexOf(i)>=0){var r=[s,i];i=r[0],s=r[1]}return[i,s].join(" ")}function s(t,e){for(var n=void 0,o=[];-1!==(n=t.indexOf(e));)o.push(t.splice(n,1));return o}function r(){var e=void 0===arguments[0]?{}:arguments[0],p=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return new(l.apply(b,[null].concat(e)))};h(p,{createContext:r,drops:[],defaults:{}});var m={classPrefix:"drop",defaults:{position:"bottom left",openOn:"click",beforeClose:null,constrainToScrollParent:!0,constrainToWindow:!0,classes:"",remove:!1,tetherOptions:{}}};h(p,m,e),h(p.defaults,m.defaults,e.defaults),"undefined"==typeof x[p.classPrefix]&&(x[p.classPrefix]=[]),p.updateBodyClasses=function(){for(var t=!1,e=x[p.classPrefix],n=e.length,o=0;n>o;++o)if(e[o].isOpened()){t=!0;break}t?u(document.body,""+p.classPrefix+"-open"):c(document.body,""+p.classPrefix+"-open")};var b=function(e){function r(t){if(n(this,r),d(Object.getPrototypeOf(r.prototype),"constructor",this).call(this),this.options=h({},p.defaults,t),this.target=this.options.target,"undefined"==typeof this.target)throw new Error("Drop Error: You must provide a target.");this.options.classes&&this.options.addTargetClasses!==!1&&u(this.target,this.options.classes),p.drops.push(this),x[p.classPrefix].push(this),this._boundEvents=[],this.bindMethods(),this.setupElements(),this.setupEvents(),this.setupTether()}return o(r,e),a(r,[{key:"_on",value:function(t,e,n){this._boundEvents.push({element:t,event:e,handler:n}),t.addEventListener(e,n)}},{key:"bindMethods",value:function(){this.transitionEndHandler=this._transitionEndHandler.bind(this)}},{key:"setupElements",value:function(){var t=this;if(this.drop=document.createElement("div"),u(this.drop,p.classPrefix),this.options.classes&&u(this.drop,this.options.classes),this.content=document.createElement("div"),u(this.content,""+p.classPrefix+"-content"),"function"==typeof this.options.content){var e=function(){var e=t.options.content.call(t,t);if("string"==typeof e)t.content.innerHTML=e;else{if("object"!=typeof e)throw new Error("Drop Error: Content function should return a string or HTMLElement.");t.content.innerHTML="",t.content.appendChild(e)}};e(),this.on("open",e.bind(this))}else"object"==typeof this.options.content?this.content.appendChild(this.options.content):this.content.innerHTML=this.options.content;this.drop.appendChild(this.content)}},{key:"setupTether",value:function(){var e=this.options.position.split(" ");e[0]=O[e[0]],e=e.join(" ");var n=[];n.push(this.options.constrainToScrollParent?{to:"scrollParent",pin:"top, bottom",attachment:"together none"}:{to:"scrollParent"}),n.push(this.options.constrainToWindow!==!1?{to:"window",attachment:"together"}:{to:"window"});var o={element:this.drop,target:this.target,attachment:i(e),targetAttachment:i(this.options.position),classPrefix:p.classPrefix,offset:"0 0",targetOffset:"0 0",enabled:!1,constraints:n,addTargetClasses:this.options.addTargetClasses};this.options.tetherOptions!==!1&&(this.tether=new t(h({},o,this.options.tetherOptions)))}},{key:"setupEvents",value:function(){var t=this;if(this.options.openOn){if("always"===this.options.openOn)return void setTimeout(this.open.bind(this));var e=this.options.openOn.split(" ");if(e.indexOf("click")>=0)for(var n=function(e){t.toggle(),e.preventDefault()},o=function(e){t.isOpened()&&(e.target===t.drop||t.drop.contains(e.target)||e.target===t.target||t.target.contains(e.target)||t.close())},i=0;i<y.length;++i){var s=y[i];this._on(this.target,s,n),this._on(document,s,o)}e.indexOf("hover")>=0&&!function(){var e=!1,n=function(){e=!0,t.open()},o=null,i=function(){e=!1,"undefined"!=typeof o&&clearTimeout(o),o=setTimeout(function(){e||t.close(),o=null},50)};t._on(t.target,"mouseover",n),t._on(t.drop,"mouseover",n),t._on(t.target,"mouseout",i),t._on(t.drop,"mouseout",i)}()}}},{key:"isOpened",value:function(){return this.drop?f(this.drop,""+p.classPrefix+"-open"):void 0}},{key:"toggle",value:function(){this.isOpened()?this.close():this.open()}},{key:"open",value:function(){var t=this;this.isOpened()||(this.drop.parentNode||document.body.appendChild(this.drop),"undefined"!=typeof this.tether&&this.tether.enable(),u(this.drop,""+p.classPrefix+"-open"),u(this.drop,""+p.classPrefix+"-open-transitionend"),setTimeout(function(){t.drop&&u(t.drop,""+p.classPrefix+"-after-open")}),"undefined"!=typeof this.tether&&this.tether.position(),this.trigger("open"),p.updateBodyClasses())}},{key:"_transitionEndHandler",value:function(){f(this.drop,""+p.classPrefix+"-open")||c(this.drop,""+p.classPrefix+"-open-transitionend"),this.drop.removeEventListener(g,this.transitionEndHandler)}},{key:"close",value:function(){if(this.isOpened()){var t=this.options,e=t.remove,n=t.beforeClose;("function"!=typeof n||n()!==!1)&&(c(this.drop,""+p.classPrefix+"-open"),c(this.drop,""+p.classPrefix+"-after-open"),this.drop.addEventListener(g,this.transitionEndHandler),this.trigger("close"),"undefined"!=typeof this.tether&&this.tether.disable(),p.updateBodyClasses(),e&&this.remove())}}},{key:"remove",value:function(){this.close(),this.drop.parentNode&&this.drop.parentNode.removeChild(this.drop)}},{key:"position",value:function(){this.isOpened()&&"undefined"!=typeof this.tether&&this.tether.position()}},{key:"destroy",value:function(){this.remove(),"undefined"!=typeof this.tether&&this.tether.destroy();for(var t=0;t<this._boundEvents.length;++t){var e=this._boundEvents[t],n=e.element,o=e.event,i=e.handler;n.removeEventListener(o,i)}this._boundEvents=[],this.tether=null,this.drop=null,this.content=null,this.target=null,s(x[p.classPrefix],this),s(p.drops,this)}}]),r}(v);return p}var a=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),d=function(t,e,n){for(var o=!0;o;){var i=t,s=e,r=n;a=l=d=void 0,o=!1;var a=Object.getOwnPropertyDescriptor(i,s);if(void 0!==a){if("value"in a)return a.value;var d=a.get;return void 0===d?void 0:d.call(r)}var l=Object.getPrototypeOf(i);if(null===l)return void 0;t=l,e=s,n=r,o=!0}},l=Function.prototype.bind,p=t.Utils,h=p.extend,u=p.addClass,c=p.removeClass,f=p.hasClass,v=p.Evented,y=["click"];"ontouchstart"in document.documentElement&&y.push("touchstart");var m={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"otransitionend",transition:"transitionend"},g="";for(var b in m)if({}.hasOwnProperty.call(m,b)){var E=document.createElement("p");"undefined"!=typeof E.style[b]&&(g=m[b])}var O={left:"right",right:"left",top:"bottom",bottom:"top",middle:"middle",center:"center"},x={},P=r();return document.addEventListener("DOMContentLoaded",function(){P.updateBodyClasses()}),P});

@@ -1,5 +0,6 @@

<link rel="stylesheet" href="/drop/css/drop-theme-basic.css" />
<link rel="stylesheet" href="/drop/css/drop-theme-arrows-bounce.css" />
<link rel="stylesheet" href="/drop/css/drop-theme-arrows-bounce-dark.css" />
<script src="/drop/drop.min.js"></script>
<link rel="stylesheet" href="/drop/dist/css/drop-theme-basic.css" />
<link rel="stylesheet" href="/drop/dist/css/drop-theme-arrows-bounce.css" />
<link rel="stylesheet" href="/drop/dist/css/drop-theme-arrows-bounce-dark.css" />
<script src="/drop/bower_components/tether/dist/js/tether.js"></script>
<script src="/drop/dist/js/drop.min.js"></script>
<script>

@@ -166,2 +167,7 @@ $(function(){

#### `beforeClose`
Function that is run before closing the drop. If the function returns `false`, the closing of the drop will be prevented. Useful if you only want to programatically close the drop.
#### `tetherOptions`

@@ -168,0 +174,0 @@

@@ -5,3 +5,2 @@ var del = require('del');

var bump = require('gulp-bump');
var filter = require('gulp-filter');
var header = require('gulp-header');

@@ -13,3 +12,2 @@ var minify = require('gulp-minify-css');

var sass = require('gulp-sass');
var tagVersion = require('gulp-tag-version');
var umd = require('gulp-wrap-umd');

@@ -79,10 +77,6 @@

(function(version) {
var pkgFilter = filter('package.json');
gulp.task('version:' + version, function() {
gulp.src(['package.json', 'bower.json'])
.pipe(bump({type: version}))
.pipe(pkgFilter)
.pipe(tagVersion())
.pipe(pkgFilter.restore())
.pipe(gulp.dest('.'))
.pipe(gulp.dest('.'));
});

@@ -101,4 +95,4 @@ })(VERSIONS[i]);

// Defaults
gulp.task('build', ['js', 'css'])
gulp.task('default', ['build'])
gulp.task('build', ['js', 'css']);
gulp.task('default', ['build']);
{
"name": "tether-drop",
"version": "1.1.2",
"version": "1.2.0",
"description": "Client-side library for creating dropdowns",

@@ -24,3 +24,2 @@ "authors": [

"gulp-bump": "^0.3.0",
"gulp-filter": "^2.0.2",
"gulp-header": "^1.2.2",

@@ -30,3 +29,2 @@ "gulp-minify-css": "^1.1.6",

"gulp-sass": "^2.0.1",
"gulp-tag-version": "^1.2.1",
"gulp-uglify": "^1.2.0",

@@ -33,0 +31,0 @@ "gulp-wrap-umd": "^0.2.1"

@@ -79,2 +79,3 @@ /* global Tether */

openOn: 'click',
beforeClose: null,
constrainToScrollParent: true,

@@ -372,2 +373,7 @@ constrainToWindow: true,

const {remove, beforeClose} = this.options;
if (typeof beforeClose === 'function' && beforeClose() === false) {
return;
}
removeClass(this.drop, `${ drop.classPrefix }-open`);

@@ -386,3 +392,3 @@ removeClass(this.drop, `${ drop.classPrefix }-after-open`);

if (this.options.remove) {
if (remove) {
this.remove();

@@ -389,0 +395,0 @@ }

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