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CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAA;AACrC,GAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,GAAG,OAAO,CAAA;AAChC,GAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,GAAG,YAAY;AAClC,KAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAA;AAC/B,WAAO,OAAO,CAAC,gBAAgB,CAAA;GAChC,CAAA;;AAED,SAAO,OAAO,CAAA;CAEf,CAAA,CAAE,MAAM,CAAC,CAAA","file":"ripples.js","sourcesContent":["const Ripples = (($) => {\n\n\n /**\n * ------------------------------------------------------------------------\n * Constants\n * ------------------------------------------------------------------------\n */\n const NAME = 'ripples'\n const DATA_KEY = `bmd.${NAME}`\n const EVENT_KEY = `.${DATA_KEY}`\n const DATA_API_KEY = '.data-api'\n const JQUERY_NO_CONFLICT = $.fn[NAME]\n const DEFAULT_OPTIONS = {}\n\n const Selector = {\n DATA_DISMISS: '[data-dismiss=\"ripples\"]'\n }\n\n const Event = {\n CLOSE: `close${EVENT_KEY}`,\n CLOSED: `closed${EVENT_KEY}`,\n CLICK_DATA_API: `click${EVENT_KEY}${DATA_API_KEY}`\n }\n\n\n /**\n * ------------------------------------------------------------------------\n * Class Definition\n * ------------------------------------------------------------------------\n */\n class Ripples {\n\n constructor(element, options) {\n this._element = $(element);\n this._options = $.extend({}, DEFAULT_OPTIONS, options);\n\n this._element.on(\"mousedown touchstart\", this._createRipple);\n }\n\n // getters\n static get NAME() {\n return NAME\n }\n\n // public\n close(element) {\n element = element || this._element\n\n let rootElement = this._getRootElement(element)\n let customEvent = this._triggerCloseEvent(rootElement)\n\n if (customEvent.isDefaultPrevented()) {\n return\n }\n\n this._removeElement(rootElement)\n }\n\n dispose() {\n $.removeData(this._element, DATA_KEY)\n this._element = null\n }\n\n\n // ------------------------------------------------------------------------\n // private\n\n _createRipple(event) {\n\n /**\n * Verify if the user is just touching on a device and return if so\n */\n if (this.isTouch() && event.type === \"mousedown\") {\n return;\n }\n\n\n /**\n * Verify if the current element already has a ripple wrapper element and\n * creates if it doesn't\n */\n if (!(this._element.find(\".ripple-container\").length)) {\n this._element.append(\"<div class=\\\"ripple-container\\\"></div>\");\n }\n\n\n /**\n * Find the ripple wrapper\n */\n var $container = this._element.children(\".ripple-container\");\n\n\n /**\n * Get relY and relX positions\n */\n var relY = this._getRelY($container, event);\n var relX = this._getRelX($container, event);\n\n\n /**\n * If relY and/or relX are false, return the event\n */\n if (!relY && !relX) {\n return;\n }\n\n\n /**\n * Get the ripple color\n */\n var rippleColor = this._getRipplesColor(this._element);\n\n\n /**\n * Create the ripple element\n */\n var $ripple = $(\"<div></div>\");\n\n $ripple\n .addClass(\"ripple\")\n .css({\n \"left\": relX,\n \"top\": relY,\n \"background-color\": rippleColor\n });\n\n\n /**\n * Append the ripple to the wrapper\n */\n $container.append($ripple);\n\n\n /**\n * Make sure the ripple has the styles applied (ugly hack but it works)\n */\n (function () {\n return window.getComputedStyle($ripple[0]).opacity;\n })();\n\n\n /**\n * Turn on the ripple animation\n */\n this.rippleOn(this._element, $ripple);\n\n\n /**\n * Call the rippleEnd function when the transition \"on\" ends\n */\n setTimeout(function () {\n this.rippleEnd($ripple);\n }, 500);\n\n\n /**\n * Detect when the user leaves the element\n */\n this._element.on(\"mouseup mouseleave touchend\", function () {\n $ripple.data(\"mousedown\", \"off\");\n\n if ($ripple.data(\"animating\") === \"off\") {\n this.rippleOut($ripple);\n }\n });\n }\n\n\n /**\n * Get the relX\n */\n _getRelX($container, event) {\n var wrapperOffset = $container.offset();\n\n if (!this.isTouch()) {\n /**\n * Get the mouse position relative to the ripple wrapper\n */\n return event.pageX - wrapperOffset.left;\n } else {\n /**\n * Make sure the user is using only one finger and then get the touch\n * position relative to the ripple wrapper\n */\n event = event.originalEvent;\n\n if (event.touches.length === 1) {\n return event.touches[0].pageX - wrapperOffset.left;\n }\n\n return false;\n }\n }\n\n\n /**\n * Get the relY\n */\n _getRelY($container, event) {\n var wrapperOffset = $container.offset();\n\n if (!this.isTouch()) {\n /**\n * Get the mouse position relative to the ripple wrapper\n */\n return event.pageY - wrapperOffset.top;\n } else {\n /**\n * Make sure the user is using only one finger and then get the touch\n * position relative to the ripple wrapper\n */\n event = event.originalEvent;\n\n if (event.touches.length === 1) {\n return event.touches[0].pageY - wrapperOffset.top;\n }\n\n return false;\n }\n }\n\n\n /**\n * Get the ripple color\n */\n _getRipplesColor($element) {\n\n var color = $element.data(\"ripple-color\") ? $element.data(\"ripple-color\") : window.getComputedStyle($element[0]).color;\n\n return color;\n }\n\n\n /**\n * Verify if the client browser has transistion support\n */\n _hasTransitionSupport() {\n var thisBody = document.body || document.documentElement;\n var thisStyle = thisBody.style;\n\n var support = (\n thisStyle.transition !== undefined ||\n thisStyle.WebkitTransition !== undefined ||\n thisStyle.MozTransition !== undefined ||\n thisStyle.MsTransition !== undefined ||\n thisStyle.OTransition !== undefined\n );\n\n return support;\n }\n\n\n /**\n * Verify if the client is using a mobile device\n */\n isTouch() {\n return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);\n }\n\n\n /**\n * End the animation of the ripple\n */\n rippleEnd($ripple) {\n $ripple.data(\"animating\", \"off\");\n\n if ($ripple.data(\"mousedown\") === \"off\") {\n this.rippleOut($ripple);\n }\n }\n\n\n /**\n * Turn off the ripple effect\n */\n rippleOut($ripple) {\n $ripple.off();\n\n if (this._hasTransitionSupport()) {\n $ripple.addClass(\"ripple-out\");\n } else {\n $ripple.animate({\"opacity\": 0}, 100, function () {\n $ripple.trigger(\"transitionend\");\n });\n }\n\n $ripple.on(\"transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd\", function () {\n $ripple.remove();\n });\n }\n\n\n /**\n * Turn on the ripple effect\n */\n rippleOn($element, $ripple) {\n var size = this._getNewSize($element, $ripple);\n\n if (this._hasTransitionSupport()) {\n $ripple\n .css({\n \"-ms-transform\": \"scale(\" + size + \")\",\n \"-moz-transform\": \"scale(\" + size + \")\",\n \"-webkit-transform\": \"scale(\" + size + \")\",\n \"transform\": \"scale(\" + size + \")\"\n })\n .addClass(\"ripple-on\")\n .data(\"animating\", \"on\")\n .data(\"mousedown\", \"on\");\n } else {\n $ripple.animate({\n \"width\": Math.max($element.outerWidth(), $element.outerHeight()) * 2,\n \"height\": Math.max($element.outerWidth(), $element.outerHeight()) * 2,\n \"margin-left\": Math.max($element.outerWidth(), $element.outerHeight()) * (-1),\n \"margin-top\": Math.max($element.outerWidth(), $element.outerHeight()) * (-1),\n \"opacity\": 0.2\n }, 500, function () {\n $ripple.trigger(\"transitionend\");\n });\n }\n }\n\n\n // ------------------------------------------------------------------------\n // static\n /**\n * Get the new size based on the element height/width and the ripple width\n */\n static _getNewSize($element, $ripple) {\n return (Math.max($element.outerWidth(), $element.outerHeight()) / $ripple.outerWidth()) * 2.5\n }\n\n\n static _jQueryInterface(options) {\n return this.each(function () {\n let $element = $(this)\n let data = $element.data(DATA_KEY)\n\n if (!data) {\n data = new Ripples(this, options)\n $element.data(DATA_KEY, data)\n }\n })\n }\n\n //static _handleClose(fooInstance) {\n // return function (event) {\n // if (event) {\n // event.preventDefault()\n // }\n //\n // fooInstance.close(this)\n // }\n //}\n }\n\n\n /**\n * ------------------------------------------------------------------------\n * Data Api implementation\n * ------------------------------------------------------------------------\n */\n\n //$(document).on(\n // Event.CLICK_DATA_API,\n // Selector.DATA_DISMISS,\n // Ripples._handleClose(new Ripples())\n //)\n\n\n /**\n * ------------------------------------------------------------------------\n * jQuery\n * ------------------------------------------------------------------------\n */\n $.fn[NAME] = Ripples._jQueryInterface\n $.fn[NAME].Constructor = Ripples\n $.fn[NAME].noConflict = function () {\n $.fn[NAME] = JQUERY_NO_CONFLICT\n return Ripples._jQueryInterface\n }\n\n return Ripples\n\n})(jQuery)\n\nexport default Ripples\n"]} |