funda-ui
Version:
React components using pure Bootstrap 5+ which does not contain any external style and script libraries.
189 lines (183 loc) • 6.92 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["RPB"] = factory();
else
root["RPB"] = factory();
})(this, () => {
return /******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ // The require scope
/******/ var __webpack_require__ = {};
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "getAbsoluteCoordinates": () => (/* binding */ getAbsoluteCoordinates),
/* harmony export */ "getAbsolutePositionOfStage": () => (/* binding */ getAbsolutePositionOfStage),
/* harmony export */ "getOffset": () => (/* binding */ getOffset),
/* harmony export */ "getPosition": () => (/* binding */ getPosition),
/* harmony export */ "getTransitionDuration": () => (/* binding */ getTransitionDuration)
/* harmony export */ });
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
/**
* Get the -webkit-transition-duration property
*
* @param {HTMLElement} el - A DOM node containing one selector to match against.
* @return {number} - Returns a pure number.
*/
function getTransitionDuration(el) {
if (_typeof(el) === ( true ? "undefined" : 0)) {
return 0;
}
var style = window.getComputedStyle(el),
duration = style.webkitTransitionDuration,
delay = style.webkitTransitionDelay;
if (_typeof(duration) != ( true ? "undefined" : 0)) {
// fix miliseconds vs seconds
duration = duration.indexOf("ms") > -1 ? parseFloat(duration) : parseFloat(duration) * 1000;
delay = delay.indexOf("ms") > -1 ? parseFloat(delay) : parseFloat(delay) * 1000;
return duration;
} else {
return 0;
}
}
/**
* Get an object's absolute position on the page
*
* @param {HTMLElement} el - A DOM node containing one selector to match against.
* @return {Json} - An object containing the properties top and left.
*/
function getAbsoluteCoordinates(el) {
var windowWidth = window.innerWidth,
leftPos = null,
topPos = null;
var pEl = el.parentElement;
if (!document.getElementsByTagName('body')[0].className.match(/rtl/)) {
leftPos = el.offsetLeft == 0 ? pEl.offsetLeft : el.offsetLeft;
topPos = el.offsetTop == 0 ? pEl.offsetTop : el.offsetTop;
} else {
// width and height in pixels, including padding and border
// Corresponds to outerWidth(), outerHeight()
leftPos = el.offsetLeft == 0 ? windowWidth - (pEl.offsetLeft + pEl.offsetWidth) : windowWidth - (el.offsetLeft + el.offsetWidth);
topPos = el.offsetTop == 0 ? windowWidth - (pEl.offsetTop + pEl.offsetHeight) : windowWidth - (el.offsetTop + el.offsetHeight);
}
return {
'left': leftPos,
'top': topPos
};
}
/**
* Get the current coordinates of the first element in the set of matched elements, relative to the document.
*
* @param {Element} el - A DOM node containing one selector to match against.
* @return {Json} - An object containing the properties top and left.
*/
function getOffset(el) {
var res = {
top: 0,
left: 0
};
var box = el.getBoundingClientRect();
var top = 0,
left = 0;
//Include scrollbar and border
top = box.top + window.pageYOffset - document.documentElement.clientTop;
left = box.left + window.pageXOffset - document.documentElement.clientLeft;
res = {
top: top,
left: left
};
return res;
}
/**
* Get the current coordinates of the first element in the set of matched elements, relative to the offset parent.
*
* @param {HTMLElement} el - A DOM node containing one selector to match against.
* @return {Json} - An object containing the properties top and left.
*/
function getPosition(el) {
var res = {
top: 0,
left: 0
};
var top = el.offsetTop ? el.offsetTop : 0,
left = el.offsetLeft ? el.offsetLeft : 0;
res = {
top: top,
left: left
};
return res;
}
/**
* Get the absolute position of the stage element
*
* @param {HTMLElement} domElement - A DOM node
* @param {Number | string} left - left offset
* @param {Number | string} top - top offset
* @returns
*/
function getAbsolutePositionOfStage(domElement) {
var left = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var top = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
if (!parseInt(left)) {
left = 0;
} else {
left = parseInt(left);
}
if (!parseInt(top)) {
top = 0;
} else {
top = parseInt(top);
}
var box = domElement.getBoundingClientRect();
var body = document.body;
var docElem = document.documentElement;
var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop;
var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft;
var clientTop = docElem.clientTop || body.clientTop || 0;
var clientLeft = docElem.clientLeft || body.clientLeft || 0;
var attr = {};
attr.y = box.top + scrollTop - clientTop + top;
attr.x = box.left + scrollLeft - clientLeft + left;
attr.width = box.width;
attr.height = box.height;
return attr;
}
/******/ return __webpack_exports__;
/******/ })()
;
});