tether-drop
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "tether-drop", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"homepage": "https://github.com/HubSpot/drop", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -1,2 +0,2 @@ | ||
/*! tether-drop 1.1.0 */ | ||
/*! tether-drop 1.1.1 */ | ||
@@ -77,3 +77,3 @@ (function(root, factory) { | ||
var tempEl = document.createElement('p'); | ||
if (tempEl.style[_name] !== 'undefined') { | ||
if (typeof tempEl.style[_name] !== 'undefined') { | ||
transitionEndEvent = transitionEndEvents[_name]; | ||
@@ -80,0 +80,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,r=void 0;try{for(var s,a=t[Symbol.iterator]();!(o=(s=a.next()).done)&&(n.push(s.value),!e||n.length!==e);o=!0);}catch(p){i=!0,r=p}finally{try{!o&&a["return"]&&a["return"]()}finally{if(i)throw r}}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],r=o[1];if(["left","right"].indexOf(i)>=0){var s=[r,i];i=s[0],r=s[1]}return[i,r].join(" ")}function r(t,e){for(var n=void 0,o=[];-1!==(n=t.indexOf(e));)o.push(t.splice(n,1));return o}function s(){var e=void 0===arguments[0]?{}:arguments[0],d=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return new(u.apply(b,[null].concat(e)))};l(d,{createContext:s,drops:[],defaults:{}});var m={classPrefix:"drop",defaults:{position:"bottom left",openOn:"click",constrainToScrollParent:!0,constrainToWindow:!0,classes:"",remove:!1,tetherOptions:{}}};l(d,m,e),l(d.defaults,m.defaults,e.defaults),"undefined"==typeof P[d.classPrefix]&&(P[d.classPrefix]=[]),d.updateBodyClasses=function(){for(var t=!1,e=P[d.classPrefix],n=e.length,o=0;n>o;++o)if(e[o].isOpened()){t=!0;break}t?h(document.body,""+d.classPrefix+"-open"):c(document.body,""+d.classPrefix+"-open")};var b=function(e){function s(t){if(n(this,s),p(Object.getPrototypeOf(s.prototype),"constructor",this).call(this),this.options=l({},d.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&&h(this.target,this.options.classes),d.drops.push(this),P[d.classPrefix].push(this),this._boundEvents=[],this.setupElements(),this.setupEvents(),this.setupTether()}return o(s,e),a(s,[{key:"_on",value:function(t,e,n){this._boundEvents.push({element:t,event:e,handler:n}),t.addEventListener(e,n)}},{key:"setupElements",value:function(){var t=this;if(this.drop=document.createElement("div"),h(this.drop,d.classPrefix),this.options.classes&&h(this.drop,this.options.classes),this.content=document.createElement("div"),h(this.content,""+d.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]=x[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:d.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 r=y[i];this._on(this.target,r,n),this._on(document,r,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,""+d.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(),h(this.drop,""+d.classPrefix+"-open"),h(this.drop,""+d.classPrefix+"-open-transitionend"),setTimeout(function(){t.drop&&h(t.drop,""+d.classPrefix+"-after-open")}),"undefined"!=typeof this.tether&&this.tether.position(),this.trigger("open"),d.updateBodyClasses())}},{key:"close",value:function(){var t=this;if(this.isOpened()){c(this.drop,""+d.classPrefix+"-open"),c(this.drop,""+d.classPrefix+"-after-open");var e=function n(){f(t.drop,""+d.classPrefix+"-open")||c(t.drop,""+d.classPrefix+"-open-transitionend"),t.drop.removeEventListener(g,n)};this.drop.addEventListener(g,e),this.trigger("close"),"undefined"!=typeof this.tether&&this.tether.disable(),d.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,r(P[d.classPrefix],this),r(d.drops,this)}}]),s}(v);return d}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}}(),p=function(t,e,n){for(var o=!0;o;){var i=t,r=e,s=n;a=u=p=void 0,o=!1;var a=Object.getOwnPropertyDescriptor(i,r);if(void 0!==a){if("value"in a)return a.value;var p=a.get;return void 0===p?void 0:p.call(s)}var u=Object.getPrototypeOf(i);if(null===u)return void 0;t=u,e=r,n=s,o=!0}},u=Function.prototype.bind,d=t.Utils,l=d.extend,h=d.addClass,c=d.removeClass,f=d.hasClass,v=d.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 O=document.createElement("p");"undefined"!==O.style[b]&&(g=m[b])}var x={left:"right",right:"left",top:"bottom",bottom:"top",middle:"middle",center:"center"},P={},E=s();return document.addEventListener("DOMContentLoaded",function(){E.updateBodyClasses()}),E}); | ||
!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,r=void 0;try{for(var s,a=t[Symbol.iterator]();!(o=(s=a.next()).done)&&(n.push(s.value),!e||n.length!==e);o=!0);}catch(p){i=!0,r=p}finally{try{!o&&a["return"]&&a["return"]()}finally{if(i)throw r}}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],r=o[1];if(["left","right"].indexOf(i)>=0){var s=[r,i];i=s[0],r=s[1]}return[i,r].join(" ")}function r(t,e){for(var n=void 0,o=[];-1!==(n=t.indexOf(e));)o.push(t.splice(n,1));return o}function s(){var e=void 0===arguments[0]?{}:arguments[0],d=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return new(u.apply(b,[null].concat(e)))};l(d,{createContext:s,drops:[],defaults:{}});var m={classPrefix:"drop",defaults:{position:"bottom left",openOn:"click",constrainToScrollParent:!0,constrainToWindow:!0,classes:"",remove:!1,tetherOptions:{}}};l(d,m,e),l(d.defaults,m.defaults,e.defaults),"undefined"==typeof P[d.classPrefix]&&(P[d.classPrefix]=[]),d.updateBodyClasses=function(){for(var t=!1,e=P[d.classPrefix],n=e.length,o=0;n>o;++o)if(e[o].isOpened()){t=!0;break}t?h(document.body,""+d.classPrefix+"-open"):c(document.body,""+d.classPrefix+"-open")};var b=function(e){function s(t){if(n(this,s),p(Object.getPrototypeOf(s.prototype),"constructor",this).call(this),this.options=l({},d.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&&h(this.target,this.options.classes),d.drops.push(this),P[d.classPrefix].push(this),this._boundEvents=[],this.setupElements(),this.setupEvents(),this.setupTether()}return o(s,e),a(s,[{key:"_on",value:function(t,e,n){this._boundEvents.push({element:t,event:e,handler:n}),t.addEventListener(e,n)}},{key:"setupElements",value:function(){var t=this;if(this.drop=document.createElement("div"),h(this.drop,d.classPrefix),this.options.classes&&h(this.drop,this.options.classes),this.content=document.createElement("div"),h(this.content,""+d.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]=x[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:d.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 r=y[i];this._on(this.target,r,n),this._on(document,r,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,""+d.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(),h(this.drop,""+d.classPrefix+"-open"),h(this.drop,""+d.classPrefix+"-open-transitionend"),setTimeout(function(){t.drop&&h(t.drop,""+d.classPrefix+"-after-open")}),"undefined"!=typeof this.tether&&this.tether.position(),this.trigger("open"),d.updateBodyClasses())}},{key:"close",value:function(){var t=this;if(this.isOpened()){c(this.drop,""+d.classPrefix+"-open"),c(this.drop,""+d.classPrefix+"-after-open");var e=function n(){f(t.drop,""+d.classPrefix+"-open")||c(t.drop,""+d.classPrefix+"-open-transitionend"),t.drop.removeEventListener(g,n)};this.drop.addEventListener(g,e),this.trigger("close"),"undefined"!=typeof this.tether&&this.tether.disable(),d.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,r(P[d.classPrefix],this),r(d.drops,this)}}]),s}(v);return d}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}}(),p=function(t,e,n){for(var o=!0;o;){var i=t,r=e,s=n;a=u=p=void 0,o=!1;var a=Object.getOwnPropertyDescriptor(i,r);if(void 0!==a){if("value"in a)return a.value;var p=a.get;return void 0===p?void 0:p.call(s)}var u=Object.getPrototypeOf(i);if(null===u)return void 0;t=u,e=r,n=s,o=!0}},u=Function.prototype.bind,d=t.Utils,l=d.extend,h=d.addClass,c=d.removeClass,f=d.hasClass,v=d.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 O=document.createElement("p");"undefined"!=typeof O.style[b]&&(g=m[b])}var x={left:"right",right:"left",top:"bottom",bottom:"top",middle:"middle",center:"center"},P={},E=s();return document.addEventListener("DOMContentLoaded",function(){E.updateBodyClasses()}),E}); |
{ | ||
"name": "tether-drop", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Client-side library for creating dropdowns", | ||
@@ -5,0 +5,0 @@ "authors": [ |
## Drop | ||
[![npm | ||
version](https://badge.fury.io/js/tether-drop.svg)](http://badge.fury.io/js/tether-drop) | ||
[![Bower | ||
version](https://badge.fury.io/bo/tether-drop.svg)](http://badge.fury.io/bo/tether-drop) | ||
Drop.js is a powerful Javascript and CSS library for creating dropdowns and other floating displays. | ||
@@ -4,0 +9,0 @@ |
@@ -44,3 +44,3 @@ /* global Tether */ | ||
let tempEl = document.createElement('p'); | ||
if (tempEl.style[name] !== 'undefined') { | ||
if (typeof tempEl.style[name] !== 'undefined') { | ||
transitionEndEvent = transitionEndEvents[name]; | ||
@@ -47,0 +47,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
735818
56