diff --git a/www/activities/settings/js/settings.js b/www/activities/settings/js/settings.js index 5a701d475..a081163ca 100644 --- a/www/activities/settings/js/settings.js +++ b/www/activities/settings/js/settings.js @@ -254,9 +254,9 @@ app.Settings = { body.className = colourTheme; if (appMode === "system") { - app.f7.enableAutoDarkMode(); // darkModeChange event will handle the rest + app.f7.enableAutoDarkTheme(); // DarkThemeChange event will handle the rest } else { - app.f7.disableAutoDarkMode(); + app.f7.disableAutoDarkTheme(); app.Settings.applyAppMode(appMode); } }, diff --git a/www/assets/framework7/bundle/package.json b/www/assets/framework7/bundle/package.json new file mode 100644 index 000000000..2cdaaea98 --- /dev/null +++ b/www/assets/framework7/bundle/package.json @@ -0,0 +1,8 @@ +{ + "name": "framework7/bundle", + "private": true, + "sideEffects": false, + "main": "../cjs/framework7-bundle.js", + "module": "../esm/framework7-bundle.js", + "typings": "../framework7.d.ts" +} diff --git a/www/assets/framework7/cjs/components/accordion/accordion.js b/www/assets/framework7/cjs/components/accordion/accordion.js new file mode 100644 index 000000000..223b487b4 --- /dev/null +++ b/www/assets/framework7/cjs/components/accordion/accordion.js @@ -0,0 +1,136 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Accordion = { + toggleClicked: function toggleClicked($clickedEl) { + var app = this; + var $accordionItemEl = $clickedEl.closest('.accordion-item').eq(0); + if (!$accordionItemEl.length) $accordionItemEl = $clickedEl.parents('li').eq(0); + var $accordionContent = $clickedEl.parents('.accordion-item-content').eq(0); + + if ($accordionContent.length) { + if ($accordionContent.parents($accordionItemEl).length) return; + } + + if ($clickedEl.parents('li').length > 1 && $clickedEl.parents('li')[0] !== $accordionItemEl[0]) return; + app.accordion.toggle($accordionItemEl); + }, + open: function open(el) { + var app = this; + var $el = (0, _dom.default)(el); + var prevented = false; + + function prevent() { + prevented = true; + } + + $el.trigger('accordion:beforeopen', { + prevent: prevent + }, prevent); + app.emit('accordionBeforeOpen', $el[0], prevent); + if (prevented) return; + var $list = $el.parents('.accordion-list').eq(0); + var $contentEl = $el.children('.accordion-item-content'); + $contentEl.removeAttr('aria-hidden'); + if ($contentEl.length === 0) $contentEl = $el.find('.accordion-item-content'); + if ($contentEl.length === 0) return; + var $openedItem = $list.length > 0 && $el.parent().children('.accordion-item-opened'); + + if ($openedItem.length > 0) { + app.accordion.close($openedItem); + } + + $contentEl.transitionEnd(function () { + if ($el.hasClass('accordion-item-opened')) { + $contentEl.transition(0); + $contentEl.css('height', 'auto'); + (0, _utils.nextFrame)(function () { + $contentEl.transition(''); + $el.trigger('accordion:opened'); + app.emit('accordionOpened', $el[0]); + }); + } else { + $contentEl.css('height', ''); + $el.trigger('accordion:closed'); + app.emit('accordionClosed', $el[0]); + } + }); + $contentEl.css('height', $contentEl[0].scrollHeight + "px"); + $el.trigger('accordion:open'); + $el.addClass('accordion-item-opened'); + app.emit('accordionOpen', $el[0]); + }, + close: function close(el) { + var app = this; + var $el = (0, _dom.default)(el); + var prevented = false; + + function prevent() { + prevented = true; + } + + $el.trigger('accordion:beforeclose', { + prevent: prevent + }, prevent); + app.emit('accordionBeforeClose', $el[0], prevent); + if (prevented) return; + var $contentEl = $el.children('.accordion-item-content'); + if ($contentEl.length === 0) $contentEl = $el.find('.accordion-item-content'); + $el.removeClass('accordion-item-opened'); + $contentEl.attr('aria-hidden', true); + $contentEl.transition(0); + $contentEl.css('height', $contentEl[0].scrollHeight + "px"); // Close + + $contentEl.transitionEnd(function () { + if ($el.hasClass('accordion-item-opened')) { + $contentEl.transition(0); + $contentEl.css('height', 'auto'); + (0, _utils.nextFrame)(function () { + $contentEl.transition(''); + $el.trigger('accordion:opened'); + app.emit('accordionOpened', $el[0]); + }); + } else { + $contentEl.css('height', ''); + $el.trigger('accordion:closed'); + app.emit('accordionClosed', $el[0]); + } + }); + (0, _utils.nextFrame)(function () { + $contentEl.transition(''); + $contentEl.css('height', ''); + $el.trigger('accordion:close'); + app.emit('accordionClose', $el[0]); + }); + }, + toggle: function toggle(el) { + var app = this; + var $el = (0, _dom.default)(el); + if ($el.length === 0) return; + if ($el.hasClass('accordion-item-opened')) app.accordion.close(el);else app.accordion.open(el); + } +}; +var _default = { + name: 'accordion', + create: function create() { + var app = this; + (0, _utils.bindMethods)(app, { + accordion: Accordion + }); + }, + clicks: { + '.accordion-item .item-link, .accordion-item-toggle, .links-list.accordion-list > ul > li > a': function open($clickedEl) { + var app = this; + Accordion.toggleClicked.call(app, $clickedEl); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/actions/actions-class.js b/www/assets/framework7/cjs/components/actions/actions-class.js new file mode 100644 index 000000000..886560b12 --- /dev/null +++ b/www/assets/framework7/cjs/components/actions/actions-class.js @@ -0,0 +1,383 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _getDevice = require("../../shared/get-device"); + +var _utils = require("../../shared/utils"); + +var _modalClass = _interopRequireDefault(require("../modal/modal-class")); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _$jsx = _interopRequireDefault(require("../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Actions = /*#__PURE__*/function (_Modal) { + _inheritsLoose(Actions, _Modal); + + function Actions(app, params) { + var _this; + + var extendedParams = (0, _utils.extend)({ + on: {} + }, app.params.actions, params); // Extends with open/close Modal methods; + + _this = _Modal.call(this, app, extendedParams) || this; + + var actions = _assertThisInitialized(_this); + + var device = (0, _getDevice.getDevice)(); + var window = (0, _ssrWindow.getWindow)(); + var document = (0, _ssrWindow.getDocument)(); + actions.params = extendedParams; // Buttons + + var groups; + + if (actions.params.buttons) { + groups = actions.params.buttons; + if (!Array.isArray(groups[0])) groups = [groups]; + } + + actions.groups = groups; // Find Element + + var $el; + + if (actions.params.el) { + $el = (0, _dom.default)(actions.params.el).eq(0); + } else if (actions.params.content) { + $el = (0, _dom.default)(actions.params.content).filter(function (node) { + return node.nodeType === 1; + }).eq(0); + } else if (actions.params.buttons) { + if (actions.params.convertToPopover) { + actions.popoverHtml = actions.renderPopover(); + } + + actions.actionsHtml = actions.render(); + } + + if ($el && $el.length > 0 && $el[0].f7Modal) { + return $el[0].f7Modal || _assertThisInitialized(_this); + } + + if ($el && $el.length === 0 && !(actions.actionsHtml || actions.popoverHtml)) { + return actions.destroy() || _assertThisInitialized(_this); + } // Backdrop + + + var $backdropEl; + + if (actions.params.backdrop && actions.params.backdropEl) { + $backdropEl = (0, _dom.default)(actions.params.backdropEl); + } else if (actions.params.backdrop) { + $backdropEl = actions.$containerEl.children('.actions-backdrop'); + + if ($backdropEl.length === 0) { + $backdropEl = (0, _dom.default)('
'); + actions.$containerEl.append($backdropEl); + } + } + + var originalOpen = actions.open; + var originalClose = actions.close; + var popover; + + function buttonOnClick(e) { + var $buttonEl = (0, _dom.default)(this); + var buttonIndex; + var groupIndex; + + if ($buttonEl.hasClass('list-button') || $buttonEl.hasClass('item-link')) { + buttonIndex = $buttonEl.parents('li').index(); + groupIndex = $buttonEl.parents('.list').index(); + } else { + buttonIndex = $buttonEl.index(); + groupIndex = $buttonEl.parents('.actions-group').index(); + } + + if (typeof groups !== 'undefined') { + var button = groups[groupIndex][buttonIndex]; + if (button.onClick) button.onClick(actions, e); + if (actions.params.onClick) actions.params.onClick(actions, e); + if (button.close !== false) actions.close(); + } + } + + actions.open = function open(animate) { + var convertToPopover = false; + var _actions$params = actions.params, + targetEl = _actions$params.targetEl, + targetX = _actions$params.targetX, + targetY = _actions$params.targetY, + targetWidth = _actions$params.targetWidth, + targetHeight = _actions$params.targetHeight; + + if (actions.params.convertToPopover && (targetEl || targetX !== undefined && targetY !== undefined)) { + // Popover + if (actions.params.forceToPopover || device.ios && device.ipad || app.width >= 768 || device.desktop && app.theme === 'aurora') { + convertToPopover = true; + } + } + + if (convertToPopover && actions.popoverHtml) { + popover = app.popover.create({ + containerEl: actions.params.containerEl, + content: actions.popoverHtml, + backdrop: actions.params.backdrop, + targetEl: targetEl, + targetX: targetX, + targetY: targetY, + targetWidth: targetWidth, + targetHeight: targetHeight, + on: { + open: function open() { + if (!actions.$el) { + actions.$el = popover.$el; + } + + actions.$el.trigger("modal:open " + actions.type.toLowerCase() + ":open"); + actions.emit("local::open modalOpen " + actions.type + "Open", actions); + }, + opened: function opened() { + if (!actions.$el) { + actions.$el = popover.$el; + } + + actions.$el.trigger("modal:opened " + actions.type.toLowerCase() + ":opened"); + actions.emit("local::opened modalOpened " + actions.type + "Opened", actions); + }, + close: function close() { + if (!actions.$el) { + actions.$el = popover.$el; + } + + actions.$el.trigger("modal:close " + actions.type.toLowerCase() + ":close"); + actions.emit("local::close modalClose " + actions.type + "Close", actions); + }, + closed: function closed() { + if (!actions.$el) { + actions.$el = popover.$el; + } + + actions.$el.trigger("modal:closed " + actions.type.toLowerCase() + ":closed"); + actions.emit("local::closed modalClosed " + actions.type + "Closed", actions); + } + } + }); + popover.open(animate); + popover.once('popoverOpened', function () { + popover.$el.find('.list-button, .item-link').each(function (buttonEl) { + (0, _dom.default)(buttonEl).on('click', buttonOnClick); + }); + }); + popover.once('popoverClosed', function () { + popover.$el.find('.list-button, .item-link').each(function (buttonEl) { + (0, _dom.default)(buttonEl).off('click', buttonOnClick); + }); + (0, _utils.nextTick)(function () { + popover.destroy(); + popover = undefined; + }); + }); + } else { + actions.$el = actions.actionsHtml ? (0, _dom.default)(actions.actionsHtml) : actions.$el; + actions.$el[0].f7Modal = actions; + + if (actions.groups) { + actions.$el.find('.actions-button').each(function (buttonEl) { + (0, _dom.default)(buttonEl).on('click', buttonOnClick); + }); + actions.once('actionsClosed', function () { + actions.$el.find('.actions-button').each(function (buttonEl) { + (0, _dom.default)(buttonEl).off('click', buttonOnClick); + }); + }); + } + + actions.el = actions.$el[0]; + originalOpen.call(actions, animate); + } + + return actions; + }; + + actions.close = function close(animate) { + if (popover) { + popover.close(animate); + } else { + originalClose.call(actions, animate); + } + + return actions; + }; + + (0, _utils.extend)(actions, { + app: app, + $el: $el, + el: $el ? $el[0] : undefined, + $backdropEl: $backdropEl, + backdropEl: $backdropEl && $backdropEl[0], + type: 'actions' + }); + + function handleClick(e) { + var target = e.target; + var $target = (0, _dom.default)(target); + var keyboardOpened = !device.desktop && device.cordova && (window.Keyboard && window.Keyboard.isVisible || window.cordova.plugins && window.cordova.plugins.Keyboard && window.cordova.plugins.Keyboard.isVisible); + if (keyboardOpened) return; + + if ($target.closest(actions.el).length === 0) { + if (actions.params.closeByBackdropClick && actions.params.backdrop && actions.backdropEl && actions.backdropEl === target) { + actions.close(); + } else if (actions.params.closeByOutsideClick) { + actions.close(); + } + } + } + + function onKeyDown(e) { + var keyCode = e.keyCode; + + if (keyCode === 27 && actions.params.closeOnEscape) { + actions.close(); + } + } + + if (actions.params.closeOnEscape) { + actions.on('open', function () { + (0, _dom.default)(document).on('keydown', onKeyDown); + }); + actions.on('close', function () { + (0, _dom.default)(document).off('keydown', onKeyDown); + }); + } + + actions.on('opened', function () { + if (actions.params.closeByBackdropClick || actions.params.closeByOutsideClick) { + app.on('click', handleClick); + } + }); + actions.on('close', function () { + if (actions.params.closeByBackdropClick || actions.params.closeByOutsideClick) { + app.off('click', handleClick); + } + }); + + if ($el) { + $el[0].f7Modal = actions; + } + + return actions || _assertThisInitialized(_this); + } + + var _proto = Actions.prototype; + + _proto.render = function render() { + var actions = this; + if (actions.params.render) return actions.params.render.call(actions, actions); + var groups = actions.groups; + var cssClass = actions.params.cssClass; + return (0, _$jsx.default)("div", { + class: "actions-modal" + (actions.params.grid ? ' actions-grid' : '') + " " + (cssClass || '') + }, groups.map(function (group) { + return (0, _$jsx.default)("div", { + class: "actions-group" + }, group.map(function (button) { + var buttonClasses = ["actions-" + (button.label ? 'label' : 'button')]; + var color = button.color, + bg = button.bg, + bold = button.bold, + disabled = button.disabled, + label = button.label, + text = button.text, + icon = button.icon; + if (color) buttonClasses.push("color-" + color); + if (bg) buttonClasses.push("bg-color-" + bg); + if (bold) buttonClasses.push('actions-button-bold'); + if (disabled) buttonClasses.push('disabled'); + + if (label) { + return (0, _$jsx.default)("div", { + class: buttonClasses.join(' ') + }, text); + } + + return (0, _$jsx.default)("div", { + class: buttonClasses.join(' ') + }, icon && (0, _$jsx.default)("div", { + class: "actions-button-media" + }, icon), (0, _$jsx.default)("div", { + class: "actions-button-text" + }, text)); + })); + })); + }; + + _proto.renderPopover = function renderPopover() { + var actions = this; + if (actions.params.renderPopover) return actions.params.renderPopover.call(actions, actions); + var groups = actions.groups; + var cssClass = actions.params.cssClass; + return (0, _$jsx.default)("div", { + class: "popover popover-from-actions " + (cssClass || '') + }, (0, _$jsx.default)("div", { + class: "popover-inner" + }, groups.map(function (group) { + return (0, _$jsx.default)("div", { + class: "list" + }, (0, _$jsx.default)("ul", null, group.map(function (button) { + var itemClasses = []; + var color = button.color, + bg = button.bg, + bold = button.bold, + disabled = button.disabled, + label = button.label, + text = button.text, + icon = button.icon; + if (color) itemClasses.push("color-" + color); + if (bg) itemClasses.push("bg-color-" + bg); + if (bold) itemClasses.push('popover-from-actions-bold'); + if (disabled) itemClasses.push('disabled'); + + if (label) { + itemClasses.push('popover-from-actions-label'); + return "
  • " + text + "
  • "; + } + + if (icon) { + itemClasses.push('item-link item-content'); + return (0, _$jsx.default)("li", null, (0, _$jsx.default)("a", { + class: itemClasses.join(' ') + }, (0, _$jsx.default)("div", { + class: "item-media" + }, icon), (0, _$jsx.default)("div", { + class: "item-inner" + }, (0, _$jsx.default)("div", { + class: "item-title" + }, text)))); + } + + itemClasses.push('list-button'); + return (0, _$jsx.default)("li", null, (0, _$jsx.default)("a", { + class: itemClasses.join(' ') + }, text)); + }))); + }))); + }; + + return Actions; +}(_modalClass.default); + +var _default = Actions; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/actions/actions.js b/www/assets/framework7/cjs/components/actions/actions.js new file mode 100644 index 000000000..8b1397b1c --- /dev/null +++ b/www/assets/framework7/cjs/components/actions/actions.js @@ -0,0 +1,58 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _actionsClass = _interopRequireDefault(require("./actions-class")); + +var _modalMethods = _interopRequireDefault(require("../../shared/modal-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'actions', + params: { + actions: { + convertToPopover: true, + forceToPopover: false, + backdrop: true, + backdropEl: undefined, + cssClass: null, + closeByBackdropClick: true, + closeOnEscape: false, + render: null, + renderPopover: null, + containerEl: null + } + }, + static: { + Actions: _actionsClass.default + }, + create: function create() { + var app = this; + app.actions = (0, _modalMethods.default)({ + app: app, + constructor: _actionsClass.default, + defaultSelector: '.actions-modal.modal-in' + }); + }, + clicks: { + '.actions-open': function openActions($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.actions.open(data.actions, data.animate, $clickedEl); + }, + '.actions-close': function closeActions($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.actions.close(data.actions, data.animate, $clickedEl); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/app/app-class.js b/www/assets/framework7/cjs/components/app/app-class.js new file mode 100644 index 000000000..b44c4a683 --- /dev/null +++ b/www/assets/framework7/cjs/components/app/app-class.js @@ -0,0 +1,378 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _utils = require("../../shared/utils"); + +var _getDevice = require("../../shared/get-device"); + +var _getSupport = require("../../shared/get-support"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _eventsClass = _interopRequireDefault(require("../../shared/events-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +var _modalMethods = _interopRequireDefault(require("../../shared/modal-methods")); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _loadModule = _interopRequireDefault(require("./load-module")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Framework7 = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(Framework7, _Framework7Class); + + function Framework7(params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params) || this; // eslint-disable-next-line + + if (Framework7.instance && typeof window !== 'undefined') { + throw new Error("Framework7 is already initialized and can't be initialized more than once"); + } + + var device = (0, _getDevice.getDevice)({ + userAgent: params.userAgent || undefined + }); + var support = (0, _getSupport.getSupport)(); + var passedParams = (0, _utils.extend)({}, params); // App Instance + + var app = _assertThisInitialized(_this); + + app.device = device; + app.support = support; + var w = (0, _ssrWindow.getWindow)(); + var d = (0, _ssrWindow.getDocument)(); + Framework7.instance = app; // Default + + var defaults = { + version: '1.0.0', + id: 'io.framework7.myapp', + el: 'body', + theme: 'auto', + language: w.navigator.language, + routes: [], + name: 'Framework7', + lazyModulesPath: null, + initOnDeviceReady: true, + init: true, + autoDarkTheme: false, + iosTranslucentBars: true, + iosTranslucentModals: true, + component: undefined, + componentUrl: undefined, + userAgent: null, + url: null + }; // Extend defaults with modules params + + app.useModulesParams(defaults); // Extend defaults with passed params + + app.params = (0, _utils.extend)(defaults, params); + (0, _utils.extend)(app, { + // App Id + id: app.params.id, + // App Name + name: app.params.name, + // App version + version: app.params.version, + // Routes + routes: app.params.routes, + // Lang + language: app.params.language, + // Theme + theme: function getTheme() { + if (app.params.theme === 'auto') { + if (device.ios) return 'ios'; + if (device.desktop && device.electron) return 'aurora'; + return 'md'; + } + + return app.params.theme; + }(), + // Initially passed parameters + passedParams: passedParams, + online: w.navigator.onLine + }); + if (params.store) app.params.store = params.store; // Save Root + + if (app.$el && app.$el[0]) { + app.$el[0].f7 = app; + } // Install Modules + + + app.useModules(); // Init Store + + app.initStore(); // Init + + if (app.params.init) { + if (device.cordova && app.params.initOnDeviceReady) { + (0, _dom.default)(d).on('deviceready', function () { + app.init(); + }); + } else { + app.init(); + } + } // Return app instance + + + return app || _assertThisInitialized(_this); + } + + var _proto = Framework7.prototype; + + _proto.mount = function mount(rootEl) { + var app = this; + var window = (0, _ssrWindow.getWindow)(); + var document = (0, _ssrWindow.getDocument)(); + var $rootEl = (0, _dom.default)(rootEl || app.params.el).eq(0); + app.$el = $rootEl; + + if (app.$el && app.$el[0]) { + app.el = app.$el[0]; + app.el.f7 = app; + app.rtl = $rootEl.css('direction') === 'rtl'; + } // Auto Dark Theme + + + var DARK = '(prefers-color-scheme: dark)'; + var LIGHT = '(prefers-color-scheme: light)'; + app.mq = {}; + + if (window.matchMedia) { + app.mq.dark = window.matchMedia(DARK); + app.mq.light = window.matchMedia(LIGHT); + } + + app.colorSchemeListener = function colorSchemeListener(_ref) { + var matches = _ref.matches, + media = _ref.media; + + if (!matches) { + return; + } + + var html = document.querySelector('html'); + + if (media === DARK) { + html.classList.add('theme-dark'); + app.darkTheme = true; + app.emit('darkThemeChange', true); + } else if (media === LIGHT) { + html.classList.remove('theme-dark'); + app.darkTheme = false; + app.emit('darkThemeChange', false); + } + }; + + app.emit('mount'); + }; + + _proto.initStore = function initStore() { + var app = this; + + if (typeof app.params.store !== 'undefined' && app.params.store.__store) { + app.store = app.params.store; + } else { + app.store = app.createStore(app.params.store); + } + }; + + _proto.enableAutoDarkTheme = function enableAutoDarkTheme() { + var window = (0, _ssrWindow.getWindow)(); + var document = (0, _ssrWindow.getDocument)(); + if (!window.matchMedia) return; + var app = this; + var html = document.querySelector('html'); + + if (app.mq.dark && app.mq.light) { + app.mq.dark.addListener(app.colorSchemeListener); + app.mq.light.addListener(app.colorSchemeListener); + } + + if (app.mq.dark && app.mq.dark.matches) { + html.classList.add('theme-dark'); + app.darkTheme = true; + app.emit('darkThemeChange', true); + } else if (app.mq.light && app.mq.light.matches) { + html.classList.remove('theme-dark'); + app.darkTheme = false; + app.emit('darkThemeChange', false); + } + }; + + _proto.disableAutoDarkTheme = function disableAutoDarkTheme() { + var window = (0, _ssrWindow.getWindow)(); + if (!window.matchMedia) return; + var app = this; + if (app.mq.dark) app.mq.dark.removeListener(app.colorSchemeListener); + if (app.mq.light) app.mq.light.removeListener(app.colorSchemeListener); + }; + + _proto.initAppComponent = function initAppComponent(callback) { + var app = this; + app.router.componentLoader(app.params.component, app.params.componentUrl, { + componentOptions: { + el: app.$el[0] + } + }, function (el) { + app.$el = (0, _dom.default)(el); + app.$el[0].f7 = app; + app.$elComponent = el.f7Component; + app.el = app.$el[0]; + if (callback) callback(); + }, function () {}); + }; + + _proto.init = function init(rootEl) { + var app = this; + app.mount(rootEl); + + var init = function init() { + if (app.initialized) return; + app.$el.addClass('framework7-initializing'); // RTL attr + + if (app.rtl) { + (0, _dom.default)('html').attr('dir', 'rtl'); + } // Auto Dark Theme + + + if (app.params.autoDarkTheme) { + app.enableAutoDarkTheme(); + } // Watch for online/offline state + + + var window = (0, _ssrWindow.getWindow)(); + window.addEventListener('offline', function () { + app.online = false; + app.emit('offline'); + app.emit('connection', false); + }); + window.addEventListener('online', function () { + app.online = true; + app.emit('online'); + app.emit('connection', true); + }); // Root class + + app.$el.addClass('framework7-root'); // Theme class + + (0, _dom.default)('html').removeClass('ios md aurora').addClass(app.theme); // iOS Translucent + + var device = app.device; + + if (app.params.iosTranslucentBars && app.theme === 'ios' && device.ios) { + (0, _dom.default)('html').addClass('ios-translucent-bars'); + } + + if (app.params.iosTranslucentModals && app.theme === 'ios' && device.ios) { + (0, _dom.default)('html').addClass('ios-translucent-modals'); + } // Init class + + + (0, _utils.nextFrame)(function () { + app.$el.removeClass('framework7-initializing'); + }); // Emit, init other modules + + app.initialized = true; + app.emit('init'); + }; + + if (app.params.component || app.params.componentUrl) { + app.initAppComponent(function () { + init(); + }); + } else { + init(); + } + + return app; + } // eslint-disable-next-line + ; + + _proto.loadModule = function loadModule() { + return Framework7.loadModule.apply(Framework7, arguments); + } // eslint-disable-next-line + ; + + _proto.loadModules = function loadModules() { + return Framework7.loadModules.apply(Framework7, arguments); + }; + + _proto.getVnodeHooks = function getVnodeHooks(hook, id) { + var app = this; + if (!app.vnodeHooks || !app.vnodeHooks[hook]) return []; + return app.vnodeHooks[hook][id] || []; + } // eslint-disable-next-line + ; + + _createClass(Framework7, [{ + key: "$", + get: function get() { + return _dom.default; + } + }], [{ + key: "Dom7", + get: function get() { + return _dom.default; + } + }, { + key: "$", + get: function get() { + return _dom.default; + } + }, { + key: "device", + get: function get() { + return (0, _getDevice.getDevice)(); + } + }, { + key: "support", + get: function get() { + return (0, _getSupport.getSupport)(); + } + }, { + key: "Class", + get: function get() { + return _class.default; + } + }, { + key: "Events", + get: function get() { + return _eventsClass.default; + } + }]); + + return Framework7; +}(_class.default); + +Framework7.ModalMethods = _modalMethods.default; +Framework7.ConstructorMethods = _constructorMethods.default; +Framework7.loadModule = _loadModule.default; + +Framework7.loadModules = function loadModules(modules) { + return Promise.all(modules.map(function (module) { + return Framework7.loadModule(module); + })); +}; + +var _default = Framework7; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/app/load-module.js b/www/assets/framework7/cjs/components/app/load-module.js new file mode 100644 index 000000000..ead837c61 --- /dev/null +++ b/www/assets/framework7/cjs/components/app/load-module.js @@ -0,0 +1,155 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _utils = require("../../shared/utils"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var fetchedModules = []; + +function loadModule(moduleToLoad) { + var Framework7 = this; + var window = (0, _ssrWindow.getWindow)(); + var document = (0, _ssrWindow.getDocument)(); + return new Promise(function (resolve, reject) { + var app = Framework7.instance; + var modulePath; + var moduleObj; + var moduleFunc; + + if (!moduleToLoad) { + reject(new Error('Framework7: Lazy module must be specified')); + return; + } + + function install(module) { + Framework7.use(module); + + if (app) { + app.useModuleParams(module, app.params); + app.useModule(module); + } + } + + if (typeof moduleToLoad === 'string') { + var matchNamePattern = moduleToLoad.match(/([a-z0-9-]*)/i); + + if (moduleToLoad.indexOf('.') < 0 && matchNamePattern && matchNamePattern[0].length === moduleToLoad.length) { + if (!app || app && !app.params.lazyModulesPath) { + reject(new Error('Framework7: "lazyModulesPath" app parameter must be specified to fetch module by name')); + return; + } + + modulePath = app.params.lazyModulesPath + "/" + moduleToLoad + "/" + moduleToLoad + ".js"; + } else { + modulePath = moduleToLoad; + } + } else if (typeof moduleToLoad === 'function') { + moduleFunc = moduleToLoad; + } else { + // considering F7-Plugin object + moduleObj = moduleToLoad; + } + + if (moduleFunc) { + var module = moduleFunc(Framework7, false); + + if (!module) { + reject(new Error("Framework7: Can't find Framework7 component in specified component function")); + return; + } // Check if it was added + + + if (Framework7.prototype.modules && Framework7.prototype.modules[module.name]) { + resolve(); + return; + } // Install It + + + install(module); + resolve(); + } + + if (moduleObj) { + var _module = moduleObj; + + if (!_module) { + reject(new Error("Framework7: Can't find Framework7 component in specified component")); + return; + } // Check if it was added + + + if (Framework7.prototype.modules && Framework7.prototype.modules[_module.name]) { + resolve(); + return; + } // Install It + + + install(_module); + resolve(); + } + + if (modulePath) { + if (fetchedModules.indexOf(modulePath) >= 0) { + resolve(); + return; + } + + fetchedModules.push(modulePath); + var scriptLoad = new Promise(function (resolveScript, rejectScript) { + Framework7.request.get(modulePath, function (scriptContent) { + var callbackId = (0, _utils.id)(); + var callbackLoadName = "f7_component_loader_callback_" + callbackId; + var scriptEl = document.createElement('script'); + scriptEl.innerHTML = "window." + callbackLoadName + " = function (Framework7, Framework7AutoInstallComponent) {return " + scriptContent.trim() + "}"; + (0, _dom.default)('head').append(scriptEl); + var componentLoader = window[callbackLoadName]; + delete window[callbackLoadName]; + (0, _dom.default)(scriptEl).remove(); + var module = componentLoader(Framework7, false); + + if (!module) { + rejectScript(new Error("Framework7: Can't find Framework7 component in " + modulePath + " file")); + return; + } // Check if it was added + + + if (Framework7.prototype.modules && Framework7.prototype.modules[module.name]) { + resolveScript(); + return; + } // Install It + + + install(module); + resolveScript(); + }, function (xhr, status) { + rejectScript(xhr, status); + }); + }); + var styleLoad = new Promise(function (resolveStyle) { + Framework7.request.get(modulePath.replace('.js', app.rtl ? '.rtl.css' : '.css'), function (styleContent) { + var styleEl = document.createElement('style'); + styleEl.innerHTML = styleContent; + (0, _dom.default)('head').append(styleEl); + resolveStyle(); + }, function () { + resolveStyle(); + }); + }); + Promise.all([scriptLoad, styleLoad]).then(function () { + resolve(); + }).catch(function (err) { + reject(err); + }); + } + }); +} + +var _default = loadModule; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/appbar/appbar.js b/www/assets/framework7/cjs/components/appbar/appbar.js new file mode 100644 index 000000000..c62c4ad68 --- /dev/null +++ b/www/assets/framework7/cjs/components/appbar/appbar.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _default = { + name: 'appbar' +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/area-chart/area-chart-class.js b/www/assets/framework7/cjs/components/area-chart/area-chart-class.js new file mode 100644 index 000000000..744c95eff --- /dev/null +++ b/www/assets/framework7/cjs/components/area-chart/area-chart-class.js @@ -0,0 +1,526 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _$jsx = _interopRequireDefault(require("../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var AreaChart = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(AreaChart, _Framework7Class); + + function AreaChart(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params, [app]) || this; + + var self = _assertThisInitialized(_this); + + var defaults = (0, _utils.extend)({}, app.params.areaChart); // Extend defaults with modules params + + self.useModulesParams(defaults); + self.params = (0, _utils.extend)(defaults, params); + var el = self.params.el; + if (!el) return self || _assertThisInitialized(_this); + var $el = (0, _dom.default)(el); + if ($el.length === 0) return self || _assertThisInitialized(_this); + if ($el[0].f7AreaChart) return $el[0].f7AreaChart || _assertThisInitialized(_this); + (0, _utils.extend)(self, { + app: app, + $el: $el, + el: $el && $el[0], + currentIndex: null, + hiddenDatasets: [], + f7Tooltip: null, + linesOffsets: null + }); + $el[0].f7AreaChart = self; // Install Modules + + self.useModules(); + self.onMouseEnter = self.onMouseEnter.bind(self); + self.onMouseMove = self.onMouseMove.bind(self); + self.onMouseLeave = self.onMouseLeave.bind(self); + self.onLegendClick = self.onLegendClick.bind(self); + self.init(); + return self || _assertThisInitialized(_this); + } + + var _proto = AreaChart.prototype; + + _proto.getVisibleLabels = function getVisibleLabels() { + var _this$params = this.params, + maxAxisLabels = _this$params.maxAxisLabels, + axisLabels = _this$params.axisLabels; + if (!maxAxisLabels || axisLabels.length <= maxAxisLabels) return axisLabels; + var skipStep = Math.ceil(axisLabels.length / maxAxisLabels); + var filtered = axisLabels.filter(function (label, index) { + return index % skipStep === 0; + }); + return filtered; + }; + + _proto.getSummValues = function getSummValues() { + var datasets = this.params.datasets; + var hiddenDatasets = this.hiddenDatasets; + var summValues = []; + datasets.filter(function (dataset, index) { + return !hiddenDatasets.includes(index); + }).forEach(function (_ref) { + var values = _ref.values; + values.forEach(function (value, valueIndex) { + if (!summValues[valueIndex]) summValues[valueIndex] = 0; + summValues[valueIndex] += value; + }); + }); + return summValues; + }; + + _proto.getChartData = function getChartData() { + var _this$params2 = this.params, + datasets = _this$params2.datasets, + lineChart = _this$params2.lineChart, + width = _this$params2.width, + height = _this$params2.height; + var hiddenDatasets = this.hiddenDatasets; + var data = []; + + if (!datasets.length) { + return data; + } + + var lastValues = datasets[0].values.map(function () { + return 0; + }); + var maxValue = 0; + + if (lineChart) { + datasets.filter(function (dataset, index) { + return !hiddenDatasets.includes(index); + }).forEach(function (_ref2) { + var values = _ref2.values; + var datasetMaxValue = Math.max.apply(Math, values); + if (datasetMaxValue > maxValue) maxValue = datasetMaxValue; + }); + } else { + maxValue = Math.max.apply(Math, this.getSummValues()); + } + + datasets.filter(function (dataset, index) { + return !hiddenDatasets.includes(index); + }).forEach(function (_ref3) { + var label = _ref3.label, + values = _ref3.values, + color = _ref3.color; + var points = values.map(function (originalValue, valueIndex) { + lastValues[valueIndex] += originalValue; + var value = lineChart ? originalValue : lastValues[valueIndex]; + var x = valueIndex / (values.length - 1) * width; + var y = height - value / maxValue * height; + + if (lineChart) { + return "" + (valueIndex === 0 ? 'M' : 'L') + x + "," + y; + } + + return x + " " + y; + }); + + if (!lineChart) { + points.push(width + " " + height + " 0 " + height); + } + + data.push({ + label: label, + points: points.join(' '), + color: color + }); + }); + return data.reverse(); + }; + + _proto.getVerticalLines = function getVerticalLines() { + var _this$params3 = this.params, + datasets = _this$params3.datasets, + width = _this$params3.width; + var lines = []; + + if (!datasets.length) { + return lines; + } + + var values = datasets[0].values; + values.forEach(function (value, valueIndex) { + var x = valueIndex / (values.length - 1) * width; + lines.push(x); + }); + return lines; + }; + + _proto.toggleDataset = function toggleDataset(index) { + var _this2 = this; + + var hiddenDatasets = this.hiddenDatasets, + toggleDatasets = this.params.toggleDatasets; + if (!toggleDatasets) return; + + if (hiddenDatasets.includes(index)) { + hiddenDatasets.splice(hiddenDatasets.indexOf(index), 1); + } else { + hiddenDatasets.push(index); + } + + if (this.$legendEl) { + this.$legendEl.find('.area-chart-legend-item').removeClass('area-chart-legend-item-hidden'); + hiddenDatasets.forEach(function (i) { + _this2.$legendEl.find(".area-chart-legend-item[data-index=\"" + i + "\"]").addClass('area-chart-legend-item-hidden'); + }); + } + + this.update({}, true); + }; + + _proto.formatAxisLabel = function formatAxisLabel(label) { + var formatAxisLabel = this.params.formatAxisLabel; + if (formatAxisLabel) return formatAxisLabel.call(this, label); + return label; + }; + + _proto.formatLegendLabel = function formatLegendLabel(label) { + var formatLegendLabel = this.params.formatLegendLabel; + if (formatLegendLabel) return formatLegendLabel.call(this, label); + return label; + }; + + _proto.calcLinesOffsets = function calcLinesOffsets() { + var lines = this.svgEl.querySelectorAll('line'); + this.linesOffsets = []; + + for (var i = 0; i < lines.length; i += 1) { + this.linesOffsets.push(lines[i].getBoundingClientRect().left); + } + }; + + _proto.formatTooltip = function formatTooltip() { + var self = this; + var currentIndex = self.currentIndex, + hiddenDatasets = self.hiddenDatasets, + _self$params = self.params, + datasets = _self$params.datasets, + axisLabels = _self$params.axisLabels, + formatTooltip = _self$params.formatTooltip, + formatTooltipTotal = _self$params.formatTooltipTotal, + formatTooltipAxisLabel = _self$params.formatTooltipAxisLabel, + formatTooltipDataset = _self$params.formatTooltipDataset; + if (currentIndex === null) return ''; + var total = 0; + var currentValues = datasets.filter(function (dataset, index) { + return !hiddenDatasets.includes(index); + }).map(function (dataset) { + return { + color: dataset.color, + label: dataset.label, + value: dataset.values[currentIndex] + }; + }); + currentValues.forEach(function (dataset) { + total += dataset.value; + }); + + if (formatTooltip) { + return formatTooltip({ + index: currentIndex, + total: total, + datasets: currentValues + }); + } + + var labelText = formatTooltipAxisLabel ? formatTooltipAxisLabel.call(self, axisLabels[currentIndex]) : this.formatAxisLabel(axisLabels[currentIndex]); + if (!labelText) labelText = ''; + var totalText = formatTooltipTotal ? formatTooltipTotal.call(self, total) : total; // prettier-ignore + + var datasetsText = currentValues.length > 0 ? "\n " : ''; // prettier-ignore + + return "\n
    " + labelText + "
    \n
    " + totalText + "
    \n " + datasetsText + "\n "; + }; + + _proto.setTooltip = function setTooltip() { + var self = this; + var app = self.app, + el = self.el, + svgEl = self.svgEl, + hiddenDatasets = self.hiddenDatasets, + currentIndex = self.currentIndex, + _self$params2 = self.params, + tooltip = _self$params2.tooltip, + datasets = _self$params2.datasets; + if (!tooltip) return; + var hasVisibleDataSets = datasets.filter(function (dataset, index) { + return !hiddenDatasets.includes(index); + }).length > 0; + + if (!hasVisibleDataSets) { + if (self.f7Tooltip && self.f7Tooltip.hide) self.f7Tooltip.hide(); + return; + } + + if (currentIndex !== null && !self.f7Tooltip) { + self.f7Tooltip = app.tooltip.create({ + trigger: 'manual', + containerEl: el, + targetEl: svgEl.querySelector("line[data-index=\"" + currentIndex + "\"]"), + text: self.formatTooltip(), + cssClass: 'area-chart-tooltip' + }); + + if (self.f7Tooltip && self.f7Tooltip.show) { + self.f7Tooltip.show(); + } + + return; + } + + if (!self.f7Tooltip || !self.f7Tooltip.hide || !self.f7Tooltip.show) { + return; + } + + if (currentIndex !== null) { + self.f7Tooltip.setText(self.formatTooltip()); + self.f7Tooltip.setTargetEl(svgEl.querySelector("line[data-index=\"" + currentIndex + "\"]")); + self.f7Tooltip.show(); + } else { + self.f7Tooltip.hide(); + } + }; + + _proto.setCurrentIndex = function setCurrentIndex(index) { + if (index === this.currentIndex) return; + this.currentIndex = index; + this.$el.trigger('areachart:select', { + index: index + }); + this.emit('local::select areaChartSelect', this, index); + this.$svgEl.find('line').removeClass('area-chart-current-line'); + this.$svgEl.find("line[data-index=\"" + index + "\"]").addClass('area-chart-current-line'); + this.setTooltip(); + }; + + _proto.onLegendClick = function onLegendClick(e) { + var index = parseInt((0, _dom.default)(e.target).closest('.area-chart-legend-item').attr('data-index'), 10); + this.toggleDataset(index); + }; + + _proto.onMouseEnter = function onMouseEnter() { + this.calcLinesOffsets(); + }; + + _proto.onMouseMove = function onMouseMove(e) { + var self = this; + + if (!self.linesOffsets) { + self.calcLinesOffsets(); + } + + var currentLeft = e.pageX; + if (typeof currentLeft === 'undefined') currentLeft = 0; + var distances = self.linesOffsets.map(function (left) { + return Math.abs(currentLeft - left); + }); + var minDistance = Math.min.apply(Math, distances); + var closestIndex = distances.indexOf(minDistance); + self.setCurrentIndex(closestIndex); + }; + + _proto.onMouseLeave = function onMouseLeave() { + this.setCurrentIndex(null); + }; + + _proto.attachEvents = function attachEvents() { + var svgEl = this.svgEl, + $el = this.$el; + if (!svgEl) return; + svgEl.addEventListener('mouseenter', this.onMouseEnter); + svgEl.addEventListener('mousemove', this.onMouseMove); + svgEl.addEventListener('mouseleave', this.onMouseLeave); + $el.on('click', '.area-chart-legend-item', this.onLegendClick); + }; + + _proto.detachEvents = function detachEvents() { + var svgEl = this.svgEl, + $el = this.$el; + if (!svgEl) return; + svgEl.removeEventListener('mouseenter', this.onMouseEnter); + svgEl.removeEventListener('mousemove', this.onMouseMove); + svgEl.removeEventListener('mouseleave', this.onMouseLeave); + $el.off('click', '.area-chart-legend-item', this.onLegendClick); + }; + + _proto.render = function render() { + var self = this; + var _self$params3 = self.params, + lineChart = _self$params3.lineChart, + toggleDatasets = _self$params3.toggleDatasets, + width = _self$params3.width, + height = _self$params3.height, + axis = _self$params3.axis, + axisLabels = _self$params3.axisLabels, + legend = _self$params3.legend, + datasets = _self$params3.datasets; + var chartData = self.getChartData(); + var verticalLines = self.getVerticalLines(); + var visibleLegends = self.getVisibleLabels(); + var LegendItemTag = toggleDatasets ? 'button' : 'span'; + return (0, _$jsx.default)("div", null, (0, _$jsx.default)("svg", { + xmlns: "http://www.w3.org/2000/svg", + width: width, + height: height, + viewBox: "0 0 " + width + " " + height, + preserveAspectRatio: "none" + }, chartData.map(function (data) { + return lineChart ? (0, _$jsx.default)("path", { + stroke: data.color, + "fill-rule": "evenodd", + d: data.points + }) : (0, _$jsx.default)("polygon", { + fill: data.color, + "fill-rule": "evenodd", + points: data.points + }); + }), verticalLines.map(function (line, index) { + return (0, _$jsx.default)("line", { + "data-index": index, + fill: "#000", + x1: line, + y1: 0, + x2: line, + y2: height + }); + })), axis && (0, _$jsx.default)("div", { + class: "area-chart-axis" + }, axisLabels.map(function (label) { + return (0, _$jsx.default)("span", null, visibleLegends.includes(label) && (0, _$jsx.default)("span", null, self.formatAxisLabel(label))); + })), legend && (0, _$jsx.default)("div", { + class: "area-chart-legend" + }, datasets.map(function (dataset, index) { + return (0, _$jsx.default)(LegendItemTag, { + "data-index": index, + class: "area-chart-legend-item " + (toggleDatasets ? 'area-chart-legend-button' : ''), + _type: toggleDatasets ? 'button' : undefined + }, (0, _$jsx.default)("span", { + style: "background-color: " + dataset.color + }), self.formatLegendLabel(dataset.label)); + }))); + }; + + _proto.update = function update(newParams, onlySvg) { + if (newParams === void 0) { + newParams = {}; + } + + if (onlySvg === void 0) { + onlySvg = false; + } + + var self = this; + var params = self.params; + Object.keys(newParams).forEach(function (param) { + if (typeof newParams[param] !== 'undefined') { + params[param] = newParams[param]; + } + }); + if (self.$svgEl.length === 0) return self; + self.detachEvents(); + self.$svgEl.remove(); + + if (!onlySvg) { + self.$axisEl.remove(); + self.$legendEl.remove(); + } + + var $rendered = (0, _dom.default)(self.render()); + var $svgEl = $rendered.find('svg'); + (0, _utils.extend)(self, { + svgEl: $svgEl && $svgEl[0], + $svgEl: $svgEl + }); + + if (!onlySvg) { + var $axisEl = $rendered.find('.area-chart-axis'); + var $legendEl = $rendered.find('.area-chart-legend'); + (0, _utils.extend)(self, { + $axisEl: $axisEl, + $legendEl: $legendEl + }); + self.$el.append($axisEl); + self.$el.append($legendEl); + } + + self.$el.prepend($svgEl); + self.attachEvents(); + return self; + }; + + _proto.init = function init() { + var self = this; + var $rendered = (0, _dom.default)(self.render()); + var $svgEl = $rendered.find('svg'); + var $axisEl = $rendered.find('.area-chart-axis'); + var $legendEl = $rendered.find('.area-chart-legend'); + (0, _utils.extend)(self, { + svgEl: $svgEl && $svgEl[0], + $svgEl: $svgEl, + $axisEl: $axisEl, + $legendEl: $legendEl + }); + self.$el.append($svgEl); + self.$el.append($axisEl); + self.$el.append($legendEl); + self.attachEvents(); + return self; + }; + + _proto.destroy = function destroy() { + var self = this; + if (!self.$el || self.destroyed) return; + self.$el.trigger('piechart:beforedestroy'); + self.emit('local::beforeDestroy areaChartBeforeDestroy', self); + self.detachEvents(); + self.$svgEl.remove(); + self.$axisEl.remove(); + self.$legendEl.remove(); + + if (self.f7Tooltip && self.f7Tooltip.destroy) { + self.f7Tooltip.destroy(); + } + + delete self.$el[0].f7AreaChart; + (0, _utils.deleteProps)(self); + self.destroyed = true; + }; + + return AreaChart; +}(_class.default); + +var _default = AreaChart; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/area-chart/area-chart.js b/www/assets/framework7/cjs/components/area-chart/area-chart.js new file mode 100644 index 000000000..028b23ad8 --- /dev/null +++ b/www/assets/framework7/cjs/components/area-chart/area-chart.js @@ -0,0 +1,56 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _areaChartClass = _interopRequireDefault(require("./area-chart-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'areaChart', + params: { + areaChart: { + el: null, + lineChart: false, + datasets: [], + axis: false, + axisLabels: [], + tooltip: false, + legend: false, + toggleDatasets: false, + width: 640, + height: 320, + maxAxisLabels: 8, + formatAxisLabel: null, + formatLegendLabel: null, + formatTooltip: null, + formatTooltipAxisLabel: null, + formatTooltipTotal: null, + formatTooltipDataset: null + } + }, + create: function create() { + var app = this; + app.areaChart = (0, _constructorMethods.default)({ + defaultSelector: '.area-chart', + constructor: _areaChartClass.default, + app: app, + domProp: 'f7AreaChart' + }); + + app.areaChart.update = function update(el, newParams) { + var $el = (0, _dom.default)(el); + if ($el.length === 0) return undefined; + var areaChart = app.areaChart.get(el); + if (!areaChart) return undefined; + areaChart.update(newParams); + return areaChart; + }; + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/autocomplete/autocomplete-class.js b/www/assets/framework7/cjs/components/autocomplete/autocomplete-class.js new file mode 100644 index 000000000..3afd56422 --- /dev/null +++ b/www/assets/framework7/cjs/components/autocomplete/autocomplete-class.js @@ -0,0 +1,975 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _getDevice = require("../../shared/get-device"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _$jsx = _interopRequireDefault(require("../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Autocomplete = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(Autocomplete, _Framework7Class); + + function Autocomplete(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params, [app]) || this; + + var ac = _assertThisInitialized(_this); + + ac.app = app; + var device = (0, _getDevice.getDevice)(); + var defaults = (0, _utils.extend)({ + on: {} + }, app.params.autocomplete); + + if (typeof defaults.searchbarDisableButton === 'undefined') { + defaults.searchbarDisableButton = app.theme !== 'aurora'; + } // Extend defaults with modules params + + + ac.useModulesParams(defaults); + ac.params = (0, _utils.extend)(defaults, params); + var $openerEl; + + if (ac.params.openerEl) { + $openerEl = (0, _dom.default)(ac.params.openerEl); + if ($openerEl.length) $openerEl[0].f7Autocomplete = ac; + } + + var $inputEl; + + if (ac.params.inputEl) { + $inputEl = (0, _dom.default)(ac.params.inputEl); + if ($inputEl.length) $inputEl[0].f7Autocomplete = ac; + } + + var uniqueId = (0, _utils.id)(); + var url = params.url; + + if (!url && $openerEl && $openerEl.length) { + if ($openerEl.attr('href')) url = $openerEl.attr('href');else if ($openerEl.find('a').length > 0) { + url = $openerEl.find('a').attr('href'); + } + } + + if (!url || url === '#' || url === '') url = ac.params.url; + var inputType = ac.params.multiple ? 'checkbox' : 'radio'; + (0, _utils.extend)(ac, { + $openerEl: $openerEl, + openerEl: $openerEl && $openerEl[0], + $inputEl: $inputEl, + inputEl: $inputEl && $inputEl[0], + id: uniqueId, + url: url, + value: ac.params.value || [], + inputType: inputType, + inputName: inputType + "-" + uniqueId, + $modalEl: undefined, + $dropdownEl: undefined + }); + var previousQuery = ''; + + function onInputChange() { + var query = ac.$inputEl.val().trim(); + if (!ac.params.source) return; + ac.params.source.call(ac, query, function (items) { + var itemsHTML = ''; + var limit = ac.params.limit ? Math.min(ac.params.limit, items.length) : items.length; + ac.items = items; + var regExp; + + if (ac.params.highlightMatches) { + query = query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); + regExp = new RegExp("(" + query + ")", 'i'); + } + + var firstValue; + var firstItem; + + for (var i = 0; i < limit; i += 1) { + var itemValue = typeof items[i] === 'object' ? items[i][ac.params.valueProperty] : items[i]; + var itemText = typeof items[i] === 'object' ? items[i][ac.params.textProperty] : items[i]; + + if (i === 0) { + firstValue = itemValue; + firstItem = ac.items[i]; + } + + itemsHTML += ac.renderItem({ + value: itemValue, + text: ac.params.highlightMatches ? itemText.replace(regExp, '$1') : itemText + }, i); + } + + if (itemsHTML === '' && query === '' && ac.params.dropdownPlaceholderText) { + itemsHTML += ac.renderItem({ + placeholder: true, + text: ac.params.dropdownPlaceholderText + }); + } + + ac.$dropdownEl.find('ul').html(itemsHTML); + + if (ac.params.typeahead) { + if (!firstValue || !firstItem) { + return; + } + + if (firstValue.toLowerCase().indexOf(query.toLowerCase()) !== 0) { + return; + } + + if (previousQuery.toLowerCase() === query.toLowerCase()) { + ac.value = []; + return; + } + + if (previousQuery.toLowerCase().indexOf(query.toLowerCase()) === 0) { + previousQuery = query; + ac.value = []; + return; + } + + $inputEl.val(firstValue); + $inputEl[0].setSelectionRange(query.length, firstValue.length); + var previousValue = typeof ac.value[0] === 'object' ? ac.value[0][ac.params.valueProperty] : ac.value[0]; + + if (!previousValue || firstValue.toLowerCase() !== previousValue.toLowerCase()) { + ac.value = [firstItem]; + ac.emit('local::change autocompleteChange', [firstItem]); + } + } + + previousQuery = query; + }); + } + + function onPageInputChange() { + var inputEl = this; + var value = inputEl.value; + var isValues = (0, _dom.default)(inputEl).parents('.autocomplete-values').length > 0; + var item; + var itemValue; + var aValue; + + if (isValues) { + if (ac.inputType === 'checkbox' && !inputEl.checked) { + for (var i = 0; i < ac.value.length; i += 1) { + aValue = typeof ac.value[i] === 'string' ? ac.value[i] : ac.value[i][ac.params.valueProperty]; + + if (aValue === value || aValue * 1 === value * 1) { + ac.value.splice(i, 1); + } + } + + ac.updateValues(); + ac.emit('local::change autocompleteChange', ac.value); + } + + return; + } // Find Related Item + + + for (var _i = 0; _i < ac.items.length; _i += 1) { + itemValue = typeof ac.items[_i] === 'object' ? ac.items[_i][ac.params.valueProperty] : ac.items[_i]; + if (itemValue === value || itemValue * 1 === value * 1) item = ac.items[_i]; + } + + if (ac.inputType === 'radio') { + ac.value = [item]; + } else if (inputEl.checked) { + ac.value.push(item); + } else { + for (var _i2 = 0; _i2 < ac.value.length; _i2 += 1) { + aValue = typeof ac.value[_i2] === 'object' ? ac.value[_i2][ac.params.valueProperty] : ac.value[_i2]; + + if (aValue === value || aValue * 1 === value * 1) { + ac.value.splice(_i2, 1); + } + } + } // Update Values Block + + + ac.updateValues(); // On Select Callback + + if (ac.inputType === 'radio' && inputEl.checked || ac.inputType === 'checkbox') { + ac.emit('local::change autocompleteChange', ac.value); + } + } + + function onHtmlClick(e) { + var $targetEl = (0, _dom.default)(e.target); + if ($targetEl.is(ac.$inputEl[0]) || ac.$dropdownEl && $targetEl.closest(ac.$dropdownEl[0]).length) return; + ac.close(); + } + + function onOpenerClick() { + ac.open(); + } + + function onInputFocus() { + ac.open(); + } + + function onInputBlur() { + if (ac.$dropdownEl.find('label.active-state').length > 0) return; + setTimeout(function () { + ac.close(); + }, 0); + } + + function onResize() { + ac.positionDropdown(); + } + + function onKeyDown(e) { + if (!ac.opened) return; + + if (e.keyCode === 27) { + // ESC + e.preventDefault(); + ac.$inputEl.blur(); + return; + } + + if (e.keyCode === 13) { + // Enter + var $selectedItemLabel = ac.$dropdownEl.find('.autocomplete-dropdown-selected label'); + + if ($selectedItemLabel.length) { + e.preventDefault(); + $selectedItemLabel.trigger('click'); + ac.$inputEl.blur(); + return; + } + + if (ac.params.typeahead) { + e.preventDefault(); + ac.$inputEl.blur(); + } + + return; + } + + if (e.keyCode !== 40 && e.keyCode !== 38) return; + e.preventDefault(); + var $selectedItem = ac.$dropdownEl.find('.autocomplete-dropdown-selected'); + var $newItem; + + if ($selectedItem.length) { + $newItem = $selectedItem[e.keyCode === 40 ? 'next' : 'prev']('li'); + + if (!$newItem.length) { + $newItem = ac.$dropdownEl.find('li').eq(e.keyCode === 40 ? 0 : ac.$dropdownEl.find('li').length - 1); + } + } else { + $newItem = ac.$dropdownEl.find('li').eq(e.keyCode === 40 ? 0 : ac.$dropdownEl.find('li').length - 1); + } + + if ($newItem.hasClass('autocomplete-dropdown-placeholder')) return; + $selectedItem.removeClass('autocomplete-dropdown-selected'); + $newItem.addClass('autocomplete-dropdown-selected'); + } + + function onDropdownClick() { + var $clickedEl = (0, _dom.default)(this); + var clickedItem; + + for (var i = 0; i < ac.items.length; i += 1) { + var itemValue = typeof ac.items[i] === 'object' ? ac.items[i][ac.params.valueProperty] : ac.items[i]; + var value = $clickedEl.attr('data-value'); + + if (itemValue === value || itemValue * 1 === value * 1) { + clickedItem = ac.items[i]; + } + } + + if (ac.params.updateInputValueOnSelect) { + ac.$inputEl.val(typeof clickedItem === 'object' ? clickedItem[ac.params.valueProperty] : clickedItem); + ac.$inputEl.trigger('input change'); + } + + ac.value = [clickedItem]; + ac.emit('local::change autocompleteChange', [clickedItem]); + ac.close(); + } + + ac.attachEvents = function attachEvents() { + if (ac.params.openIn !== 'dropdown' && ac.$openerEl) { + ac.$openerEl.on('click', onOpenerClick); + } + + if (ac.params.openIn === 'dropdown' && ac.$inputEl) { + ac.$inputEl.on('focus', onInputFocus); + ac.$inputEl.on(ac.params.inputEvents, onInputChange); + + if (device.android) { + (0, _dom.default)('html').on('click', onHtmlClick); + } else { + ac.$inputEl.on('blur', onInputBlur); + } + + ac.$inputEl.on('keydown', onKeyDown); + } + }; + + ac.detachEvents = function attachEvents() { + if (ac.params.openIn !== 'dropdown' && ac.$openerEl) { + ac.$openerEl.off('click', onOpenerClick); + } + + if (ac.params.openIn === 'dropdown' && ac.$inputEl) { + ac.$inputEl.off('focus', onInputFocus); + ac.$inputEl.off(ac.params.inputEvents, onInputChange); + + if (device.android) { + (0, _dom.default)('html').off('click', onHtmlClick); + } else { + ac.$inputEl.off('blur', onInputBlur); + } + + ac.$inputEl.off('keydown', onKeyDown); + } + }; + + ac.attachDropdownEvents = function attachDropdownEvents() { + ac.$dropdownEl.on('click', 'label', onDropdownClick); + app.on('resize', onResize); + }; + + ac.detachDropdownEvents = function detachDropdownEvents() { + ac.$dropdownEl.off('click', 'label', onDropdownClick); + app.off('resize', onResize); + }; + + ac.attachPageEvents = function attachPageEvents() { + ac.$el.on('change', 'input[type="radio"], input[type="checkbox"]', onPageInputChange); + + if (ac.params.closeOnSelect && !ac.params.multiple) { + ac.$el.once('click', '.list label', function () { + (0, _utils.nextTick)(function () { + ac.close(); + }); + }); + } + }; + + ac.detachPageEvents = function detachPageEvents() { + ac.$el.off('change', 'input[type="radio"], input[type="checkbox"]', onPageInputChange); + }; // Install Modules + + + ac.useModules(); // Init + + ac.init(); + return ac || _assertThisInitialized(_this); + } + + var _proto = Autocomplete.prototype; + + _proto.positionDropdown = function positionDropdown() { + var _$dropdownEl$children; + + var ac = this; + var $inputEl = ac.$inputEl, + app = ac.app, + $dropdownEl = ac.$dropdownEl; + var $pageContentEl = $inputEl.parents('.page-content'); + if ($pageContentEl.length === 0) return; + var inputOffset = $inputEl.offset(); + var inputOffsetWidth = $inputEl[0].offsetWidth; + var inputOffsetHeight = $inputEl[0].offsetHeight; + var $listEl = $inputEl.parents('.list'); + var $listParent; + $listEl.parents().each(function (parentEl) { + if ($listParent) return; + var $parentEl = (0, _dom.default)(parentEl); + if ($parentEl.parent($pageContentEl).length) $listParent = $parentEl; + }); + var listOffset = $listEl.offset(); + var paddingBottom = parseInt($pageContentEl.css('padding-bottom'), 10); + var listOffsetLeft = $listEl.length > 0 ? listOffset.left - $pageContentEl.offset().left : 0; + var inputOffsetLeft = inputOffset.left - ($listEl.length > 0 ? listOffset.left : 0) - (app.rtl ? 0 : 0); + var inputOffsetTop = inputOffset.top - ($pageContentEl.offset().top - $pageContentEl[0].scrollTop); + var maxHeight = $pageContentEl[0].scrollHeight - paddingBottom - (inputOffsetTop + $pageContentEl[0].scrollTop) - $inputEl[0].offsetHeight; + var paddingProp = app.rtl ? 'padding-right' : 'padding-left'; + var paddingValue; + + if ($listEl.length && !ac.params.expandInput) { + paddingValue = (app.rtl ? $listEl[0].offsetWidth - inputOffsetLeft - inputOffsetWidth : inputOffsetLeft) - (app.theme === 'md' ? 16 : 15); + } + + $dropdownEl.css({ + left: ($listEl.length > 0 ? listOffsetLeft : inputOffsetLeft) + "px", + top: inputOffsetTop + $pageContentEl[0].scrollTop + inputOffsetHeight + "px", + width: ($listEl.length > 0 ? $listEl[0].offsetWidth : inputOffsetWidth) + "px" + }); + $dropdownEl.children('.autocomplete-dropdown-inner').css((_$dropdownEl$children = { + maxHeight: maxHeight + "px" + }, _$dropdownEl$children[paddingProp] = $listEl.length > 0 && !ac.params.expandInput ? paddingValue + "px" : '', _$dropdownEl$children)); + }; + + _proto.focus = function focus() { + var ac = this; + ac.$el.find('input[type=search]').focus(); + }; + + _proto.source = function source(query) { + var ac = this; + if (!ac.params.source) return; + var $el = ac.$el; + ac.params.source.call(ac, query, function (items) { + var itemsHTML = ''; + var limit = ac.params.limit ? Math.min(ac.params.limit, items.length) : items.length; + ac.items = items; + + for (var i = 0; i < limit; i += 1) { + var selected = false; + var itemValue = typeof items[i] === 'object' ? items[i][ac.params.valueProperty] : items[i]; + + for (var j = 0; j < ac.value.length; j += 1) { + var aValue = typeof ac.value[j] === 'object' ? ac.value[j][ac.params.valueProperty] : ac.value[j]; + if (aValue === itemValue || aValue * 1 === itemValue * 1) selected = true; + } + + itemsHTML += ac.renderItem({ + value: itemValue, + text: typeof items[i] === 'object' ? items[i][ac.params.textProperty] : items[i], + inputType: ac.inputType, + id: ac.id, + inputName: ac.inputName, + selected: selected + }, i); + } + + $el.find('.autocomplete-found ul').html(itemsHTML); + + if (items.length === 0) { + if (query.length !== 0) { + $el.find('.autocomplete-not-found').show(); + $el.find('.autocomplete-found, .autocomplete-values').hide(); + } else { + $el.find('.autocomplete-values').show(); + $el.find('.autocomplete-found, .autocomplete-not-found').hide(); + } + } else { + $el.find('.autocomplete-found').show(); + $el.find('.autocomplete-not-found, .autocomplete-values').hide(); + } + }); + }; + + _proto.updateValues = function updateValues() { + var ac = this; + var valuesHTML = ''; + + for (var i = 0; i < ac.value.length; i += 1) { + valuesHTML += ac.renderItem({ + value: typeof ac.value[i] === 'object' ? ac.value[i][ac.params.valueProperty] : ac.value[i], + text: typeof ac.value[i] === 'object' ? ac.value[i][ac.params.textProperty] : ac.value[i], + inputType: ac.inputType, + id: ac.id, + inputName: ac.inputName + "-checked}", + selected: true + }, i); + } + + ac.$el.find('.autocomplete-values ul').html(valuesHTML); + }; + + _proto.preloaderHide = function preloaderHide() { + var ac = this; + + if (ac.params.openIn === 'dropdown' && ac.$dropdownEl) { + ac.$dropdownEl.find('.autocomplete-preloader').removeClass('autocomplete-preloader-visible'); + } else { + (0, _dom.default)('.autocomplete-preloader').removeClass('autocomplete-preloader-visible'); + } + }; + + _proto.preloaderShow = function preloaderShow() { + var ac = this; + + if (ac.params.openIn === 'dropdown' && ac.$dropdownEl) { + ac.$dropdownEl.find('.autocomplete-preloader').addClass('autocomplete-preloader-visible'); + } else { + (0, _dom.default)('.autocomplete-preloader').addClass('autocomplete-preloader-visible'); + } + }; + + _proto.renderPreloader = function renderPreloader() { + var ac = this; + var preloaders = { + iosPreloaderContent: _utils.iosPreloaderContent, + mdPreloaderContent: _utils.mdPreloaderContent, + auroraPreloaderContent: _utils.auroraPreloaderContent + }; + return (0, _$jsx.default)("div", { + class: "autocomplete-preloader preloader " + (ac.params.preloaderColor ? "color-" + ac.params.preloaderColor : '') + }, preloaders[ac.app.theme + "PreloaderContent"] || ''); + }; + + _proto.renderSearchbar = function renderSearchbar() { + var ac = this; + if (ac.params.renderSearchbar) return ac.params.renderSearchbar.call(ac); + return (0, _$jsx.default)("form", { + class: "searchbar" + }, (0, _$jsx.default)("div", { + class: "searchbar-inner" + }, (0, _$jsx.default)("div", { + class: "searchbar-input-wrap" + }, (0, _$jsx.default)("input", { + type: "search", + spellcheck: ac.params.searchbarSpellcheck || 'false', + placeholder: ac.params.searchbarPlaceholder + }), (0, _$jsx.default)("i", { + class: "searchbar-icon" + }), (0, _$jsx.default)("span", { + class: "input-clear-button" + })), ac.params.searchbarDisableButton && (0, _$jsx.default)("span", { + class: "searchbar-disable-button" + }, ac.params.searchbarDisableText))); + }; + + _proto.renderItem = function renderItem(item, index) { + var ac = this; + if (ac.params.renderItem) return ac.params.renderItem.call(ac, item, index); + var itemValue = item.value && typeof item.value === 'string' ? item.value.replace(/"/g, '"') : item.value; + + if (ac.params.openIn !== 'dropdown') { + return (0, _$jsx.default)("li", null, (0, _$jsx.default)("label", { + class: "item-" + item.inputType + " item-content" + }, (0, _$jsx.default)("input", { + type: item.inputType, + name: item.inputName, + value: itemValue, + _checked: item.selected + }), (0, _$jsx.default)("i", { + class: "icon icon-" + item.inputType + }), (0, _$jsx.default)("div", { + class: "item-inner" + }, (0, _$jsx.default)("div", { + class: "item-title" + }, item.text)))); + } // Dropdown + + + if (!item.placeholder) { + return (0, _$jsx.default)("li", null, (0, _$jsx.default)("label", { + class: "item-radio item-content", + "data-value": itemValue + }, (0, _$jsx.default)("div", { + class: "item-inner" + }, (0, _$jsx.default)("div", { + class: "item-title" + }, item.text)))); + } // Dropwdown placeholder + + + return (0, _$jsx.default)("li", { + class: "autocomplete-dropdown-placeholder" + }, (0, _$jsx.default)("label", { + class: "item-content" + }, (0, _$jsx.default)("div", { + class: "item-inner" + }, (0, _$jsx.default)("div", { + class: "item-title" + }, item.text)))); + }; + + _proto.renderNavbar = function renderNavbar() { + var ac = this; + if (ac.params.renderNavbar) return ac.params.renderNavbar.call(ac); + var pageTitle = ac.params.pageTitle; + + if (typeof pageTitle === 'undefined' && ac.$openerEl && ac.$openerEl.length) { + pageTitle = ac.$openerEl.find('.item-title').text().trim(); + } + + var inPopup = ac.params.openIn === 'popup'; // eslint-disable-next-line + + var navbarLeft = inPopup ? ac.params.preloader && (0, _$jsx.default)("div", { + class: "left" + }, ac.renderPreloader()) : (0, _$jsx.default)("div", { + class: "left sliding" + }, (0, _$jsx.default)("a", { + class: "link back" + }, (0, _$jsx.default)("i", { + class: "icon icon-back" + }), (0, _$jsx.default)("span", { + class: "if-not-md" + }, ac.params.pageBackLinkText))); + var navbarRight = inPopup ? (0, _$jsx.default)("div", { + class: "right" + }, (0, _$jsx.default)("a", { + class: "link popup-close", + "data-popup": ".autocomplete-popup" + }, ac.params.popupCloseLinkText)) : ac.params.preloader && (0, _$jsx.default)("div", { + class: "right" + }, ac.renderPreloader()); + return (0, _$jsx.default)("div", { + class: "navbar " + (ac.params.navbarColorTheme ? "color-" + ac.params.navbarColorTheme : '') + }, (0, _$jsx.default)("div", { + class: "navbar-bg" + }), (0, _$jsx.default)("div", { + class: "navbar-inner " + (ac.params.navbarColorTheme ? "color-" + ac.params.navbarColorTheme : '') + }, navbarLeft, pageTitle && (0, _$jsx.default)("div", { + class: "title sliding" + }, pageTitle), navbarRight, (0, _$jsx.default)("div", { + class: "subnavbar sliding" + }, ac.renderSearchbar()))); + }; + + _proto.renderDropdown = function renderDropdown() { + var ac = this; + if (ac.params.renderDropdown) return ac.params.renderDropdown.call(ac, ac.items); + return (0, _$jsx.default)("div", { + class: "autocomplete-dropdown" + }, (0, _$jsx.default)("div", { + class: "autocomplete-dropdown-inner" + }, (0, _$jsx.default)("div", { + class: "list " + (!ac.params.expandInput ? 'no-safe-areas' : '') + }, (0, _$jsx.default)("ul", null))), ac.params.preloader && ac.renderPreloader()); + }; + + _proto.renderPage = function renderPage(inPopup) { + var ac = this; + if (ac.params.renderPage) return ac.params.renderPage.call(ac, ac.items); + return (0, _$jsx.default)("div", { + class: "page page-with-subnavbar autocomplete-page", + "data-name": "autocomplete-page" + }, ac.renderNavbar(inPopup), (0, _$jsx.default)("div", { + class: "searchbar-backdrop" + }), (0, _$jsx.default)("div", { + class: "page-content" + }, (0, _$jsx.default)("div", { + class: "list autocomplete-list autocomplete-found autocomplete-list-" + ac.id + " " + (ac.params.formColorTheme ? "color-" + ac.params.formColorTheme : '') + }, (0, _$jsx.default)("ul", null)), (0, _$jsx.default)("div", { + class: "list autocomplete-not-found" + }, (0, _$jsx.default)("ul", null, (0, _$jsx.default)("li", { + class: "item-content" + }, (0, _$jsx.default)("div", { + class: "item-inner" + }, (0, _$jsx.default)("div", { + class: "item-title" + }, ac.params.notFoundText))))), (0, _$jsx.default)("div", { + class: "list autocomplete-values" + }, (0, _$jsx.default)("ul", null)))); + }; + + _proto.renderPopup = function renderPopup() { + var ac = this; + if (ac.params.renderPopup) return ac.params.renderPopup.call(ac, ac.items); + return (0, _$jsx.default)("div", { + class: "popup autocomplete-popup" + }, (0, _$jsx.default)("div", { + class: "view" + }, ac.renderPage(true), ";")); + }; + + _proto.onOpen = function onOpen(type, el) { + var ac = this; + var app = ac.app; + var $el = (0, _dom.default)(el); + ac.$el = $el; + ac.el = $el[0]; + ac.openedIn = type; + ac.opened = true; + + if (ac.params.openIn === 'dropdown') { + ac.attachDropdownEvents(); + ac.$dropdownEl.addClass('autocomplete-dropdown-in'); + ac.$inputEl.trigger('input'); + } else { + // Init SB + var $searchbarEl = $el.find('.searchbar'); + + if (ac.params.openIn === 'page' && app.theme === 'ios' && $searchbarEl.length === 0) { + $searchbarEl = (0, _dom.default)(app.navbar.getElByPage($el)).find('.searchbar'); + } + + ac.searchbar = app.searchbar.create({ + el: $searchbarEl, + backdropEl: $el.find('.searchbar-backdrop'), + customSearch: true, + on: { + search: function search(sb, query) { + if (query.length === 0 && ac.searchbar.enabled) { + ac.searchbar.backdropShow(); + } else { + ac.searchbar.backdropHide(); + } + + ac.source(query); + } + } + }); // Attach page events + + ac.attachPageEvents(); // Update Values On Page Init + + ac.updateValues(); // Source on load + + if (ac.params.requestSourceOnOpen) ac.source(''); + } + + ac.emit('local::open autocompleteOpen', ac); + }; + + _proto.autoFocus = function autoFocus() { + var ac = this; + + if (ac.searchbar && ac.searchbar.$inputEl) { + ac.searchbar.$inputEl.focus(); + } + + return ac; + }; + + _proto.onOpened = function onOpened() { + var ac = this; + + if (ac.params.openIn !== 'dropdown' && ac.params.autoFocus) { + ac.autoFocus(); + } + + ac.emit('local::opened autocompleteOpened', ac); + }; + + _proto.onClose = function onClose() { + var ac = this; + if (ac.destroyed) return; // Destroy SB + + if (ac.searchbar && ac.searchbar.destroy) { + ac.searchbar.destroy(); + ac.searchbar = null; + delete ac.searchbar; + } + + if (ac.params.openIn === 'dropdown') { + ac.detachDropdownEvents(); + ac.$dropdownEl.removeClass('autocomplete-dropdown-in').remove(); + ac.$inputEl.parents('.item-content-dropdown-expanded').removeClass('item-content-dropdown-expanded'); + } else { + ac.detachPageEvents(); + } + + ac.emit('local::close autocompleteClose', ac); + }; + + _proto.onClosed = function onClosed() { + var ac = this; + if (ac.destroyed) return; + ac.opened = false; + ac.$el = null; + ac.el = null; + delete ac.$el; + delete ac.el; + ac.emit('local::closed autocompleteClosed', ac); + }; + + _proto.openPage = function openPage() { + var ac = this; + if (ac.opened) return ac; + var pageHtml = ac.renderPage(); + ac.view.router.navigate({ + url: ac.url, + route: { + content: pageHtml, + path: ac.url, + on: { + pageBeforeIn: function pageBeforeIn(e, page) { + ac.onOpen('page', page.el); + }, + pageAfterIn: function pageAfterIn(e, page) { + ac.onOpened('page', page.el); + }, + pageBeforeOut: function pageBeforeOut(e, page) { + ac.onClose('page', page.el); + }, + pageAfterOut: function pageAfterOut(e, page) { + ac.onClosed('page', page.el); + } + }, + options: { + animate: ac.params.animate + } + } + }); + return ac; + }; + + _proto.openPopup = function openPopup() { + var ac = this; + if (ac.opened) return ac; + var popupHtml = ac.renderPopup(); + var popupParams = { + content: popupHtml, + animate: ac.params.animate, + push: ac.params.popupPush, + swipeToClose: ac.params.popupSwipeToClose, + on: { + popupOpen: function popupOpen(popup) { + ac.onOpen('popup', popup.el); + }, + popupOpened: function popupOpened(popup) { + ac.onOpened('popup', popup.el); + }, + popupClose: function popupClose(popup) { + ac.onClose('popup', popup.el); + }, + popupClosed: function popupClosed(popup) { + ac.onClosed('popup', popup.el); + } + } + }; + + if (ac.params.routableModals && ac.view) { + ac.view.router.navigate({ + url: ac.url, + route: { + path: ac.url, + popup: popupParams + } + }); + } else { + ac.modal = ac.app.popup.create(popupParams).open(ac.params.animate); + } + + return ac; + }; + + _proto.openDropdown = function openDropdown() { + var ac = this; + + if (!ac.$dropdownEl) { + ac.$dropdownEl = (0, _dom.default)(ac.renderDropdown()); + } + + var $listEl = ac.$inputEl.parents('.list'); + + if ($listEl.length && ac.$inputEl.parents('.item-content').length > 0 && ac.params.expandInput) { + ac.$inputEl.parents('.item-content').addClass('item-content-dropdown-expanded'); + } + + var $pageContentEl = ac.$inputEl.parents('.page-content'); + + if (ac.params.dropdownContainerEl) { + (0, _dom.default)(ac.params.dropdownContainerEl).append(ac.$dropdownEl); + } else if ($pageContentEl.length === 0) { + ac.$dropdownEl.insertAfter(ac.$inputEl); + } else { + ac.positionDropdown(); + $pageContentEl.append(ac.$dropdownEl); + } + + ac.onOpen('dropdown', ac.$dropdownEl); + ac.onOpened('dropdown', ac.$dropdownEl); + }; + + _proto.open = function open() { + var ac = this; + if (ac.opened) return ac; + var openIn = ac.params.openIn; + ac["open" + openIn.split('').map(function (el, index) { + if (index === 0) return el.toUpperCase(); + return el; + }).join('')](); + return ac; + }; + + _proto.close = function close() { + var ac = this; + if (!ac.opened) return ac; + + if (ac.params.openIn === 'dropdown') { + ac.onClose(); + ac.onClosed(); + } else if (ac.params.routableModals && ac.view || ac.openedIn === 'page') { + ac.view.router.back({ + animate: ac.params.animate + }); + } else { + ac.modal.once('modalClosed', function () { + (0, _utils.nextTick)(function () { + if (ac.destroyed) return; + ac.modal.destroy(); + delete ac.modal; + }); + }); + ac.modal.close(); + } + + return ac; + }; + + _proto.init = function init() { + var ac = this; + ac.attachEvents(); + }; + + _proto.destroy = function destroy() { + var ac = this; + ac.emit('local::beforeDestroy autocompleteBeforeDestroy', ac); + ac.detachEvents(); + + if (ac.$inputEl && ac.$inputEl[0]) { + delete ac.$inputEl[0].f7Autocomplete; + } + + if (ac.$openerEl && ac.$openerEl[0]) { + delete ac.$openerEl[0].f7Autocomplete; + } + + (0, _utils.deleteProps)(ac); + ac.destroyed = true; + }; + + _createClass(Autocomplete, [{ + key: "view", + get: function get() { + var ac = this; + var $openerEl = ac.$openerEl, + $inputEl = ac.$inputEl, + app = ac.app; + var view; + + if (ac.params.view) { + view = ac.params.view; + } else if ($openerEl || $inputEl) { + var $el = $openerEl || $inputEl; + view = $el.closest('.view').length && $el.closest('.view')[0].f7View; + } + + if (!view) view = app.views.main; + return view; + } + }]); + + return Autocomplete; +}(_class.default); + +var _default = Autocomplete; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/autocomplete/autocomplete.js b/www/assets/framework7/cjs/components/autocomplete/autocomplete.js new file mode 100644 index 000000000..4e064007b --- /dev/null +++ b/www/assets/framework7/cjs/components/autocomplete/autocomplete.js @@ -0,0 +1,93 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _utils = require("../../shared/utils"); + +var _autocompleteClass = _interopRequireDefault(require("./autocomplete-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'autocomplete', + params: { + autocomplete: { + openerEl: undefined, + inputEl: undefined, + view: undefined, + // DropDown + dropdownContainerEl: undefined, + dropdownPlaceholderText: undefined, + typeahead: false, + highlightMatches: true, + expandInput: false, + updateInputValueOnSelect: true, + inputEvents: 'input', + value: undefined, + multiple: false, + source: undefined, + limit: undefined, + valueProperty: 'id', + textProperty: 'text', + openIn: 'page', + // or 'popup' or 'dropdown' + pageBackLinkText: 'Back', + popupCloseLinkText: 'Close', + pageTitle: undefined, + searchbarPlaceholder: 'Search...', + searchbarDisableText: 'Cancel', + searchbarDisableButton: undefined, + searchbarSpellcheck: false, + popupPush: false, + popupSwipeToClose: undefined, + animate: true, + autoFocus: false, + closeOnSelect: false, + notFoundText: 'Nothing found', + requestSourceOnOpen: false, + // Preloader + preloaderColor: undefined, + preloader: false, + // Colors + formColorTheme: undefined, + navbarColorTheme: undefined, + // Routing + routableModals: false, + url: 'select/', + // Custom render functions + renderDropdown: undefined, + renderPage: undefined, + renderPopup: undefined, + renderItem: undefined, + renderSearchbar: undefined, + renderNavbar: undefined + } + }, + static: { + Autocomplete: _autocompleteClass.default + }, + create: function create() { + var app = this; + app.autocomplete = (0, _utils.extend)((0, _constructorMethods.default)({ + defaultSelector: undefined, + constructor: _autocompleteClass.default, + app: app, + domProp: 'f7Autocomplete' + }), { + open: function open(autocompleteEl) { + var ac = app.autocomplete.get(autocompleteEl); + if (ac && ac.open) return ac.open(); + return undefined; + }, + close: function close(autocompleteEl) { + var ac = app.autocomplete.get(autocompleteEl); + if (ac && ac.close) return ac.close(); + return undefined; + } + }); + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/badge/badge.js b/www/assets/framework7/cjs/components/badge/badge.js new file mode 100644 index 000000000..30228dd38 --- /dev/null +++ b/www/assets/framework7/cjs/components/badge/badge.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _default = { + name: 'badge' +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/block/block.js b/www/assets/framework7/cjs/components/block/block.js new file mode 100644 index 000000000..b102d2734 --- /dev/null +++ b/www/assets/framework7/cjs/components/block/block.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _default = { + name: 'block' +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/button/button.js b/www/assets/framework7/cjs/components/button/button.js new file mode 100644 index 000000000..16e0059c8 --- /dev/null +++ b/www/assets/framework7/cjs/components/button/button.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _default = { + name: 'button' +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/calendar/calendar-class.js b/www/assets/framework7/cjs/components/calendar/calendar-class.js new file mode 100644 index 000000000..a19217fd5 --- /dev/null +++ b/www/assets/framework7/cjs/components/calendar/calendar-class.js @@ -0,0 +1,2095 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _getDevice = require("../../shared/get-device"); + +var _getSupport = require("../../shared/get-support"); + +var _$jsx = _interopRequireDefault(require("../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Calendar = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(Calendar, _Framework7Class); + + function Calendar(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params, [app]) || this; + + var calendar = _assertThisInitialized(_this); + + calendar.params = (0, _utils.extend)({}, app.params.calendar, params); + var $containerEl; + + if (calendar.params.containerEl) { + $containerEl = (0, _dom.default)(calendar.params.containerEl); + if ($containerEl.length === 0) return calendar || _assertThisInitialized(_this); + } + + var $inputEl; + + if (calendar.params.inputEl) { + $inputEl = (0, _dom.default)(calendar.params.inputEl); + } + + var isHorizontal = calendar.params.direction === 'horizontal'; + var inverter = 1; + + if (isHorizontal) { + inverter = app.rtl ? -1 : 1; + } + + (0, _utils.extend)(calendar, { + app: app, + $containerEl: $containerEl, + containerEl: $containerEl && $containerEl[0], + inline: $containerEl && $containerEl.length > 0, + $inputEl: $inputEl, + inputEl: $inputEl && $inputEl[0], + initialized: false, + opened: false, + url: calendar.params.url, + isHorizontal: isHorizontal, + inverter: inverter, + animating: false, + allowTouchMove: true, + hasTimePicker: calendar.params.timePicker && !calendar.params.rangePicker && !calendar.params.multiple + }); + + calendar.dayFormatter = function (date) { + var formatter = new Intl.DateTimeFormat(calendar.params.locale, { + day: 'numeric' + }); + return formatter.format(date).replace(/日/, ''); + }; + + calendar.monthFormatter = function (date) { + var formatter = new Intl.DateTimeFormat(calendar.params.locale, { + month: 'long' + }); + return formatter.format(date); + }; + + calendar.yearFormatter = function (date) { + var formatter = new Intl.DateTimeFormat(calendar.params.locale, { + year: 'numeric' + }); + return formatter.format(date); + }; + + calendar.timeSelectorFormatter = function (date) { + var formatter = new Intl.DateTimeFormat(calendar.params.locale, calendar.params.timePickerFormat); + return formatter.format(date); + }; + + var timeFormatCheckDate = calendar.timeSelectorFormatter(new Date()).toLowerCase(); + calendar.is12HoursFormat = timeFormatCheckDate.indexOf('pm') >= 0 || timeFormatCheckDate.indexOf('am') >= 0; // Auto names + + var _calendar$params = calendar.params, + monthNames = _calendar$params.monthNames, + monthNamesShort = _calendar$params.monthNamesShort, + dayNames = _calendar$params.dayNames, + dayNamesShort = _calendar$params.dayNamesShort; + + var _calendar$getIntlName = calendar.getIntlNames(), + monthNamesIntl = _calendar$getIntlName.monthNamesIntl, + monthNamesShortIntl = _calendar$getIntlName.monthNamesShortIntl, + dayNamesIntl = _calendar$getIntlName.dayNamesIntl, + dayNamesShortIntl = _calendar$getIntlName.dayNamesShortIntl; + + if (monthNames === 'auto') monthNames = monthNamesIntl; + if (monthNamesShort === 'auto') monthNamesShort = monthNamesShortIntl; + if (dayNames === 'auto') dayNames = dayNamesIntl; + if (dayNamesShort === 'auto') dayNamesShort = dayNamesShortIntl; + (0, _utils.extend)(calendar, { + monthNames: monthNames, + monthNamesShort: monthNamesShort, + dayNames: dayNames, + dayNamesShort: dayNamesShort + }); + + function onInputClick() { + calendar.open(); + } + + function onInputFocus(e) { + e.preventDefault(); + } + + function onInputClear() { + calendar.setValue([]); + + if (calendar.opened) { + calendar.update(); + } + } + + function onHtmlClick(e) { + var $targetEl = (0, _dom.default)(e.target); + if (calendar.destroyed || !calendar.params) return; + if (calendar.isPopover()) return; + if (!calendar.opened || calendar.closing) return; + if ($targetEl.closest('[class*="backdrop"]').length) return; + + if ($inputEl && $inputEl.length > 0) { + if ($targetEl[0] !== $inputEl[0] && $targetEl.closest('.sheet-modal, .calendar-modal').length === 0) { + calendar.close(); + } + } else if ((0, _dom.default)(e.target).closest('.sheet-modal, .calendar-modal').length === 0) { + calendar.close(); + } + } // Events + + + (0, _utils.extend)(calendar, { + attachInputEvents: function attachInputEvents() { + calendar.$inputEl.on('click', onInputClick); + calendar.$inputEl.on('input:clear', onInputClear); + + if (calendar.params.inputReadOnly) { + calendar.$inputEl.on('focus mousedown', onInputFocus); + + if (calendar.$inputEl[0]) { + calendar.$inputEl[0].f7ValidateReadonly = true; + } + } + }, + detachInputEvents: function detachInputEvents() { + calendar.$inputEl.off('click', onInputClick); + calendar.$inputEl.off('input:clear', onInputClear); + + if (calendar.params.inputReadOnly) { + calendar.$inputEl.off('focus mousedown', onInputFocus); + + if (calendar.$inputEl[0]) { + delete calendar.$inputEl[0].f7ValidateReadonly; + } + } + }, + attachHtmlEvents: function attachHtmlEvents() { + app.on('click', onHtmlClick); + }, + detachHtmlEvents: function detachHtmlEvents() { + app.off('click', onHtmlClick); + } + }); + + calendar.attachCalendarEvents = function attachCalendarEvents() { + var allowItemClick = true; + var isTouched; + var isMoved; + var touchStartX; + var touchStartY; + var touchCurrentX; + var touchCurrentY; + var touchStartTime; + var touchEndTime; + var currentTranslate; + var wrapperWidth; + var wrapperHeight; + var percentage; + var touchesDiff; + var isScrolling; + var $el = calendar.$el, + $wrapperEl = calendar.$wrapperEl; + + function handleTouchStart(e) { + if (isMoved || isTouched) return; + isTouched = true; + touchStartX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; + touchCurrentX = touchStartX; + touchStartY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + touchCurrentY = touchStartY; + touchStartTime = new Date().getTime(); + percentage = 0; + allowItemClick = true; + isScrolling = undefined; + currentTranslate = calendar.monthsTranslate; + } + + function handleTouchMove(e) { + if (!isTouched) return; + var isH = calendar.isHorizontal; + touchCurrentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; + touchCurrentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; + + if (typeof isScrolling === 'undefined') { + isScrolling = !!(isScrolling || Math.abs(touchCurrentY - touchStartY) > Math.abs(touchCurrentX - touchStartX)); + } + + if (isH && isScrolling || !calendar.allowTouchMove) { + isTouched = false; + return; + } + + e.preventDefault(); + + if (calendar.animating) { + isTouched = false; + return; + } + + allowItemClick = false; + + if (!isMoved) { + // First move + isMoved = true; + wrapperWidth = $wrapperEl[0].offsetWidth; + wrapperHeight = $wrapperEl[0].offsetHeight; + $wrapperEl.transition(0); + } + + touchesDiff = isH ? touchCurrentX - touchStartX : touchCurrentY - touchStartY; + percentage = touchesDiff / (isH ? wrapperWidth : wrapperHeight); + currentTranslate = (calendar.monthsTranslate * calendar.inverter + percentage) * 100; // Transform wrapper + + $wrapperEl.transform("translate3d(" + (isH ? currentTranslate : 0) + "%, " + (isH ? 0 : currentTranslate) + "%, 0)"); + } + + function handleTouchEnd() { + if (!isTouched || !isMoved) { + isTouched = false; + isMoved = false; + return; + } + + isTouched = false; + isMoved = false; + touchEndTime = new Date().getTime(); + + if (touchEndTime - touchStartTime < 300) { + if (Math.abs(touchesDiff) < 10) { + calendar.resetMonth(); + } else if (touchesDiff >= 10) { + if (app.rtl) calendar.nextMonth();else calendar.prevMonth(); + } else if (app.rtl) calendar.prevMonth();else calendar.nextMonth(); + } else if (percentage <= -0.5) { + if (app.rtl) calendar.prevMonth();else calendar.nextMonth(); + } else if (percentage >= 0.5) { + if (app.rtl) calendar.nextMonth();else calendar.prevMonth(); + } else { + calendar.resetMonth(); + } // Allow click + + + setTimeout(function () { + allowItemClick = true; + }, 100); + } + + function handleDayClick(e) { + if (!allowItemClick) return; + var $dayEl = (0, _dom.default)(e.target).parents('.calendar-day'); + + if ($dayEl.length === 0 && (0, _dom.default)(e.target).hasClass('calendar-day')) { + $dayEl = (0, _dom.default)(e.target); + } + + if ($dayEl.length === 0) return; + if ($dayEl.hasClass('calendar-day-disabled')) return; + + if (!calendar.params.rangePicker) { + if ($dayEl.hasClass('calendar-day-next')) calendar.nextMonth(); + if ($dayEl.hasClass('calendar-day-prev')) calendar.prevMonth(); + } + + var dateYear = parseInt($dayEl.attr('data-year'), 10); + var dateMonth = parseInt($dayEl.attr('data-month'), 10); + var dateDay = parseInt($dayEl.attr('data-day'), 10); + calendar.emit('local::dayClick calendarDayClick', calendar, $dayEl[0], dateYear, dateMonth, dateDay); + + if (!$dayEl.hasClass('calendar-day-selected') || calendar.params.multiple || calendar.params.rangePicker) { + var valueToAdd = new Date(dateYear, dateMonth, dateDay, 0, 0, 0); + + if (calendar.hasTimePicker) { + if (calendar.value && calendar.value[0]) { + valueToAdd.setHours(calendar.value[0].getHours(), calendar.value[0].getMinutes()); + } else { + valueToAdd.setHours(new Date().getHours(), new Date().getMinutes()); + } + } + + calendar.addValue(valueToAdd); + } + + if (calendar.params.closeOnSelect) { + if (calendar.params.rangePicker && calendar.value.length === 2 || !calendar.params.rangePicker) { + calendar.close(); + } + } + } + + function onNextMonthClick() { + calendar.nextMonth(); + } + + function onPrevMonthClick() { + calendar.prevMonth(); + } + + function onNextYearClick() { + calendar.nextYear(); + } + + function onPrevYearClick() { + calendar.prevYear(); + } + + function onMonthSelectorClick() { + $el.append(calendar.renderMonthPicker()); + } + + function onMonthSelectorItemClick() { + var $clickedEl = (0, _dom.default)(this); + + if ($clickedEl.hasClass('calendar-month-picker-item-current')) { + $el.find('.calendar-month-picker').remove(); + return; + } + + $el.find('.calendar-month-picker-item-current').add($clickedEl).toggleClass('calendar-month-picker-item-current'); + var index = $clickedEl.index(); + var localeMonthIndex = parseInt(calendar.$el.find('.calendar-month-current').attr('data-locale-month'), 10); + var monthIndex = calendar.currentMonth; + var diff = localeMonthIndex - monthIndex; + var diffIndex = index - diff; + calendar.setYearMonth(calendar.currentYear, diffIndex, 0); + setTimeout(function () { + $el.find('.calendar-month-picker').remove(); + }, 200); + } + + function onYearSelectorClick() { + $el.append(calendar.renderYearPicker()); + var $currentEl = $el.find('.calendar-year-picker-item-current'); + var $yearPickerEl = $el.find('.calendar-year-picker'); + if (!$currentEl || !$currentEl.length) return; + $yearPickerEl.scrollTop($currentEl[0].offsetTop - $yearPickerEl[0].offsetHeight / 2 + $currentEl[0].offsetHeight / 2); + } + + function onYearSelectorItemClick() { + var $clickedEl = (0, _dom.default)(this); + + if ($clickedEl.hasClass('calendar-year-picker-item-current')) { + $el.find('.calendar-year-picker').remove(); + return; + } + + $el.find('.calendar-year-picker-item-current').add($clickedEl).toggleClass('calendar-year-picker-item-current'); + var year = parseInt($clickedEl.attr('data-year'), 10); + calendar.setYearMonth(year, undefined, 0); + setTimeout(function () { + $el.find('.calendar-year-picker').remove(); + }, 200); + } + + function onTimeSelectorClick() { + calendar.openTimePicker(); + } + + function onTimePickerCloseClick() { + calendar.closeTimePicker(); + } + + var passiveListener = app.touchEvents.start === 'touchstart' && (0, _getSupport.getSupport)().passiveListener ? { + passive: true, + capture: false + } : false; // Selectors clicks + + $el.find('.calendar-prev-month-button').on('click', onPrevMonthClick); + $el.find('.calendar-next-month-button').on('click', onNextMonthClick); + $el.find('.calendar-prev-year-button').on('click', onPrevYearClick); + $el.find('.calendar-next-year-button').on('click', onNextYearClick); + + if (calendar.params.monthPicker) { + $el.find('.current-month-value').on('click', onMonthSelectorClick); + $el.on('click', '.calendar-month-picker-item', onMonthSelectorItemClick); + } + + if (calendar.params.yearPicker) { + $el.find('.current-year-value').on('click', onYearSelectorClick); + $el.on('click', '.calendar-year-picker-item', onYearSelectorItemClick); + } + + if (calendar.hasTimePicker) { + $el.find('.calendar-time-selector a').on('click', onTimeSelectorClick); + $el.on('click', '.calendar-time-picker-close', onTimePickerCloseClick); + } // Day clicks + + + $wrapperEl.on('click', handleDayClick); // Touch events + + if (calendar.params.touchMove) { + $wrapperEl.on(app.touchEvents.start, handleTouchStart, passiveListener); + app.on('touchmove:active', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + } + + calendar.detachCalendarEvents = function detachCalendarEvents() { + $el.find('.calendar-prev-month-button').off('click', onPrevMonthClick); + $el.find('.calendar-next-month-button').off('click', onNextMonthClick); + $el.find('.calendar-prev-year-button').off('click', onPrevYearClick); + $el.find('.calendar-next-year-button').off('click', onNextYearClick); + + if (calendar.params.monthPicker) { + $el.find('.current-month-value').off('click', onMonthSelectorClick); + $el.off('click', '.calendar-month-picker-item', onMonthSelectorItemClick); + } + + if (calendar.params.yearPicker) { + $el.find('.current-year-value').off('click', onYearSelectorClick); + $el.off('click', '.calendar-year-picker-item', onYearSelectorItemClick); + } + + if (calendar.hasTimePicker) { + $el.find('.calendar-time-selector a').off('click', onTimeSelectorClick); + $el.off('click', '.calendar-time-picker-close', onTimePickerCloseClick); + } + + $wrapperEl.off('click', handleDayClick); + + if (calendar.params.touchMove) { + $wrapperEl.off(app.touchEvents.start, handleTouchStart, passiveListener); + app.off('touchmove:active', handleTouchMove); + app.off('touchend:passive', handleTouchEnd); + } + }; + }; + + calendar.init(); + return calendar || _assertThisInitialized(_this); + } + + var _proto = Calendar.prototype; + + _proto.getIntlNames = function getIntlNames() { + var calendar = this; + var locale = calendar.params.locale; + var monthNamesIntl = []; + var monthNamesShortIntl = []; + var dayNamesIntl = []; + var dayNamesShortIntl = []; + var formatterMonthNames = new Intl.DateTimeFormat(locale, { + month: 'long' + }); + var formatterMonthNamesShort = new Intl.DateTimeFormat(locale, { + month: 'short' + }); + var formatterDayNames = new Intl.DateTimeFormat(locale, { + weekday: 'long' + }); + var formatterDayNamesShort = new Intl.DateTimeFormat(locale, { + weekday: 'short' + }); + var year; + var yearStarted; + var yearEnded; + + for (var i = 0; i < 24; i += 1) { + var date = new Date().setMonth(i, 1); + var currentYear = calendar.yearFormatter(date); + + if (year && currentYear !== year) { + if (yearStarted) yearEnded = true; + yearStarted = true; + year = currentYear; + } + + if (!year) { + year = currentYear; + } + + if (yearStarted && year === currentYear && !yearEnded) { + monthNamesIntl.push(formatterMonthNames.format(date)); + monthNamesShortIntl.push(formatterMonthNamesShort.format(date)); + } + } + + var weekDay = new Date().getDay(); + + for (var _i = 0; _i < 7; _i += 1) { + var _date = new Date().getTime() + (_i - weekDay) * 24 * 60 * 60 * 1000; + + dayNamesIntl.push(formatterDayNames.format(_date)); + dayNamesShortIntl.push(formatterDayNamesShort.format(_date)); + } + + return { + monthNamesIntl: monthNamesIntl, + monthNamesShortIntl: monthNamesShortIntl, + dayNamesIntl: dayNamesIntl, + dayNamesShortIntl: dayNamesShortIntl + }; + }; + + _proto.normalizeDate = function normalizeDate(date) { + var calendar = this; + var d = new Date(date); + + if (calendar.hasTimePicker) { + return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes()); + } + + return new Date(d.getFullYear(), d.getMonth(), d.getDate()); + }; + + _proto.normalizeValues = function normalizeValues(values) { + var calendar = this; + var newValues = []; + + if (values && Array.isArray(values)) { + newValues = values.map(function (val) { + return calendar.normalizeDate(val); + }); + } + + return newValues; + }; + + _proto.initInput = function initInput() { + var calendar = this; + if (!calendar.$inputEl) return; + if (calendar.params.inputReadOnly) calendar.$inputEl.prop('readOnly', true); + }; + + _proto.isPopover = function isPopover() { + var calendar = this; + var app = calendar.app, + modal = calendar.modal, + params = calendar.params; + var device = (0, _getDevice.getDevice)(); + if (params.openIn === 'sheet') return false; + if (modal && modal.type !== 'popover') return false; + + if (!calendar.inline && calendar.inputEl) { + if (params.openIn === 'popover') return true; + + if (device.ios) { + return !!device.ipad; + } + + if (app.width >= 768) { + return true; + } + + if (device.desktop && app.theme === 'aurora') { + return true; + } + } + + return false; + }; + + _proto.formatDate = function formatDate(d) { + var calendar = this; + var date = new Date(d); + var year = date.getFullYear(); + var month = date.getMonth(); + var month1 = month + 1; + var day = date.getDate(); + var weekDay = date.getDay(); + var monthNames = calendar.monthNames, + monthNamesShort = calendar.monthNamesShort, + dayNames = calendar.dayNames, + dayNamesShort = calendar.dayNamesShort; + var _calendar$params2 = calendar.params, + dateFormat = _calendar$params2.dateFormat, + locale = _calendar$params2.locale; + + function twoDigits(number) { + return number < 10 ? "0" + number : number; + } + + if (typeof dateFormat === 'string') { + var tokens = { + yyyy: year, + yy: String(year).substring(2), + mm: twoDigits(month1), + m: month1, + MM: monthNames[month], + M: monthNamesShort[month], + dd: twoDigits(day), + d: day, + DD: dayNames[weekDay], + D: dayNamesShort[weekDay] + }; + + if (calendar.params.timePicker) { + var hours = date.getHours(); + var minutes = date.getMinutes(); + var seconds = date.getSeconds(); + var hours12 = hours; + if (hours > 12) hours12 = hours - 12; + if (hours === 0) hours12 = 12; + var a = hours >= 12 && hours !== 0 ? 'pm' : 'am'; + Object.assign(tokens, { + HH: twoDigits(hours), + H: hours, + hh: twoDigits(hours12), + h: hours12, + ss: twoDigits(seconds), + s: seconds, + ':mm': twoDigits(minutes), + ':m': minutes, + a: a, + A: a.toUpperCase() + }); + } + + var regexp = new RegExp(Object.keys(tokens).map(function (t) { + return "(" + t + ")"; + }).join('|'), 'g'); + return dateFormat.replace(regexp, function (token) { + if (token in tokens) return tokens[token]; + return token; + }); + } + + if (typeof dateFormat === 'function') { + return dateFormat(date); + } // Intl Object + + + var formatter = new Intl.DateTimeFormat(locale, dateFormat); + return formatter.format(date); + }; + + _proto.formatValue = function formatValue() { + var calendar = this; + var value = calendar.value; + + if (calendar.params.formatValue) { + return calendar.params.formatValue.call(calendar, value); + } + + return value.map(function (v) { + return calendar.formatDate(v); + }).join(calendar.params.rangePicker ? ' - ' : ', '); + }; + + _proto.addValue = function addValue(newValue) { + var calendar = this; + var _calendar$params3 = calendar.params, + multiple = _calendar$params3.multiple, + rangePicker = _calendar$params3.rangePicker, + rangePickerMinDays = _calendar$params3.rangePickerMinDays, + rangePickerMaxDays = _calendar$params3.rangePickerMaxDays; + + if (multiple) { + if (!calendar.value) calendar.value = []; + var inValuesIndex; + + for (var i = 0; i < calendar.value.length; i += 1) { + if (new Date(newValue).getTime() === new Date(calendar.value[i]).getTime()) { + inValuesIndex = i; + } + } + + if (typeof inValuesIndex === 'undefined') { + calendar.value.push(newValue); + } else { + calendar.value.splice(inValuesIndex, 1); + } + + calendar.updateValue(); + } else if (rangePicker) { + if (!calendar.value) calendar.value = []; + + if (calendar.value.length === 2 || calendar.value.length === 0) { + calendar.value = []; + } + + if (calendar.value.length === 0 || Math.abs(calendar.value[0].getTime() - newValue.getTime()) >= (rangePickerMinDays - 1) * 60 * 60 * 24 * 1000 && (rangePickerMaxDays === 0 || Math.abs(calendar.value[0].getTime() - newValue.getTime()) <= (rangePickerMaxDays - 1) * 60 * 60 * 24 * 1000)) calendar.value.push(newValue);else calendar.value = []; + calendar.value.sort(function (a, b) { + return a - b; + }); + calendar.updateValue(); + } else { + calendar.value = [newValue]; + calendar.updateValue(); + } + }; + + _proto.setValue = function setValue(values) { + var calendar = this; + var currentValue = calendar.value; + + if (Array.isArray(currentValue) && Array.isArray(values) && currentValue.length === values.length) { + var equal = true; + currentValue.forEach(function (v, index) { + if (v !== values[index]) equal = false; + }); + if (equal) return; + } + + calendar.value = values; + calendar.updateValue(); + }; + + _proto.getValue = function getValue() { + var calendar = this; + return calendar.value; + }; + + _proto.updateValue = function updateValue(onlyHeader) { + var calendar = this; + var $el = calendar.$el, + $wrapperEl = calendar.$wrapperEl, + $inputEl = calendar.$inputEl, + value = calendar.value, + params = calendar.params; + var i; + + if ($el && $el.length > 0) { + $wrapperEl.find('.calendar-day-selected').removeClass('calendar-day-selected calendar-day-selected-range calendar-day-selected-left calendar-day-selected-right'); + var valueDate; + + if (params.rangePicker && value.length === 2) { + var leftDate = new Date(value[0]).getTime(); + var rightDate = new Date(value[1]).getTime(); + + for (i = leftDate; i <= rightDate; i += 24 * 60 * 60 * 1000) { + valueDate = new Date(i); + var addClass = 'calendar-day-selected'; + + if (leftDate !== rightDate) { + if (i !== leftDate && i !== rightDate) { + addClass += ' calendar-day-selected-range'; + } + + if (i === leftDate) { + addClass += ' calendar-day-selected-left'; + } + + if (i === rightDate) { + addClass += ' calendar-day-selected-right'; + } + } + + $wrapperEl.find(".calendar-day[data-date=\"" + valueDate.getFullYear() + "-" + valueDate.getMonth() + "-" + valueDate.getDate() + "\"]").addClass(addClass); + } + + valueDate = new Date(leftDate); + $wrapperEl.find(".calendar-day[data-date=\"" + valueDate.getFullYear() + "-" + valueDate.getMonth() + "-" + valueDate.getDate() + "\"]").removeClass('calendar-day-selected-range').addClass('calendar-day-selected calendar-day-selected-left'); + valueDate = new Date(rightDate); + $wrapperEl.find(".calendar-day[data-date=\"" + valueDate.getFullYear() + "-" + valueDate.getMonth() + "-" + valueDate.getDate() + "\"]").removeClass('calendar-day-selected-range').addClass('calendar-day-selected calendar-day-selected-right'); + } else { + for (i = 0; i < calendar.value.length; i += 1) { + valueDate = new Date(value[i]); + $wrapperEl.find(".calendar-day[data-date=\"" + valueDate.getFullYear() + "-" + valueDate.getMonth() + "-" + valueDate.getDate() + "\"]").addClass('calendar-day-selected'); + } + } + } + + if (!onlyHeader) { + calendar.emit('local::change calendarChange', calendar, value); + } + + if ($el && $el.length > 0 && calendar.hasTimePicker) { + $el.find('.calendar-time-selector a').text(value && value.length ? calendar.timeSelectorFormatter(value[0]) : calendar.params.timePickerPlaceholder); + } + + if ($inputEl && $inputEl.length || params.header) { + var inputValue = calendar.formatValue(value); + + if (params.header && $el && $el.length) { + $el.find('.calendar-selected-date').text(inputValue); + } + + if ($inputEl && $inputEl.length && !onlyHeader) { + $inputEl.val(inputValue); + $inputEl.trigger('change'); + } + } + }; + + _proto.updateCurrentMonthYear = function updateCurrentMonthYear(dir) { + var calendar = this; + var $months = calendar.$months, + $el = calendar.$el, + monthNames = calendar.monthNames; + var currentLocaleMonth; + var currentLocaleYear; + + if (typeof dir === 'undefined') { + calendar.currentMonth = parseInt($months.eq(1).attr('data-month'), 10); + calendar.currentYear = parseInt($months.eq(1).attr('data-year'), 10); + currentLocaleMonth = $months.eq(1).attr('data-locale-month'); + currentLocaleYear = $months.eq(1).attr('data-locale-year'); + } else { + calendar.currentMonth = parseInt($months.eq(dir === 'next' ? $months.length - 1 : 0).attr('data-month'), 10); + calendar.currentYear = parseInt($months.eq(dir === 'next' ? $months.length - 1 : 0).attr('data-year'), 10); + currentLocaleMonth = $months.eq(dir === 'next' ? $months.length - 1 : 0).attr('data-locale-month'); + currentLocaleYear = $months.eq(dir === 'next' ? $months.length - 1 : 0).attr('data-locale-year'); + } + + $el.find('.current-month-value').text(monthNames[currentLocaleMonth]); + $el.find('.current-year-value').text(currentLocaleYear); + }; + + _proto.update = function update() { + var calendar = this; + var currentYear = calendar.currentYear, + currentMonth = calendar.currentMonth, + $wrapperEl = calendar.$wrapperEl; + var currentDate = new Date(currentYear, currentMonth); + var prevMonthHtml = calendar.renderMonth(currentDate, 'prev'); + var currentMonthHtml = calendar.renderMonth(currentDate); + var nextMonthHtml = calendar.renderMonth(currentDate, 'next'); + $wrapperEl.transition(0).html("" + prevMonthHtml + currentMonthHtml + nextMonthHtml).transform('translate3d(0,0,0)'); + calendar.$months = $wrapperEl.find('.calendar-month'); + calendar.monthsTranslate = 0; + calendar.setMonthsTranslate(); + calendar.$months.each(function (monthEl) { + calendar.emit('local::monthAdd calendarMonthAdd', monthEl); + }); + }; + + _proto.onMonthChangeStart = function onMonthChangeStart(dir) { + var calendar = this; + var $months = calendar.$months, + currentYear = calendar.currentYear, + currentMonth = calendar.currentMonth; + calendar.updateCurrentMonthYear(dir); + $months.removeClass('calendar-month-current calendar-month-prev calendar-month-next'); + var currentIndex = dir === 'next' ? $months.length - 1 : 0; + $months.eq(currentIndex).addClass('calendar-month-current'); + $months.eq(dir === 'next' ? currentIndex - 1 : currentIndex + 1).addClass(dir === 'next' ? 'calendar-month-prev' : 'calendar-month-next'); + calendar.emit('local::monthYearChangeStart calendarMonthYearChangeStart', calendar, currentYear, currentMonth); + }; + + _proto.onMonthChangeEnd = function onMonthChangeEnd(dir, rebuildBoth) { + var calendar = this; + var currentYear = calendar.currentYear, + currentMonth = calendar.currentMonth, + $wrapperEl = calendar.$wrapperEl, + monthsTranslate = calendar.monthsTranslate; + calendar.animating = false; + var nextMonthHtml; + var prevMonthHtml; + var currentMonthHtml; + $wrapperEl.find('.calendar-month:not(.calendar-month-prev):not(.calendar-month-current):not(.calendar-month-next)').remove(); + + if (typeof dir === 'undefined') { + dir = 'next'; // eslint-disable-line + + rebuildBoth = true; // eslint-disable-line + } + + if (!rebuildBoth) { + currentMonthHtml = calendar.renderMonth(new Date(currentYear, currentMonth), dir); + } else { + $wrapperEl.find('.calendar-month-next, .calendar-month-prev').remove(); + prevMonthHtml = calendar.renderMonth(new Date(currentYear, currentMonth), 'prev'); + nextMonthHtml = calendar.renderMonth(new Date(currentYear, currentMonth), 'next'); + } + + if (dir === 'next' || rebuildBoth) { + $wrapperEl.append(currentMonthHtml || nextMonthHtml); + } + + if (dir === 'prev' || rebuildBoth) { + $wrapperEl.prepend(currentMonthHtml || prevMonthHtml); + } + + var $months = $wrapperEl.find('.calendar-month'); + calendar.$months = $months; + calendar.setMonthsTranslate(monthsTranslate); + calendar.emit('local::monthAdd calendarMonthAdd', calendar, dir === 'next' ? $months.eq($months.length - 1)[0] : $months.eq(0)[0]); + calendar.emit('local::monthYearChangeEnd calendarMonthYearChangeEnd', calendar, currentYear, currentMonth); + }; + + _proto.setMonthsTranslate = function setMonthsTranslate(translate) { + var calendar = this; + var $months = calendar.$months, + isH = calendar.isHorizontal, + inverter = calendar.inverter; // eslint-disable-next-line + + translate = translate || calendar.monthsTranslate || 0; + + if (typeof calendar.monthsTranslate === 'undefined') { + calendar.monthsTranslate = translate; + } + + $months.removeClass('calendar-month-current calendar-month-prev calendar-month-next'); + var prevMonthTranslate = -(translate + 1) * 100 * inverter; + var currentMonthTranslate = -translate * 100 * inverter; + var nextMonthTranslate = -(translate - 1) * 100 * inverter; + $months.eq(0).transform("translate3d(" + (isH ? prevMonthTranslate : 0) + "%, " + (isH ? 0 : prevMonthTranslate) + "%, 0)").addClass('calendar-month-prev'); + $months.eq(1).transform("translate3d(" + (isH ? currentMonthTranslate : 0) + "%, " + (isH ? 0 : currentMonthTranslate) + "%, 0)").addClass('calendar-month-current'); + $months.eq(2).transform("translate3d(" + (isH ? nextMonthTranslate : 0) + "%, " + (isH ? 0 : nextMonthTranslate) + "%, 0)").addClass('calendar-month-next'); + }; + + _proto.nextMonth = function nextMonth(transition) { + var calendar = this; + var params = calendar.params, + $wrapperEl = calendar.$wrapperEl, + inverter = calendar.inverter, + isH = calendar.isHorizontal; + + if (typeof transition === 'undefined' || typeof transition === 'object') { + transition = ''; // eslint-disable-line + + if (!params.animate) transition = 0; // eslint-disable-line + } + + var nextMonth = parseInt(calendar.$months.eq(calendar.$months.length - 1).attr('data-month'), 10); + var nextYear = parseInt(calendar.$months.eq(calendar.$months.length - 1).attr('data-year'), 10); + var nextDate = new Date(nextYear, nextMonth); + var nextDateTime = nextDate.getTime(); + var transitionEndCallback = !calendar.animating; + + if (params.maxDate) { + if (nextDateTime > new Date(params.maxDate).getTime()) { + calendar.resetMonth(); + return; + } + } + + calendar.monthsTranslate -= 1; + + if (nextMonth === calendar.currentMonth) { + var nextMonthTranslate = -calendar.monthsTranslate * 100 * inverter; + var nextMonthHtml = (0, _dom.default)(calendar.renderMonth(nextDateTime, 'next')).transform("translate3d(" + (isH ? nextMonthTranslate : 0) + "%, " + (isH ? 0 : nextMonthTranslate) + "%, 0)").addClass('calendar-month-next'); + $wrapperEl.append(nextMonthHtml[0]); + calendar.$months = $wrapperEl.find('.calendar-month'); + calendar.emit('local::monthAdd calendarMonthAdd', calendar.$months.eq(calendar.$months.length - 1)[0]); + } + + calendar.animating = true; + calendar.onMonthChangeStart('next'); + var translate = calendar.monthsTranslate * 100 * inverter; + $wrapperEl.transition(transition).transform("translate3d(" + (isH ? translate : 0) + "%, " + (isH ? 0 : translate) + "%, 0)"); + + if (transitionEndCallback) { + $wrapperEl.transitionEnd(function () { + calendar.onMonthChangeEnd('next'); + }); + } + + if (!params.animate) { + calendar.onMonthChangeEnd('next'); + } + }; + + _proto.prevMonth = function prevMonth(transition) { + var calendar = this; + var params = calendar.params, + $wrapperEl = calendar.$wrapperEl, + inverter = calendar.inverter, + isH = calendar.isHorizontal; + + if (typeof transition === 'undefined' || typeof transition === 'object') { + transition = ''; // eslint-disable-line + + if (!params.animate) transition = 0; // eslint-disable-line + } + + var prevMonth = parseInt(calendar.$months.eq(0).attr('data-month'), 10); + var prevYear = parseInt(calendar.$months.eq(0).attr('data-year'), 10); + var prevDate = new Date(prevYear, prevMonth + 1, -1); + var prevDateTime = prevDate.getTime(); + var transitionEndCallback = !calendar.animating; + + if (params.minDate) { + var minDate = new Date(params.minDate); + minDate = new Date(minDate.getFullYear(), minDate.getMonth(), 1); + + if (prevDateTime < minDate.getTime()) { + calendar.resetMonth(); + return; + } + } + + calendar.monthsTranslate += 1; + + if (prevMonth === calendar.currentMonth) { + var prevMonthTranslate = -calendar.monthsTranslate * 100 * inverter; + var prevMonthHtml = (0, _dom.default)(calendar.renderMonth(prevDateTime, 'prev')).transform("translate3d(" + (isH ? prevMonthTranslate : 0) + "%, " + (isH ? 0 : prevMonthTranslate) + "%, 0)").addClass('calendar-month-prev'); + $wrapperEl.prepend(prevMonthHtml[0]); + calendar.$months = $wrapperEl.find('.calendar-month'); + calendar.emit('local::monthAdd calendarMonthAdd', calendar.$months.eq(0)[0]); + } + + calendar.animating = true; + calendar.onMonthChangeStart('prev'); + var translate = calendar.monthsTranslate * 100 * inverter; + $wrapperEl.transition(transition).transform("translate3d(" + (isH ? translate : 0) + "%, " + (isH ? 0 : translate) + "%, 0)"); + + if (transitionEndCallback) { + $wrapperEl.transitionEnd(function () { + calendar.onMonthChangeEnd('prev'); + }); + } + + if (!params.animate) { + calendar.onMonthChangeEnd('prev'); + } + }; + + _proto.resetMonth = function resetMonth(transition) { + if (transition === void 0) { + transition = ''; + } + + var calendar = this; + var $wrapperEl = calendar.$wrapperEl, + inverter = calendar.inverter, + isH = calendar.isHorizontal, + monthsTranslate = calendar.monthsTranslate; + var translate = monthsTranslate * 100 * inverter; + $wrapperEl.transition(transition).transform("translate3d(" + (isH ? translate : 0) + "%, " + (isH ? 0 : translate) + "%, 0)"); + } // eslint-disable-next-line + ; + + _proto.setYearMonth = function setYearMonth(year, month, transition) { + var calendar = this; + var params = calendar.params, + isH = calendar.isHorizontal, + $wrapperEl = calendar.$wrapperEl, + inverter = calendar.inverter; // eslint-disable-next-line + + if (typeof year === 'undefined') year = calendar.currentYear; // eslint-disable-next-line + + if (typeof month === 'undefined') month = calendar.currentMonth; + + if (typeof transition === 'undefined' || typeof transition === 'object') { + // eslint-disable-next-line + transition = ''; // eslint-disable-next-line + + if (!params.animate) transition = 0; + } + + var targetDate; + + if (year < calendar.currentYear) { + targetDate = new Date(year, month + 1, -1).getTime(); + } else { + targetDate = new Date(year, month).getTime(); + } + + if (params.maxDate && targetDate > new Date(params.maxDate).getTime()) { + return false; + } + + if (params.minDate) { + var minDate = new Date(params.minDate); + minDate = new Date(minDate.getFullYear(), minDate.getMonth(), 1); + + if (targetDate < minDate.getTime()) { + return false; + } + } + + var currentDate = new Date(calendar.currentYear, calendar.currentMonth).getTime(); + var dir = targetDate > currentDate ? 'next' : 'prev'; + var newMonthHTML = calendar.renderMonth(new Date(year, month)); + calendar.monthsTranslate = calendar.monthsTranslate || 0; + var prevTranslate = calendar.monthsTranslate; + var monthTranslate; + var transitionEndCallback = !calendar.animating && transition !== 0; + + if (targetDate > currentDate) { + // To next + calendar.monthsTranslate -= 1; + if (!calendar.animating) calendar.$months.eq(calendar.$months.length - 1).remove(); + $wrapperEl.append(newMonthHTML); + calendar.$months = $wrapperEl.find('.calendar-month'); + monthTranslate = -(prevTranslate - 1) * 100 * inverter; + calendar.$months.eq(calendar.$months.length - 1).transform("translate3d(" + (isH ? monthTranslate : 0) + "%, " + (isH ? 0 : monthTranslate) + "%, 0)").addClass('calendar-month-next'); + } else { + // To prev + calendar.monthsTranslate += 1; + if (!calendar.animating) calendar.$months.eq(0).remove(); + $wrapperEl.prepend(newMonthHTML); + calendar.$months = $wrapperEl.find('.calendar-month'); + monthTranslate = -(prevTranslate + 1) * 100 * inverter; + calendar.$months.eq(0).transform("translate3d(" + (isH ? monthTranslate : 0) + "%, " + (isH ? 0 : monthTranslate) + "%, 0)").addClass('calendar-month-prev'); + } + + calendar.emit('local::monthAdd calendarMonthAdd', dir === 'next' ? calendar.$months.eq(calendar.$months.length - 1)[0] : calendar.$months.eq(0)[0]); + calendar.animating = true; + calendar.onMonthChangeStart(dir); + var wrapperTranslate = calendar.monthsTranslate * 100 * inverter; + $wrapperEl.transition(transition).transform("translate3d(" + (isH ? wrapperTranslate : 0) + "%, " + (isH ? 0 : wrapperTranslate) + "%, 0)"); + + if (transitionEndCallback) { + $wrapperEl.transitionEnd(function () { + calendar.onMonthChangeEnd(dir, true); + }); + } + + if (!params.animate || transition === 0) { + calendar.onMonthChangeEnd(dir, true); + } + }; + + _proto.nextYear = function nextYear() { + var calendar = this; + calendar.setYearMonth(calendar.currentYear + 1); + }; + + _proto.prevYear = function prevYear() { + var calendar = this; + calendar.setYearMonth(calendar.currentYear - 1); + } // eslint-disable-next-line + ; + + _proto.dateInRange = function dateInRange(dayDate, range) { + var match = false; + var i; + if (!range) return false; + + if (Array.isArray(range)) { + for (i = 0; i < range.length; i += 1) { + if (range[i].from || range[i].to) { + if (range[i].from && range[i].to) { + if (dayDate <= new Date(range[i].to).getTime() && dayDate >= new Date(range[i].from).getTime()) { + match = true; + } + } else if (range[i].from) { + if (dayDate >= new Date(range[i].from).getTime()) { + match = true; + } + } else if (range[i].to) { + if (dayDate <= new Date(range[i].to).getTime()) { + match = true; + } + } + } else if (range[i].date) { + if (dayDate === new Date(range[i].date).getTime()) { + match = true; + } + } else if (dayDate === new Date(range[i]).getTime()) { + match = true; + } + } + } else if (range.from || range.to) { + if (range.from && range.to) { + if (dayDate <= new Date(range.to).getTime() && dayDate >= new Date(range.from).getTime()) { + match = true; + } + } else if (range.from) { + if (dayDate >= new Date(range.from).getTime()) { + match = true; + } + } else if (range.to) { + if (dayDate <= new Date(range.to).getTime()) { + match = true; + } + } + } else if (range.date) { + match = dayDate === new Date(range.date).getTime(); + } else if (typeof range === 'function') { + match = range(new Date(dayDate)); + } + + return match; + } // eslint-disable-next-line + ; + + _proto.daysInMonth = function daysInMonth(date) { + var d = new Date(date); + return new Date(d.getFullYear(), d.getMonth() + 1, 0).getDate(); + }; + + _proto.renderMonths = function renderMonths(date) { + var calendar = this; + + if (calendar.params.renderMonths) { + return calendar.params.renderMonths.call(calendar, date); + } + + return (0, _$jsx.default)("div", { + class: "calendar-months-wrapper" + }, calendar.renderMonth(date, 'prev'), calendar.renderMonth(date), calendar.renderMonth(date, 'next')); + }; + + _proto.renderMonth = function renderMonth(d, offset) { + var calendar = this; + var params = calendar.params, + value = calendar.value; + + if (params.renderMonth) { + return params.renderMonth.call(calendar, d, offset); + } + + var date = new Date(d); + var year = date.getFullYear(); + var month = date.getMonth(); + var localeMonth = calendar.monthNames.indexOf(calendar.monthFormatter(date)); + if (localeMonth < 0) localeMonth = month; + var localeYear = calendar.yearFormatter(date); + + if (offset === 'next') { + if (month === 11) date = new Date(year + 1, 0);else date = new Date(year, month + 1, 1); + } + + if (offset === 'prev') { + if (month === 0) date = new Date(year - 1, 11);else date = new Date(year, month - 1, 1); + } + + if (offset === 'next' || offset === 'prev') { + month = date.getMonth(); + year = date.getFullYear(); + localeMonth = calendar.monthNames.indexOf(calendar.monthFormatter(date)); + if (localeMonth < 0) localeMonth = month; + localeYear = calendar.yearFormatter(date); + } + + var currentValues = []; + var today = new Date().setHours(0, 0, 0, 0); + var minDate = params.minDate ? new Date(params.minDate).getTime() : null; + var maxDate = params.maxDate ? new Date(params.maxDate).getTime() : null; + var rows = 6; + var cols = 7; + var daysInPrevMonth = calendar.daysInMonth(new Date(date.getFullYear(), date.getMonth()).getTime() - 10 * 24 * 60 * 60 * 1000); + var daysInMonth = calendar.daysInMonth(date); + var minDayNumber = params.firstDay === 6 ? 0 : 1; + var monthHtml = ''; + var dayIndex = 0 + (params.firstDay - 1); + var disabled; + var hasEvents; + var firstDayOfMonthIndex = new Date(date.getFullYear(), date.getMonth()).getDay(); + if (firstDayOfMonthIndex === 0) firstDayOfMonthIndex = 7; + + if (value && value.length) { + for (var i = 0; i < value.length; i += 1) { + currentValues.push(new Date(value[i]).setHours(0, 0, 0, 0)); + } + } + + for (var row = 1; row <= rows; row += 1) { + var rowHtml = ''; + + var _loop = function _loop(col) { + dayIndex += 1; + var dayDate = void 0; + var dayNumber = dayIndex - firstDayOfMonthIndex; + var addClass = ''; + + if (row === 1 && col === 1 && dayNumber > minDayNumber && params.firstDay !== 1) { + dayIndex -= 7; + dayNumber = dayIndex - firstDayOfMonthIndex; + } + + var weekDayIndex = col - 1 + params.firstDay > 6 ? col - 1 - 7 + params.firstDay : col - 1 + params.firstDay; + + if (dayNumber < 0) { + dayNumber = daysInPrevMonth + dayNumber + 1; + addClass += ' calendar-day-prev'; + dayDate = new Date(month - 1 < 0 ? year - 1 : year, month - 1 < 0 ? 11 : month - 1, dayNumber).getTime(); + } else { + dayNumber += 1; + + if (dayNumber > daysInMonth) { + dayNumber -= daysInMonth; + addClass += ' calendar-day-next'; + dayDate = new Date(month + 1 > 11 ? year + 1 : year, month + 1 > 11 ? 0 : month + 1, dayNumber).getTime(); + } else { + dayDate = new Date(year, month, dayNumber).getTime(); + } + } // Today + + + if (dayDate === today) addClass += ' calendar-day-today'; // Selected + + if (params.rangePicker && currentValues.length === 2) { + if (dayDate >= currentValues[0] && dayDate <= currentValues[1]) { + addClass += ' calendar-day-selected'; + } + + if (currentValues[0] !== currentValues[1]) { + if (dayDate > currentValues[0] && dayDate < currentValues[1]) { + addClass += ' calendar-day-selected-range'; + } + + if (dayDate === currentValues[0]) { + addClass += ' calendar-day-selected-left'; + } + + if (dayDate === currentValues[1]) { + addClass += ' calendar-day-selected-right'; + } + } + } else if (currentValues.indexOf(dayDate) >= 0) addClass += ' calendar-day-selected'; // Weekend + + + if (params.weekendDays.indexOf(weekDayIndex) >= 0) { + addClass += ' calendar-day-weekend'; + } // Events + + + var eventsHtml = ''; + hasEvents = false; + + if (params.events) { + if (calendar.dateInRange(dayDate, params.events)) { + hasEvents = true; + } + } + + if (hasEvents) { + addClass += ' calendar-day-has-events'; // prettier-ignore + + eventsHtml = "\n \n \n \n "; + + if (Array.isArray(params.events)) { + var eventDots = []; + params.events.forEach(function (ev) { + var color = ev.color || ''; + + if (eventDots.indexOf(color) < 0 && calendar.dateInRange(dayDate, ev)) { + eventDots.push(color); + } + }); // prettier-ignore + + eventsHtml = "\n \n " + eventDots.map(function (color) { + return ("\n \n ").trim(); + }).join('') + "\n \n "; + } + } // Custom Ranges + + + if (params.rangesClasses) { + for (var k = 0; k < params.rangesClasses.length; k += 1) { + if (calendar.dateInRange(dayDate, params.rangesClasses[k].range)) { + addClass += " " + params.rangesClasses[k].cssClass; + } + } + } // Disabled + + + disabled = false; + + if (minDate && dayDate < minDate || maxDate && dayDate > maxDate) { + disabled = true; + } + + if (params.disabled) { + if (calendar.dateInRange(dayDate, params.disabled)) { + disabled = true; + } + } + + if (disabled) { + addClass += ' calendar-day-disabled'; + } + + dayDate = new Date(dayDate); + var dayYear = dayDate.getFullYear(); + var dayMonth = dayDate.getMonth(); + var dayNumberDisplay = calendar.dayFormatter(dayDate); // prettier-ignore + + rowHtml += ("\n
    \n " + dayNumberDisplay + eventsHtml + "\n
    ").trim(); + }; + + for (var col = 1; col <= cols; col += 1) { + _loop(col); + } + + monthHtml += "
    " + rowHtml + "
    "; + } + + monthHtml = "
    " + monthHtml + "
    "; + return monthHtml; + }; + + _proto.renderWeekHeader = function renderWeekHeader() { + var calendar = this; + + if (calendar.params.renderWeekHeader) { + return calendar.params.renderWeekHeader.call(calendar); + } + + var params = calendar.params; + var weekDaysHtml = ''; + + for (var i = 0; i < 7; i += 1) { + var dayIndex = i + params.firstDay > 6 ? i - 7 + params.firstDay : i + params.firstDay; + var dayName = calendar.dayNamesShort[dayIndex]; + weekDaysHtml += "
    " + dayName + "
    "; + } + + return (0, _$jsx.default)("div", { + class: "calendar-week-header" + }, weekDaysHtml); + }; + + _proto.renderMonthSelector = function renderMonthSelector() { + var calendar = this; + + if (calendar.params.renderMonthSelector) { + return calendar.params.renderMonthSelector.call(calendar); + } + + return (0, _$jsx.default)("div", { + class: "calendar-month-selector" + }, (0, _$jsx.default)("a", { + class: "link icon-only calendar-prev-month-button" + }, (0, _$jsx.default)("i", { + class: "icon icon-prev" + })), calendar.params.monthPicker ? (0, _$jsx.default)("a", { + class: "current-month-value link" + }) : (0, _$jsx.default)("span", { + class: "current-month-value" + }), (0, _$jsx.default)("a", { + class: "link icon-only calendar-next-month-button" + }, (0, _$jsx.default)("i", { + class: "icon icon-next" + }))); + }; + + _proto.renderMonthPicker = function renderMonthPicker() { + var calendar = this; + var localeMonth = parseInt(calendar.$el.find('.calendar-month-current').attr('data-locale-month'), 10); + return (0, _$jsx.default)("div", { + class: "calendar-month-picker" + }, calendar.monthNames.map(function (m, index) { + return (0, _$jsx.default)("div", { + class: "calendar-month-picker-item " + (localeMonth === index ? 'calendar-month-picker-item-current' : '') + }, (0, _$jsx.default)("span", null, m)); + })); + }; + + _proto.renderYearSelector = function renderYearSelector() { + var calendar = this; + + if (calendar.params.renderYearSelector) { + return calendar.params.renderYearSelector.call(calendar); + } + + return (0, _$jsx.default)("div", { + class: "calendar-year-selector" + }, (0, _$jsx.default)("a", { + class: "link icon-only calendar-prev-year-button" + }, (0, _$jsx.default)("i", { + class: "icon icon-prev" + })), calendar.params.yearPicker ? (0, _$jsx.default)("a", { + class: "current-year-value link" + }) : (0, _$jsx.default)("span", { + class: "current-year-value" + }), (0, _$jsx.default)("a", { + class: "link icon-only calendar-next-year-button" + }, (0, _$jsx.default)("i", { + class: "icon icon-next" + }))); + }; + + _proto.renderYearPicker = function renderYearPicker() { + var calendar = this; + var currentYear = calendar.currentYear; + var yearMin = calendar.params.yearPickerMin || new Date().getFullYear() - 100; + + if (calendar.params.minDate) { + yearMin = Math.max(yearMin, new Date(calendar.params.minDate).getFullYear()); + } + + var yearMax = calendar.params.yearPickerMax || new Date().getFullYear() + 100; + + if (calendar.params.maxDate) { + yearMax = Math.min(yearMax, new Date(calendar.params.maxDate).getFullYear()); + } + + var years = []; + + for (var i = yearMin; i <= yearMax; i += 1) { + years.push(i); + } + + return (0, _$jsx.default)("div", { + class: "calendar-year-picker" + }, years.map(function (year) { + return (0, _$jsx.default)("div", { + "data-year": year, + class: "calendar-year-picker-item " + (year === currentYear ? 'calendar-year-picker-item-current' : '') + }, (0, _$jsx.default)("span", null, calendar.yearFormatter(new Date().setFullYear(year)))); + })); + } // eslint-disable-next-line + ; + + _proto.renderTimeSelector = function renderTimeSelector() { + var calendar = this; + var value = calendar.value && calendar.value[0]; + var timeString; + if (value) timeString = calendar.timeSelectorFormatter(value); + return (0, _$jsx.default)("div", { + class: "calendar-time-selector" + }, (0, _$jsx.default)("a", { + class: "link" + }, timeString || calendar.params.timePickerPlaceholder)); + }; + + _proto.renderHeader = function renderHeader() { + var calendar = this; + + if (calendar.params.renderHeader) { + return calendar.params.renderHeader.call(calendar); + } + + return (0, _$jsx.default)("div", { + class: "calendar-header" + }, (0, _$jsx.default)("div", { + class: "calendar-selected-date" + }, calendar.params.headerPlaceholder)); + }; + + _proto.renderFooter = function renderFooter() { + var calendar = this; + var app = calendar.app; + + if (calendar.params.renderFooter) { + return calendar.params.renderFooter.call(calendar); + } + + return (0, _$jsx.default)("div", { + class: "calendar-footer" + }, (0, _$jsx.default)("a", { + class: (app.theme === 'md' ? 'button' : 'link') + " calendar-close sheet-close popover-close" + }, calendar.params.toolbarCloseText)); + }; + + _proto.renderToolbar = function renderToolbar() { + var calendar = this; + + if (calendar.params.renderToolbar) { + return calendar.params.renderToolbar.call(calendar, calendar); + } // prettier-ignore + + + return (0, _$jsx.default)("div", { + class: "toolbar toolbar-top no-shadow" + }, (0, _$jsx.default)("div", { + class: "toolbar-inner" + }, calendar.params.monthSelector ? calendar.renderMonthSelector() : '', calendar.params.yearSelector ? calendar.renderYearSelector() : '')); + } // eslint-disable-next-line + ; + + _proto.renderInline = function renderInline() { + var calendar = this; + var _calendar$params4 = calendar.params, + cssClass = _calendar$params4.cssClass, + toolbar = _calendar$params4.toolbar, + header = _calendar$params4.header, + footer = _calendar$params4.footer, + rangePicker = _calendar$params4.rangePicker, + weekHeader = _calendar$params4.weekHeader; + var value = calendar.value, + hasTimePicker = calendar.hasTimePicker; + var date = value && value.length ? value[0] : new Date().setHours(0, 0, 0); + return (0, _$jsx.default)("div", { + class: "calendar calendar-inline " + (rangePicker ? 'calendar-range' : '') + " " + (cssClass || '') + }, header && calendar.renderHeader(), toolbar && calendar.renderToolbar(), weekHeader && calendar.renderWeekHeader(), (0, _$jsx.default)("div", { + class: "calendar-months" + }, calendar.renderMonths(date)), hasTimePicker && calendar.renderTimeSelector(), footer && calendar.renderFooter()); + }; + + _proto.renderCustomModal = function renderCustomModal() { + var calendar = this; + var _calendar$params5 = calendar.params, + cssClass = _calendar$params5.cssClass, + toolbar = _calendar$params5.toolbar, + header = _calendar$params5.header, + footer = _calendar$params5.footer, + rangePicker = _calendar$params5.rangePicker, + weekHeader = _calendar$params5.weekHeader; + var value = calendar.value, + hasTimePicker = calendar.hasTimePicker; + var date = value && value.length ? value[0] : new Date().setHours(0, 0, 0); + return (0, _$jsx.default)("div", { + class: "calendar calendar-modal " + (rangePicker ? 'calendar-range' : '') + " " + (cssClass || '') + }, header && calendar.renderHeader(), toolbar && calendar.renderToolbar(), weekHeader && calendar.renderWeekHeader(), (0, _$jsx.default)("div", { + class: "calendar-months" + }, calendar.renderMonths(date)), hasTimePicker && calendar.renderTimeSelector(), footer && calendar.renderFooter()); + }; + + _proto.renderSheet = function renderSheet() { + var calendar = this; + var _calendar$params6 = calendar.params, + cssClass = _calendar$params6.cssClass, + toolbar = _calendar$params6.toolbar, + header = _calendar$params6.header, + footer = _calendar$params6.footer, + rangePicker = _calendar$params6.rangePicker, + weekHeader = _calendar$params6.weekHeader; + var value = calendar.value, + hasTimePicker = calendar.hasTimePicker; + var date = value && value.length ? value[0] : new Date().setHours(0, 0, 0); + return (0, _$jsx.default)("div", { + class: "sheet-modal calendar calendar-sheet " + (rangePicker ? 'calendar-range' : '') + " " + (cssClass || '') + }, header && calendar.renderHeader(), toolbar && calendar.renderToolbar(), weekHeader && calendar.renderWeekHeader(), (0, _$jsx.default)("div", { + class: "sheet-modal-inner calendar-months" + }, calendar.renderMonths(date)), hasTimePicker && calendar.renderTimeSelector(), footer && calendar.renderFooter()); + }; + + _proto.renderPopover = function renderPopover() { + var calendar = this; + var _calendar$params7 = calendar.params, + cssClass = _calendar$params7.cssClass, + toolbar = _calendar$params7.toolbar, + header = _calendar$params7.header, + footer = _calendar$params7.footer, + rangePicker = _calendar$params7.rangePicker, + weekHeader = _calendar$params7.weekHeader; + var value = calendar.value, + hasTimePicker = calendar.hasTimePicker; + var date = value && value.length ? value[0] : new Date().setHours(0, 0, 0); + return (0, _$jsx.default)("div", { + class: "popover calendar-popover" + }, (0, _$jsx.default)("div", { + class: "popover-inner" + }, (0, _$jsx.default)("div", { + class: "calendar " + (rangePicker ? 'calendar-range' : '') + " " + (cssClass || '') + }, header && calendar.renderHeader(), toolbar && calendar.renderToolbar(), weekHeader && calendar.renderWeekHeader(), (0, _$jsx.default)("div", { + class: "calendar-months" + }, calendar.renderMonths(date)), hasTimePicker && calendar.renderTimeSelector(), footer && calendar.renderFooter()))); + }; + + _proto.render = function render() { + var calendar = this; + var params = calendar.params; + if (params.render) return params.render.call(calendar); + + if (!calendar.inline) { + var modalType = params.openIn; + if (modalType === 'auto') modalType = calendar.isPopover() ? 'popover' : 'sheet'; + if (modalType === 'popover') return calendar.renderPopover(); + if (modalType === 'sheet') return calendar.renderSheet(); + return calendar.renderCustomModal(); + } + + return calendar.renderInline(); + }; + + _proto.openTimePicker = function openTimePicker() { + var calendar = this; + var $el = calendar.$el, + app = calendar.app, + is12HoursFormat = calendar.is12HoursFormat; + if (!$el || !$el.length) return; + $el.append('
    '); + var hoursArr = []; + var minutesArr = []; + var hoursMin = is12HoursFormat ? 1 : 0; + var hoursMax = is12HoursFormat ? 12 : 23; + + for (var i = hoursMin; i <= hoursMax; i += 1) { + hoursArr.push(i); + } + + for (var _i2 = 0; _i2 <= 59; _i2 += 1) { + minutesArr.push(_i2); + } + + var value; + + if (calendar.value && calendar.value.length) { + value = [calendar.value[0].getHours(), calendar.value[0].getMinutes()]; + } else { + value = [new Date().getHours(), new Date().getMinutes()]; + } + + if (is12HoursFormat) { + value.push(value[0] < 12 ? 'AM' : 'PM'); + if (value[0] > 12) value[0] -= 12; + if (value[0] === 0) value[0] = 12; + } + + calendar.timePickerInstance = app.picker.create({ + containerEl: $el.find('.calendar-time-picker'), + value: value, + toolbar: true, + rotateEffect: false, + toolbarCloseText: calendar.params.toolbarCloseText, + cols: [{ + values: hoursArr + }, { + divider: true, + content: ':' + }, { + values: minutesArr, + displayValues: minutesArr.map(function (m) { + return m < 10 ? "0" + m : m; + }) + }].concat(is12HoursFormat ? [{ + values: ['AM', 'PM'] + }] : []) + }); + calendar.timePickerInstance.$el.find('.toolbar a').removeClass('sheet-close popover-close').addClass('calendar-time-picker-close'); + }; + + _proto.closeTimePicker = function closeTimePicker() { + var calendar = this; + var is12HoursFormat = calendar.is12HoursFormat; + + if (calendar.timePickerInstance) { + var timePickerValue = calendar.timePickerInstance.value; + var hours = parseInt(timePickerValue[0], 10); + var minutes = parseInt(timePickerValue[1], 10); + var period = calendar.timePickerInstance.value[2]; + + if (is12HoursFormat) { + if (period === 'AM' && hours === 12) { + hours = 0; + } else if (period === 'PM' && hours !== 12) { + hours += 12; + } + } + + var value = calendar.value && calendar.value.length && calendar.value[0]; + + if (!value) { + value = new Date(); + value.setHours(hours, minutes, 0, 0); + } else { + value = new Date(value); + value.setHours(hours, minutes); + } + + calendar.setValue([value]); + calendar.timePickerInstance.close(); + calendar.timePickerInstance.destroy(); + delete calendar.timePickerInstance; + } + + if (calendar.$el && calendar.$el.length) { + calendar.$el.find('.calendar-time-picker').remove(); + } + }; + + _proto.onOpen = function onOpen() { + var calendar = this; + var initialized = calendar.initialized, + $el = calendar.$el, + app = calendar.app, + $inputEl = calendar.$inputEl, + inline = calendar.inline, + value = calendar.value, + params = calendar.params; + calendar.closing = false; + calendar.opened = true; + calendar.opening = true; // Init main events + + calendar.attachCalendarEvents(); + var updateValue = !value && params.value; // Set value + + if (!initialized) { + if (value) calendar.setValue(value, 0);else if (params.value) { + calendar.setValue(calendar.normalizeValues(params.value), 0); + } + } else if (value) { + calendar.setValue(value, 0); + } // Update current month and year + + + calendar.updateCurrentMonthYear(); // Set initial translate + + calendar.monthsTranslate = 0; + calendar.setMonthsTranslate(); // Update input value + + if (updateValue) calendar.updateValue();else if (params.header && value) { + calendar.updateValue(true); + } // Extra focus + + if (!inline && $inputEl && $inputEl.length && app.theme === 'md') { + $inputEl.trigger('focus'); + } + + calendar.initialized = true; + calendar.$months.each(function (monthEl) { + calendar.emit('local::monthAdd calendarMonthAdd', monthEl); + }); // Trigger events + + if ($el) { + $el.trigger('calendar:open'); + } + + if ($inputEl) { + $inputEl.trigger('calendar:open'); + } + + calendar.emit('local::open calendarOpen', calendar); + }; + + _proto.onOpened = function onOpened() { + var calendar = this; + calendar.opening = false; + + if (calendar.$el) { + calendar.$el.trigger('calendar:opened'); + } + + if (calendar.$inputEl) { + calendar.$inputEl.trigger('calendar:opened'); + } + + calendar.emit('local::opened calendarOpened', calendar); + }; + + _proto.onClose = function onClose() { + var calendar = this; + var app = calendar.app; + calendar.opening = false; + calendar.closing = true; + + if (calendar.$inputEl) { + if (app.theme === 'md') { + calendar.$inputEl.trigger('blur'); + } else { + var validate = calendar.$inputEl.attr('validate'); + var required = calendar.$inputEl.attr('required'); + + if (validate && required) { + app.input.validate(calendar.$inputEl); + } + } + } + + if (calendar.detachCalendarEvents) { + calendar.detachCalendarEvents(); + } + + if (calendar.$el) { + calendar.$el.trigger('calendar:close'); + } + + if (calendar.$inputEl) { + calendar.$inputEl.trigger('calendar:close'); + } + + calendar.emit('local::close calendarClose', calendar); + }; + + _proto.onClosed = function onClosed() { + var calendar = this; + calendar.opened = false; + calendar.closing = false; + + if (!calendar.inline) { + (0, _utils.nextTick)(function () { + if (calendar.modal && calendar.modal.el && calendar.modal.destroy) { + if (!calendar.params.routableModals) { + calendar.modal.destroy(); + } + } + + delete calendar.modal; + }); + } + + if (calendar.timePickerInstance) { + if (calendar.timePickerInstance.destroy) calendar.timePickerInstance.destroy(); + delete calendar.timePickerInstance; + } + + if (calendar.$el) { + calendar.$el.trigger('calendar:closed'); + } + + if (calendar.$inputEl) { + calendar.$inputEl.trigger('calendar:closed'); + } + + calendar.emit('local::closed calendarClosed', calendar); + }; + + _proto.open = function open() { + var calendar = this; + var app = calendar.app, + opened = calendar.opened, + inline = calendar.inline, + $inputEl = calendar.$inputEl, + params = calendar.params; + if (opened) return; + + if (inline) { + calendar.$el = (0, _dom.default)(calendar.render()); + calendar.$el[0].f7Calendar = calendar; + calendar.$wrapperEl = calendar.$el.find('.calendar-months-wrapper'); + calendar.$months = calendar.$wrapperEl.find('.calendar-month'); + calendar.$containerEl.append(calendar.$el); + calendar.onOpen(); + calendar.onOpened(); + return; + } + + var modalType = params.openIn; + + if (modalType === 'auto') { + modalType = calendar.isPopover() ? 'popover' : 'sheet'; + } + + var modalContent = calendar.render(); + var modalParams = { + targetEl: $inputEl, + scrollToEl: params.scrollToInput ? $inputEl : undefined, + content: modalContent, + backdrop: params.backdrop === true || modalType === 'popover' && app.params.popover.backdrop !== false && params.backdrop !== false, + closeByBackdropClick: params.closeByBackdropClick, + on: { + open: function open() { + var modal = this; + calendar.modal = modal; + calendar.$el = modalType === 'popover' ? modal.$el.find('.calendar') : modal.$el; + calendar.$wrapperEl = calendar.$el.find('.calendar-months-wrapper'); + calendar.$months = calendar.$wrapperEl.find('.calendar-month'); + calendar.$el[0].f7Calendar = calendar; + + if (modalType === 'customModal') { + (0, _dom.default)(calendar.$el).find('.calendar-close').once('click', function () { + calendar.close(); + }); + } + + calendar.onOpen(); + }, + opened: function opened() { + calendar.onOpened(); + }, + close: function close() { + calendar.onClose(); + }, + closed: function closed() { + calendar.onClosed(); + } + } + }; + + if (modalType === 'sheet') { + modalParams.push = params.sheetPush; + modalParams.swipeToClose = params.sheetSwipeToClose; + } + + if (params.routableModals && calendar.view) { + var _route; + + calendar.view.router.navigate({ + url: calendar.url, + route: (_route = { + path: calendar.url + }, _route[modalType] = modalParams, _route) + }); + } else { + calendar.modal = app[modalType].create(modalParams); + calendar.modal.open(); + } + }; + + _proto.close = function close() { + var calendar = this; + var opened = calendar.opened, + inline = calendar.inline; + if (!opened) return; + + if (inline) { + calendar.onClose(); + calendar.onClosed(); + return; + } + + if (calendar.params.routableModals && calendar.view) { + calendar.view.router.back(); + } else { + calendar.modal.close(); + } + }; + + _proto.init = function init() { + var calendar = this; + calendar.initInput(); + + if (calendar.inline) { + calendar.open(); + calendar.emit('local::init calendarInit', calendar); + return; + } + + if (!calendar.initialized && calendar.params.value) { + calendar.setValue(calendar.normalizeValues(calendar.params.value)); + } // Attach input Events + + + if (calendar.$inputEl) { + calendar.attachInputEvents(); + } + + if (calendar.params.closeByOutsideClick) { + calendar.attachHtmlEvents(); + } + + calendar.emit('local::init calendarInit', calendar); + }; + + _proto.destroy = function destroy() { + var calendar = this; + if (calendar.destroyed) return; + var $el = calendar.$el; + calendar.emit('local::beforeDestroy calendarBeforeDestroy', calendar); + if ($el) $el.trigger('calendar:beforedestroy'); + calendar.close(); // Detach Events + + if (calendar.$inputEl) { + calendar.detachInputEvents(); + } + + if (calendar.params.closeByOutsideClick) { + calendar.detachHtmlEvents(); + } + + if (calendar.timePickerInstance) { + if (calendar.timePickerInstance.destroy) calendar.timePickerInstance.destroy(); + delete calendar.timePickerInstance; + } + + if ($el && $el.length) delete calendar.$el[0].f7Calendar; + (0, _utils.deleteProps)(calendar); + calendar.destroyed = true; + }; + + _createClass(Calendar, [{ + key: "view", + get: function get() { + var $inputEl = this.$inputEl, + app = this.app, + params = this.params; + var view; + + if (params.view) { + view = params.view; + } else if ($inputEl) { + view = $inputEl.parents('.view').length && $inputEl.parents('.view')[0].f7View; + } + + if (!view) view = app.views.main; + return view; + } + }]); + + return Calendar; +}(_class.default); + +var _default = Calendar; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/calendar/calendar.js b/www/assets/framework7/cjs/components/calendar/calendar.js new file mode 100644 index 000000000..8564d4191 --- /dev/null +++ b/www/assets/framework7/cjs/components/calendar/calendar.js @@ -0,0 +1,124 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +var _calendarClass = _interopRequireDefault(require("./calendar-class")); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'calendar', + static: { + Calendar: _calendarClass.default + }, + create: function create() { + var app = this; + app.calendar = (0, _constructorMethods.default)({ + defaultSelector: '.calendar', + constructor: _calendarClass.default, + app: app, + domProp: 'f7Calendar' + }); + + app.calendar.close = function close(el) { + if (el === void 0) { + el = '.calendar'; + } + + var $el = (0, _dom.default)(el); + if ($el.length === 0) return; + var calendar = $el[0].f7Calendar; + if (!calendar || calendar && !calendar.opened) return; + calendar.close(); + }; + }, + params: { + calendar: { + // Calendar settings + dateFormat: undefined, + monthNames: 'auto', + monthNamesShort: 'auto', + dayNames: 'auto', + dayNamesShort: 'auto', + locale: undefined, + firstDay: 1, + // First day of the week, Monday + weekendDays: [0, 6], + // Sunday and Saturday + multiple: false, + rangePicker: false, + rangePickerMinDays: 1, + // when calendar is used as rangePicker + rangePickerMaxDays: 0, + // when calendar is used as rangePicker, 0 means unlimited + direction: 'horizontal', + // or 'vertical' + minDate: null, + maxDate: null, + disabled: null, + // dates range of disabled days + events: null, + // dates range of days with events + rangesClasses: null, + // array with custom classes date ranges + touchMove: true, + animate: true, + closeOnSelect: false, + monthSelector: true, + monthPicker: true, + yearSelector: true, + yearPicker: true, + yearPickerMin: undefined, + yearPickerMax: undefined, + timePicker: false, + timePickerFormat: { + hour: 'numeric', + minute: 'numeric' + }, + timePickerPlaceholder: 'Select time', + weekHeader: true, + value: null, + // Common opener settings + containerEl: null, + openIn: 'auto', + // or 'popover' or 'sheet' or 'customModal' + sheetPush: false, + sheetSwipeToClose: undefined, + formatValue: null, + inputEl: null, + inputReadOnly: true, + closeByOutsideClick: true, + scrollToInput: true, + header: false, + headerPlaceholder: 'Select date', + toolbar: true, + toolbarCloseText: 'Done', + footer: false, + cssClass: null, + routableModals: false, + view: null, + url: 'date/', + backdrop: null, + closeByBackdropClick: true, + // Render functions + renderWeekHeader: null, + renderMonths: null, + renderMonth: null, + renderMonthSelector: null, + renderYearSelector: null, + renderHeader: null, + renderFooter: null, + renderToolbar: null, + renderInline: null, + renderPopover: null, + renderSheet: null, + render: null + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/card/card.js b/www/assets/framework7/cjs/components/card/card.js new file mode 100644 index 000000000..a9d1817de --- /dev/null +++ b/www/assets/framework7/cjs/components/card/card.js @@ -0,0 +1,625 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _utils = require("../../shared/utils"); + +var _getSupport = require("../../shared/get-support"); + +var _getDevice = require("../../shared/get-device"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* eslint no-param-reassign: "off" */ +var CardExpandable = { + open: function open(cardEl, animate) { + if (cardEl === void 0) { + cardEl = '.card-expandable'; + } + + if (animate === void 0) { + animate = true; + } + + var app = this; + var device = (0, _getDevice.getDevice)(); + var document = (0, _ssrWindow.getDocument)(); + var support = (0, _getSupport.getSupport)(); + var $cardEl = (0, _dom.default)(cardEl).eq(0); + if (!$cardEl || !$cardEl.length) return; + if ($cardEl.hasClass('card-opened') || $cardEl.hasClass('card-opening') || $cardEl.hasClass('card-closing')) return; + var $pageEl = $cardEl.parents('.page').eq(0); + if (!$pageEl.length) return; + + if ($pageEl.find('.card-opened').length) { + return; + } + + var prevented; + + function prevent() { + prevented = true; + } + + $cardEl.trigger('card:beforeopen', { + prevent: prevent + }); + app.emit('cardBeforeOpen', $cardEl[0], prevent); + if (prevented) return; + var cardParams = Object.assign({ + animate: animate + }, app.params.card, $cardEl.dataset()); + var $pageContentEl = $cardEl.parents('.page-content'); + var $backdropEl; + + if ($cardEl.attr('data-backdrop-el')) { + $backdropEl = (0, _dom.default)($cardEl.attr('data-backdrop-el')); + } + + if (!$backdropEl && cardParams.backdrop) { + $backdropEl = $pageContentEl.find('.card-backdrop'); + + if (!$backdropEl.length) { + $backdropEl = (0, _dom.default)('
    '); + $pageContentEl.append($backdropEl); + } + } + + var $navbarEl; + var $toolbarEl; + + if (cardParams.hideNavbarOnOpen) { + $navbarEl = $pageEl.children('.navbar'); + + if (!$navbarEl.length) { + if ($pageEl[0].f7Page) $navbarEl = $pageEl[0].f7Page.$navbarEl; + } + } + + if (cardParams.hideToolbarOnOpen) { + $toolbarEl = $pageEl.children('.toolbar'); + + if (!$toolbarEl.length) { + $toolbarEl = $pageEl.parents('.view').children('.toolbar'); + } + + if (!$toolbarEl.length) { + $toolbarEl = $pageEl.parents('.views').children('.toolbar'); + } + } + + var currTransform = $cardEl.css('transform'); + var hasTransform; + + if (currTransform && currTransform.match(/[2-9]/)) { + hasTransform = true; + } + + var $cardContentEl = $cardEl.children('.card-content'); + var $cardSizeEl = (0, _dom.default)(document.createElement('div')).addClass('card-expandable-size'); + $cardEl.append($cardSizeEl); + var cardWidth = $cardEl[0].offsetWidth; + var cardHeight = $cardEl[0].offsetHeight; + var pageWidth = $pageEl[0].offsetWidth; + var pageHeight = $pageEl[0].offsetHeight; + var maxWidth = $cardSizeEl[0].offsetWidth || pageWidth; + var maxHeight = $cardSizeEl[0].offsetHeight || pageHeight; + var statusbarHeight; + + if ($navbarEl && !cardParams.hideStatusbarOnOpen && maxHeight === pageHeight) { + statusbarHeight = parseInt($navbarEl.css('--f7-safe-area-top'), 10); + if (Number.isNaN(statusbarHeight)) statusbarHeight = 0; + } + + if (statusbarHeight) { + maxHeight -= statusbarHeight; + } + + var scaleX = maxWidth / cardWidth; + var scaleY = maxHeight / cardHeight; + var offset = $cardEl.offset(); + var pageOffset = $pageEl.offset(); + + if (statusbarHeight) { + pageOffset.top += statusbarHeight / 2; + } + + offset.left -= pageOffset.left; + var cardLeftOffset; + var cardTopOffset; + + if (hasTransform) { + var transformValues = currTransform.replace(/matrix\(|\)/g, '').split(',').map(function (el) { + return el.trim(); + }); + + if (transformValues && transformValues.length > 1) { + var scale = parseFloat(transformValues[0]); + cardLeftOffset = offset.left - cardWidth * (1 - scale) / 2; + cardTopOffset = offset.top - pageOffset.top - cardHeight * (1 - scale) / 2; + if (app.rtl) cardLeftOffset -= $cardEl[0].scrollLeft; + } else { + cardLeftOffset = $cardEl[0].offsetLeft; + cardTopOffset = $cardEl[0].offsetTop - ($pageContentEl.length ? $pageContentEl[0].scrollTop : 0); + } + } else { + cardLeftOffset = offset.left; + cardTopOffset = offset.top - pageOffset.top; + if (app.rtl) cardLeftOffset -= $cardEl[0].scrollLeft; + } + + cardLeftOffset -= (pageWidth - maxWidth) / 2; + cardTopOffset -= (pageHeight - maxHeight) / 2; + var cardRightOffset = maxWidth - cardWidth - cardLeftOffset; + + if (app.rtl) { + var _ref = [cardRightOffset, cardLeftOffset]; + cardLeftOffset = _ref[0]; + cardRightOffset = _ref[1]; + } + + var cardBottomOffset = maxHeight - cardHeight - cardTopOffset; + var translateX = (cardRightOffset - cardLeftOffset) / 2; + var translateY = (cardBottomOffset - cardTopOffset) / 2; + + if (cardParams.hideNavbarOnOpen && $navbarEl && $navbarEl.length) { + if ($navbarEl.closest('.navbar-hidden').length) { + // Was hidden + $cardEl[0].f7KeepNavbarOnClose = true; + } else { + delete $cardEl[0].f7KeepNavbarOnClose; + app.navbar.hide($navbarEl, cardParams.animate, cardParams.hideStatusbarOnOpen, true); + } + } + + if (cardParams.hideToolbarOnOpen && $toolbarEl && $toolbarEl.length) { + if ($toolbarEl.closest('.toolbar-hidden').length) { + // Was hidden + $cardEl[0].f7KeepToolbarOnClose = true; + } else { + delete $cardEl[0].f7KeepToolbarOnClose; + app.toolbar.hide($toolbarEl, cardParams.animate); + } + } + + if ($backdropEl) { + $backdropEl.removeClass('card-backdrop-out').addClass('card-backdrop-in'); + } + + $cardEl.removeClass('card-transitioning'); + + if (cardParams.animate) { + $cardEl.addClass('card-opening'); + } + + $cardEl.trigger('card:open'); + app.emit('cardOpen', $cardEl[0]); + + function transitionEnd() { + $pageEl.addClass('page-with-card-opened'); + + if (device.ios && $pageContentEl.length) { + $pageContentEl.css('height', $pageContentEl[0].offsetHeight + 1 + "px"); + setTimeout(function () { + $pageContentEl.css('height', ''); + }); + } + + $cardEl.addClass('card-opened'); + $cardEl.removeClass('card-opening'); + $cardEl.trigger('card:opened'); + app.emit('cardOpened', $cardEl[0], $pageEl[0]); + } + + $cardContentEl.css({ + width: maxWidth + "px", + height: maxHeight + "px" + }).transform("translate3d(" + (app.rtl ? cardLeftOffset + translateX : -cardLeftOffset - translateX) + "px, 0px, 0) scale(" + 1 / scaleX + ", " + 1 / scaleY + ")"); + $cardEl.transform("translate3d(" + (app.rtl ? -translateX : translateX) + "px, " + translateY + "px, 0) scale(" + scaleX + ", " + scaleY + ")"); + + if (cardParams.animate) { + $cardEl.transitionEnd(function () { + transitionEnd(); + }); + } else { + transitionEnd(); + } + + function onResize() { + $cardEl.removeClass('card-transitioning'); + cardWidth = $cardEl[0].offsetWidth; + cardHeight = $cardEl[0].offsetHeight; + pageWidth = $pageEl[0].offsetWidth; + pageHeight = $pageEl[0].offsetHeight; + maxWidth = $cardSizeEl[0].offsetWidth || pageWidth; + maxHeight = $cardSizeEl[0].offsetHeight || pageHeight; + statusbarHeight = 0; + + if ($navbarEl && !cardParams.hideStatusbarOnOpen && maxHeight === pageHeight) { + statusbarHeight = parseInt($navbarEl.css('--f7-safe-area-top'), 10); + if (Number.isNaN(statusbarHeight)) statusbarHeight = 0; + } + + if (statusbarHeight) { + maxHeight -= statusbarHeight; + } + + scaleX = maxWidth / cardWidth; + scaleY = maxHeight / cardHeight; + $cardEl.transform('translate3d(0px, 0px, 0) scale(1)'); + offset = $cardEl.offset(); + pageOffset = $pageEl.offset(); + + if (statusbarHeight) { + pageOffset.top += statusbarHeight / 2; + } + + offset.left -= pageOffset.left; + offset.top -= pageOffset.top; + cardLeftOffset = offset.left - (pageWidth - maxWidth) / 2; + if (app.rtl) cardLeftOffset -= $cardEl[0].scrollLeft; + cardTopOffset = offset.top - (pageHeight - maxHeight) / 2; + cardRightOffset = maxWidth - cardWidth - cardLeftOffset; + cardBottomOffset = maxHeight - cardHeight - cardTopOffset; + + if (app.rtl) { + var _ref2 = [cardRightOffset, cardLeftOffset]; + cardLeftOffset = _ref2[0]; + cardRightOffset = _ref2[1]; + } + + translateX = (cardRightOffset - cardLeftOffset) / 2; + translateY = (cardBottomOffset - cardTopOffset) / 2; + $cardEl.transform("translate3d(" + (app.rtl ? -translateX : translateX) + "px, " + translateY + "px, 0) scale(" + scaleX + ", " + scaleY + ")"); + $cardContentEl.css({ + width: maxWidth + "px", + height: maxHeight + "px" + }).transform("translate3d(" + (app.rtl ? cardLeftOffset + translateX : -cardLeftOffset - translateX) + "px, 0px, 0) scale(" + 1 / scaleX + ", " + 1 / scaleY + ")"); + } + + var cardScrollTop; + var isTouched; + var isMoved; + var touchStartX; + var touchStartY; + var touchEndX; + var touchEndY; + var isScrolling; + var progress; + var isV; + var isH; + var $cardScrollableEl; + + function onTouchStart(e) { + if (!(0, _dom.default)(e.target).closest($cardEl).length) return; + if (!$cardEl.hasClass('card-opened')) return; + $cardScrollableEl = $cardEl.find(cardParams.scrollableEl); + + if ($cardScrollableEl[0] && $cardScrollableEl[0] !== $cardContentEl[0] && !$cardScrollableEl[0].contains(e.target)) { + cardScrollTop = 0; + } else { + cardScrollTop = $cardScrollableEl.scrollTop(); + } + + isTouched = true; + touchStartX = e.targetTouches[0].pageX; + touchStartY = e.targetTouches[0].pageY; + isScrolling = undefined; + isV = false; + isH = false; + } + + function onTouchMove(e) { + if (!isTouched) return; + touchEndX = e.targetTouches[0].pageX; + touchEndY = e.targetTouches[0].pageY; + + if (typeof isScrolling === 'undefined') { + isScrolling = !!(isScrolling || Math.abs(touchEndY - touchStartY) > Math.abs(touchEndX - touchStartX)); + } + + if (!isH && !isV) { + if (!isScrolling && e.targetTouches[0].clientX <= 50) { + isH = true; + } else { + isV = true; + } + } + + if (!(isH || isV) || isV && cardScrollTop !== 0) { + isTouched = true; + isMoved = true; + return; + } + + if (!isMoved) { + $cardEl.removeClass('card-transitioning'); + } + + isMoved = true; + progress = isV ? Math.max((touchEndY - touchStartY) / 150, 0) : Math.max((touchEndX - touchStartX) / (cardWidth / 2), 0); + + if (progress > 0 && isV || isH) { + if (isV && device.ios && $cardScrollableEl[0] === $cardContentEl[0]) { + $cardScrollableEl.css('-webkit-overflow-scrolling', 'auto'); + $cardScrollableEl.scrollTop(0); + } + + e.preventDefault(); + } + + if (progress > 1) progress = Math.pow(progress, 0.3); + + if (progress > (isV ? 1.3 : 1.1)) { + isTouched = false; + isMoved = false; + app.card.close($cardEl); + } else { + $cardEl.transform("translate3d(" + (app.rtl ? -translateX : translateX) + "px, " + translateY + "px, 0) scale(" + scaleX * (1 - progress * 0.2) + ", " + scaleY * (1 - progress * 0.2) + ")"); + } + } + + function onTouchEnd() { + if (!isTouched || !isMoved) return; + isTouched = false; + isMoved = false; + + if (device.ios) { + $cardScrollableEl.css('-webkit-overflow-scrolling', ''); + } + + if (progress >= 0.8) { + app.card.close($cardEl); + } else { + $cardEl.addClass('card-transitioning').transform("translate3d(" + (app.rtl ? -translateX : translateX) + "px, " + translateY + "px, 0) scale(" + scaleX + ", " + scaleY + ")"); + } + } + + $cardEl[0].detachEventHandlers = function detachEventHandlers() { + app.off('resize', onResize); + + if (support.touch && cardParams.swipeToClose) { + app.off('touchstart:passive', onTouchStart); + app.off('touchmove:active', onTouchMove); + app.off('touchend:passive', onTouchEnd); + } + }; + + app.on('resize', onResize); + + if (support.touch && cardParams.swipeToClose) { + app.on('touchstart:passive', onTouchStart); + app.on('touchmove:active', onTouchMove); + app.on('touchend:passive', onTouchEnd); + } + }, + close: function close(cardEl, animate) { + if (cardEl === void 0) { + cardEl = '.card-expandable.card-opened'; + } + + if (animate === void 0) { + animate = true; + } + + var app = this; + var device = (0, _getDevice.getDevice)(); + var $cardEl = (0, _dom.default)(cardEl).eq(0); + if (!$cardEl || !$cardEl.length) return; + if (!$cardEl.hasClass('card-opened') || $cardEl.hasClass('card-opening') || $cardEl.hasClass('card-closing')) return; + var $cardContentEl = $cardEl.children('.card-content'); + var $pageContentEl = $cardEl.parents('.page-content'); + var $pageEl = $cardEl.parents('.page').eq(0); + if (!$pageEl.length) return; + var cardParams = Object.assign({ + animate: animate + }, app.params.card, $cardEl.dataset()); + var $cardScrollableEl = $cardEl.find(cardParams.scrollableEl); + var $navbarEl; + var $toolbarEl; + var $backdropEl; + + if ($cardEl.attr('data-backdrop-el')) { + $backdropEl = (0, _dom.default)($cardEl.attr('data-backdrop-el')); + } + + if (cardParams.backdrop) { + $backdropEl = $cardEl.parents('.page-content').find('.card-backdrop'); + } + + if (cardParams.hideNavbarOnOpen) { + $navbarEl = $pageEl.children('.navbar'); + + if (!$navbarEl.length) { + if ($pageEl[0].f7Page) $navbarEl = $pageEl[0].f7Page.$navbarEl; + } + + if ($navbarEl && $navbarEl.length && !$cardEl[0].f7KeepNavbarOnClose) { + app.navbar.show($navbarEl, cardParams.animate, true); + } + } + + if (cardParams.hideToolbarOnOpen) { + $toolbarEl = $pageEl.children('.toolbar'); + + if (!$toolbarEl.length) { + $toolbarEl = $pageEl.parents('.view').children('.toolbar'); + } + + if (!$toolbarEl.length) { + $toolbarEl = $pageEl.parents('.views').children('.toolbar'); + } + + if ($toolbarEl && $toolbarEl.length && !$cardEl[0].f7KeepToolbarOnClose) { + app.toolbar.show($toolbarEl, cardParams.animate); + } + } + + $pageEl.removeClass('page-with-card-opened'); + + if (device.ios && $pageContentEl.length) { + $pageContentEl.css('height', $pageContentEl[0].offsetHeight + 1 + "px"); + setTimeout(function () { + $pageContentEl.css('height', ''); + }); + } + + if ($backdropEl && $backdropEl.length) { + $backdropEl.removeClass('card-backdrop-in').addClass('card-backdrop-out'); + } + + $cardEl.removeClass('card-opened card-transitioning'); + + if (cardParams.animate) { + $cardEl.addClass('card-closing'); + } else { + $cardEl.addClass('card-no-transition'); + } + + $cardEl.transform(''); + $cardEl.trigger('card:close'); + app.emit('cardClose', $cardEl[0], $pageEl[0]); + var animateWidth = $cardEl.hasClass('card-expandable-animate-width'); + + function transitionEnd() { + if (!animateWidth) { + $cardContentEl.css({ + width: '', + height: '' + }); + } + + if ($backdropEl && $backdropEl.length) { + $backdropEl.removeClass('card-backdrop-in card-backdrop-out'); + } + + $cardEl.removeClass('card-closing card-no-transition'); + $cardEl.trigger('card:closed'); + $cardEl.find('.card-expandable-size').remove(); + app.emit('cardClosed', $cardEl[0], $pageEl[0]); + } + + if (animateWidth) { + $cardContentEl.css({ + width: '', + height: '' + }); + } + + $cardContentEl.transform('').scrollTop(0, animate ? 300 : 0); + + if ($cardScrollableEl.length && $cardScrollableEl[0] !== $cardContentEl[0]) { + $cardScrollableEl.scrollTop(0, animate ? 300 : 0); + } + + if (animate) { + $cardContentEl.transitionEnd(function () { + transitionEnd(); + }); + } else { + transitionEnd(); + } + + if ($cardEl[0].detachEventHandlers) { + $cardEl[0].detachEventHandlers(); + delete $cardEl[0].detachEventHandlers; + } + }, + toggle: function toggle(cardEl, animate) { + if (cardEl === void 0) { + cardEl = '.card-expandable'; + } + + var app = this; + var $cardEl = (0, _dom.default)(cardEl).eq(0); + if (!$cardEl.length) return; + + if ($cardEl.hasClass('card-opened')) { + app.card.close($cardEl, animate); + } else { + app.card.open($cardEl, animate); + } + } +}; +var _default = { + name: 'card', + params: { + card: { + hideNavbarOnOpen: true, + hideStatusbarOnOpen: true, + hideToolbarOnOpen: true, + scrollableEl: '.card-content', + swipeToClose: true, + closeByBackdropClick: true, + backdrop: true + } + }, + create: function create() { + var app = this; + (0, _utils.bindMethods)(app, { + card: CardExpandable + }); + }, + on: { + pageBeforeIn: function pageBeforeIn(page) { + var app = this; + + if (app.params.card.hideNavbarOnOpen && page.navbarEl && page.$el.find('.card-opened.card-expandable').length) { + app.navbar.hide(page.navbarEl, true, app.params.card.hideStatusbarOnOpen, true); + } + + if (app.params.card.hideToolbarOnOpen && page.$el.find('.card-opened.card-expandable').length) { + var $toolbarEl = page.$el.children('.toolbar'); + + if (!$toolbarEl.length) { + $toolbarEl = page.$el.parents('.view').children('.toolbar'); + } + + if (!$toolbarEl.length) { + $toolbarEl = page.$el.parents('.views').children('.toolbar'); + } + + if ($toolbarEl && $toolbarEl.length) { + app.toolbar.hide($toolbarEl); + } + } + } + }, + clicks: { + '.card-close': function closeCard($clickedEl, data) { + var app = this; + app.card.close(data.card, data.animate); + }, + '.card-open': function closeCard($clickedEl, data) { + var app = this; + app.card.open(data.card, data.animate); + }, + '.card-expandable': function toggleExpandableCard($clickedEl, data, e) { + var app = this; + if ($clickedEl.hasClass('card-opened') || $clickedEl.hasClass('card-opening') || $clickedEl.hasClass('card-closing')) return; + if ((0, _dom.default)(e.target).closest('.card-prevent-open, .card-close').length) return; + app.card.open($clickedEl); + }, + '.card-backdrop-in': function onBackdropClick() { + var app = this; + var needToClose = false; + if (app.params.card.closeByBackdropClick) needToClose = true; + var $openedCardEl = (0, _dom.default)('.card-opened'); + if (!$openedCardEl.length) return; + + if ($openedCardEl.attr('data-close-by-backdrop-click') === 'true') { + needToClose = true; + } else if ($openedCardEl.attr('data-close-by-backdrop-click') === 'false') { + needToClose = false; + } + + if (needToClose) app.card.close($openedCardEl); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/checkbox/checkbox.js b/www/assets/framework7/cjs/components/checkbox/checkbox.js new file mode 100644 index 000000000..88f495652 --- /dev/null +++ b/www/assets/framework7/cjs/components/checkbox/checkbox.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _default = { + name: 'checkbox' +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/chip/chip.js b/www/assets/framework7/cjs/components/chip/chip.js new file mode 100644 index 000000000..0207c72f9 --- /dev/null +++ b/www/assets/framework7/cjs/components/chip/chip.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _default = { + name: 'chip' +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/color-picker/color-picker-class.js b/www/assets/framework7/cjs/components/color-picker/color-picker-class.js new file mode 100644 index 000000000..472c31c28 --- /dev/null +++ b/www/assets/framework7/cjs/components/color-picker/color-picker-class.js @@ -0,0 +1,1022 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _getDevice = require("../../shared/get-device"); + +var _alphaSlider = _interopRequireDefault(require("./modules/alpha-slider")); + +var _currentColor = _interopRequireDefault(require("./modules/current-color")); + +var _hex = _interopRequireDefault(require("./modules/hex")); + +var _hsbSliders = _interopRequireDefault(require("./modules/hsb-sliders")); + +var _hueSlider = _interopRequireDefault(require("./modules/hue-slider")); + +var _brightnessSlider = _interopRequireDefault(require("./modules/brightness-slider")); + +var _palette = _interopRequireDefault(require("./modules/palette")); + +var _initialCurrentColors = _interopRequireDefault(require("./modules/initial-current-colors")); + +var _rgbBars = _interopRequireDefault(require("./modules/rgb-bars")); + +var _rgbSliders = _interopRequireDefault(require("./modules/rgb-sliders")); + +var _sbSpectrum = _interopRequireDefault(require("./modules/sb-spectrum")); + +var _hsSpectrum = _interopRequireDefault(require("./modules/hs-spectrum")); + +var _wheel = _interopRequireDefault(require("./modules/wheel")); + +var _$jsx = _interopRequireDefault(require("../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var ColorPicker = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(ColorPicker, _Framework7Class); + + function ColorPicker(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params, [app]) || this; + + var self = _assertThisInitialized(_this); + + self.params = (0, _utils.extend)({}, app.params.colorPicker, params); + var $containerEl; + + if (self.params.containerEl) { + $containerEl = (0, _dom.default)(self.params.containerEl); + if ($containerEl.length === 0) return self || _assertThisInitialized(_this); + } + + var $inputEl; + + if (self.params.inputEl) { + $inputEl = (0, _dom.default)(self.params.inputEl); + } + + var $targetEl; + + if (self.params.targetEl) { + $targetEl = (0, _dom.default)(self.params.targetEl); + } + + (0, _utils.extend)(self, { + app: app, + $containerEl: $containerEl, + containerEl: $containerEl && $containerEl[0], + inline: $containerEl && $containerEl.length > 0, + $inputEl: $inputEl, + inputEl: $inputEl && $inputEl[0], + $targetEl: $targetEl, + targetEl: $targetEl && $targetEl[0], + initialized: false, + opened: false, + url: self.params.url, + modules: { + 'alpha-slider': _alphaSlider.default, + 'current-color': _currentColor.default, + hex: _hex.default, + // eslint-disable-line + 'hsb-sliders': _hsbSliders.default, + 'hue-slider': _hueSlider.default, + 'brightness-slider': _brightnessSlider.default, + palette: _palette.default, + // eslint-disable-line + 'initial-current-colors': _initialCurrentColors.default, + 'rgb-bars': _rgbBars.default, + 'rgb-sliders': _rgbSliders.default, + 'sb-spectrum': _sbSpectrum.default, + 'hs-spectrum': _hsSpectrum.default, + wheel: _wheel.default // eslint-disable-line + + } + }); + + function onInputClick() { + self.open(); + } + + function onInputFocus(e) { + e.preventDefault(); + } + + function onTargetClick() { + self.open(); + } + + function onHtmlClick(e) { + if (self.destroyed || !self.params) return; + if (self.params.openIn === 'page') return; + var $clickTargetEl = (0, _dom.default)(e.target); + if (!self.opened || self.closing) return; + if ($clickTargetEl.closest('[class*="backdrop"]').length) return; + if ($clickTargetEl.closest('.color-picker-popup, .color-picker-popover').length) return; + + if ($inputEl && $inputEl.length > 0) { + if ($clickTargetEl[0] !== $inputEl[0] && $clickTargetEl.closest('.sheet-modal').length === 0) { + self.close(); + } + } else if ((0, _dom.default)(e.target).closest('.sheet-modal').length === 0) { + self.close(); + } + } // Events + + + (0, _utils.extend)(self, { + attachInputEvents: function attachInputEvents() { + self.$inputEl.on('click', onInputClick); + + if (self.params.inputReadOnly) { + self.$inputEl.on('focus mousedown', onInputFocus); + + if (self.$inputEl[0]) { + self.$inputEl[0].f7ValidateReadonly = true; + } + } + }, + detachInputEvents: function detachInputEvents() { + self.$inputEl.off('click', onInputClick); + + if (self.params.inputReadOnly) { + self.$inputEl.off('focus mousedown', onInputFocus); + + if (self.$inputEl[0]) { + delete self.$inputEl[0].f7ValidateReadonly; + } + } + }, + attachTargetEvents: function attachTargetEvents() { + self.$targetEl.on('click', onTargetClick); + }, + detachTargetEvents: function detachTargetEvents() { + self.$targetEl.off('click', onTargetClick); + }, + attachHtmlEvents: function attachHtmlEvents() { + app.on('click', onHtmlClick); + }, + detachHtmlEvents: function detachHtmlEvents() { + app.off('click', onHtmlClick); + } + }); + self.init(); + return self || _assertThisInitialized(_this); + } + + var _proto = ColorPicker.prototype; + + _proto.attachEvents = function attachEvents() { + var self = this; + self.centerModules = self.centerModules.bind(self); + + if (self.params.centerModules) { + self.app.on('resize', self.centerModules); + } + }; + + _proto.detachEvents = function detachEvents() { + var self = this; + + if (self.params.centerModules) { + self.app.off('resize', self.centerModules); + } + }; + + _proto.centerModules = function centerModules() { + var self = this; + if (!self.opened || !self.$el || self.inline) return; + var $pageContentEl = self.$el.find('.page-content'); + if (!$pageContentEl.length) return; + var _$pageContentEl$ = $pageContentEl[0], + scrollHeight = _$pageContentEl$.scrollHeight, + offsetHeight = _$pageContentEl$.offsetHeight; + + if (scrollHeight <= offsetHeight) { + $pageContentEl.addClass('justify-content-center'); + } else { + $pageContentEl.removeClass('justify-content-center'); + } + }; + + _proto.initInput = function initInput() { + var self = this; + if (!self.$inputEl) return; + if (self.params.inputReadOnly) self.$inputEl.prop('readOnly', true); + }; + + _proto.getModalType = function getModalType() { + var self = this; + var app = self.app, + modal = self.modal, + params = self.params; + var openIn = params.openIn, + openInPhone = params.openInPhone; + var device = (0, _getDevice.getDevice)(); + if (modal && modal.type) return modal.type; + if (openIn !== 'auto') return openIn; + if (self.inline) return null; + + if (device.ios) { + return device.ipad ? 'popover' : openInPhone; + } + + if (app.width >= 768 || device.desktop && app.theme === 'aurora') { + return 'popover'; + } + + return openInPhone; + }; + + _proto.formatValue = function formatValue() { + var self = this; + var value = self.value; + + if (self.params.formatValue) { + return self.params.formatValue.call(self, value); + } + + return value.hex; + } // eslint-disable-next-line + ; + + _proto.normalizeHsValues = function normalizeHsValues(arr) { + return [Math.floor(arr[0] * 10) / 10, Math.floor(arr[1] * 1000) / 1000, Math.floor(arr[2] * 1000) / 1000]; + }; + + _proto.setValue = function setValue(value, updateModules) { + if (value === void 0) { + value = {}; + } + + if (updateModules === void 0) { + updateModules = true; + } + + var self = this; + if (typeof value === 'undefined') return; + + var _ref = self.value || {}, + hex = _ref.hex, + rgb = _ref.rgb, + hsl = _ref.hsl, + hsb = _ref.hsb, + _ref$alpha = _ref.alpha, + alpha = _ref$alpha === void 0 ? 1 : _ref$alpha, + hue = _ref.hue, + rgba = _ref.rgba, + hsla = _ref.hsla; + + var needChangeEvent = self.value || !self.value && !self.params.value; + var valueChanged; + Object.keys(value).forEach(function (k) { + if (!self.value || typeof self.value[k] === 'undefined') { + valueChanged = true; + return; + } + + var v = value[k]; + + if (Array.isArray(v)) { + v.forEach(function (subV, subIndex) { + if (subV !== self.value[k][subIndex]) { + valueChanged = true; + } + }); + } else if (v !== self.value[k]) { + valueChanged = true; + } + }); + if (!valueChanged) return; + + if (value.rgb || value.rgba) { + var _ref2 = value.rgb || value.rgba, + r = _ref2[0], + g = _ref2[1], + b = _ref2[2], + _ref2$ = _ref2[3], + a = _ref2$ === void 0 ? alpha : _ref2$; + + rgb = [r, g, b]; + hex = _utils.colorRgbToHex.apply(void 0, rgb); + hsl = _utils.colorRgbToHsl.apply(void 0, rgb); + hsb = _utils.colorHslToHsb.apply(void 0, hsl); + hsl = self.normalizeHsValues(hsl); + hsb = self.normalizeHsValues(hsb); + hue = hsb[0]; + alpha = a; + rgba = [rgb[0], rgb[1], rgb[2], a]; + hsla = [hsl[0], hsl[1], hsl[2], a]; + } + + if (value.hsl || value.hsla) { + var _ref3 = value.hsl || value.hsla, + h = _ref3[0], + s = _ref3[1], + l = _ref3[2], + _ref3$ = _ref3[3], + _a = _ref3$ === void 0 ? alpha : _ref3$; + + hsl = [h, s, l]; + rgb = _utils.colorHslToRgb.apply(void 0, hsl); + hex = _utils.colorRgbToHex.apply(void 0, rgb); + hsb = _utils.colorHslToHsb.apply(void 0, hsl); + hsl = self.normalizeHsValues(hsl); + hsb = self.normalizeHsValues(hsb); + hue = hsb[0]; + alpha = _a; + rgba = [rgb[0], rgb[1], rgb[2], _a]; + hsla = [hsl[0], hsl[1], hsl[2], _a]; + } + + if (value.hsb) { + var _value$hsb = value.hsb, + _h = _value$hsb[0], + _s = _value$hsb[1], + _b = _value$hsb[2], + _value$hsb$ = _value$hsb[3], + _a2 = _value$hsb$ === void 0 ? alpha : _value$hsb$; + + hsb = [_h, _s, _b]; + hsl = _utils.colorHsbToHsl.apply(void 0, hsb); + rgb = _utils.colorHslToRgb.apply(void 0, hsl); + hex = _utils.colorRgbToHex.apply(void 0, rgb); + hsl = self.normalizeHsValues(hsl); + hsb = self.normalizeHsValues(hsb); + hue = hsb[0]; + alpha = _a2; + rgba = [rgb[0], rgb[1], rgb[2], _a2]; + hsla = [hsl[0], hsl[1], hsl[2], _a2]; + } + + if (value.hex) { + rgb = (0, _utils.colorHexToRgb)(value.hex); + hex = _utils.colorRgbToHex.apply(void 0, rgb); + hsl = _utils.colorRgbToHsl.apply(void 0, rgb); + hsb = _utils.colorHslToHsb.apply(void 0, hsl); + hsl = self.normalizeHsValues(hsl); + hsb = self.normalizeHsValues(hsb); + hue = hsb[0]; + rgba = [rgb[0], rgb[1], rgb[2], alpha]; + hsla = [hsl[0], hsl[1], hsl[2], alpha]; + } + + if (typeof value.alpha !== 'undefined') { + alpha = value.alpha; + + if (typeof rgb !== 'undefined') { + rgba = [rgb[0], rgb[1], rgb[2], alpha]; + } + + if (typeof hsl !== 'undefined') { + hsla = [hsl[0], hsl[1], hsl[2], alpha]; + } + } + + if (typeof value.hue !== 'undefined') { + var _hsl = hsl, + _h2 = _hsl[0], + _s2 = _hsl[1], + _l = _hsl[2]; // eslint-disable-line + + hsl = [value.hue, _s2, _l]; + hsb = _utils.colorHslToHsb.apply(void 0, hsl); + rgb = _utils.colorHslToRgb.apply(void 0, hsl); + hex = _utils.colorRgbToHex.apply(void 0, rgb); + hsl = self.normalizeHsValues(hsl); + hsb = self.normalizeHsValues(hsb); + hue = hsb[0]; + rgba = [rgb[0], rgb[1], rgb[2], alpha]; + hsla = [hsl[0], hsl[1], hsl[2], alpha]; + } + + self.value = { + hex: hex, + alpha: alpha, + hue: hue, + rgb: rgb, + hsl: hsl, + hsb: hsb, + rgba: rgba, + hsla: hsla + }; + if (!self.initialValue) self.initialValue = (0, _utils.extend)({}, self.value); + self.updateValue(needChangeEvent); + + if (self.opened && updateModules) { + self.updateModules(); + } + }; + + _proto.getValue = function getValue() { + var self = this; + return self.value; + }; + + _proto.updateValue = function updateValue(fireEvents) { + if (fireEvents === void 0) { + fireEvents = true; + } + + var self = this; + var $inputEl = self.$inputEl, + value = self.value, + $targetEl = self.$targetEl; + + if ($targetEl && self.params.targetElSetBackgroundColor) { + var rgba = value.rgba; + $targetEl.css('background-color', "rgba(" + rgba.join(', ') + ")"); + } + + if (fireEvents) { + self.emit('local::change colorPickerChange', self, value); + } + + if ($inputEl && $inputEl.length) { + var inputValue = self.formatValue(value); + + if ($inputEl && $inputEl.length) { + $inputEl.val(inputValue); + + if (fireEvents) { + $inputEl.trigger('change'); + } + } + } + }; + + _proto.updateModules = function updateModules() { + var self = this; + var modules = self.modules; + self.params.modules.forEach(function (m) { + if (typeof m === 'string' && modules[m] && modules[m].update) { + modules[m].update(self); + } else if (m && m.update) { + m.update(self); + } + }); + }; + + _proto.update = function update() { + var self = this; + self.updateModules(); + }; + + _proto.renderPicker = function renderPicker() { + var self = this; + var params = self.params, + modules = self.modules; + var html = ''; + params.modules.forEach(function (m) { + if (typeof m === 'string' && modules[m] && modules[m].render) { + html += modules[m].render(self); + } else if (m && m.render) { + html += m.render(self); + } + }); + return html; + }; + + _proto.renderNavbar = function renderNavbar() { + var self = this; + + if (self.params.renderNavbar) { + return self.params.renderNavbar.call(self, self); + } + + var _self$params = self.params, + openIn = _self$params.openIn, + navbarTitleText = _self$params.navbarTitleText, + navbarBackLinkText = _self$params.navbarBackLinkText, + navbarCloseText = _self$params.navbarCloseText; + return (0, _$jsx.default)("div", { + class: "navbar" + }, (0, _$jsx.default)("div", { + class: "navbar-bg" + }), (0, _$jsx.default)("div", { + class: "navbar-inner sliding" + }, openIn === 'page' && (0, _$jsx.default)("div", { + class: "left" + }, (0, _$jsx.default)("a", { + class: "link back" + }, (0, _$jsx.default)("i", { + class: "icon icon-back" + }), (0, _$jsx.default)("span", { + class: "if-not-md" + }, navbarBackLinkText))), (0, _$jsx.default)("div", { + class: "title" + }, navbarTitleText), openIn !== 'page' && (0, _$jsx.default)("div", { + class: "right" + }, (0, _$jsx.default)("a", { + class: "link popup-close", + "data-popup": ".color-picker-popup" + }, navbarCloseText)))); + }; + + _proto.renderToolbar = function renderToolbar() { + var self = this; + + if (self.params.renderToolbar) { + return self.params.renderToolbar.call(self, self); + } + + return (0, _$jsx.default)("div", { + class: "toolbar toolbar-top no-shadow" + }, (0, _$jsx.default)("div", { + class: "toolbar-inner" + }, (0, _$jsx.default)("div", { + class: "left" + }), (0, _$jsx.default)("div", { + class: "right" + }, (0, _$jsx.default)("a", { + class: "link sheet-close popover-close", + "data-sheet": ".color-picker-sheet-modal", + "data-popover": ".color-picker-popover" + }, self.params.toolbarCloseText)))); + }; + + _proto.renderInline = function renderInline() { + var self = this; + var _self$params2 = self.params, + cssClass = _self$params2.cssClass, + groupedModules = _self$params2.groupedModules; + return (0, _$jsx.default)("div", { + class: "color-picker color-picker-inline " + (groupedModules ? 'color-picker-grouped-modules' : '') + " " + (cssClass || '') + }, self.renderPicker()); + }; + + _proto.renderSheet = function renderSheet() { + var self = this; + var _self$params3 = self.params, + cssClass = _self$params3.cssClass, + toolbarSheet = _self$params3.toolbarSheet, + groupedModules = _self$params3.groupedModules; + return (0, _$jsx.default)("div", { + class: "sheet-modal color-picker color-picker-sheet-modal " + (groupedModules ? 'color-picker-grouped-modules' : '') + " " + (cssClass || '') + }, toolbarSheet && self.renderToolbar(), (0, _$jsx.default)("div", { + class: "sheet-modal-inner" + }, (0, _$jsx.default)("div", { + class: "page-content" + }, self.renderPicker()))); + }; + + _proto.renderPopover = function renderPopover() { + var self = this; + var _self$params4 = self.params, + cssClass = _self$params4.cssClass, + toolbarPopover = _self$params4.toolbarPopover, + groupedModules = _self$params4.groupedModules; + return (0, _$jsx.default)("div", { + class: "popover color-picker-popover " + (cssClass || '') + }, (0, _$jsx.default)("div", { + class: "popover-inner" + }, (0, _$jsx.default)("div", { + class: "color-picker " + (groupedModules ? 'color-picker-grouped-modules' : '') + }, toolbarPopover && self.renderToolbar(), (0, _$jsx.default)("div", { + class: "page-content" + }, self.renderPicker())))); + }; + + _proto.renderPopup = function renderPopup() { + var self = this; + var _self$params5 = self.params, + cssClass = _self$params5.cssClass, + navbarPopup = _self$params5.navbarPopup, + groupedModules = _self$params5.groupedModules; + return (0, _$jsx.default)("div", { + class: "popup color-picker-popup " + (cssClass || '') + }, (0, _$jsx.default)("div", { + class: "page" + }, navbarPopup && self.renderNavbar(), (0, _$jsx.default)("div", { + class: "color-picker " + (groupedModules ? 'color-picker-grouped-modules' : '') + }, (0, _$jsx.default)("div", { + class: "page-content" + }, self.renderPicker())))); + }; + + _proto.renderPage = function renderPage() { + var self = this; + var _self$params6 = self.params, + cssClass = _self$params6.cssClass, + groupedModules = _self$params6.groupedModules; + return (0, _$jsx.default)("div", { + class: "page color-picker-page " + (cssClass || ''), + "data-name": "color-picker-page" + }, self.renderNavbar(), (0, _$jsx.default)("div", { + class: "color-picker " + (groupedModules ? 'color-picker-grouped-modules' : '') + }, (0, _$jsx.default)("div", { + class: "page-content" + }, self.renderPicker()))); + } // eslint-disable-next-line + ; + + _proto.render = function render() { + var self = this; + var params = self.params; + if (params.render) return params.render.call(self); + if (self.inline) return self.renderInline(); + + if (params.openIn === 'page') { + return self.renderPage(); + } + + var modalType = self.getModalType(); + if (modalType === 'popover') return self.renderPopover(); + if (modalType === 'sheet') return self.renderSheet(); + if (modalType === 'popup') return self.renderPopup(); + }; + + _proto.onOpen = function onOpen() { + var self = this; + var initialized = self.initialized, + $el = self.$el, + app = self.app, + $inputEl = self.$inputEl, + inline = self.inline, + value = self.value, + params = self.params, + modules = self.modules; + self.closing = false; + self.opened = true; + self.opening = true; // Init main events + + self.attachEvents(); + params.modules.forEach(function (m) { + if (typeof m === 'string' && modules[m] && modules[m].init) { + modules[m].init(self); + } else if (m && m.init) { + m.init(self); + } + }); + var updateValue = !value && params.value; // Set value + + if (!initialized) { + if (value) self.setValue(value);else if (params.value) { + self.setValue(params.value, false); + } else if (!params.value) { + self.setValue({ + hex: '#ff0000' + }, false); + } + } else if (value) { + self.initialValue = (0, _utils.extend)({}, value); + self.setValue(value, false); + } // Update input value + + + if (updateValue) self.updateValue(); + self.updateModules(); // Center modules + + if (params.centerModules) { + self.centerModules(); + } // Extra focus + + + if (!inline && $inputEl && $inputEl.length && app.theme === 'md') { + $inputEl.trigger('focus'); + } + + self.initialized = true; // Trigger events + + if ($el) { + $el.trigger('colorpicker:open'); + } + + if ($inputEl) { + $inputEl.trigger('colorpicker:open'); + } + + self.emit('local::open colorPickerOpen', self); + }; + + _proto.onOpened = function onOpened() { + var self = this; + self.opening = false; + + if (self.$el) { + self.$el.trigger('colorpicker:opened'); + } + + if (self.$inputEl) { + self.$inputEl.trigger('colorpicker:opened'); + } + + self.emit('local::opened colorPickerOpened', self); + }; + + _proto.onClose = function onClose() { + var self = this; + var app = self.app, + params = self.params, + modules = self.modules; + self.opening = false; + self.closing = true; // Detach events + + self.detachEvents(); + + if (self.$inputEl) { + if (app.theme === 'md') { + self.$inputEl.trigger('blur'); + } else { + var validate = self.$inputEl.attr('validate'); + var required = self.$inputEl.attr('required'); + + if (validate && required) { + app.input.validate(self.$inputEl); + } + } + } + + params.modules.forEach(function (m) { + if (typeof m === 'string' && modules[m] && modules[m].destroy) { + modules[m].destroy(self); + } else if (m && m.destroy) { + m.destroy(self); + } + }); + + if (self.$el) { + self.$el.trigger('colorpicker:close'); + } + + if (self.$inputEl) { + self.$inputEl.trigger('colorpicker:close'); + } + + self.emit('local::close colorPickerClose', self); + }; + + _proto.onClosed = function onClosed() { + var self = this; + self.opened = false; + self.closing = false; + + if (!self.inline) { + (0, _utils.nextTick)(function () { + if (self.modal && self.modal.el && self.modal.destroy) { + if (!self.params.routableModals) { + self.modal.destroy(); + } + } + + delete self.modal; + }); + } + + if (self.$el) { + self.$el.trigger('colorpicker:closed'); + } + + if (self.$inputEl) { + self.$inputEl.trigger('colorpicker:closed'); + } + + self.emit('local::closed colorPickerClosed', self); + }; + + _proto.open = function open() { + var self = this; + var app = self.app, + opened = self.opened, + inline = self.inline, + $inputEl = self.$inputEl, + $targetEl = self.$targetEl, + params = self.params; + if (opened) return; + + if (inline) { + self.$el = (0, _dom.default)(self.render()); + self.$el[0].f7ColorPicker = self; + self.$containerEl.append(self.$el); + self.onOpen(); + self.onOpened(); + return; + } + + var colorPickerContent = self.render(); + + if (params.openIn === 'page') { + self.view.router.navigate({ + url: self.url, + route: { + content: colorPickerContent, + path: self.url, + on: { + pageBeforeIn: function pageBeforeIn(e, page) { + self.$el = page.$el.find('.color-picker'); + self.$el[0].f7ColorPicker = self; + self.onOpen(); + }, + pageAfterIn: function pageAfterIn() { + self.onOpened(); + }, + pageBeforeOut: function pageBeforeOut() { + self.onClose(); + }, + pageAfterOut: function pageAfterOut() { + self.onClosed(); + + if (self.$el && self.$el[0]) { + self.$el[0].f7ColorPicker = null; + delete self.$el[0].f7ColorPicker; + } + } + } + } + }); + } else { + var modalType = self.getModalType(); + var backdrop = params.backdrop; + + if (backdrop === null || typeof backdrop === 'undefined') { + if (modalType === 'popover' && app.params.popover.backdrop !== false) backdrop = true; + if (modalType === 'popup') backdrop = true; + } + + var modalParams = { + targetEl: $targetEl || $inputEl, + scrollToEl: params.scrollToInput ? $targetEl || $inputEl : undefined, + content: colorPickerContent, + backdrop: backdrop, + closeByBackdropClick: params.closeByBackdropClick, + on: { + open: function open() { + var modal = this; + self.modal = modal; + self.$el = modalType === 'popover' || modalType === 'popup' ? modal.$el.find('.color-picker') : modal.$el; + self.$el[0].f7ColorPicker = self; + self.onOpen(); + }, + opened: function opened() { + self.onOpened(); + }, + close: function close() { + self.onClose(); + }, + closed: function closed() { + self.onClosed(); + + if (self.$el && self.$el[0]) { + self.$el[0].f7ColorPicker = null; + delete self.$el[0].f7ColorPicker; + } + } + } + }; + + if (modalType === 'popup') { + modalParams.push = params.popupPush; + modalParams.swipeToClose = params.popupSwipeToClose; + } + + if (modalType === 'sheet') { + modalParams.push = params.sheetPush; + modalParams.swipeToClose = params.sheetSwipeToClose; + } + + if (params.routableModals && self.view) { + var _route; + + self.view.router.navigate({ + url: self.url, + route: (_route = { + path: self.url + }, _route[modalType] = modalParams, _route) + }); + } else { + self.modal = app[modalType].create(modalParams); + self.modal.open(); + } + } + }; + + _proto.close = function close() { + var self = this; + var opened = self.opened, + inline = self.inline; + if (!opened) return; + + if (inline) { + self.onClose(); + self.onClosed(); + return; + } + + if (self.params.routableModals && self.view || self.params.openIn === 'page') { + self.view.router.back(); + } else { + self.modal.close(); + } + }; + + _proto.init = function init() { + var self = this; + self.initInput(); + + if (self.inline) { + self.open(); + self.emit('local::init colorPickerInit', self); + return; + } + + if (!self.initialized && self.params.value) { + self.setValue(self.params.value); + } // Attach input Events + + + if (self.$inputEl) { + self.attachInputEvents(); + } + + if (self.$targetEl) { + self.attachTargetEvents(); + } + + if (self.params.closeByOutsideClick) { + self.attachHtmlEvents(); + } + + self.emit('local::init colorPickerInit', self); + }; + + _proto.destroy = function destroy() { + var self = this; + if (self.destroyed) return; + var $el = self.$el; + self.emit('local::beforeDestroy colorPickerBeforeDestroy', self); + if ($el) $el.trigger('colorpicker:beforedestroy'); + self.close(); // Detach Events + + self.detachEvents(); + + if (self.$inputEl) { + self.detachInputEvents(); + } + + if (self.$targetEl) { + self.detachTargetEvents(); + } + + if (self.params.closeByOutsideClick) { + self.detachHtmlEvents(); + } + + if ($el && $el.length) delete self.$el[0].f7ColorPicker; + (0, _utils.deleteProps)(self); + self.destroyed = true; + }; + + _createClass(ColorPicker, [{ + key: "view", + get: function get() { + var $inputEl = this.$inputEl, + $targetEl = this.$targetEl, + app = this.app, + params = this.params; + var view; + + if (params.view) { + view = params.view; + } else { + if ($inputEl) { + view = $inputEl.parents('.view').length && $inputEl.parents('.view')[0].f7View; + } + + if (!view && $targetEl) { + view = $targetEl.parents('.view').length && $targetEl.parents('.view')[0].f7View; + } + } + + if (!view) view = app.views.main; + return view; + } + }]); + + return ColorPicker; +}(_class.default); + +var _default = ColorPicker; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/color-picker/color-picker.js b/www/assets/framework7/cjs/components/color-picker/color-picker.js new file mode 100644 index 000000000..119c13938 --- /dev/null +++ b/www/assets/framework7/cjs/components/color-picker/color-picker.js @@ -0,0 +1,105 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +var _colorPickerClass = _interopRequireDefault(require("./color-picker-class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'colorPicker', + static: { + ColorPicker: _colorPickerClass.default + }, + create: function create() { + var app = this; + app.colorPicker = (0, _constructorMethods.default)({ + defaultSelector: '.color-picker', + constructor: _colorPickerClass.default, + app: app, + domProp: 'f7ColorPicker' + }); + + app.colorPicker.close = function close(el) { + if (el === void 0) { + el = '.color-picker'; + } + + var $el = (0, _dom.default)(el); + if ($el.length === 0) return; + var colorPicker = $el[0].f7ColorPicker; + if (!colorPicker || colorPicker && !colorPicker.opened) return; + colorPicker.close(); + }; + }, + params: { + colorPicker: { + // Color picker settings + value: null, + modules: ['wheel'], + palette: [['#FFEBEE', '#FFCDD2', '#EF9A9A', '#E57373', '#EF5350', '#F44336', '#E53935', '#D32F2F', '#C62828', '#B71C1C'], ['#F3E5F5', '#E1BEE7', '#CE93D8', '#BA68C8', '#AB47BC', '#9C27B0', '#8E24AA', '#7B1FA2', '#6A1B9A', '#4A148C'], ['#E8EAF6', '#C5CAE9', '#9FA8DA', '#7986CB', '#5C6BC0', '#3F51B5', '#3949AB', '#303F9F', '#283593', '#1A237E'], ['#E1F5FE', '#B3E5FC', '#81D4FA', '#4FC3F7', '#29B6F6', '#03A9F4', '#039BE5', '#0288D1', '#0277BD', '#01579B'], ['#E0F2F1', '#B2DFDB', '#80CBC4', '#4DB6AC', '#26A69A', '#009688', '#00897B', '#00796B', '#00695C', '#004D40'], ['#F1F8E9', '#DCEDC8', '#C5E1A5', '#AED581', '#9CCC65', '#8BC34A', '#7CB342', '#689F38', '#558B2F', '#33691E'], ['#FFFDE7', '#FFF9C4', '#FFF59D', '#FFF176', '#FFEE58', '#FFEB3B', '#FDD835', '#FBC02D', '#F9A825', '#F57F17'], ['#FFF3E0', '#FFE0B2', '#FFCC80', '#FFB74D', '#FFA726', '#FF9800', '#FB8C00', '#F57C00', '#EF6C00', '#E65100']], + groupedModules: false, + centerModules: true, + sliderLabel: false, + sliderValue: false, + sliderValueEdiable: false, + barLabel: false, + barValue: false, + barValueEdiable: false, + hexLabel: false, + hexValueEditable: false, + redLabelText: 'R', + greenLabelText: 'G', + blueLabelText: 'B', + hueLabelText: 'H', + saturationLabelText: 'S', + brightnessLabelText: 'B', + hexLabelText: 'HEX', + alphaLabelText: 'A', + // Common opener settings + containerEl: null, + openIn: 'popover', + // or 'popover' or 'sheet' or 'popup' or 'page' or 'auto' + openInPhone: 'popup', + // or 'popover' or 'sheet' or 'popup' or 'page' + popupPush: false, + popupSwipeToClose: undefined, + sheetPush: false, + sheetSwipeToClose: undefined, + formatValue: null, + targetEl: null, + targetElSetBackgroundColor: false, + inputEl: null, + inputReadOnly: true, + closeByOutsideClick: true, + scrollToInput: true, + toolbarSheet: true, + toolbarPopover: false, + toolbarCloseText: 'Done', + navbarPopup: true, + navbarCloseText: 'Done', + navbarTitleText: 'Color', + navbarBackLinkText: 'Back', + cssClass: null, + routableModals: false, + view: null, + url: 'color/', + backdrop: null, + closeByBackdropClick: true, + // Render functions + renderToolbar: null, + renderNavbar: null, + renderInline: null, + renderPopover: null, + renderSheet: null, + renderPopup: null, + render: null + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/color-picker/modules/alpha-slider.js b/www/assets/framework7/cjs/components/color-picker/modules/alpha-slider.js new file mode 100644 index 000000000..f42fab42b --- /dev/null +++ b/www/assets/framework7/cjs/components/color-picker/modules/alpha-slider.js @@ -0,0 +1,101 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _$jsx = _interopRequireDefault(require("../../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @jsx $jsx */ +var _default = { + render: function render(self) { + var _self$params = self.params, + sliderLabel = _self$params.sliderLabel, + sliderValue = _self$params.sliderValue, + sliderValueEditable = _self$params.sliderValueEditable, + alphaLabelText = _self$params.alphaLabelText; + return (0, _$jsx.default)("div", { + class: "color-picker-module color-picker-module-alpha-slider" + }, (0, _$jsx.default)("div", { + class: "color-picker-slider-wrap" + }, sliderLabel && (0, _$jsx.default)("div", { + class: "color-picker-slider-label" + }, alphaLabelText), (0, _$jsx.default)("div", { + class: "range-slider color-picker-slider color-picker-slider-alpha" + }), sliderValue && (0, _$jsx.default)("div", { + class: "color-picker-slider-value" + }, sliderValueEditable ? (0, _$jsx.default)("input", { + type: "number", + step: "0.01", + min: "0", + max: "1", + class: "color-picker-value-alpha" + }) : (0, _$jsx.default)("span", { + class: "color-picker-value-alpha" + })))); + }, + init: function init(self) { + self.alphaRangeSlider = self.app.range.create({ + el: self.$el.find('.color-picker-slider-alpha'), + min: 0, + max: 1, + step: 0.01, + value: 1, + on: { + change: function change(range, value) { + var alpha = Math.floor(value * 100) / 100; + self.setValue({ + alpha: alpha + }); + } + } + }); + + function handleInputChange(e) { + var alpha = self.value.alpha; + var value = parseFloat(e.target.value); + + if (Number.isNaN(value)) { + e.target.value = alpha; + return; + } + + value = Math.max(0, Math.min(1, value)); + self.setValue({ + alpha: value + }); + } + + self.$el.on('change', '.color-picker-module-alpha-slider input', handleInputChange); + + self.destroyAlphaSliderEvents = function destroyAlphaSliderEvents() { + self.$el.off('change', '.color-picker-module-alpha-slider input', handleInputChange); + }; + }, + update: function update(self) { + var value = self.value; + var _self$params2 = self.params, + sliderValue = _self$params2.sliderValue, + sliderValueEditable = _self$params2.sliderValueEditable; + var alpha = value.alpha; + self.alphaRangeSlider.value = alpha; + self.alphaRangeSlider.layout(); + + if (sliderValue && sliderValueEditable) { + self.$el.find('input.color-picker-value-alpha').val(alpha); + } else { + self.$el.find('span.color-picker-value-alpha').text(alpha); + } + }, + destroy: function destroy(self) { + if (self.alphaRangeSlider && self.alphaRangeSlider.destroy) { + self.alphaRangeSlider.destroy(); + } + + delete self.alphaRangeSlider; + if (self.destroyAlphaSliderEvents) self.destroyAlphaSliderEvents(); + delete self.destroyAlphaSliderEvents; + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/color-picker/modules/brightness-slider.js b/www/assets/framework7/cjs/components/color-picker/modules/brightness-slider.js new file mode 100644 index 000000000..3aed05f60 --- /dev/null +++ b/www/assets/framework7/cjs/components/color-picker/modules/brightness-slider.js @@ -0,0 +1,86 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _utils = require("../../../shared/utils"); + +var _$jsx = _interopRequireDefault(require("../../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @jsx $jsx */ +var _default = { + render: function render(self) { + var _self$params = self.params, + sliderLabel = _self$params.sliderLabel, + sliderValue = _self$params.sliderValue, + sliderValueEditable = _self$params.sliderValueEditable, + brightnessLabelText = _self$params.brightnessLabelText; + return (0, _$jsx.default)("div", { + class: "color-picker-module color-picker-module-brightness-slider" + }, (0, _$jsx.default)("div", { + class: "color-picker-slider-wrap" + }, sliderLabel && (0, _$jsx.default)("div", { + class: "color-picker-slider-label" + }, brightnessLabelText), (0, _$jsx.default)("div", { + class: "range-slider color-picker-slider color-picker-slider-brightness" + }), sliderValue && (0, _$jsx.default)("div", { + class: "color-picker-slider-value" + }, sliderValueEditable ? (0, _$jsx.default)("input", { + type: "number", + step: "0.1", + min: "0", + max: "100", + class: "color-picker-value-brightness" + }) : (0, _$jsx.default)("span", { + class: "color-picker-value-brightness" + })))); + }, + init: function init(self) { + self.brightnessRangeSlider = self.app.range.create({ + el: self.$el.find('.color-picker-slider-brightness'), + min: 0, + max: 1, + step: 0.001, + value: 0, + on: { + change: function change(range, value) { + var b = Math.floor(value * 1000) / 1000; + self.setValue({ + hsb: [self.value.hsb[0], self.value.hsb[1], b] + }); + } + } + }); + }, + update: function update(self) { + var value = self.value, + app = self.app; + var _self$params2 = self.params, + sliderValue = _self$params2.sliderValue, + sliderValueEditable = _self$params2.sliderValueEditable; + var hsb = value.hsb; + self.brightnessRangeSlider.value = hsb[2]; + self.brightnessRangeSlider.layout(); + var hslCurrent = (0, _utils.colorHsbToHsl)(hsb[0], hsb[1], hsb[2]); + var hslLeft = (0, _utils.colorHsbToHsl)(hsb[0], hsb[1], 0); + var hslRight = (0, _utils.colorHsbToHsl)(hsb[0], hsb[1], 1); + self.brightnessRangeSlider.$el[0].style.setProperty('--f7-range-knob-color', "hsl(" + hslCurrent[0] + ", " + hslCurrent[1] * 100 + "%, " + hslCurrent[2] * 100 + "%)"); + self.brightnessRangeSlider.$el.find('.range-bar').css('background-image', "linear-gradient(" + (app.rtl ? 'to left' : 'to right') + ", hsl(" + hslLeft[0] + ", " + hslLeft[1] * 100 + "%, " + hslLeft[2] * 100 + "%), hsl(" + hslRight[0] + ", " + hslRight[1] * 100 + "%, " + hslRight[2] * 100 + "%))"); + + if (sliderValue && sliderValueEditable) { + self.$el.find('input.color-picker-value-brightness').val("" + hsb[2] * 1000 / 10); + } else if (sliderValue) { + self.$el.find('span.color-picker-value-brightness').text("" + hsb[2] * 1000 / 10); + } + }, + destroy: function destroy(self) { + if (self.brightnessRangeSlider && self.brightnessRangeSlider.destroy) { + self.brightnessRangeSlider.destroy(); + } + + delete self.brightnessRangeSlider; + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/color-picker/modules/current-color.js b/www/assets/framework7/cjs/components/color-picker/modules/current-color.js new file mode 100644 index 000000000..e561d3246 --- /dev/null +++ b/www/assets/framework7/cjs/components/color-picker/modules/current-color.js @@ -0,0 +1,23 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _$jsx = _interopRequireDefault(require("../../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @jsx $jsx */ +var _default = { + render: function render() { + return (0, _$jsx.default)("div", { + class: "color-picker-module color-picker-module-current-color" + }, (0, _$jsx.default)("div", { + class: "color-picker-current-color" + })); + }, + update: function update(self) { + self.$el.find('.color-picker-module-current-color .color-picker-current-color').css('background-color', self.value.hex); + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/color-picker/modules/hex.js b/www/assets/framework7/cjs/components/color-picker/modules/hex.js new file mode 100644 index 000000000..85941b02b --- /dev/null +++ b/www/assets/framework7/cjs/components/color-picker/modules/hex.js @@ -0,0 +1,81 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _$jsx = _interopRequireDefault(require("../../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @jsx $jsx */ +var _default = { + render: function render(self) { + var _self$params = self.params, + hexLabel = _self$params.hexLabel, + hexLabelText = _self$params.hexLabelText, + hexValueEditable = _self$params.hexValueEditable; + return (0, _$jsx.default)("div", { + class: "color-picker-module color-picker-module-hex" + }, (0, _$jsx.default)("div", { + class: "color-picker-hex-wrap" + }, hexLabel && (0, _$jsx.default)("div", { + class: "color-picker-hex-label" + }, hexLabelText), (0, _$jsx.default)("div", { + class: "color-picker-hex-value" + }, hexValueEditable ? (0, _$jsx.default)("input", { + type: "text", + class: "color-picker-value-hex" + }) : (0, _$jsx.default)("span", { + class: "color-picker-value-hex" + })))); + }, + init: function init(self) { + function handleInputChange(e) { + var hex = self.value.hex; + var value = e.target.value.replace(/#/g, ''); + + if (Number.isNaN(value) || !value || value.length !== 3 && value.length !== 6) { + e.target.value = hex; + return; + } + + var min = 0; + var current = parseInt(value, 16); + var max = parseInt('ffffff', 16); // eslint-disable-line + + if (current > max) { + value = 'fff'; + } + + if (current < min) { + value = '000'; + } + + self.setValue({ + hex: value + }); + } + + self.$el.on('change', '.color-picker-module-hex input', handleInputChange); + + self.destroyHexEvents = function destroyHexEvents() { + self.$el.off('change', '.color-picker-module-hex input', handleInputChange); + }; + }, + update: function update(self) { + var value = self.value; + var hexValueEditable = self.params.hexValueEditable; + var hex = value.hex; + + if (hexValueEditable) { + self.$el.find('input.color-picker-value-hex').val(hex); + } else { + self.$el.find('span.color-picker-value-hex').text(hex); + } + }, + destroy: function destroy(self) { + if (self.destroyHexEvents) self.destroyHexEvents(); + delete self.destroyHexEvents; + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/color-picker/modules/hs-spectrum.js b/www/assets/framework7/cjs/components/color-picker/modules/hs-spectrum.js new file mode 100644 index 000000000..79a0b7401 --- /dev/null +++ b/www/assets/framework7/cjs/components/color-picker/modules/hs-spectrum.js @@ -0,0 +1,137 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../../shared/dom7")); + +var _utils = require("../../../shared/utils"); + +var _getSupport = require("../../../shared/get-support"); + +var _$jsx = _interopRequireDefault(require("../../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @jsx $jsx */ +var _default = { + render: function render() { + return (0, _$jsx.default)("div", { + class: "color-picker-module color-picker-module-hs-spectrum" + }, (0, _$jsx.default)("div", { + class: "color-picker-hs-spectrum" + }, (0, _$jsx.default)("div", { + class: "color-picker-hs-spectrum-handle" + }))); + }, + init: function init(self) { + var app = self.app; + var isTouched; + var isMoved; + var touchStartX; + var touchStartY; + var touchCurrentX; + var touchCurrentY; + var specterRect; + var specterIsTouched; + var specterHandleIsTouched; + var $el = self.$el; + + function setHSFromSpecterCoords(x, y) { + var h = (x - specterRect.left) / specterRect.width * 360; + var s = (y - specterRect.top) / specterRect.height; + h = Math.max(0, Math.min(360, h)); + s = 1 - Math.max(0, Math.min(1, s)); + self.setValue({ + hsb: [h, s, self.value.hsb[2]] + }); + } + + function handleTouchStart(e) { + if (isMoved || isTouched) return; + touchStartX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; + touchCurrentX = touchStartX; + touchStartY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + touchCurrentY = touchStartY; + var $targetEl = (0, _dom.default)(e.target); + specterHandleIsTouched = $targetEl.closest('.color-picker-hs-spectrum-handle').length > 0; + + if (!specterHandleIsTouched) { + specterIsTouched = $targetEl.closest('.color-picker-hs-spectrum').length > 0; + } + + if (specterIsTouched) { + specterRect = $el.find('.color-picker-hs-spectrum')[0].getBoundingClientRect(); + setHSFromSpecterCoords(touchStartX, touchStartY); + } + + if (specterHandleIsTouched || specterIsTouched) { + $el.find('.color-picker-hs-spectrum-handle').addClass('color-picker-hs-spectrum-handle-pressed'); + } + } + + function handleTouchMove(e) { + if (!(specterIsTouched || specterHandleIsTouched)) return; + touchCurrentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; + touchCurrentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; + e.preventDefault(); + + if (!isMoved) { + // First move + isMoved = true; + + if (specterHandleIsTouched) { + specterRect = $el.find('.color-picker-hs-spectrum')[0].getBoundingClientRect(); + } + } + + if (specterIsTouched || specterHandleIsTouched) { + setHSFromSpecterCoords(touchCurrentX, touchCurrentY); + } + } + + function handleTouchEnd() { + isMoved = false; + + if (specterIsTouched || specterHandleIsTouched) { + $el.find('.color-picker-hs-spectrum-handle').removeClass('color-picker-hs-spectrum-handle-pressed'); + } + + specterIsTouched = false; + specterHandleIsTouched = false; + } + + function handleResize() { + self.modules['hs-spectrum'].update(self); + } + + var passiveListener = app.touchEvents.start === 'touchstart' && (0, _getSupport.getSupport)().passiveListener ? { + passive: true, + capture: false + } : false; + self.$el.on(app.touchEvents.start, handleTouchStart, passiveListener); + app.on('touchmove:active', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + app.on('resize', handleResize); + + self.destroySpectrumEvents = function destroySpectrumEvents() { + self.$el.off(app.touchEvents.start, handleTouchStart, passiveListener); + app.off('touchmove:active', handleTouchMove); + app.off('touchend:passive', handleTouchEnd); + app.off('resize', handleResize); + }; + }, + update: function update(self) { + var value = self.value; + var hsb = value.hsb; + var specterWidth = self.$el.find('.color-picker-hs-spectrum')[0].offsetWidth; + var specterHeight = self.$el.find('.color-picker-hs-spectrum')[0].offsetHeight; + var hslBright = (0, _utils.colorHsbToHsl)(hsb[0], hsb[1], 1); + self.$el.find('.color-picker-hs-spectrum-handle').css('background-color', "hsl(" + hslBright[0] + ", " + hslBright[1] * 100 + "%, " + hslBright[2] * 100 + "%)").transform("translate(" + specterWidth * (hsb[0] / 360) + "px, " + specterHeight * (1 - hsb[1]) + "px)"); + }, + destroy: function destroy(self) { + if (self.destroySpectrumEvents) self.destroySpectrumEvents(); + delete self.destroySpectrumEvents; + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/color-picker/modules/hsb-sliders.js b/www/assets/framework7/cjs/components/color-picker/modules/hsb-sliders.js new file mode 100644 index 000000000..6531df295 --- /dev/null +++ b/www/assets/framework7/cjs/components/color-picker/modules/hsb-sliders.js @@ -0,0 +1,206 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../../shared/dom7")); + +var _utils = require("../../../shared/utils"); + +var _$jsx = _interopRequireDefault(require("../../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @jsx $jsx */ +var _default = { + render: function render(self) { + var _self$params = self.params, + sliderLabel = _self$params.sliderLabel, + sliderValue = _self$params.sliderValue, + sliderValueEditable = _self$params.sliderValueEditable, + hueLabelText = _self$params.hueLabelText, + saturationLabelText = _self$params.saturationLabelText, + brightnessLabelText = _self$params.brightnessLabelText; + return (0, _$jsx.default)("div", { + class: "color-picker-module color-picker-module-hsb-sliders" + }, (0, _$jsx.default)("div", { + class: "color-picker-slider-wrap" + }, sliderLabel && (0, _$jsx.default)("div", { + class: "color-picker-slider-label" + }, hueLabelText), (0, _$jsx.default)("div", { + class: "range-slider color-picker-slider color-picker-slider-hue" + }), sliderValue && (0, _$jsx.default)("div", { + class: "color-picker-slider-value" + }, sliderValueEditable ? (0, _$jsx.default)("input", { + type: "number", + step: "0.1", + min: "0", + max: "360", + class: "color-picker-value-hue", + "data-color-index": "0" + }) : (0, _$jsx.default)("span", { + class: "color-picker-value-hue" + }))), (0, _$jsx.default)("div", { + class: "color-picker-slider-wrap" + }, sliderLabel && (0, _$jsx.default)("div", { + class: "color-picker-slider-label" + }, saturationLabelText), (0, _$jsx.default)("div", { + class: "range-slider color-picker-slider color-picker-slider-saturation" + }), sliderValue && (0, _$jsx.default)("div", { + class: "color-picker-slider-value" + }, sliderValueEditable ? (0, _$jsx.default)("input", { + type: "number", + step: "0.1", + min: "0", + max: "100", + class: "color-picker-value-saturation", + "data-color-index": "1" + }) : (0, _$jsx.default)("span", { + class: "color-picker-value-saturation" + }))), (0, _$jsx.default)("div", { + class: "color-picker-slider-wrap" + }, sliderLabel && (0, _$jsx.default)("div", { + class: "color-picker-slider-label" + }, brightnessLabelText), (0, _$jsx.default)("div", { + class: "range-slider color-picker-slider color-picker-slider-brightness" + }), sliderValue && (0, _$jsx.default)("div", { + class: "color-picker-slider-value" + }, sliderValueEditable ? (0, _$jsx.default)("input", { + type: "number", + step: "0.1", + min: "0", + max: "100", + class: "color-picker-value-brightness", + "data-color-index": "2" + }) : (0, _$jsx.default)("span", { + class: "color-picker-value-brightness" + })))); + }, + init: function init(self) { + self.hueRangeSlider = self.app.range.create({ + el: self.$el.find('.color-picker-slider-hue'), + min: 0, + max: 360, + step: 0.1, + value: 0, + on: { + change: function change(range, value) { + self.setValue({ + hue: value + }); + } + } + }); + self.saturationRangeSlider = self.app.range.create({ + el: self.$el.find('.color-picker-slider-saturation'), + min: 0, + max: 1, + step: 0.001, + value: 0, + on: { + change: function change(range, value) { + var s = Math.floor(value * 1000) / 1000; + self.setValue({ + hsb: [self.value.hsb[0], s, self.value.hsb[2]] + }); + } + } + }); + self.brightnessRangeSlider = self.app.range.create({ + el: self.$el.find('.color-picker-slider-brightness'), + min: 0, + max: 1, + step: 0.001, + value: 0, + on: { + change: function change(range, value) { + var b = Math.floor(value * 1000) / 1000; + self.setValue({ + hsb: [self.value.hsb[0], self.value.hsb[1], b] + }); + } + } + }); + + function handleInputChange(e) { + var hsb = [].concat(self.value.hsb); + var index = parseInt((0, _dom.default)(e.target).attr('data-color-index'), 10); + var value = parseFloat(e.target.value); + + if (Number.isNaN(value)) { + e.target.value = hsb[index]; + return; + } + + if (index === 0) { + value = Math.max(0, Math.min(360, value)); + } else { + value = Math.max(0, Math.min(100, value)) / 100; + } + + hsb[index] = value; + self.setValue({ + hsb: hsb + }); + } + + self.$el.on('change', '.color-picker-module-hsb-sliders input', handleInputChange); + + self.destroyHsbSlidersEvents = function destroyHsbSlidersEvents() { + self.$el.off('change', '.color-picker-module-hsb-sliders input', handleInputChange); + }; + }, + update: function update(self) { + var app = self.app, + value = self.value; + var _self$params2 = self.params, + sliderValue = _self$params2.sliderValue, + sliderValueEditable = _self$params2.sliderValueEditable; + var hsb = value.hsb, + hue = value.hue; + self.hueRangeSlider.value = hue; + self.saturationRangeSlider.value = hsb[1]; + self.brightnessRangeSlider.value = hsb[2]; + self.hueRangeSlider.layout(); + self.saturationRangeSlider.layout(); + self.brightnessRangeSlider.layout(); + var hslCurrent = (0, _utils.colorHsbToHsl)(hsb[0], hsb[1], 1); + var hslLeft = (0, _utils.colorHsbToHsl)(hsb[0], 0, 1); + var hslRight = (0, _utils.colorHsbToHsl)(hsb[0], 1, 1); + var brightness = hsb[2]; + self.hueRangeSlider.$el[0].style.setProperty('--f7-range-knob-color', "hsl(" + hue + ", 100%, 50%)"); + self.saturationRangeSlider.$el[0].style.setProperty('--f7-range-knob-color', "hsl(" + hslCurrent[0] + ", " + hslCurrent[1] * 100 + "%, " + hslCurrent[2] * 100 + "%)"); + self.brightnessRangeSlider.$el[0].style.setProperty('--f7-range-knob-color', "rgb(" + brightness * 255 + ", " + brightness * 255 + ", " + brightness * 255 + ")"); + self.saturationRangeSlider.$el.find('.range-bar').css('background-image', "linear-gradient(" + (app.rtl ? 'to left' : 'to right') + ", hsl(" + hslLeft[0] + ", " + hslLeft[1] * 100 + "%, " + hslLeft[2] * 100 + "%), hsl(" + hslRight[0] + ", " + hslRight[1] * 100 + "%, " + hslRight[2] * 100 + "%))"); + + if (sliderValue && sliderValueEditable) { + self.$el.find('input.color-picker-value-hue').val("" + hue); + self.$el.find('input.color-picker-value-saturation').val("" + hsb[1] * 1000 / 10); + self.$el.find('input.color-picker-value-brightness').val("" + hsb[2] * 1000 / 10); + } else if (sliderValue) { + self.$el.find('span.color-picker-value-hue').text("" + hue); + self.$el.find('span.color-picker-value-saturation').text("" + hsb[1] * 1000 / 10); + self.$el.find('span.color-picker-value-brightness').text("" + hsb[2] * 1000 / 10); + } + }, + destroy: function destroy(self) { + if (self.hueRangeSlider && self.hueRangeSlider.destroy) { + self.hueRangeSlider.destroy(); + } + + if (self.saturationRangeSlider && self.saturationRangeSlider.destroy) { + self.saturationRangeSlider.destroy(); + } + + if (self.brightnessRangeSlider && self.brightnessRangeSlider.destroy) { + self.brightnessRangeSlider.destroy(); + } + + delete self.hueRangeSlider; + delete self.saturationRangeSlider; + delete self.brightnessRangeSlider; + if (self.destroyHsbSlidersEvents) self.destroyHsbSlidersEvents(); + delete self.destroyHsbSlidersEvents; + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/color-picker/modules/hue-slider.js b/www/assets/framework7/cjs/components/color-picker/modules/hue-slider.js new file mode 100644 index 000000000..6cde98158 --- /dev/null +++ b/www/assets/framework7/cjs/components/color-picker/modules/hue-slider.js @@ -0,0 +1,78 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _$jsx = _interopRequireDefault(require("../../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @jsx $jsx */ +var _default = { + render: function render(self) { + var _self$params = self.params, + sliderLabel = _self$params.sliderLabel, + sliderValue = _self$params.sliderValue, + sliderValueEditable = _self$params.sliderValueEditable, + hueLabelText = _self$params.hueLabelText; + return (0, _$jsx.default)("div", { + class: "color-picker-module color-picker-module-hue-slider" + }, (0, _$jsx.default)("div", { + class: "color-picker-slider-wrap" + }, sliderLabel && (0, _$jsx.default)("div", { + class: "color-picker-slider-label" + }, hueLabelText), (0, _$jsx.default)("div", { + class: "range-slider color-picker-slider color-picker-slider-hue" + }), sliderValue && (0, _$jsx.default)("div", { + class: "color-picker-slider-value" + }, sliderValueEditable ? (0, _$jsx.default)("input", { + type: "number", + step: "0.1", + min: "0", + max: "360", + class: "color-picker-value-hue" + }) : (0, _$jsx.default)("span", { + class: "color-picker-value-hue" + })))); + }, + init: function init(self) { + self.hueRangeSlider = self.app.range.create({ + el: self.$el.find('.color-picker-slider-hue'), + min: 0, + max: 360, + step: 0.1, + value: 0, + on: { + change: function change(range, value) { + self.setValue({ + hue: value + }); + } + } + }); + }, + update: function update(self) { + var value = self.value; + var _self$params2 = self.params, + sliderValue = _self$params2.sliderValue, + sliderValueEditable = _self$params2.sliderValueEditable; + var hue = value.hue; + self.hueRangeSlider.value = hue; + self.hueRangeSlider.layout(); + self.hueRangeSlider.$el[0].style.setProperty('--f7-range-knob-color', "hsl(" + hue + ", 100%, 50%)"); + + if (sliderValue && sliderValueEditable) { + self.$el.find('input.color-picker-value-hue').val("" + hue); + } else if (sliderValue) { + self.$el.find('span.color-picker-value-hue').text("" + hue); + } + }, + destroy: function destroy(self) { + if (self.hueRangeSlider && self.hueRangeSlider.destroy) { + self.hueRangeSlider.destroy(); + } + + delete self.hueRangeSlider; + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/color-picker/modules/initial-current-colors.js b/www/assets/framework7/cjs/components/color-picker/modules/initial-current-colors.js new file mode 100644 index 000000000..8c7193366 --- /dev/null +++ b/www/assets/framework7/cjs/components/color-picker/modules/initial-current-colors.js @@ -0,0 +1,54 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _$jsx = _interopRequireDefault(require("../../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @jsx $jsx */ +var _default = { + render: function render() { + return (0, _$jsx.default)("div", { + class: "color-picker-module color-picker-module-initial-current-colors" + }, (0, _$jsx.default)("div", { + class: "color-picker-initial-current-colors" + }, (0, _$jsx.default)("div", { + class: "color-picker-initial-color" + }), (0, _$jsx.default)("div", { + class: "color-picker-current-color" + }))); + }, + init: function init(self) { + function handleInitialColorClick() { + if (self.initialValue) { + var _self$initialValue = self.initialValue, + hex = _self$initialValue.hex, + alpha = _self$initialValue.alpha; + self.setValue({ + hex: hex, + alpha: alpha + }); + } + } + + self.$el.on('click', '.color-picker-initial-color', handleInitialColorClick); + + self.destroyInitialCurrentEvents = function destroyInitialCurrentEvents() { + self.$el.off('click', '.color-picker-initial-color', handleInitialColorClick); + }; + }, + update: function update(self) { + self.$el.find('.color-picker-module-initial-current-colors .color-picker-initial-color').css('background-color', self.initialValue.hex); + self.$el.find('.color-picker-module-initial-current-colors .color-picker-current-color').css('background-color', self.value.hex); + }, + destroy: function destroy(self) { + if (self.destroyInitialCurrentEvents) { + self.destroyInitialCurrentEvents(); + } + + delete self.destroyInitialCurrentEvents; + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/color-picker/modules/palette.js b/www/assets/framework7/cjs/components/color-picker/modules/palette.js new file mode 100644 index 000000000..ecc5c367c --- /dev/null +++ b/www/assets/framework7/cjs/components/color-picker/modules/palette.js @@ -0,0 +1,61 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../../shared/dom7")); + +var _$jsx = _interopRequireDefault(require("../../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* eslint indent: ["off"] */ + +/** @jsx $jsx */ +var _default = { + render: function render(self) { + return (0, _$jsx.default)("div", { + class: "color-picker-module color-picker-module-palette" + }, (0, _$jsx.default)("div", { + class: "color-picker-palette" + }, self.params.palette.map(function (p) { + if (Array.isArray(p)) { + var row = '
    '; // prettier-ignore + + row += p.map(function (c) { + return "\n
    \n "; + }).join(''); + row += '
    '; + return row; + } + + return (0, _$jsx.default)("div", { + class: "color-picker-palette-value", + "data-palette-color": p, + style: "background-color: " + p + }); + }))); + }, + init: function init(self) { + function handlePaletteClick(e) { + var hex = (0, _dom.default)(e.target).attr('data-palette-color'); + self.setValue({ + hex: hex + }); + } + + self.$el.on('click', '.color-picker-module-palette .color-picker-palette-value', handlePaletteClick); + + self.destroyPaletteEvents = function destroyPaletteEvents() { + self.$el.off('click', '.color-picker-module-hex input', handlePaletteClick); + }; + }, + destroy: function destroy(self) { + if (self.destroyPaletteEvents) { + self.destroyPaletteEvents(); + } + + delete self.destroyPaletteEvents; + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/color-picker/modules/rgb-bars.js b/www/assets/framework7/cjs/components/color-picker/modules/rgb-bars.js new file mode 100644 index 000000000..ba210ca97 --- /dev/null +++ b/www/assets/framework7/cjs/components/color-picker/modules/rgb-bars.js @@ -0,0 +1,196 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../../shared/dom7")); + +var _$jsx = _interopRequireDefault(require("../../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @jsx $jsx */ +var _default = { + render: function render(self) { + var _self$params = self.params, + barLabel = _self$params.barLabel, + barValue = _self$params.barValue, + barValueEditable = _self$params.barValueEditable, + redLabelText = _self$params.redLabelText, + greenLabelText = _self$params.greenLabelText, + blueLabelText = _self$params.blueLabelText; + return (0, _$jsx.default)("div", { + class: "color-picker-module color-picker-module-rgb-bars" + }, (0, _$jsx.default)("div", { + class: "color-picker-bar-wrap" + }, barLabel && (0, _$jsx.default)("div", { + class: "color-picker-bar-label" + }, redLabelText), (0, _$jsx.default)("div", { + class: "range-slider color-picker-bar color-picker-bar-red" + }), barValue && (0, _$jsx.default)("div", { + class: "color-picker-bar-value" + }, barValueEditable ? (0, _$jsx.default)("input", { + type: "number", + step: "1", + min: "0", + max: "255", + class: "color-picker-value-bar-red", + "data-color-index": "0" + }) : (0, _$jsx.default)("span", { + class: "color-picker-value-bar-red" + }))), (0, _$jsx.default)("div", { + class: "color-picker-bar-wrap" + }, barLabel && (0, _$jsx.default)("div", { + class: "color-picker-bar-label" + }, greenLabelText), (0, _$jsx.default)("div", { + class: "range-slider color-picker-bar color-picker-bar-green" + }), barValue && (0, _$jsx.default)("div", { + class: "color-picker-bar-value" + }, barValueEditable ? (0, _$jsx.default)("input", { + type: "number", + step: "1", + min: "0", + max: "255", + class: "color-picker-value-bar-green", + "data-color-index": "1" + }) : (0, _$jsx.default)("span", { + class: "color-picker-value-bar-green" + }))), (0, _$jsx.default)("div", { + class: "color-picker-bar-wrap" + }, barLabel && (0, _$jsx.default)("div", { + class: "color-picker-bar-label" + }, blueLabelText), (0, _$jsx.default)("div", { + class: "range-slider color-picker-bar color-picker-bar-blue" + }), barValue && (0, _$jsx.default)("div", { + class: "color-picker-bar-value" + }, barValueEditable ? (0, _$jsx.default)("input", { + type: "number", + step: "1", + min: "0", + max: "255", + class: "color-picker-value-bar-blue", + "data-color-index": "2" + }) : (0, _$jsx.default)("span", { + class: "color-picker-value-bar-blue" + })))); + }, + init: function init(self) { + self.redBar = self.app.range.create({ + el: self.$el.find('.color-picker-bar-red'), + min: 0, + max: 255, + step: 1, + value: 0, + vertical: true, + on: { + change: function change(range, value) { + self.setValue({ + rgb: [value, self.value.rgb[1], self.value.rgb[2]] + }); + } + } + }); + self.greenBar = self.app.range.create({ + el: self.$el.find('.color-picker-bar-green'), + min: 0, + max: 255, + step: 1, + value: 0, + vertical: true, + on: { + change: function change(range, value) { + self.setValue({ + rgb: [self.value.rgb[0], value, self.value.rgb[2]] + }); + } + } + }); + self.blueBar = self.app.range.create({ + el: self.$el.find('.color-picker-bar-blue'), + min: 0, + max: 255, + step: 1, + value: 0, + vertical: true, + on: { + change: function change(range, value) { + self.setValue({ + rgb: [self.value.rgb[0], self.value.rgb[1], value] + }); + } + } + }); + + function handleInputChange(e) { + var rgb = [].concat(self.value.rgb); + var index = parseInt((0, _dom.default)(e.target).attr('data-color-index'), 10); + var value = parseInt(e.target.value, 10); + + if (Number.isNaN(value)) { + e.target.value = rgb[index]; + return; + } + + value = Math.max(0, Math.min(255, value)); + rgb[index] = value; + self.setValue({ + rgb: rgb + }); + } + + self.$el.on('change', '.color-picker-module-rgb-bars input', handleInputChange); + + self.destroyRgbBarsEvents = function destroyRgbBarsEvents() { + self.$el.off('change', '.color-picker-module-rgb-bars input', handleInputChange); + }; + }, + update: function update(self) { + var value = self.value, + redBar = self.redBar, + greenBar = self.greenBar, + blueBar = self.blueBar; + var _self$params2 = self.params, + barValue = _self$params2.barValue, + barValueEditable = _self$params2.barValueEditable; + var rgb = value.rgb; + redBar.value = rgb[0]; + greenBar.value = rgb[1]; + blueBar.value = rgb[2]; + redBar.layout(); + greenBar.layout(); + blueBar.layout(); + redBar.$el.find('.range-bar').css('background-image', "linear-gradient(to top, rgb(0, " + rgb[1] + ", " + rgb[2] + "), rgb(255, " + rgb[1] + ", " + rgb[2] + "))"); + greenBar.$el.find('.range-bar').css('background-image', "linear-gradient(to top, rgb(" + rgb[0] + ", 0, " + rgb[2] + "), rgb(" + rgb[0] + ", 255, " + rgb[2] + "))"); + blueBar.$el.find('.range-bar').css('background-image', "linear-gradient(to top, rgb(" + rgb[0] + ", " + rgb[1] + ", 0), rgb(" + rgb[0] + ", " + rgb[1] + ", 255))"); + + if (barValue && barValueEditable) { + self.$el.find('input.color-picker-value-bar-red').val(rgb[0]); + self.$el.find('input.color-picker-value-bar-green').val(rgb[1]); + self.$el.find('input.color-picker-value-bar-blue').val(rgb[2]); + } else if (barValue) { + self.$el.find('span.color-picker-value-bar-red').text(rgb[0]); + self.$el.find('span.color-picker-value-bar-green').text(rgb[1]); + self.$el.find('span.color-picker-value-bar-blue').text(rgb[2]); + } + }, + destroy: function destroy(self) { + if (self.redBar && self.redBar.destroy) { + self.redBar.destroy(); + } + + if (self.greenBar && self.greenBar.destroy) { + self.greenBar.destroy(); + } + + if (self.blueBar && self.blueBar.destroy) { + self.blueBar.destroy(); + } + + delete self.redBar; + delete self.greenBar; + delete self.blueBar; + if (self.destroyRgbBarsEvents) self.destroyRgbBarsEvents(); + delete self.destroyRgbBarsEvents; + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/color-picker/modules/rgb-sliders.js b/www/assets/framework7/cjs/components/color-picker/modules/rgb-sliders.js new file mode 100644 index 000000000..83222c756 --- /dev/null +++ b/www/assets/framework7/cjs/components/color-picker/modules/rgb-sliders.js @@ -0,0 +1,198 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../../shared/dom7")); + +var _$jsx = _interopRequireDefault(require("../../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @jsx $jsx */ +var _default = { + render: function render(self) { + var _self$params = self.params, + sliderLabel = _self$params.sliderLabel, + sliderValue = _self$params.sliderValue, + sliderValueEditable = _self$params.sliderValueEditable, + redLabelText = _self$params.redLabelText, + greenLabelText = _self$params.greenLabelText, + blueLabelText = _self$params.blueLabelText; + return (0, _$jsx.default)("div", { + class: "color-picker-module color-picker-module-rgb-sliders" + }, (0, _$jsx.default)("div", { + class: "color-picker-slider-wrap" + }, sliderLabel && (0, _$jsx.default)("div", { + class: "color-picker-slider-label" + }, redLabelText), (0, _$jsx.default)("div", { + class: "range-slider color-picker-slider color-picker-slider-red" + }), sliderValue && (0, _$jsx.default)("div", { + class: "color-picker-slider-value" + }, sliderValueEditable ? (0, _$jsx.default)("input", { + type: "number", + step: "1", + min: "0", + max: "255", + class: "color-picker-value-red", + "data-color-index": "0" + }) : (0, _$jsx.default)("span", { + class: "color-picker-value-red" + }))), (0, _$jsx.default)("div", { + class: "color-picker-slider-wrap" + }, sliderLabel && (0, _$jsx.default)("div", { + class: "color-picker-slider-label" + }, greenLabelText), (0, _$jsx.default)("div", { + class: "range-slider color-picker-slider color-picker-slider-green" + }), sliderValue && (0, _$jsx.default)("div", { + class: "color-picker-slider-value" + }, sliderValueEditable ? (0, _$jsx.default)("input", { + type: "number", + step: "1", + min: "0", + max: "255", + class: "color-picker-value-green", + "data-color-index": "1" + }) : (0, _$jsx.default)("span", { + class: "color-picker-value-green" + }))), (0, _$jsx.default)("div", { + class: "color-picker-slider-wrap" + }, sliderLabel && (0, _$jsx.default)("div", { + class: "color-picker-slider-label" + }, blueLabelText), (0, _$jsx.default)("div", { + class: "range-slider color-picker-slider color-picker-slider-blue" + }), sliderValue && (0, _$jsx.default)("div", { + class: "color-picker-slider-value" + }, sliderValueEditable ? (0, _$jsx.default)("input", { + type: "number", + step: "1", + min: "0", + max: "255", + class: "color-picker-value-blue", + "data-color-index": "2" + }) : (0, _$jsx.default)("span", { + class: "color-picker-value-blue" + })))); + }, + init: function init(self) { + self.redRangeSlider = self.app.range.create({ + el: self.$el.find('.color-picker-slider-red'), + min: 0, + max: 255, + step: 1, + value: 0, + on: { + change: function change(range, value) { + self.setValue({ + rgb: [value, self.value.rgb[1], self.value.rgb[2]] + }); + } + } + }); + self.greenRangeSlider = self.app.range.create({ + el: self.$el.find('.color-picker-slider-green'), + min: 0, + max: 255, + step: 1, + value: 0, + on: { + change: function change(range, value) { + self.setValue({ + rgb: [self.value.rgb[0], value, self.value.rgb[2]] + }); + } + } + }); + self.blueRangeSlider = self.app.range.create({ + el: self.$el.find('.color-picker-slider-blue'), + min: 0, + max: 255, + step: 1, + value: 0, + on: { + change: function change(range, value) { + self.setValue({ + rgb: [self.value.rgb[0], self.value.rgb[1], value] + }); + } + } + }); + + function handleInputChange(e) { + var rgb = [].concat(self.value.rgb); + var index = parseInt((0, _dom.default)(e.target).attr('data-color-index'), 10); + var value = parseInt(e.target.value, 10); + + if (Number.isNaN(value)) { + e.target.value = rgb[index]; + return; + } + + value = Math.max(0, Math.min(255, value)); + rgb[index] = value; + self.setValue({ + rgb: rgb + }); + } + + self.$el.on('change', '.color-picker-module-rgb-sliders input', handleInputChange); + + self.destroyRgbSlidersEvents = function destroyRgbSlidersEvents() { + self.$el.off('change', '.color-picker-module-rgb-sliders input', handleInputChange); + }; + }, + update: function update(self) { + var app = self.app, + value = self.value, + redRangeSlider = self.redRangeSlider, + greenRangeSlider = self.greenRangeSlider, + blueRangeSlider = self.blueRangeSlider; + var _self$params2 = self.params, + sliderValue = _self$params2.sliderValue, + sliderValueEditable = _self$params2.sliderValueEditable; + var rgb = value.rgb; + redRangeSlider.value = rgb[0]; + greenRangeSlider.value = rgb[1]; + blueRangeSlider.value = rgb[2]; + redRangeSlider.layout(); + greenRangeSlider.layout(); + blueRangeSlider.layout(); + redRangeSlider.$el[0].style.setProperty('--f7-range-knob-color', "rgb(" + rgb[0] + ", " + rgb[1] + ", " + rgb[2] + ")"); + greenRangeSlider.$el[0].style.setProperty('--f7-range-knob-color', "rgb(" + rgb[0] + ", " + rgb[1] + ", " + rgb[2] + ")"); + blueRangeSlider.$el[0].style.setProperty('--f7-range-knob-color', "rgb(" + rgb[0] + ", " + rgb[1] + ", " + rgb[2] + ")"); + var direction = app.rtl ? 'to left' : 'to right'; + redRangeSlider.$el.find('.range-bar').css('background-image', "linear-gradient(" + direction + ", rgb(0, " + rgb[1] + ", " + rgb[2] + "), rgb(255, " + rgb[1] + ", " + rgb[2] + "))"); + greenRangeSlider.$el.find('.range-bar').css('background-image', "linear-gradient(" + direction + ", rgb(" + rgb[0] + ", 0, " + rgb[2] + "), rgb(" + rgb[0] + ", 255, " + rgb[2] + "))"); + blueRangeSlider.$el.find('.range-bar').css('background-image', "linear-gradient(" + direction + ", rgb(" + rgb[0] + ", " + rgb[1] + ", 0), rgb(" + rgb[0] + ", " + rgb[1] + ", 255))"); + + if (sliderValue && sliderValueEditable) { + self.$el.find('input.color-picker-value-red').val(rgb[0]); + self.$el.find('input.color-picker-value-green').val(rgb[1]); + self.$el.find('input.color-picker-value-blue').val(rgb[2]); + } else if (sliderValue) { + self.$el.find('span.color-picker-value-red').text(rgb[0]); + self.$el.find('span.color-picker-value-green').text(rgb[1]); + self.$el.find('span.color-picker-value-blue').text(rgb[2]); + } + }, + destroy: function destroy(self) { + if (self.redRangeSlider && self.redRangeSlider.destroy) { + self.redRangeSlider.destroy(); + } + + if (self.greenRangeSlider && self.greenRangeSlider.destroy) { + self.greenRangeSlider.destroy(); + } + + if (self.blueRangeSlider && self.blueRangeSlider.destroy) { + self.blueRangeSlider.destroy(); + } + + delete self.redRangeSlider; + delete self.greenRangeSlider; + delete self.blueRangeSlider; + if (self.destroyRgbSlidersEvents) self.destroyRgbSlidersEvents(); + delete self.destroyRgbSlidersEvents; + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/color-picker/modules/sb-spectrum.js b/www/assets/framework7/cjs/components/color-picker/modules/sb-spectrum.js new file mode 100644 index 000000000..2028d9369 --- /dev/null +++ b/www/assets/framework7/cjs/components/color-picker/modules/sb-spectrum.js @@ -0,0 +1,137 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../../shared/dom7")); + +var _getSupport = require("../../../shared/get-support"); + +var _$jsx = _interopRequireDefault(require("../../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @jsx $jsx */ +var _default = { + render: function render() { + return (0, _$jsx.default)("div", { + class: "color-picker-module color-picker-module-sb-spectrum" + }, (0, _$jsx.default)("div", { + class: "color-picker-sb-spectrum", + style: "background-color: hsl(0, 100%, 50%)" + }, (0, _$jsx.default)("div", { + class: "color-picker-sb-spectrum-handle" + }))); + }, + init: function init(self) { + var app = self.app; + var isTouched; + var isMoved; + var touchStartX; + var touchStartY; + var touchCurrentX; + var touchCurrentY; + var specterRect; + var specterIsTouched; + var specterHandleIsTouched; + var $el = self.$el; + + function setSBFromSpecterCoords(x, y) { + var s = (x - specterRect.left) / specterRect.width; + var b = (y - specterRect.top) / specterRect.height; + s = Math.max(0, Math.min(1, s)); + b = 1 - Math.max(0, Math.min(1, b)); + self.setValue({ + hsb: [self.value.hue, s, b] + }); + } + + function handleTouchStart(e) { + if (isMoved || isTouched) return; + touchStartX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; + touchCurrentX = touchStartX; + touchStartY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + touchCurrentY = touchStartY; + var $targetEl = (0, _dom.default)(e.target); + specterHandleIsTouched = $targetEl.closest('.color-picker-sb-spectrum-handle').length > 0; + + if (!specterHandleIsTouched) { + specterIsTouched = $targetEl.closest('.color-picker-sb-spectrum').length > 0; + } + + if (specterIsTouched) { + specterRect = $el.find('.color-picker-sb-spectrum')[0].getBoundingClientRect(); + setSBFromSpecterCoords(touchStartX, touchStartY); + } + + if (specterHandleIsTouched || specterIsTouched) { + $el.find('.color-picker-sb-spectrum-handle').addClass('color-picker-sb-spectrum-handle-pressed'); + } + } + + function handleTouchMove(e) { + if (!(specterIsTouched || specterHandleIsTouched)) return; + touchCurrentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; + touchCurrentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; + e.preventDefault(); + + if (!isMoved) { + // First move + isMoved = true; + + if (specterHandleIsTouched) { + specterRect = $el.find('.color-picker-sb-spectrum')[0].getBoundingClientRect(); + } + } + + if (specterIsTouched || specterHandleIsTouched) { + setSBFromSpecterCoords(touchCurrentX, touchCurrentY); + } + } + + function handleTouchEnd() { + isMoved = false; + + if (specterIsTouched || specterHandleIsTouched) { + $el.find('.color-picker-sb-spectrum-handle').removeClass('color-picker-sb-spectrum-handle-pressed'); + } + + specterIsTouched = false; + specterHandleIsTouched = false; + } + + function handleResize() { + self.modules['sb-spectrum'].update(self); + } + + var passiveListener = app.touchEvents.start === 'touchstart' && (0, _getSupport.getSupport)().passiveListener ? { + passive: true, + capture: false + } : false; + self.$el.on(app.touchEvents.start, handleTouchStart, passiveListener); + app.on('touchmove:active', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + app.on('resize', handleResize); + + self.destroySpectrumEvents = function destroySpectrumEvents() { + self.$el.off(app.touchEvents.start, handleTouchStart, passiveListener); + app.off('touchmove:active', handleTouchMove); + app.off('touchend:passive', handleTouchEnd); + app.off('resize', handleResize); + }; + }, + update: function update(self) { + var value = self.value; + var hsl = value.hsl, + hsb = value.hsb; + var specterWidth = self.$el.find('.color-picker-sb-spectrum')[0].offsetWidth; + var specterHeight = self.$el.find('.color-picker-sb-spectrum')[0].offsetHeight; + self.$el.find('.color-picker-sb-spectrum').css('background-color', "hsl(" + hsl[0] + ", 100%, 50%)"); + self.$el.find('.color-picker-sb-spectrum-handle').css('background-color', "hsl(" + hsl[0] + ", " + hsl[1] * 100 + "%, " + hsl[2] * 100 + "%)").transform("translate(" + specterWidth * hsb[1] + "px, " + specterHeight * (1 - hsb[2]) + "px)"); + }, + destroy: function destroy(self) { + if (self.destroySpectrumEvents) self.destroySpectrumEvents(); + delete self.destroySpectrumEvents; + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/color-picker/modules/wheel.js b/www/assets/framework7/cjs/components/color-picker/modules/wheel.js new file mode 100644 index 000000000..00cbb3a12 --- /dev/null +++ b/www/assets/framework7/cjs/components/color-picker/modules/wheel.js @@ -0,0 +1,198 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../../shared/dom7")); + +var _getSupport = require("../../../shared/get-support"); + +var _$jsx = _interopRequireDefault(require("../../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @jsx $jsx */ +function svgWheelCircles() { + var total = 256; + var circles = ''; + + for (var i = total; i > 0; i -= 1) { + var angle = i * Math.PI / (total / 2); + var hue = 360 / total * i; + circles += ""; + } + + return circles; +} + +var _default = { + render: function render() { + return (0, _$jsx.default)("div", { + class: "color-picker-module color-picker-module-wheel" + }, (0, _$jsx.default)("div", { + class: "color-picker-wheel" + }, (0, _$jsx.default)("svg", { + viewBox: "0 0 300 300", + width: "300", + height: "300" + }, svgWheelCircles()), (0, _$jsx.default)("div", { + class: "color-picker-wheel-handle" + }), (0, _$jsx.default)("div", { + class: "color-picker-sb-spectrum", + style: "background-color: hsl(0, 100%, 50%)" + }, (0, _$jsx.default)("div", { + class: "color-picker-sb-spectrum-handle" + })))); + }, + init: function init(self) { + var app = self.app; + var isTouched; + var isMoved; + var touchStartX; + var touchStartY; + var touchCurrentX; + var touchCurrentY; + var wheelRect; + var wheelIsTouched; + var wheelHandleIsTouched; + var specterRect; + var specterIsTouched; + var specterHandleIsTouched; + var $el = self.$el; + + function setHueFromWheelCoords(x, y) { + var wheelCenterX = wheelRect.left + wheelRect.width / 2; + var wheelCenterY = wheelRect.top + wheelRect.height / 2; + var angleRad = Math.atan2(y - wheelCenterY, x - wheelCenterX); + var angleDeg = angleRad * 180 / Math.PI + 90; + if (angleDeg < 0) angleDeg += 360; + angleDeg = 360 - angleDeg; + self.setValue({ + hue: angleDeg + }); + } + + function setSBFromSpecterCoords(x, y) { + var s = (x - specterRect.left) / specterRect.width; + var b = (y - specterRect.top) / specterRect.height; + s = Math.max(0, Math.min(1, s)); + b = 1 - Math.max(0, Math.min(1, b)); + self.setValue({ + hsb: [self.value.hue, s, b] + }); + } + + function handleTouchStart(e) { + if (isMoved || isTouched) return; + touchStartX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; + touchCurrentX = touchStartX; + touchStartY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + touchCurrentY = touchStartY; + var $targetEl = (0, _dom.default)(e.target); + wheelHandleIsTouched = $targetEl.closest('.color-picker-wheel-handle').length > 0; + wheelIsTouched = $targetEl.closest('circle').length > 0; + specterHandleIsTouched = $targetEl.closest('.color-picker-sb-spectrum-handle').length > 0; + + if (!specterHandleIsTouched) { + specterIsTouched = $targetEl.closest('.color-picker-sb-spectrum').length > 0; + } + + if (wheelIsTouched) { + wheelRect = $el.find('.color-picker-wheel')[0].getBoundingClientRect(); + setHueFromWheelCoords(touchStartX, touchStartY); + } + + if (specterIsTouched) { + specterRect = $el.find('.color-picker-sb-spectrum')[0].getBoundingClientRect(); + setSBFromSpecterCoords(touchStartX, touchStartY); + } + + if (specterHandleIsTouched || specterIsTouched) { + $el.find('.color-picker-sb-spectrum-handle').addClass('color-picker-sb-spectrum-handle-pressed'); + } + } + + function handleTouchMove(e) { + if (!(wheelIsTouched || wheelHandleIsTouched) && !(specterIsTouched || specterHandleIsTouched)) return; + touchCurrentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; + touchCurrentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; + e.preventDefault(); + + if (!isMoved) { + // First move + isMoved = true; + + if (wheelHandleIsTouched) { + wheelRect = $el.find('.color-picker-wheel')[0].getBoundingClientRect(); + } + + if (specterHandleIsTouched) { + specterRect = $el.find('.color-picker-sb-spectrum')[0].getBoundingClientRect(); + } + } + + if (wheelIsTouched || wheelHandleIsTouched) { + setHueFromWheelCoords(touchCurrentX, touchCurrentY); + } + + if (specterIsTouched || specterHandleIsTouched) { + setSBFromSpecterCoords(touchCurrentX, touchCurrentY); + } + } + + function handleTouchEnd() { + isMoved = false; + + if (specterIsTouched || specterHandleIsTouched) { + $el.find('.color-picker-sb-spectrum-handle').removeClass('color-picker-sb-spectrum-handle-pressed'); + } + + wheelIsTouched = false; + wheelHandleIsTouched = false; + specterIsTouched = false; + specterHandleIsTouched = false; + } + + function handleResize() { + self.modules.wheel.update(self); + } + + var passiveListener = app.touchEvents.start === 'touchstart' && (0, _getSupport.getSupport)().passiveListener ? { + passive: true, + capture: false + } : false; + self.$el.on(app.touchEvents.start, handleTouchStart, passiveListener); + app.on('touchmove:active', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + app.on('resize', handleResize); + + self.destroyWheelEvents = function destroyWheelEvents() { + self.$el.off(app.touchEvents.start, handleTouchStart, passiveListener); + app.off('touchmove:active', handleTouchMove); + app.off('touchend:passive', handleTouchEnd); + app.off('resize', handleResize); + }; + }, + update: function update(self) { + var value = self.value; + var hsl = value.hsl, + hsb = value.hsb; + var specterWidth = self.$el.find('.color-picker-sb-spectrum')[0].offsetWidth; + var specterHeight = self.$el.find('.color-picker-sb-spectrum')[0].offsetHeight; + var wheelSize = self.$el.find('.color-picker-wheel')[0].offsetWidth; + var wheelHalfSize = wheelSize / 2; + var angleRad = value.hue * Math.PI / 180; + var handleSize = wheelSize / 6; + var handleHalfSize = handleSize / 2; + var tX = wheelHalfSize - Math.sin(angleRad) * (wheelHalfSize - handleHalfSize) - handleHalfSize; + var tY = wheelHalfSize - Math.cos(angleRad) * (wheelHalfSize - handleHalfSize) - handleHalfSize; + self.$el.find('.color-picker-wheel-handle').css('background-color', "hsl(" + hsl[0] + ", 100%, 50%)").transform("translate(" + tX + "px, " + tY + "px)"); + self.$el.find('.color-picker-sb-spectrum').css('background-color', "hsl(" + hsl[0] + ", 100%, 50%)"); + self.$el.find('.color-picker-sb-spectrum-handle').css('background-color', "hsl(" + hsl[0] + ", " + hsl[1] * 100 + "%, " + hsl[2] * 100 + "%)").transform("translate(" + specterWidth * hsb[1] + "px, " + specterHeight * (1 - hsb[2]) + "px)"); + }, + destroy: function destroy(self) { + if (self.destroyWheelEvents) self.destroyWheelEvents(); + delete self.destroyWheelEvents; + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/contacts-list/contacts-list.js b/www/assets/framework7/cjs/components/contacts-list/contacts-list.js new file mode 100644 index 000000000..bcb0fa509 --- /dev/null +++ b/www/assets/framework7/cjs/components/contacts-list/contacts-list.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _default = { + name: 'contactsList' +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/data-table/data-table-class.js b/www/assets/framework7/cjs/components/data-table/data-table-class.js new file mode 100644 index 000000000..3d9ad8b92 --- /dev/null +++ b/www/assets/framework7/cjs/components/data-table/data-table-class.js @@ -0,0 +1,188 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var DataTable = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(DataTable, _Framework7Class); + + function DataTable(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params, [app]) || this; + + var table = _assertThisInitialized(_this); + + var defaults = {}; // Extend defaults with modules params + + table.useModulesParams(defaults); + table.params = (0, _utils.extend)(defaults, params); // El + + var $el = (0, _dom.default)(table.params.el); + if ($el.length === 0) return undefined || _assertThisInitialized(_this); + table.$el = $el; + table.el = $el[0]; + + if (table.$el[0].f7DataTable) { + var instance = table.$el[0].f7DataTable; + table.destroy(); + return instance || _assertThisInitialized(_this); + } + + table.$el[0].f7DataTable = table; + (0, _utils.extend)(table, { + collapsible: $el.hasClass('data-table-collapsible'), + // Headers + $headerEl: $el.find('.data-table-header'), + $headerSelectedEl: $el.find('.data-table-header-selected') + }); // Events + + function handleChange(e) { + if (e.detail && e.detail.sentByF7DataTable) { + // Scripted event, don't do anything + return; + } + + var $inputEl = (0, _dom.default)(this); + var checked = $inputEl[0].checked; + var columnIndex = $inputEl.parents('td,th').index(); + + if ($inputEl.parents('thead').length > 0) { + if (columnIndex === 0) { + $el.find('tbody tr')[checked ? 'addClass' : 'removeClass']('data-table-row-selected'); + } + + $el.find("tbody tr td:nth-child(" + (columnIndex + 1) + ") input").prop('checked', checked).trigger('change', { + sentByF7DataTable: true + }); + $inputEl.prop('indeterminate', false); + } else { + if (columnIndex === 0) { + $inputEl.parents('tr')[checked ? 'addClass' : 'removeClass']('data-table-row-selected'); + } + + var checkedRows = $el.find("tbody .checkbox-cell:nth-child(" + (columnIndex + 1) + ") input[type=\"checkbox\"]:checked").length; + var totalRows = $el.find('tbody tr').length; + var $headCheckboxEl = $el.find("thead .checkbox-cell:nth-child(" + (columnIndex + 1) + ") input[type=\"checkbox\"]"); + + if (!checked) { + $headCheckboxEl.prop('checked', false); + } else if (checkedRows === totalRows) { + $headCheckboxEl.prop('checked', true).trigger('change', { + sentByF7DataTable: true + }); + } + + $headCheckboxEl.prop('indeterminate', checkedRows > 0 && checkedRows < totalRows); + } + + table.checkSelectedHeader(); + } + + function handleSortableClick() { + var $cellEl = (0, _dom.default)(this); + var isActive = $cellEl.hasClass('sortable-cell-active'); + var currentSort = $cellEl.hasClass('sortable-desc') ? 'desc' : 'asc'; + var newSort; + + if (isActive) { + newSort = currentSort === 'desc' ? 'asc' : 'desc'; + $cellEl.removeClass('sortable-desc sortable-asc').addClass("sortable-" + newSort); + } else { + $el.find('thead .sortable-cell-active').removeClass('sortable-cell-active'); + $cellEl.addClass('sortable-cell-active'); + newSort = currentSort; + } + + $cellEl.trigger('datatable:sort', newSort); + table.emit('local::sort dataTableSort', table, newSort); + } + + table.attachEvents = function attachEvents() { + table.$el.on('change', '.checkbox-cell input[type="checkbox"]', handleChange); + table.$el.find('thead .sortable-cell').on('click', handleSortableClick); + }; + + table.detachEvents = function detachEvents() { + table.$el.off('change', '.checkbox-cell input[type="checkbox"]', handleChange); + table.$el.find('thead .sortable-cell').off('click', handleSortableClick); + }; // Install Modules + + + table.useModules(); // Init + + table.init(); + return table || _assertThisInitialized(_this); + } + + var _proto = DataTable.prototype; + + _proto.setCollapsibleLabels = function setCollapsibleLabels() { + var table = this; + if (!table.collapsible) return; + table.$el.find('tbody td:not(.checkbox-cell)').each(function (el) { + var $el = (0, _dom.default)(el); + var elIndex = $el.index(); + var collpsibleTitle = $el.attr('data-collapsible-title'); + + if (!collpsibleTitle && collpsibleTitle !== '') { + $el.attr('data-collapsible-title', table.$el.find('thead th').eq(elIndex).text()); + } + }); + }; + + _proto.checkSelectedHeader = function checkSelectedHeader() { + var table = this; + + if (table.$headerEl.length > 0 && table.$headerSelectedEl.length > 0) { + var checkedItems = table.$el.find('tbody .checkbox-cell input:checked').length; + table.$el[checkedItems > 0 ? 'addClass' : 'removeClass']('data-table-has-checked'); + table.$headerSelectedEl.find('.data-table-selected-count').text(checkedItems); + } + }; + + _proto.init = function init() { + var table = this; + table.attachEvents(); + table.setCollapsibleLabels(); + table.checkSelectedHeader(); + }; + + _proto.destroy = function destroy() { + var table = this; + table.$el.trigger('datatable:beforedestroy'); + table.emit('local::beforeDestroy dataTableBeforeDestroy', table); + table.attachEvents(); + + if (table.$el[0]) { + table.$el[0].f7DataTable = null; + delete table.$el[0].f7DataTable; + } + + (0, _utils.deleteProps)(table); + table = null; + }; + + return DataTable; +}(_class.default); + +var _default = DataTable; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/data-table/data-table.js b/www/assets/framework7/cjs/components/data-table/data-table.js new file mode 100644 index 000000000..f8ec93c48 --- /dev/null +++ b/www/assets/framework7/cjs/components/data-table/data-table.js @@ -0,0 +1,75 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _dataTableClass = _interopRequireDefault(require("./data-table-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'dataTable', + static: { + DataTable: _dataTableClass.default + }, + create: function create() { + var app = this; + app.dataTable = (0, _constructorMethods.default)({ + defaultSelector: '.data-table', + constructor: _dataTableClass.default, + app: app, + domProp: 'f7DataTable' + }); + }, + on: { + tabBeforeRemove: function tabBeforeRemove(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.data-table-init').each(function (tableEl) { + app.dataTable.destroy(tableEl); + }); + }, + tabMounted: function tabMounted(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.data-table-init').each(function (tableEl) { + app.dataTable.create({ + el: tableEl + }); + }); + }, + pageBeforeRemove: function pageBeforeRemove(page) { + var app = this; + page.$el.find('.data-table-init').each(function (tableEl) { + app.dataTable.destroy(tableEl); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.data-table-init').each(function (tableEl) { + app.dataTable.create({ + el: tableEl + }); + }); + } + }, + vnode: { + 'data-table-init': { + insert: function insert(vnode) { + var app = this; + var tableEl = vnode.elm; + app.dataTable.create({ + el: tableEl + }); + }, + destroy: function destroy(vnode) { + var app = this; + var tableEl = vnode.elm; + app.dataTable.destroy(tableEl); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/dialog/dialog-class.js b/www/assets/framework7/cjs/components/dialog/dialog-class.js new file mode 100644 index 000000000..9128dae28 --- /dev/null +++ b/www/assets/framework7/cjs/components/dialog/dialog-class.js @@ -0,0 +1,250 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _getDevice = require("../../shared/get-device"); + +var _modalClass = _interopRequireDefault(require("../modal/modal-class")); + +var _$jsx = _interopRequireDefault(require("../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Dialog = /*#__PURE__*/function (_Modal) { + _inheritsLoose(Dialog, _Modal); + + function Dialog(app, params) { + var _this; + + var extendedParams = (0, _utils.extend)({ + title: app.params.dialog.title, + text: undefined, + content: '', + buttons: [], + verticalButtons: false, + onClick: undefined, + cssClass: undefined, + destroyOnClose: false, + on: {} + }, params); + + if (typeof extendedParams.closeByBackdropClick === 'undefined') { + extendedParams.closeByBackdropClick = app.params.dialog.closeByBackdropClick; + } + + if (typeof extendedParams.backdrop === 'undefined') { + extendedParams.backdrop = app.params.dialog.backdrop; + } // Extends with open/close Modal methods; + + + _this = _Modal.call(this, app, extendedParams) || this; + + var dialog = _assertThisInitialized(_this); + + var device = (0, _getDevice.getDevice)(); + var document = (0, _ssrWindow.getDocument)(); + var title = extendedParams.title, + text = extendedParams.text, + content = extendedParams.content, + buttons = extendedParams.buttons, + verticalButtons = extendedParams.verticalButtons, + cssClass = extendedParams.cssClass, + backdrop = extendedParams.backdrop; + dialog.params = extendedParams; // Find Element + + var $el; + + if (!dialog.params.el) { + var dialogClasses = ['dialog']; + if (buttons.length === 0) dialogClasses.push('dialog-no-buttons'); + if (buttons.length > 0) dialogClasses.push("dialog-buttons-" + buttons.length); + if (verticalButtons) dialogClasses.push('dialog-buttons-vertical'); + if (cssClass) dialogClasses.push(cssClass); + var buttonsHTML = ''; + + if (buttons.length > 0) { + buttonsHTML = (0, _$jsx.default)("div", { + class: "dialog-buttons" + }, buttons.map(function (button) { + return (0, _$jsx.default)("span", { + class: "dialog-button" + (button.bold ? ' dialog-button-bold' : '') + (button.color ? " color-" + button.color : '') + (button.cssClass ? " " + button.cssClass : '') + }, button.text); + })); + } + + var dialogHtml = (0, _$jsx.default)("div", { + class: dialogClasses.join(' ') + }, (0, _$jsx.default)("div", { + class: "dialog-inner" + }, title && (0, _$jsx.default)("div", { + class: "dialog-title" + }, title), text && (0, _$jsx.default)("div", { + class: "dialog-text" + }, text), content), buttonsHTML); + $el = (0, _dom.default)(dialogHtml); + } else { + $el = (0, _dom.default)(dialog.params.el); + } + + if ($el && $el.length > 0 && $el[0].f7Modal) { + return $el[0].f7Modal || _assertThisInitialized(_this); + } + + if ($el.length === 0) { + return dialog.destroy() || _assertThisInitialized(_this); + } + + var $backdropEl; + + if (backdrop) { + $backdropEl = app.$el.children('.dialog-backdrop'); + + if ($backdropEl.length === 0) { + $backdropEl = (0, _dom.default)('
    '); + app.$el.append($backdropEl); + } + } // Assign events + + + function buttonOnClick(e) { + var buttonEl = this; + var index = (0, _dom.default)(buttonEl).index(); + var button = buttons[index]; + if (button.onClick) button.onClick(dialog, e); + if (dialog.params.onClick) dialog.params.onClick(dialog, index); + if (button.close !== false) dialog.close(); + } + + var addKeyboardHander; + + function onKeyDown(e) { + var keyCode = e.keyCode; + buttons.forEach(function (button, index) { + if (button.keyCodes && button.keyCodes.indexOf(keyCode) >= 0) { + if (document.activeElement) document.activeElement.blur(); + if (button.onClick) button.onClick(dialog, e); + if (dialog.params.onClick) dialog.params.onClick(dialog, index); + if (button.close !== false) dialog.close(); + } + }); + } + + if (buttons && buttons.length > 0) { + dialog.on('open', function () { + $el.find('.dialog-button').each(function (buttonEl, index) { + var button = buttons[index]; + if (button.keyCodes) addKeyboardHander = true; + (0, _dom.default)(buttonEl).on('click', buttonOnClick); + }); + + if (addKeyboardHander && !device.ios && !device.android && !device.cordova && !device.capacitor) { + (0, _dom.default)(document).on('keydown', onKeyDown); + } + }); + dialog.on('close', function () { + $el.find('.dialog-button').each(function (buttonEl) { + (0, _dom.default)(buttonEl).off('click', buttonOnClick); + }); + + if (addKeyboardHander && !device.ios && !device.android && !device.cordova && !device.capacitor) { + (0, _dom.default)(document).off('keydown', onKeyDown); + } + + addKeyboardHander = false; + }); + } + + (0, _utils.extend)(dialog, { + app: app, + $el: $el, + el: $el[0], + $backdropEl: $backdropEl, + backdropEl: $backdropEl && $backdropEl[0], + type: 'dialog', + setProgress: function setProgress(progress, duration) { + app.progressbar.set($el.find('.progressbar'), progress, duration); + return dialog; + }, + setText: function setText(newText) { + var $textEl = $el.find('.dialog-text'); + + if ($textEl.length === 0) { + $textEl = (0, _dom.default)('
    '); + + if (typeof title !== 'undefined') { + $textEl.insertAfter($el.find('.dialog-title')); + } else { + $el.find('.dialog-inner').prepend($textEl); + } + } + + $textEl.html(newText); + dialog.params.text = newText; + return dialog; + }, + setTitle: function setTitle(newTitle) { + var $titleEl = $el.find('.dialog-title'); + + if ($titleEl.length === 0) { + $titleEl = (0, _dom.default)('
    '); + $el.find('.dialog-inner').prepend($titleEl); + } + + $titleEl.html(newTitle); + dialog.params.title = newTitle; + return dialog; + } + }); + + function handleClick(e) { + var target = e.target; + var $target = (0, _dom.default)(target); + + if ($target.closest(dialog.el).length === 0) { + if (dialog.params.closeByBackdropClick && dialog.backdropEl && dialog.backdropEl === target) { + dialog.close(); + } + } + } + + dialog.on('opened', function () { + if (dialog.params.closeByBackdropClick) { + app.on('click', handleClick); + } + }); + dialog.on('close', function () { + if (dialog.params.closeByBackdropClick) { + app.off('click', handleClick); + } + }); + $el[0].f7Modal = dialog; + + if (dialog.params.destroyOnClose) { + dialog.once('closed', function () { + setTimeout(function () { + dialog.destroy(); + }, 0); + }); + } + + return dialog || _assertThisInitialized(_this); + } + + return Dialog; +}(_modalClass.default); + +var _default = Dialog; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/dialog/dialog.js b/www/assets/framework7/cjs/components/dialog/dialog.js new file mode 100644 index 000000000..3605b5e74 --- /dev/null +++ b/www/assets/framework7/cjs/components/dialog/dialog.js @@ -0,0 +1,297 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _utils = require("../../shared/utils"); + +var _dialogClass = _interopRequireDefault(require("./dialog-class")); + +var _modalMethods = _interopRequireDefault(require("../../shared/modal-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +var _default = { + name: 'dialog', + params: { + dialog: { + title: undefined, + buttonOk: 'OK', + buttonCancel: 'Cancel', + usernamePlaceholder: 'Username', + passwordPlaceholder: 'Password', + preloaderTitle: 'Loading... ', + progressTitle: 'Loading... ', + backdrop: true, + closeByBackdropClick: false, + destroyPredefinedDialogs: true, + keyboardActions: true, + autoFocus: true + } + }, + static: { + Dialog: _dialogClass.default + }, + create: function create() { + var app = this; + + function defaultDialogTitle() { + return app.params.dialog.title || app.name; + } + + var destroyOnClose = app.params.dialog.destroyPredefinedDialogs; + var keyboardActions = app.params.dialog.keyboardActions; + var autoFocus = app.params.dialog.autoFocus; + var autoFocusHandler = autoFocus ? { + on: { + opened: function opened(dialog) { + dialog.$el.find('input').eq(0).focus(); + } + } + } : {}; + app.dialog = (0, _utils.extend)((0, _modalMethods.default)({ + app: app, + constructor: _dialogClass.default, + defaultSelector: '.dialog.modal-in' + }), { + // Shortcuts + alert: function alert() { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var text = args[0], + title = args[1], + callbackOk = args[2]; + + if (args.length === 2 && typeof args[1] === 'function') { + text = args[0]; + callbackOk = args[1]; + title = args[2]; + } + + return new _dialogClass.default(app, { + title: typeof title === 'undefined' ? defaultDialogTitle() : title, + text: text, + buttons: [{ + text: app.params.dialog.buttonOk, + bold: true, + onClick: callbackOk, + keyCodes: keyboardActions ? [13, 27] : null + }], + destroyOnClose: destroyOnClose + }).open(); + }, + prompt: function prompt() { + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var text = args[0], + title = args[1], + callbackOk = args[2], + callbackCancel = args[3], + defaultValue = args[4]; + + if (typeof args[1] === 'function') { + text = args[0]; + callbackOk = args[1]; + callbackCancel = args[2]; + defaultValue = args[3]; + title = args[4]; + } + + defaultValue = typeof defaultValue === 'undefined' || defaultValue === null ? '' : defaultValue; + return new _dialogClass.default(app, _extends({ + title: typeof title === 'undefined' ? defaultDialogTitle() : title, + text: text, + content: "
    ", + buttons: [{ + text: app.params.dialog.buttonCancel, + keyCodes: keyboardActions ? [27] : null, + color: app.theme === 'aurora' ? 'gray' : null + }, { + text: app.params.dialog.buttonOk, + bold: true, + keyCodes: keyboardActions ? [13] : null + }], + onClick: function onClick(dialog, index) { + var inputValue = dialog.$el.find('.dialog-input').val(); + if (index === 0 && callbackCancel) callbackCancel(inputValue); + if (index === 1 && callbackOk) callbackOk(inputValue); + }, + destroyOnClose: destroyOnClose + }, autoFocusHandler)).open(); + }, + confirm: function confirm() { + for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + var text = args[0], + title = args[1], + callbackOk = args[2], + callbackCancel = args[3]; + + if (typeof args[1] === 'function') { + text = args[0]; + callbackOk = args[1]; + callbackCancel = args[2]; + title = args[3]; + } + + return new _dialogClass.default(app, { + title: typeof title === 'undefined' ? defaultDialogTitle() : title, + text: text, + buttons: [{ + text: app.params.dialog.buttonCancel, + onClick: callbackCancel, + keyCodes: keyboardActions ? [27] : null, + color: app.theme === 'aurora' ? 'gray' : null + }, { + text: app.params.dialog.buttonOk, + bold: true, + onClick: callbackOk, + keyCodes: keyboardActions ? [13] : null + }], + destroyOnClose: destroyOnClose + }).open(); + }, + login: function login() { + for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + args[_key4] = arguments[_key4]; + } + + var text = args[0], + title = args[1], + callbackOk = args[2], + callbackCancel = args[3]; + + if (typeof args[1] === 'function') { + text = args[0]; + callbackOk = args[1]; + callbackCancel = args[2]; + title = args[3]; + } + + return new _dialogClass.default(app, _extends({ + title: typeof title === 'undefined' ? defaultDialogTitle() : title, + text: text, + // prettier-ignore + content: "\n
    \n \n
    \n
    \n \n
    ", + buttons: [{ + text: app.params.dialog.buttonCancel, + keyCodes: keyboardActions ? [27] : null, + color: app.theme === 'aurora' ? 'gray' : null + }, { + text: app.params.dialog.buttonOk, + bold: true, + keyCodes: keyboardActions ? [13] : null + }], + onClick: function onClick(dialog, index) { + var username = dialog.$el.find('[name="dialog-username"]').val(); + var password = dialog.$el.find('[name="dialog-password"]').val(); + if (index === 0 && callbackCancel) callbackCancel(username, password); + if (index === 1 && callbackOk) callbackOk(username, password); + }, + destroyOnClose: destroyOnClose + }, autoFocusHandler)).open(); + }, + password: function password() { + for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { + args[_key5] = arguments[_key5]; + } + + var text = args[0], + title = args[1], + callbackOk = args[2], + callbackCancel = args[3]; + + if (typeof args[1] === 'function') { + text = args[0]; + callbackOk = args[1]; + callbackCancel = args[2]; + title = args[3]; + } + + return new _dialogClass.default(app, _extends({ + title: typeof title === 'undefined' ? defaultDialogTitle() : title, + text: text, + // prettier-ignore + content: "\n
    \n \n
    ", + buttons: [{ + text: app.params.dialog.buttonCancel, + keyCodes: keyboardActions ? [27] : null, + color: app.theme === 'aurora' ? 'gray' : null + }, { + text: app.params.dialog.buttonOk, + bold: true, + keyCodes: keyboardActions ? [13] : null + }], + onClick: function onClick(dialog, index) { + var password = dialog.$el.find('[name="dialog-password"]').val(); + if (index === 0 && callbackCancel) callbackCancel(password); + if (index === 1 && callbackOk) callbackOk(password); + }, + destroyOnClose: destroyOnClose + }, autoFocusHandler)).open(); + }, + preloader: function preloader(title, color) { + var preloaders = { + iosPreloaderContent: _utils.iosPreloaderContent, + mdPreloaderContent: _utils.mdPreloaderContent, + auroraPreloaderContent: _utils.auroraPreloaderContent + }; + var preloaderInner = preloaders[app.theme + "PreloaderContent"] || ''; + return new _dialogClass.default(app, { + title: typeof title === 'undefined' || title === null ? app.params.dialog.preloaderTitle : title, + // prettier-ignore + content: "
    " + preloaderInner + "
    ", + cssClass: 'dialog-preloader', + destroyOnClose: destroyOnClose + }).open(); + }, + progress: function progress() { + for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { + args[_key6] = arguments[_key6]; + } + + var title = args[0], + progress = args[1], + color = args[2]; + + if (args.length === 2) { + if (typeof args[0] === 'number') { + progress = args[0]; + color = args[1]; + title = args[2]; + } else if (typeof args[0] === 'string' && typeof args[1] === 'string') { + title = args[0]; + color = args[1]; + progress = args[2]; + } + } else if (args.length === 1) { + if (typeof args[0] === 'number') { + progress = args[0]; + title = args[1]; + color = args[2]; + } + } + + var infinite = typeof progress === 'undefined'; + var dialog = new _dialogClass.default(app, { + title: typeof title === 'undefined' ? app.params.dialog.progressTitle : title, + cssClass: 'dialog-progress', + // prettier-ignore + content: "\n
    \n " + (!infinite ? '' : '') + "\n
    \n ", + destroyOnClose: destroyOnClose + }); + if (!infinite) dialog.setProgress(progress); + return dialog.open(); + } + }); + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/elevation/elevation.js b/www/assets/framework7/cjs/components/elevation/elevation.js new file mode 100644 index 000000000..20953195d --- /dev/null +++ b/www/assets/framework7/cjs/components/elevation/elevation.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _default = { + name: 'elevation' +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/fab/fab.js b/www/assets/framework7/cjs/components/fab/fab.js new file mode 100644 index 000000000..158dbb456 --- /dev/null +++ b/www/assets/framework7/cjs/components/fab/fab.js @@ -0,0 +1,195 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +var Fab = { + morphOpen: function morphOpen(fabEl, targetEl) { + var app = this; + var $fabEl = (0, _dom.default)(fabEl); + var $targetEl = (0, _dom.default)(targetEl); + if ($targetEl.length === 0) return; + $targetEl.transition(0).addClass('fab-morph-target-visible'); + var target = { + width: $targetEl[0].offsetWidth, + height: $targetEl[0].offsetHeight, + offset: $targetEl.offset(), + borderRadius: $targetEl.css('border-radius'), + zIndex: $targetEl.css('z-index') + }; + var fab = { + width: $fabEl[0].offsetWidth, + height: $fabEl[0].offsetHeight, + offset: $fabEl.offset(), + translateX: (0, _utils.getTranslate)($fabEl[0], 'x'), + translateY: (0, _utils.getTranslate)($fabEl[0], 'y') + }; + $fabEl[0].f7FabMorphData = { + $targetEl: $targetEl, + target: target, + fab: fab + }; + var diffX = fab.offset.left + fab.width / 2 - (target.offset.left + target.width / 2) - fab.translateX; + var diffY = fab.offset.top + fab.height / 2 - (target.offset.top + target.height / 2) - fab.translateY; + var scaleX = target.width / fab.width; + var scaleY = target.height / fab.height; + var borderRadius = Math.ceil(parseInt(target.borderRadius, 10) / Math.max(scaleX, scaleY)); + if (borderRadius > 0) borderRadius += 2; + + $fabEl[0].f7FabMorphResizeHandler = function resizeHandler() { + $fabEl.transition(0).transform(''); + $targetEl.transition(0); + target.width = $targetEl[0].offsetWidth; + target.height = $targetEl[0].offsetHeight; + target.offset = $targetEl.offset(); + fab.offset = $fabEl.offset(); + var diffXNew = fab.offset.left + fab.width / 2 - (target.offset.left + target.width / 2) - fab.translateX; + var diffYNew = fab.offset.top + fab.height / 2 - (target.offset.top + target.height / 2) - fab.translateY; + var scaleXNew = target.width / fab.width; + var scaleYNew = target.height / fab.height; + $fabEl.transform("translate3d(" + -diffXNew + "px, " + -diffYNew + "px, 0) scale(" + scaleXNew + ", " + scaleYNew + ")"); + }; + + $targetEl.css('opacity', 0).transform("scale(" + 1 / scaleX + ", " + 1 / scaleY + ")"); + $fabEl.addClass('fab-opened').css('z-index', target.zIndex - 1).transform("translate3d(" + -diffX + "px, " + -diffY + "px, 0)"); + $fabEl.transitionEnd(function () { + $targetEl.transition(''); + (0, _utils.nextFrame)(function () { + $targetEl.css('opacity', 1).transform('scale(1,1)'); + $fabEl.transform("translate3d(" + -diffX + "px, " + -diffY + "px, 0) scale(" + scaleX + ", " + scaleY + ")").css('border-radius', borderRadius + "px").css('box-shadow', 'none').css('opacity', '0'); + }); + app.on('resize', $fabEl[0].f7FabMorphResizeHandler); + + if ($targetEl.parents('.page-content').length > 0) { + $targetEl.parents('.page-content').on('scroll', $fabEl[0].f7FabMorphResizeHandler); + } + }); + }, + morphClose: function morphClose(fabEl) { + var app = this; + var $fabEl = (0, _dom.default)(fabEl); + var morphData = $fabEl[0].f7FabMorphData; + if (!morphData) return; + var $targetEl = morphData.$targetEl, + target = morphData.target, + fab = morphData.fab; + if ($targetEl.length === 0) return; + var diffX = fab.offset.left + fab.width / 2 - (target.offset.left + target.width / 2) - fab.translateX; + var diffY = fab.offset.top + fab.height / 2 - (target.offset.top + target.height / 2) - fab.translateY; + var scaleX = target.width / fab.width; + var scaleY = target.height / fab.height; + app.off('resize', $fabEl[0].f7FabMorphResizeHandler); + + if ($targetEl.parents('.page-content').length > 0) { + $targetEl.parents('.page-content').off('scroll', $fabEl[0].f7FabMorphResizeHandler); + } + + $targetEl.css('opacity', 0).transform("scale(" + 1 / scaleX + ", " + 1 / scaleY + ")"); + $fabEl.transition('').css('box-shadow', '').css('border-radius', '').css('opacity', '1').transform("translate3d(" + -diffX + "px, " + -diffY + "px, 0)"); + $fabEl.transitionEnd(function () { + $fabEl.css('z-index', '').removeClass('fab-opened').transform(''); + (0, _utils.nextFrame)(function () { + $fabEl.transitionEnd(function () { + $targetEl.removeClass('fab-morph-target-visible').css('opacity', '').transform('').transition(''); + }); + }); + }); + }, + open: function open(fabEl, targetEl) { + var app = this; + var $fabEl = (0, _dom.default)(fabEl).eq(0); + var $buttonsEl = $fabEl.find('.fab-buttons'); + if (!$fabEl.length) return; + if ($fabEl.hasClass('fab-opened')) return; + if (!$buttonsEl.length && !$fabEl.hasClass('fab-morph')) return; + + if (app.fab.openedEl) { + if (app.fab.openedEl === $fabEl[0]) return; + app.fab.close(app.fab.openedEl); + } + + app.fab.openedEl = $fabEl[0]; + + if ($fabEl.hasClass('fab-morph')) { + app.fab.morphOpen($fabEl, targetEl || $fabEl.attr('data-morph-to')); + } else { + $fabEl.addClass('fab-opened'); + } + + $fabEl.siblings('.fab-backdrop').addClass('backdrop-in'); + $fabEl.trigger('fab:open'); + }, + close: function close(fabEl) { + if (fabEl === void 0) { + fabEl = '.fab-opened'; + } + + var app = this; + var $fabEl = (0, _dom.default)(fabEl).eq(0); + var $buttonsEl = $fabEl.find('.fab-buttons'); + if (!$fabEl.length) return; + if (!$fabEl.hasClass('fab-opened')) return; + if (!$buttonsEl.length && !$fabEl.hasClass('fab-morph')) return; + app.fab.openedEl = null; + + if ($fabEl.hasClass('fab-morph')) { + app.fab.morphClose($fabEl); + } else { + $fabEl.removeClass('fab-opened'); + } + + $fabEl.siblings('.fab-backdrop').removeClass('backdrop-in'); + $fabEl.trigger('fab:close'); + }, + toggle: function toggle(fabEl) { + var app = this; + var $fabEl = (0, _dom.default)(fabEl); + if (!$fabEl.hasClass('fab-opened')) app.fab.open(fabEl);else app.fab.close(fabEl); + } +}; +var _default = { + name: 'fab', + create: function create() { + var app = this; + (0, _utils.bindMethods)(app, { + fab: _extends({ + openedEl: null + }, Fab) + }); + }, + clicks: { + '.fab > a': function open($clickedEl) { + var app = this; + app.fab.toggle($clickedEl.parents('.fab')); + }, + '.fab-open': function open($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.fab.open(data.fab); + }, + '.fab-close': function close($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.fab.close(data.fab); + }, + '.fab-backdrop': function close() { + var app = this; + app.fab.close(); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/form/form.js b/www/assets/framework7/cjs/components/form/form.js new file mode 100644 index 000000000..c12b49fa7 --- /dev/null +++ b/www/assets/framework7/cjs/components/form/form.js @@ -0,0 +1,341 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Form Data +var FormData = { + store: function store(form, data) { + var app = this; + var window = (0, _ssrWindow.getWindow)(); + var formId = form; + var $formEl = (0, _dom.default)(form); + + if ($formEl.length && $formEl.is('form') && $formEl.attr('id')) { + formId = $formEl.attr('id'); + } // Store form data in app.formsData + + + app.form.data["form-" + formId] = data; // Store form data in local storage also + + window.localStorage["f7form-" + formId] = JSON.stringify(data); + }, + get: function get(form) { + var app = this; + var window = (0, _ssrWindow.getWindow)(); + var formId = form; + var $formEl = (0, _dom.default)(form); + + if ($formEl.length && $formEl.is('form') && $formEl.attr('id')) { + formId = $formEl.attr('id'); + } + + if (window.localStorage["f7form-" + formId]) { + return JSON.parse(window.localStorage["f7form-" + formId]); + } + + if (app.form.data["form-" + formId]) { + return app.form.data["form-" + formId]; + } + + return undefined; + }, + remove: function remove(form) { + var app = this; + var window = (0, _ssrWindow.getWindow)(); + var formId = form; + var $formEl = (0, _dom.default)(form); + + if ($formEl.length && $formEl.is('form') && $formEl.attr('id')) { + formId = $formEl.attr('id'); + } // Delete form data from app.formsData + + + if (app.form.data["form-" + formId]) { + app.form.data["form-" + formId] = ''; + delete app.form.data["form-" + formId]; + } // Delete form data from local storage also + + + if (window.localStorage["f7form-" + formId]) { + window.localStorage["f7form-" + formId] = ''; + window.localStorage.removeItem("f7form-" + formId); + } + } +}; // Form Storage + +var FormStorage = { + init: function init(formEl) { + var app = this; + var $formEl = (0, _dom.default)(formEl); + var formId = $formEl.attr('id'); + if (!formId) return; + var initialData = app.form.getFormData(formId); + + if (initialData) { + app.form.fillFromData($formEl, initialData); + } + + function store() { + var data = app.form.convertToData($formEl); + if (!data) return; + app.form.storeFormData(formId, data); + $formEl.trigger('form:storedata', data); + app.emit('formStoreData', $formEl[0], data); + } + + $formEl.on('change submit', store); + }, + destroy: function destroy(formEl) { + var $formEl = (0, _dom.default)(formEl); + $formEl.off('change submit'); + } +}; // Form To/From Data + +function formToData(formEl) { + var app = this; + var $formEl = (0, _dom.default)(formEl).eq(0); + if ($formEl.length === 0) return undefined; // Form data + + var data = {}; // Skip input types + + var skipTypes = ['submit', 'image', 'button', 'file']; + var skipNames = []; + $formEl.find('input, select, textarea').each(function (inputEl) { + var $inputEl = (0, _dom.default)(inputEl); + + if ($inputEl.hasClass('ignore-store-data') || $inputEl.hasClass('no-store-data')) { + return; + } + + var name = $inputEl.attr('name'); + var type = $inputEl.attr('type'); + var tag = inputEl.nodeName.toLowerCase(); + if (skipTypes.indexOf(type) >= 0) return; + if (skipNames.indexOf(name) >= 0 || !name) return; + + if (tag === 'select' && $inputEl.prop('multiple')) { + skipNames.push(name); + data[name] = []; + $formEl.find("select[name=\"" + name + "\"] option").each(function (el) { + if (el.selected) data[name].push(el.value); + }); + } else { + switch (type) { + case 'checkbox': + skipNames.push(name); + data[name] = []; + $formEl.find("input[name=\"" + name + "\"]").each(function (el) { + if (el.checked) data[name].push(el.value); + }); + break; + + case 'radio': + skipNames.push(name); + $formEl.find("input[name=\"" + name + "\"]").each(function (el) { + if (el.checked) data[name] = el.value; + }); + break; + + default: + data[name] = $inputEl.val(); + break; + } + } + }); + $formEl.trigger('form:todata', data); + app.emit('formToData', $formEl[0], data); + return data; +} + +function formFromData(formEl, formData) { + var app = this; + var $formEl = (0, _dom.default)(formEl).eq(0); + if (!$formEl.length) return; + var data = formData; + var formId = $formEl.attr('id'); + + if (!data && formId) { + data = app.form.getFormData(formId); + } + + if (!data) return; // Skip input types + + var skipTypes = ['submit', 'image', 'button', 'file']; + var skipNames = []; + $formEl.find('input, select, textarea').each(function (inputEl) { + var $inputEl = (0, _dom.default)(inputEl); + + if ($inputEl.hasClass('ignore-store-data') || $inputEl.hasClass('no-store-data')) { + return; + } + + var name = $inputEl.attr('name'); + var type = $inputEl.attr('type'); + var tag = inputEl.nodeName.toLowerCase(); + if (typeof data[name] === 'undefined' || data[name] === null) return; + if (skipTypes.indexOf(type) >= 0) return; + if (skipNames.indexOf(name) >= 0 || !name) return; + + if (tag === 'select' && $inputEl.prop('multiple')) { + skipNames.push(name); + $formEl.find("select[name=\"" + name + "\"] option").each(function (el) { + var selectEl = el; + if (data[name].indexOf(el.value) >= 0) selectEl.selected = true;else selectEl.selected = false; + }); + } else { + switch (type) { + case 'checkbox': + skipNames.push(name); + $formEl.find("input[name=\"" + name + "\"]").each(function (el) { + var checkboxEl = el; + if (data[name].indexOf(el.value) >= 0) checkboxEl.checked = true;else checkboxEl.checked = false; + }); + break; + + case 'radio': + skipNames.push(name); + $formEl.find("input[name=\"" + name + "\"]").each(function (el) { + var radioEl = el; + if (data[name] === el.value) radioEl.checked = true;else radioEl.checked = false; + }); + break; + + default: + $inputEl.val(data[name]); + break; + } + } + + if (tag === 'select' || tag === 'input' || tag === 'textarea') { + $inputEl.trigger('change', 'fromdata'); + } + }); + $formEl.trigger('form:fromdata', data); + app.emit('formFromData', $formEl[0], data); +} + +function initAjaxForm() { + var app = this; + var window = (0, _ssrWindow.getWindow)(); + var document = (0, _ssrWindow.getDocument)(); + + function onSubmitChange(e, fromData) { + var $formEl = (0, _dom.default)(this); + if (e.type === 'change' && !$formEl.hasClass('form-ajax-submit-onchange')) return; + if (e.type === 'submit') e.preventDefault(); + if (e.type === 'change' && fromData === 'fromdata') return; + var method = ($formEl.attr('method') || 'GET').toUpperCase(); + var contentType = $formEl.prop('enctype') || $formEl.attr('enctype'); + var url = $formEl.attr('action'); + if (!url) return; + var data; + + if (method === 'POST') { + if (contentType === 'application/x-www-form-urlencoded') { + data = app.form.convertToData($formEl[0]); + } else { + data = new window.FormData($formEl[0]); + } + } else { + data = (0, _utils.serializeObject)(app.form.convertToData($formEl[0])); + } + + app.request({ + method: method, + url: url, + contentType: contentType, + data: data, + beforeSend: function beforeSend(xhr) { + $formEl.trigger('formajax:beforesend', { + data: data, + xhr: xhr + }); + app.emit('formAjaxBeforeSend', $formEl[0], data, xhr); + }, + error: function error(xhr) { + $formEl.trigger('formajax:error', { + data: data, + xhr: xhr + }); + app.emit('formAjaxError', $formEl[0], data, xhr); + }, + complete: function complete(xhr) { + $formEl.trigger('formajax:complete', { + data: data, + xhr: xhr + }); + app.emit('formAjaxComplete', $formEl[0], data, xhr); + }, + success: function success(response, status, xhr) { + $formEl.trigger('formajax:success', { + data: data, + xhr: xhr + }); + app.emit('formAjaxSuccess', $formEl[0], data, xhr); + } + }); + } + + (0, _dom.default)(document).on('submit change', 'form.form-ajax-submit, form.form-ajax-submit-onchange', onSubmitChange); +} + +var _default = { + name: 'form', + create: function create() { + var app = this; + (0, _utils.extend)(app, { + form: { + data: {}, + storeFormData: FormData.store.bind(app), + getFormData: FormData.get.bind(app), + removeFormData: FormData.remove.bind(app), + convertToData: formToData.bind(app), + fillFromData: formFromData.bind(app), + storage: { + init: FormStorage.init.bind(app), + destroy: FormStorage.destroy.bind(app) + } + } + }); + }, + on: { + init: function init() { + var app = this; + initAjaxForm.call(app); + }, + tabBeforeRemove: function tabBeforeRemove(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.form-store-data').each(function (formEl) { + app.form.storage.destroy(formEl); + }); + }, + tabMounted: function tabMounted(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.form-store-data').each(function (formEl) { + app.form.storage.init(formEl); + }); + }, + pageBeforeRemove: function pageBeforeRemove(page) { + var app = this; + page.$el.find('.form-store-data').each(function (formEl) { + app.form.storage.destroy(formEl); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.form-store-data').each(function (formEl) { + app.form.storage.init(formEl); + }); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/gauge/gauge-class.js b/www/assets/framework7/cjs/components/gauge/gauge-class.js new file mode 100644 index 000000000..e902c1734 --- /dev/null +++ b/www/assets/framework7/cjs/components/gauge/gauge-class.js @@ -0,0 +1,332 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _$jsx = _interopRequireDefault(require("../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Gauge = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(Gauge, _Framework7Class); + + function Gauge(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params, [app]) || this; + + var self = _assertThisInitialized(_this); + + var defaults = (0, _utils.extend)({}, app.params.gauge); // Extend defaults with modules params + + self.useModulesParams(defaults); + self.params = (0, _utils.extend)(defaults, params); + var el = self.params.el; + if (!el) return self || _assertThisInitialized(_this); + var $el = (0, _dom.default)(el); + if ($el.length === 0) return self || _assertThisInitialized(_this); + if ($el[0].f7Gauge) return $el[0].f7Gauge || _assertThisInitialized(_this); + (0, _utils.extend)(self, { + app: app, + $el: $el, + el: $el && $el[0] + }); + $el[0].f7Gauge = self; // Install Modules + + self.useModules(); + self.init(); + return self || _assertThisInitialized(_this); + } + + var _proto = Gauge.prototype; + + _proto.calcRadius = function calcRadius() { + var self = this; + var _self$params = self.params, + size = _self$params.size, + borderWidth = _self$params.borderWidth; + return size / 2 - borderWidth / 2; + }; + + _proto.calcBorderLength = function calcBorderLength() { + var self = this; + var radius = self.calcRadius(); + return 2 * Math.PI * radius; + }; + + _proto.render = function render() { + var self = this; + if (self.params.render) return self.params.render.call(self, self); + var _self$params2 = self.params, + type = _self$params2.type, + value = _self$params2.value, + size = _self$params2.size, + bgColor = _self$params2.bgColor, + borderBgColor = _self$params2.borderBgColor, + borderColor = _self$params2.borderColor, + borderWidth = _self$params2.borderWidth, + valueText = _self$params2.valueText, + valueTextColor = _self$params2.valueTextColor, + valueFontSize = _self$params2.valueFontSize, + valueFontWeight = _self$params2.valueFontWeight, + labelText = _self$params2.labelText, + labelTextColor = _self$params2.labelTextColor, + labelFontSize = _self$params2.labelFontSize, + labelFontWeight = _self$params2.labelFontWeight; + var semiCircle = type === 'semicircle'; + var radius = self.calcRadius(); + var length = self.calcBorderLength(); + var progress = Math.max(Math.min(value, 1), 0); + return (0, _$jsx.default)("svg", { + class: "gauge-svg", + width: size + "px", + height: (semiCircle ? size / 2 : size) + "px", + viewBox: "0 0 " + size + " " + (semiCircle ? size / 2 : size) + }, semiCircle && (0, _$jsx.default)("path", { + class: "gauge-back-semi", + d: "M" + (size - borderWidth / 2) + "," + size / 2 + " a1,1 0 0,0 -" + (size - borderWidth) + ",0", + stroke: borderBgColor, + "stroke-width": borderWidth, + fill: bgColor || 'none' + }), semiCircle && (0, _$jsx.default)("path", { + class: "gauge-front-semi", + d: "M" + (size - borderWidth / 2) + "," + size / 2 + " a1,1 0 0,0 -" + (size - borderWidth) + ",0", + stroke: borderColor, + "stroke-width": borderWidth, + "stroke-dasharray": length / 2, + "stroke-dashoffset": length / 2 * (1 + progress), + fill: borderBgColor ? 'none' : bgColor || 'none' + }), !semiCircle && borderBgColor && (0, _$jsx.default)("circle", { + class: "gauge-back-circle", + stroke: borderBgColor, + "stroke-width": borderWidth, + fill: bgColor || 'none', + cx: size / 2, + cy: size / 2, + r: radius + }), !semiCircle && (0, _$jsx.default)("circle", { + class: "gauge-front-circle", + transform: "rotate(-90 " + size / 2 + " " + size / 2 + ")", + stroke: borderColor, + "stroke-width": borderWidth, + "stroke-dasharray": length, + "stroke-dashoffset": length * (1 - progress), + fill: borderBgColor ? 'none' : bgColor || 'none', + cx: size / 2, + cy: size / 2, + r: radius + }), valueText && (0, _$jsx.default)("text", { + class: "gauge-value-text", + x: "50%", + y: semiCircle ? '100%' : '50%', + "font-weight": valueFontWeight, + "font-size": valueFontSize, + fill: valueTextColor, + dy: semiCircle ? labelText ? -labelFontSize - 15 : -5 : 0, + "text-anchor": "middle", + "dominant-baseline": !semiCircle && 'middle' + }, valueText), labelText && (0, _$jsx.default)("text", { + class: "gauge-label-text", + x: "50%", + y: semiCircle ? '100%' : '50%', + "font-weight": labelFontWeight, + "font-size": labelFontSize, + fill: labelTextColor, + dy: semiCircle ? -5 : valueText ? valueFontSize / 2 + 10 : 0, + "text-anchor": "middle", + "dominant-baseline": !semiCircle && 'middle' + }, labelText)); + }; + + _proto.update = function update(newParams) { + if (newParams === void 0) { + newParams = {}; + } + + var self = this; + var document = (0, _ssrWindow.getDocument)(); + var params = self.params, + $svgEl = self.$svgEl; + Object.keys(newParams).forEach(function (param) { + if (typeof newParams[param] !== 'undefined') { + params[param] = newParams[param]; + } + }); + if ($svgEl.length === 0) return self; + var value = params.value, + size = params.size, + bgColor = params.bgColor, + borderBgColor = params.borderBgColor, + borderColor = params.borderColor, + borderWidth = params.borderWidth, + valueText = params.valueText, + valueTextColor = params.valueTextColor, + valueFontSize = params.valueFontSize, + valueFontWeight = params.valueFontWeight, + labelText = params.labelText, + labelTextColor = params.labelTextColor, + labelFontSize = params.labelFontSize, + labelFontWeight = params.labelFontWeight; + var length = self.calcBorderLength(); + var progress = Math.max(Math.min(value, 1), 0); + var radius = self.calcRadius(); + var semiCircle = params.type === 'semicircle'; + var svgAttrs = { + width: size + "px", + height: (semiCircle ? size / 2 : size) + "px", + viewBox: "0 0 " + size + " " + (semiCircle ? size / 2 : size) + }; + Object.keys(svgAttrs).forEach(function (attr) { + $svgEl.attr(attr, svgAttrs[attr]); + }); + + if (semiCircle) { + var backAttrs = { + d: "M" + (size - borderWidth / 2) + "," + size / 2 + " a1,1 0 0,0 -" + (size - borderWidth) + ",0", + stroke: borderBgColor, + 'stroke-width': borderWidth, + fill: bgColor || 'none' + }; + var frontAttrs = { + d: "M" + (size - borderWidth / 2) + "," + size / 2 + " a1,1 0 0,0 -" + (size - borderWidth) + ",0", + stroke: borderColor, + 'stroke-width': borderWidth, + 'stroke-dasharray': length / 2, + 'stroke-dashoffset': length / 2 * (1 + progress), + fill: borderBgColor ? 'none' : bgColor || 'none' + }; + Object.keys(backAttrs).forEach(function (attr) { + $svgEl.find('.gauge-back-semi').attr(attr, backAttrs[attr]); + }); + Object.keys(frontAttrs).forEach(function (attr) { + $svgEl.find('.gauge-front-semi').attr(attr, frontAttrs[attr]); + }); + } else { + var _backAttrs = { + stroke: borderBgColor, + 'stroke-width': borderWidth, + fill: bgColor || 'none', + cx: size / 2, + cy: size / 2, + r: radius + }; + var _frontAttrs = { + transform: "rotate(-90 " + size / 2 + " " + size / 2 + ")", + stroke: borderColor, + 'stroke-width': borderWidth, + 'stroke-dasharray': length, + 'stroke-dashoffset': length * (1 - progress), + fill: borderBgColor ? 'none' : bgColor || 'none', + cx: size / 2, + cy: size / 2, + r: radius + }; + Object.keys(_backAttrs).forEach(function (attr) { + $svgEl.find('.gauge-back-circle').attr(attr, _backAttrs[attr]); + }); + Object.keys(_frontAttrs).forEach(function (attr) { + $svgEl.find('.gauge-front-circle').attr(attr, _frontAttrs[attr]); + }); + } + + if (valueText) { + if (!$svgEl.find('.gauge-value-text').length) { + var textEl = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + textEl.classList.add('gauge-value-text'); + $svgEl.append(textEl); + } + + var textAttrs = { + x: '50%', + y: semiCircle ? '100%' : '50%', + 'font-weight': valueFontWeight, + 'font-size': valueFontSize, + fill: valueTextColor, + dy: semiCircle ? labelText ? -labelFontSize - 15 : -5 : 0, + 'text-anchor': 'middle', + 'dominant-baseline': !semiCircle && 'middle' + }; + Object.keys(textAttrs).forEach(function (attr) { + $svgEl.find('.gauge-value-text').attr(attr, textAttrs[attr]); + }); + $svgEl.find('.gauge-value-text').text(valueText); + } else { + $svgEl.find('.gauge-value-text').remove(); + } + + if (labelText) { + if (!$svgEl.find('.gauge-label-text').length) { + var _textEl = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + + _textEl.classList.add('gauge-label-text'); + + $svgEl.append(_textEl); + } + + var labelAttrs = { + x: '50%', + y: semiCircle ? '100%' : '50%', + 'font-weight': labelFontWeight, + 'font-size': labelFontSize, + fill: labelTextColor, + dy: semiCircle ? -5 : valueText ? valueFontSize / 2 + 10 : 0, + 'text-anchor': 'middle', + 'dominant-baseline': !semiCircle && 'middle' + }; + Object.keys(labelAttrs).forEach(function (attr) { + $svgEl.find('.gauge-label-text').attr(attr, labelAttrs[attr]); + }); + $svgEl.find('.gauge-label-text').text(labelText); + } else { + $svgEl.find('.gauge-label-text').remove(); + } + + return self; + }; + + _proto.init = function init() { + var self = this; + var $svgEl = (0, _dom.default)(self.render()).eq(0); + $svgEl.f7Gauge = self; + (0, _utils.extend)(self, { + $svgEl: $svgEl, + svgEl: $svgEl && $svgEl[0] + }); + self.$el.append($svgEl); + return self; + }; + + _proto.destroy = function destroy() { + var self = this; + if (!self.$el || self.destroyed) return; + self.$el.trigger('gauge:beforedestroy'); + self.emit('local::beforeDestroy gaugeBeforeDestroy', self); + self.$svgEl.remove(); + delete self.$el[0].f7Gauge; + (0, _utils.deleteProps)(self); + self.destroyed = true; + }; + + return Gauge; +}(_class.default); + +var _default = Gauge; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/gauge/gauge.js b/www/assets/framework7/cjs/components/gauge/gauge.js new file mode 100644 index 000000000..d44c2c39c --- /dev/null +++ b/www/assets/framework7/cjs/components/gauge/gauge.js @@ -0,0 +1,103 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _gaugeClass = _interopRequireDefault(require("./gauge-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +var _utils = require("../../shared/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'gauge', + static: { + Gauge: _gaugeClass.default + }, + create: function create() { + var app = this; + app.gauge = (0, _constructorMethods.default)({ + defaultSelector: '.gauge', + constructor: _gaugeClass.default, + app: app, + domProp: 'f7Gauge' + }); + + app.gauge.update = function update(el, newParams) { + var $el = (0, _dom.default)(el); + if ($el.length === 0) return undefined; + var gauge = app.gauge.get(el); + if (!gauge) return undefined; + gauge.update(newParams); + return gauge; + }; + }, + params: { + gauge: { + el: null, + type: 'circle', + value: 0, + size: 200, + bgColor: 'transparent', + borderBgColor: '#eeeeee', + borderColor: '#000000', + borderWidth: 10, + valueText: null, + valueTextColor: '#000000', + valueFontSize: 31, + valueFontWeight: 500, + labelText: null, + labelTextColor: '#888888', + labelFontSize: 14, + labelFontWeight: 400 + } + }, + on: { + tabMounted: function tabMounted(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.gauge-init').each(function (el) { + app.gauge.create((0, _utils.extend)({ + el: el + }, (0, _dom.default)(el).dataset() || {})); + }); + }, + tabBeforeRemove: function tabBeforeRemove(tabEl) { + (0, _dom.default)(tabEl).find('.gauge-init').each(function (el) { + if (el.f7Gauge) el.f7Gauge.destroy(); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.gauge-init').each(function (el) { + app.gauge.create((0, _utils.extend)({ + el: el + }, (0, _dom.default)(el).dataset() || {})); + }); + }, + pageBeforeRemove: function pageBeforeRemove(page) { + page.$el.find('.gauge-init').each(function (el) { + if (el.f7Gauge) el.f7Gauge.destroy(); + }); + } + }, + vnode: { + 'gauge-init': { + insert: function insert(vnode) { + var app = this; + var el = vnode.elm; + app.gauge.create((0, _utils.extend)({ + el: el + }, (0, _dom.default)(el).dataset() || {})); + }, + destroy: function destroy(vnode) { + var el = vnode.elm; + if (el.f7Gauge) el.f7Gauge.destroy(); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/grid/grid.js b/www/assets/framework7/cjs/components/grid/grid.js new file mode 100644 index 000000000..b0c7d60de --- /dev/null +++ b/www/assets/framework7/cjs/components/grid/grid.js @@ -0,0 +1,233 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function getElMinSize(dimension, $el) { + var minSize = $el.css("min-" + dimension); + + if (minSize === 'auto' || minSize === 'none') { + minSize = 0; + } else if (minSize.indexOf('px') >= 0) { + minSize = parseFloat(minSize); + } else if (minSize.indexOf('%') >= 0) { + minSize = $el.parent()[0][dimension === 'height' ? 'offsetHeight' : 'offsetWidth'] * parseFloat(minSize) / 100; + } + + return minSize; +} + +function getElMaxSize(dimension, $el) { + var maxSize = $el.css("max-" + dimension); + + if (maxSize === 'auto' || maxSize === 'none') { + maxSize = null; + } else if (maxSize.indexOf('px') >= 0) { + maxSize = parseFloat(maxSize); + } else if (maxSize.indexOf('%') >= 0) { + maxSize = $el.parent()[0][dimension === 'height' ? 'offsetHeight' : 'offsetWidth'] * parseFloat(maxSize) / 100; + } + + return maxSize; +} + +var Grid = { + init: function init() { + var app = this; + var isTouched; + var isMoved; + var touchStartX; + var touchStartY; + var $resizeHandlerEl; + var $prevResizableEl; + var $nextResizableEl; + var prevElSize; + var prevElMinSize; + var prevElMaxSize; + var nextElSize; + var nextElMinSize; + var nextElMaxSize; + var parentSize; + var itemsInFlow; + var gapSize; + var isScrolling; + + function handleTouchStart(e) { + if (isTouched || isMoved) return; + $resizeHandlerEl = (0, _dom.default)(e.target).closest('.resize-handler'); + touchStartX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; + touchStartY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + isTouched = true; + $prevResizableEl = undefined; + $nextResizableEl = undefined; + isScrolling = undefined; + } + + function handleTouchMove(e) { + if (!isTouched) return; + var isRow = $resizeHandlerEl.parent('.row').length === 1; + var sizeProp = isRow ? 'height' : 'width'; + var getSizeProp = isRow ? 'offsetHeight' : 'offsetWidth'; + + if (!isMoved) { + $prevResizableEl = $resizeHandlerEl.parent(isRow ? '.row' : '.col'); + + if ($prevResizableEl.length && (!$prevResizableEl.hasClass('resizable') || $prevResizableEl.hasClass('resizable-fixed'))) { + $prevResizableEl = $prevResizableEl.prevAll('.resizable:not(.resizable-fixed)').eq(0); + } + + $nextResizableEl = $prevResizableEl.next(isRow ? '.row' : '.col'); + + if ($nextResizableEl.length && (!$nextResizableEl.hasClass('resizable') || $nextResizableEl.hasClass('resizable-fixed'))) { + $nextResizableEl = $nextResizableEl.nextAll('.resizable:not(.resizable-fixed)').eq(0); + } + + if ($prevResizableEl.length) { + prevElSize = $prevResizableEl[0][getSizeProp]; + prevElMinSize = getElMinSize(sizeProp, $prevResizableEl); + prevElMaxSize = getElMaxSize(sizeProp, $prevResizableEl); + parentSize = $prevResizableEl.parent()[0][getSizeProp]; + itemsInFlow = $prevResizableEl.parent().children(isRow ? '.row' : '[class*="col-"], .col').length; + gapSize = parseFloat($prevResizableEl.css(isRow ? '--f7-grid-row-gap' : '--f7-grid-gap')); + } + + if ($nextResizableEl.length) { + nextElSize = $nextResizableEl[0][getSizeProp]; + nextElMinSize = getElMinSize(sizeProp, $nextResizableEl); + nextElMaxSize = getElMaxSize(sizeProp, $nextResizableEl); + + if (!$prevResizableEl.length) { + parentSize = $nextResizableEl.parent()[0][getSizeProp]; + itemsInFlow = $nextResizableEl.parent().children(isRow ? '.row' : '[class*="col-"], .col').length; + gapSize = parseFloat($nextResizableEl.css(isRow ? '--f7-grid-row-gap' : '--f7-grid-gap')); + } + } + } + + isMoved = true; + var touchCurrentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; + var touchCurrentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; + + if (typeof isScrolling === 'undefined' && !isRow) { + isScrolling = !!(isScrolling || Math.abs(touchCurrentY - touchStartY) > Math.abs(touchCurrentX - touchStartX)); + } + + if (isScrolling) { + isTouched = false; + isMoved = false; + return; + } + + var isAbsolute = $prevResizableEl.hasClass('resizable-absolute') || $nextResizableEl.hasClass('resizable-absolute'); + var resizeNextEl = !isRow || isRow && !isAbsolute; + + if (resizeNextEl && !$nextResizableEl.length || !$prevResizableEl.length) { + isTouched = false; + isMoved = false; + return; + } + + e.preventDefault(); + var diff = isRow ? touchCurrentY - touchStartY : touchCurrentX - touchStartX; + var prevElNewSize; + var nextElNewSize; + + if ($prevResizableEl.length) { + prevElNewSize = prevElSize + diff; + + if (prevElNewSize < prevElMinSize) { + prevElNewSize = prevElMinSize; + diff = prevElNewSize - prevElSize; + } + + if (prevElMaxSize && prevElNewSize > prevElMaxSize) { + prevElNewSize = prevElMaxSize; + diff = prevElNewSize - prevElSize; + } + } + + if ($nextResizableEl.length && resizeNextEl) { + nextElNewSize = nextElSize - diff; + + if (nextElNewSize < nextElMinSize) { + nextElNewSize = nextElMinSize; + diff = nextElSize - nextElNewSize; + prevElNewSize = prevElSize + diff; + } + + if (nextElMaxSize && nextElNewSize > nextElMaxSize) { + nextElNewSize = nextElMaxSize; + diff = nextElSize - nextElNewSize; + prevElNewSize = prevElSize + diff; + } + } + + if (isAbsolute) { + $prevResizableEl[0].style[sizeProp] = prevElNewSize + "px"; + + if (resizeNextEl) { + $nextResizableEl[0].style[sizeProp] = nextElNewSize + "px"; + } + + $prevResizableEl.trigger('grid:resize'); + $nextResizableEl.trigger('grid:resize'); + app.emit('gridResize', $prevResizableEl[0]); + app.emit('gridResize', $nextResizableEl[0]); + return; + } + + var gapAddSize = (itemsInFlow - 1) * gapSize / itemsInFlow; + var gapAddSizeCSS = isRow ? itemsInFlow - 1 + " * var(--f7-grid-row-gap) / " + itemsInFlow : '(var(--f7-cols-per-row) - 1) * var(--f7-grid-gap) / var(--f7-cols-per-row)'; + var prevElNewSizeNormalized = prevElNewSize + gapAddSize; + var nextElNewSizeNormalized = nextElNewSize + gapAddSize; + $prevResizableEl[0].style[sizeProp] = "calc(" + prevElNewSizeNormalized / parentSize * 100 + "% - " + gapAddSizeCSS + ")"; + $nextResizableEl[0].style[sizeProp] = "calc(" + nextElNewSizeNormalized / parentSize * 100 + "% - " + gapAddSizeCSS + ")"; + $prevResizableEl.trigger('grid:resize'); + $nextResizableEl.trigger('grid:resize'); + app.emit('gridResize', $prevResizableEl[0]); + app.emit('gridResize', $nextResizableEl[0]); + } + + function handleTouchEnd() { + if (!isTouched) return; + + if (!isMoved) { + isTouched = false; + } + + isTouched = false; + isMoved = false; + } + + var document = (0, _ssrWindow.getDocument)(); + (0, _dom.default)(document).on(app.touchEvents.start, '.col > .resize-handler, .row > .resize-handler', handleTouchStart); + app.on('touchmove', handleTouchMove); + app.on('touchend', handleTouchEnd); + } +}; +var _default = { + name: 'grid', + create: function create() { + var app = this; + (0, _utils.extend)(app, { + grid: { + init: Grid.init.bind(app) + } + }); + }, + on: { + init: function init() { + var app = this; + app.grid.init(); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/icon/icon.js b/www/assets/framework7/cjs/components/icon/icon.js new file mode 100644 index 000000000..031c61b8b --- /dev/null +++ b/www/assets/framework7/cjs/components/icon/icon.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _default = { + name: 'icon' +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/infinite-scroll/infinite-scroll.js b/www/assets/framework7/cjs/components/infinite-scroll/infinite-scroll.js new file mode 100644 index 000000000..0770c69fa --- /dev/null +++ b/www/assets/framework7/cjs/components/infinite-scroll/infinite-scroll.js @@ -0,0 +1,111 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var InfiniteScroll = { + handle: function handle(el, e) { + var app = this; + var $el = (0, _dom.default)(el); + var scrollTop = $el[0].scrollTop; + var scrollHeight = $el[0].scrollHeight; + var height = $el[0].offsetHeight; + var distance = $el[0].getAttribute('data-infinite-distance'); + var virtualListContainer = $el.find('.virtual-list'); + var virtualList; + var onTop = $el.hasClass('infinite-scroll-top'); + if (!distance) distance = 50; + + if (typeof distance === 'string' && distance.indexOf('%') >= 0) { + distance = parseInt(distance, 10) / 100 * height; + } + + if (distance > height) distance = height; + + if (onTop) { + if (scrollTop < distance) { + $el.trigger('infinite', e); + app.emit('infinite', $el[0], e); + } + } else if (scrollTop + height >= scrollHeight - distance) { + if (virtualListContainer.length > 0) { + virtualList = virtualListContainer.eq(-1)[0].f7VirtualList; + + if (virtualList && !virtualList.reachEnd && !virtualList.params.updatableScroll) { + return; + } + } + + $el.trigger('infinite', e); + app.emit('infinite', $el[0], e); + } + }, + create: function create(el) { + var $el = (0, _dom.default)(el); + var app = this; + + function scrollHandler(e) { + app.infiniteScroll.handle(this, e); + } + + $el.each(function (element) { + element.f7InfiniteScrollHandler = scrollHandler; + element.addEventListener('scroll', element.f7InfiniteScrollHandler); + }); + }, + destroy: function destroy(el) { + var $el = (0, _dom.default)(el); + $el.each(function (element) { + element.removeEventListener('scroll', element.f7InfiniteScrollHandler); + delete element.f7InfiniteScrollHandler; + }); + } +}; +var _default = { + name: 'infiniteScroll', + create: function create() { + var app = this; + (0, _utils.bindMethods)(app, { + infiniteScroll: InfiniteScroll + }); + }, + on: { + tabMounted: function tabMounted(tabEl) { + var app = this; + var $tabEl = (0, _dom.default)(tabEl); + var $isEls = $tabEl.find('.infinite-scroll-content'); + if ($tabEl.is('.infinite-scroll-content')) $isEls.add($tabEl); + $isEls.each(function (el) { + app.infiniteScroll.create(el); + }); + }, + tabBeforeRemove: function tabBeforeRemove(tabEl) { + var $tabEl = (0, _dom.default)(tabEl); + var app = this; + var $isEls = $tabEl.find('.infinite-scroll-content'); + if ($tabEl.is('.infinite-scroll-content')) $isEls.add($tabEl); + $isEls.each(function (el) { + app.infiniteScroll.destroy(el); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.infinite-scroll-content').each(function (el) { + app.infiniteScroll.create(el); + }); + }, + pageBeforeRemove: function pageBeforeRemove(page) { + var app = this; + page.$el.find('.infinite-scroll-content').each(function (el) { + app.infiniteScroll.destroy(el); + }); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/input/input.js b/www/assets/framework7/cjs/components/input/input.js new file mode 100644 index 000000000..e4117c67d --- /dev/null +++ b/www/assets/framework7/cjs/components/input/input.js @@ -0,0 +1,396 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _getDevice = require("../../shared/get-device"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Input = { + ignoreTypes: ['checkbox', 'button', 'submit', 'range', 'radio', 'image'], + createTextareaResizableShadow: function createTextareaResizableShadow() { + var document = (0, _ssrWindow.getDocument)(); + var $shadowEl = (0, _dom.default)(document.createElement('textarea')); + $shadowEl.addClass('textarea-resizable-shadow'); + $shadowEl.prop({ + disabled: true, + readonly: true + }); + Input.textareaResizableShadow = $shadowEl; + }, + textareaResizableShadow: undefined, + resizeTextarea: function resizeTextarea(textareaEl) { + var app = this; + var window = (0, _ssrWindow.getWindow)(); + var $textareaEl = (0, _dom.default)(textareaEl); + + if (!Input.textareaResizableShadow) { + Input.createTextareaResizableShadow(); + } + + var $shadowEl = Input.textareaResizableShadow; + if (!$textareaEl.length) return; + if (!$textareaEl.hasClass('resizable')) return; + + if (Input.textareaResizableShadow.parents().length === 0) { + app.$el.append($shadowEl); + } + + var styles = window.getComputedStyle($textareaEl[0]); + 'padding-top padding-bottom padding-left padding-right margin-left margin-right margin-top margin-bottom width font-size font-family font-style font-weight line-height font-variant text-transform letter-spacing border box-sizing display'.split(' ').forEach(function (style) { + var styleValue = styles[style]; + + if ('font-size line-height letter-spacing width'.split(' ').indexOf(style) >= 0) { + styleValue = styleValue.replace(',', '.'); + } + + $shadowEl.css(style, styleValue); + }); + var currentHeight = $textareaEl[0].clientHeight; + $shadowEl.val(''); + var initialHeight = $shadowEl[0].scrollHeight; + $shadowEl.val($textareaEl.val()); + $shadowEl.css('height', 0); + var scrollHeight = $shadowEl[0].scrollHeight; + + if (currentHeight !== scrollHeight) { + if (scrollHeight > initialHeight) { + $textareaEl.css('height', scrollHeight + "px"); + } else if (scrollHeight < currentHeight) { + $textareaEl.css('height', ''); + } + + if (scrollHeight > initialHeight || scrollHeight < currentHeight) { + $textareaEl.trigger('textarea:resize', { + initialHeight: initialHeight, + currentHeight: currentHeight, + scrollHeight: scrollHeight + }); + app.emit('textareaResize', { + initialHeight: initialHeight, + currentHeight: currentHeight, + scrollHeight: scrollHeight + }); + } + } + }, + validate: function validate(inputEl) { + var $inputEl = (0, _dom.default)(inputEl); + if (!$inputEl.length) return true; + var $itemInputEl = $inputEl.parents('.item-input'); + var $inputWrapEl = $inputEl.parents('.input'); + + function unsetReadonly() { + if ($inputEl[0].f7ValidateReadonly) { + $inputEl[0].readOnly = false; + } + } + + function setReadonly() { + if ($inputEl[0].f7ValidateReadonly) { + $inputEl[0].readOnly = true; + } + } + + unsetReadonly(); + var validity = $inputEl[0].validity; + var validationMessage = $inputEl.dataset().errorMessage || $inputEl[0].validationMessage || ''; + + if (!validity) { + setReadonly(); + return true; + } + + if (!validity.valid) { + var $errorEl = $inputEl.nextAll('.item-input-error-message, .input-error-message'); + + if (validationMessage) { + if ($errorEl.length === 0) { + $errorEl = (0, _dom.default)("
    "); + $errorEl.insertAfter($inputEl); + } + + $errorEl.text(validationMessage); + } + + if ($errorEl.length > 0) { + $itemInputEl.addClass('item-input-with-error-message'); + $inputWrapEl.addClass('input-with-error-message'); + } + + $itemInputEl.addClass('item-input-invalid'); + $inputWrapEl.addClass('input-invalid'); + $inputEl.addClass('input-invalid'); + setReadonly(); + return false; + } + + $itemInputEl.removeClass('item-input-invalid item-input-with-error-message'); + $inputWrapEl.removeClass('input-invalid input-with-error-message'); + $inputEl.removeClass('input-invalid'); + setReadonly(); + return true; + }, + validateInputs: function validateInputs(el) { + var app = this; + var validates = (0, _dom.default)(el).find('input, textarea, select').map(function (inputEl) { + return app.input.validate(inputEl); + }); + return validates.indexOf(false) < 0; + }, + focus: function focus(inputEl) { + var $inputEl = (0, _dom.default)(inputEl); + var type = $inputEl.attr('type'); + if (Input.ignoreTypes.indexOf(type) >= 0) return; + $inputEl.parents('.item-input').addClass('item-input-focused'); + $inputEl.parents('.input').addClass('input-focused'); + $inputEl.addClass('input-focused'); + }, + blur: function blur(inputEl) { + var $inputEl = (0, _dom.default)(inputEl); + $inputEl.parents('.item-input').removeClass('item-input-focused'); + $inputEl.parents('.input').removeClass('input-focused'); + $inputEl.removeClass('input-focused'); + }, + checkEmptyState: function checkEmptyState(inputEl) { + var app = this; + var $inputEl = (0, _dom.default)(inputEl); + + if (!$inputEl.is('input, select, textarea, .item-input [contenteditable]')) { + $inputEl = $inputEl.find('input, select, textarea, .item-input [contenteditable]').eq(0); + } + + if (!$inputEl.length) return; + var isContentEditable = $inputEl[0].hasAttribute('contenteditable'); + var value; + + if (isContentEditable) { + if ($inputEl.find('.text-editor-placeholder').length) value = '';else value = $inputEl.html(); + } else { + value = $inputEl.val(); + } + + var $itemInputEl = $inputEl.parents('.item-input'); + var $inputWrapEl = $inputEl.parents('.input'); + + if (value && typeof value === 'string' && value.trim() !== '' || Array.isArray(value) && value.length > 0) { + $itemInputEl.addClass('item-input-with-value'); + $inputWrapEl.addClass('input-with-value'); + $inputEl.addClass('input-with-value'); + $inputEl.trigger('input:notempty'); + app.emit('inputNotEmpty', $inputEl[0]); + } else { + $itemInputEl.removeClass('item-input-with-value'); + $inputWrapEl.removeClass('input-with-value'); + $inputEl.removeClass('input-with-value'); + $inputEl.trigger('input:empty'); + app.emit('inputEmpty', $inputEl[0]); + } + }, + scrollIntoView: function scrollIntoView(inputEl, duration, centered, force) { + if (duration === void 0) { + duration = 0; + } + + var $inputEl = (0, _dom.default)(inputEl); + var $scrollableEl = $inputEl.parents('.page-content, .panel, .card-expandable .card-content').eq(0); + + if (!$scrollableEl.length) { + return false; + } + + var contentHeight = $scrollableEl[0].offsetHeight; + var contentScrollTop = $scrollableEl[0].scrollTop; + var contentPaddingTop = parseInt($scrollableEl.css('padding-top'), 10); + var contentPaddingBottom = parseInt($scrollableEl.css('padding-bottom'), 10); + var contentOffsetTop = $scrollableEl.offset().top - contentScrollTop; + var inputOffsetTop = $inputEl.offset().top - contentOffsetTop; + var inputHeight = $inputEl[0].offsetHeight; + var min = inputOffsetTop + contentScrollTop - contentPaddingTop; + var max = inputOffsetTop + contentScrollTop - contentHeight + contentPaddingBottom + inputHeight; + var centeredPosition = min + (max - min) / 2; + + if (contentScrollTop > min) { + $scrollableEl.scrollTop(centered ? centeredPosition : min, duration); + return true; + } + + if (contentScrollTop < max) { + $scrollableEl.scrollTop(centered ? centeredPosition : max, duration); + return true; + } + + if (force) { + $scrollableEl.scrollTop(centered ? centeredPosition : max, duration); + } + + return false; + }, + init: function init() { + var app = this; + var device = (0, _getDevice.getDevice)(); + var window = (0, _ssrWindow.getWindow)(); + var document = (0, _ssrWindow.getDocument)(); + Input.createTextareaResizableShadow(); + + function onFocus() { + var inputEl = this; + + if (app.params.input.scrollIntoViewOnFocus) { + if (device.android) { + (0, _dom.default)(window).once('resize', function () { + if (document && document.activeElement === inputEl) { + app.input.scrollIntoView(inputEl, app.params.input.scrollIntoViewDuration, app.params.input.scrollIntoViewCentered, app.params.input.scrollIntoViewAlways); + } + }); + } else { + app.input.scrollIntoView(inputEl, app.params.input.scrollIntoViewDuration, app.params.input.scrollIntoViewCentered, app.params.input.scrollIntoViewAlways); + } + } + + app.input.focus(inputEl); + } + + function onBlur() { + var $inputEl = (0, _dom.default)(this); + var tag = $inputEl[0].nodeName.toLowerCase(); + app.input.blur($inputEl); + + if ($inputEl.dataset().validate || $inputEl.attr('validate') !== null || $inputEl.attr('data-validate-on-blur') !== null) { + app.input.validate($inputEl); + } // Resize textarea + + + if (tag === 'textarea' && $inputEl.hasClass('resizable')) { + if (Input.textareaResizableShadow) Input.textareaResizableShadow.remove(); + } + } + + function onChange() { + var $inputEl = (0, _dom.default)(this); + var type = $inputEl.attr('type'); + var tag = $inputEl[0].nodeName.toLowerCase(); + var isContentEditable = $inputEl[0].hasAttribute('contenteditable'); + if (Input.ignoreTypes.indexOf(type) >= 0) return; // Check Empty State + + app.input.checkEmptyState($inputEl); + if (isContentEditable) return; // Check validation + + if ($inputEl.attr('data-validate-on-blur') === null && ($inputEl.dataset().validate || $inputEl.attr('validate') !== null)) { + app.input.validate($inputEl); + } // Resize textarea + + + if (tag === 'textarea' && $inputEl.hasClass('resizable')) { + app.input.resizeTextarea($inputEl); + } + } + + function onInvalid(e) { + var $inputEl = (0, _dom.default)(this); + + if ($inputEl.attr('data-validate-on-blur') === null && ($inputEl.dataset().validate || $inputEl.attr('validate') !== null)) { + e.preventDefault(); + app.input.validate($inputEl); + } + } + + function clearInput() { + var $clicked = (0, _dom.default)(this); + var $inputEl = $clicked.siblings('input, textarea').eq(0); + var previousValue = $inputEl.val(); + $inputEl.val('').trigger('input change').focus().trigger('input:clear', previousValue); + app.emit('inputClear', previousValue); + } + + function preventDefault(e) { + e.preventDefault(); + } + + (0, _dom.default)(document).on('click', '.input-clear-button', clearInput); + (0, _dom.default)(document).on('mousedown', '.input-clear-button', preventDefault); + (0, _dom.default)(document).on('change input', 'input, textarea, select, .item-input [contenteditable]', onChange, true); + (0, _dom.default)(document).on('focus', 'input, textarea, select, .item-input [contenteditable]', onFocus, true); + (0, _dom.default)(document).on('blur', 'input, textarea, select, .item-input [contenteditable]', onBlur, true); + (0, _dom.default)(document).on('invalid', 'input, textarea, select', onInvalid, true); + } +}; +var _default = { + name: 'input', + params: { + input: { + scrollIntoViewOnFocus: undefined, + scrollIntoViewCentered: false, + scrollIntoViewDuration: 0, + scrollIntoViewAlways: false + } + }, + create: function create() { + var app = this; + + if (typeof app.params.input.scrollIntoViewOnFocus === 'undefined') { + app.params.input.scrollIntoViewOnFocus = (0, _getDevice.getDevice)().android; + } + + (0, _utils.bindMethods)(app, { + input: Input + }); + }, + on: { + init: function init() { + var app = this; + app.input.init(); + }, + tabMounted: function tabMounted(tabEl) { + var app = this; + var $tabEl = (0, _dom.default)(tabEl); + $tabEl.find('.item-input, .input').each(function (itemInputEl) { + var $itemInputEl = (0, _dom.default)(itemInputEl); + $itemInputEl.find('input, select, textarea, [contenteditable]').each(function (inputEl) { + var $inputEl = (0, _dom.default)(inputEl); + if (Input.ignoreTypes.indexOf($inputEl.attr('type')) >= 0) return; + app.input.checkEmptyState($inputEl); + }); + }); + $tabEl.find('textarea.resizable').each(function (textareaEl) { + app.input.resizeTextarea(textareaEl); + }); + }, + pageInit: function pageInit(page) { + var app = this; + var $pageEl = page.$el; + $pageEl.find('.item-input, .input').each(function (itemInputEl) { + var $itemInputEl = (0, _dom.default)(itemInputEl); + $itemInputEl.find('input, select, textarea, [contenteditable]').each(function (inputEl) { + var $inputEl = (0, _dom.default)(inputEl); + if (Input.ignoreTypes.indexOf($inputEl.attr('type')) >= 0) return; + app.input.checkEmptyState($inputEl); + }); + }); + $pageEl.find('textarea.resizable').each(function (textareaEl) { + app.input.resizeTextarea(textareaEl); + }); + }, + 'panelBreakpoint panelCollapsedBreakpoint panelResize panelOpen panelSwipeOpen resize viewMasterDetailBreakpoint': function onPanelOpen(instance) { + var app = this; + + if (instance && instance.$el) { + instance.$el.find('textarea.resizable').each(function (textareaEl) { + app.input.resizeTextarea(textareaEl); + }); + } else { + (0, _dom.default)('textarea.resizable').each(function (textareaEl) { + app.input.resizeTextarea(textareaEl); + }); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/lazy/lazy.js b/www/assets/framework7/cjs/components/lazy/lazy.js new file mode 100644 index 000000000..1bc4879e9 --- /dev/null +++ b/www/assets/framework7/cjs/components/lazy/lazy.js @@ -0,0 +1,283 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _getSupport = require("../../shared/get-support"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Lazy = { + destroy: function destroy(pageEl) { + var $pageEl = (0, _dom.default)(pageEl).closest('.page'); + if (!$pageEl.length) return; + + if ($pageEl[0].f7LazyDestroy) { + $pageEl[0].f7LazyDestroy(); + } + }, + create: function create(pageEl) { + var app = this; + var window = (0, _ssrWindow.getWindow)(); + var support = (0, _getSupport.getSupport)(); + var $pageEl = (0, _dom.default)(pageEl).closest('.page').eq(0); // Lazy images + + var $lazyLoadImages = $pageEl.find('.lazy'); + if ($lazyLoadImages.length === 0 && !$pageEl.hasClass('lazy')) return; // Placeholder + + var placeholderSrc = app.params.lazy.placeholder; + + if (placeholderSrc !== false) { + $lazyLoadImages.each(function (lazyEl) { + if ((0, _dom.default)(lazyEl).attr('data-src') && !(0, _dom.default)(lazyEl).attr('src')) (0, _dom.default)(lazyEl).attr('src', placeholderSrc); + }); + } // load image + + + var imagesSequence = []; + var imageIsLoading = false; + + function onImageComplete(lazyEl) { + if (imagesSequence.indexOf(lazyEl) >= 0) { + imagesSequence.splice(imagesSequence.indexOf(lazyEl), 1); + } + + imageIsLoading = false; + + if (app.params.lazy.sequential && imagesSequence.length > 0) { + imageIsLoading = true; + app.lazy.loadImage(imagesSequence[0], onImageComplete); + } + } + + function observerCallback(entries, observer) { + entries.forEach(function (entry) { + if (entry.isIntersecting) { + if (app.params.lazy.sequential && imageIsLoading) { + if (imagesSequence.indexOf(entry.target) < 0) imagesSequence.push(entry.target); + return; + } // Load image + + + imageIsLoading = true; + app.lazy.loadImage(entry.target, onImageComplete); // Detach + + observer.unobserve(entry.target); + } + }); + } + + if (app.params.lazy.observer && support.intersectionObserver) { + var observer = $pageEl[0].f7LazyObserver; + + if (!observer) { + observer = new window.IntersectionObserver(observerCallback, { + root: $pageEl[0] + }); + } + + $lazyLoadImages.each(function (el) { + if (el.f7LazyObserverAdded) return; + el.f7LazyObserverAdded = true; + observer.observe(el); + }); + + if (!$pageEl[0].f7LazyDestroy) { + $pageEl[0].f7LazyDestroy = function () { + observer.disconnect(); + delete $pageEl[0].f7LazyDestroy; + delete $pageEl[0].f7LazyObserver; + }; + } + + return; + } + + function lazyHandler() { + app.lazy.load($pageEl, function (lazyEl) { + if (app.params.lazy.sequential && imageIsLoading) { + if (imagesSequence.indexOf(lazyEl) < 0) imagesSequence.push(lazyEl); + return; + } + + imageIsLoading = true; + app.lazy.loadImage(lazyEl, onImageComplete); + }); + } + + function attachEvents() { + $pageEl[0].f7LazyAttached = true; + $pageEl.on('lazy', lazyHandler); + $pageEl.on('scroll', lazyHandler, true); + $pageEl.find('.tab').on('tab:mounted tab:show', lazyHandler); + app.on('resize', lazyHandler); + } + + function detachEvents() { + $pageEl[0].f7LazyAttached = false; + delete $pageEl[0].f7LazyAttached; + $pageEl.off('lazy', lazyHandler); + $pageEl.off('scroll', lazyHandler, true); + $pageEl.find('.tab').off('tab:mounted tab:show', lazyHandler); + app.off('resize', lazyHandler); + } // Store detach function + + + if (!$pageEl[0].f7LazyDestroy) { + $pageEl[0].f7LazyDestroy = detachEvents; + } // Attach events + + + if (!$pageEl[0].f7LazyAttached) { + attachEvents(); + } // Run loader on page load/init + + + lazyHandler(); + }, + isInViewport: function isInViewport(lazyEl) { + var app = this; + var rect = lazyEl.getBoundingClientRect(); + var threshold = app.params.lazy.threshold || 0; + return rect.top >= 0 - threshold && rect.left >= 0 - threshold && rect.top <= app.height + threshold && rect.left <= app.width + threshold; + }, + loadImage: function loadImage(imageEl, callback) { + var app = this; + var window = (0, _ssrWindow.getWindow)(); + var $imageEl = (0, _dom.default)(imageEl); + var bg = $imageEl.attr('data-background'); + var src = bg || $imageEl.attr('data-src'); + + function onLoad() { + $imageEl.removeClass('lazy').addClass('lazy-loaded'); + + if (bg) { + $imageEl.css('background-image', "url(" + src + ")"); + } else if (src) { + $imageEl.attr('src', src); + } + + if (callback) callback(imageEl); + $imageEl.trigger('lazy:loaded'); + app.emit('lazyLoaded', $imageEl[0]); + } + + if (!src) { + $imageEl.trigger('lazy:load'); + app.emit('lazyLoad', $imageEl[0]); + onLoad(); + return; + } + + function onError() { + $imageEl.removeClass('lazy').addClass('lazy-loaded'); + + if (bg) { + $imageEl.css('background-image', "url(" + (app.params.lazy.placeholder || '') + ")"); + } else { + $imageEl.attr('src', app.params.lazy.placeholder || ''); + } + + if (callback) callback(imageEl); + $imageEl.trigger('lazy:error'); + app.emit('lazyError', $imageEl[0]); + } + + var image = new window.Image(); + image.onload = onLoad; + image.onerror = onError; + image.src = src; + $imageEl.removeAttr('data-src').removeAttr('data-background'); // Add loaded callback and events + + $imageEl.trigger('lazy:load'); + app.emit('lazyLoad', $imageEl[0]); + }, + load: function load(pageEl, callback) { + var app = this; + var $pageEl = (0, _dom.default)(pageEl); + if (!$pageEl.hasClass('page')) $pageEl = $pageEl.parents('.page').eq(0); + + if ($pageEl.length === 0) { + return; + } + + $pageEl.find('.lazy').each(function (lazyEl) { + var $lazyEl = (0, _dom.default)(lazyEl); + + if ($lazyEl.parents('.tab:not(.tab-active)').length > 0) { + return; + } + + if (app.lazy.isInViewport(lazyEl)) { + if (callback) callback(lazyEl);else app.lazy.loadImage(lazyEl); + } + }); + } +}; +var _default = { + name: 'lazy', + params: { + lazy: { + placeholder: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEXCwsK592mkAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==', + threshold: 0, + sequential: true, + observer: true + } + }, + create: function create() { + var app = this; + (0, _utils.bindMethods)(app, { + lazy: Lazy + }); + }, + on: { + pageInit: function pageInit(page) { + var app = this; + + if (page.$el.find('.lazy').length > 0 || page.$el.hasClass('lazy')) { + app.lazy.create(page.$el); + } + }, + pageAfterIn: function pageAfterIn(page) { + var app = this; + var support = (0, _getSupport.getSupport)(); + if (app.params.lazy.observer && support.intersectionObserver) return; + + if (page.$el.find('.lazy').length > 0 || page.$el.hasClass('lazy')) { + app.lazy.create(page.$el); + } + }, + pageBeforeRemove: function pageBeforeRemove(page) { + var app = this; + + if (page.$el.find('.lazy').length > 0 || page.$el.hasClass('lazy')) { + app.lazy.destroy(page.$el); + } + }, + tabMounted: function tabMounted(tabEl) { + var app = this; + var $tabEl = (0, _dom.default)(tabEl); + + if ($tabEl.find('.lazy').length > 0 || $tabEl.hasClass('lazy')) { + app.lazy.create($tabEl); + } + }, + tabBeforeRemove: function tabBeforeRemove(tabEl) { + var app = this; + var support = (0, _getSupport.getSupport)(); + if (app.params.lazy.observer && support.intersectionObserver) return; + var $tabEl = (0, _dom.default)(tabEl); + + if ($tabEl.find('.lazy').length > 0 || $tabEl.hasClass('lazy')) { + app.lazy.destroy($tabEl); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/link/link.js b/www/assets/framework7/cjs/components/link/link.js new file mode 100644 index 000000000..7d12c164d --- /dev/null +++ b/www/assets/framework7/cjs/components/link/link.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _default = { + name: 'link' +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/list-index/list-index-class.js b/www/assets/framework7/cjs/components/list-index/list-index-class.js new file mode 100644 index 000000000..9dee2308a --- /dev/null +++ b/www/assets/framework7/cjs/components/list-index/list-index-class.js @@ -0,0 +1,405 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _getSupport = require("../../shared/get-support"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var ListIndex = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(ListIndex, _Framework7Class); + + function ListIndex(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params, [app]) || this; + + var index = _assertThisInitialized(_this); + + var defaults = { + el: null, + // where to render indexes + listEl: null, + // list el to generate indexes + indexes: 'auto', + // or array of indexes + iosItemHeight: 14, + mdItemHeight: 14, + auroraItemHeight: 14, + scrollList: true, + label: false, + // eslint-disable-next-line + renderItem: function renderItem(itemContent, itemIndex) { + return ("\n
  • " + itemContent + "
  • \n ").trim(); + }, + renderSkipPlaceholder: function renderSkipPlaceholder() { + return '
  • '; + }, + on: {} + }; // Extend defaults with modules params + + index.useModulesParams(defaults); + index.params = (0, _utils.extend)(defaults, params); + var $el; + var $listEl; + var $pageContentEl; + var $ul; + + if (index.params.el) { + $el = (0, _dom.default)(index.params.el); + } else { + return index || _assertThisInitialized(_this); + } + + if ($el[0].f7ListIndex) { + return $el[0].f7ListIndex || _assertThisInitialized(_this); + } + + $ul = $el.find('ul'); + + if ($ul.length === 0) { + $ul = (0, _dom.default)(''); + $el.append($ul); + } + + if (index.params.listEl) { + $listEl = (0, _dom.default)(index.params.listEl); + } + + if (index.params.indexes === 'auto' && !$listEl) { + return index || _assertThisInitialized(_this); + } + + if ($listEl) { + $pageContentEl = $listEl.parents('.page-content').eq(0); + } else { + $pageContentEl = $el.siblings('.page-content').eq(0); + + if ($pageContentEl.length === 0) { + $pageContentEl = $el.parents('.page').eq(0).find('.page-content').eq(0); + } + } + + $el[0].f7ListIndex = index; + (0, _utils.extend)(index, { + app: app, + $el: $el, + el: $el && $el[0], + $ul: $ul, + ul: $ul && $ul[0], + $listEl: $listEl, + listEl: $listEl && $listEl[0], + $pageContentEl: $pageContentEl, + pageContentEl: $pageContentEl && $pageContentEl[0], + indexes: params.indexes, + height: 0, + skipRate: 0 + }); // Install Modules + + index.useModules(); // Attach events + + function handleResize() { + var height = { + index: index + }; + index.calcSize(); + + if (height !== index.height) { + index.render(); + } + } + + function handleClick(e) { + var $clickedLi = (0, _dom.default)(e.target).closest('li'); + if (!$clickedLi.length) return; + var itemIndex = $clickedLi.index(); + + if (index.skipRate > 0) { + var percentage = itemIndex / ($clickedLi.siblings('li').length - 1); + itemIndex = Math.round((index.indexes.length - 1) * percentage); + } + + var itemContent = index.indexes[itemIndex]; + index.$el.trigger('listindex:click', { + content: itemContent, + index: itemIndex + }); + index.emit('local::click listIndexClick', index, itemContent, itemIndex); + index.$el.trigger('listindex:select', { + content: itemContent, + index: itemIndex + }); + index.emit('local::select listIndexSelect', index, itemContent, itemIndex); + + if (index.$listEl && index.params.scrollList) { + index.scrollListToIndex(itemContent, itemIndex); + } + } + + var touchesStart = {}; + var isTouched; + var isMoved; + var topPoint; + var bottomPoint; + var $labelEl; + var previousIndex = null; + + function handleTouchStart(e) { + var $children = $ul.children(); + if (!$children.length) return; + topPoint = $children[0].getBoundingClientRect().top; + bottomPoint = $children[$children.length - 1].getBoundingClientRect().top + $children[0].offsetHeight; + touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; + touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + isTouched = true; + isMoved = false; + previousIndex = null; + } + + function handleTouchMove(e) { + if (!isTouched) return; + + if (!isMoved && index.params.label) { + $labelEl = (0, _dom.default)(''); + $el.append($labelEl); + } + + isMoved = true; + var pageY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; + e.preventDefault(); + var percentage = (pageY - topPoint) / (bottomPoint - topPoint); + percentage = Math.min(Math.max(percentage, 0), 1); + var itemIndex = Math.round((index.indexes.length - 1) * percentage); + var itemContent = index.indexes[itemIndex]; + var ulHeight = bottomPoint - topPoint; + var bubbleBottom = (index.height - ulHeight) / 2 + (1 - percentage) * ulHeight; + + if (itemIndex !== previousIndex) { + if (index.params.label) { + $labelEl.html(itemContent).transform("translateY(-" + bubbleBottom + "px)"); + } + + if (index.$listEl && index.params.scrollList) { + index.scrollListToIndex(itemContent, itemIndex); + } + } + + previousIndex = itemIndex; + index.$el.trigger('listindex:select'); + index.emit('local::select listIndexSelect', index, itemContent, itemIndex); + } + + function handleTouchEnd() { + if (!isTouched) return; + isTouched = false; + isMoved = false; + + if (index.params.label) { + if ($labelEl) $labelEl.remove(); + $labelEl = undefined; + } + } + + var passiveListener = (0, _getSupport.getSupport)().passiveListener ? { + passive: true + } : false; + + index.attachEvents = function attachEvents() { + $el.parents('.tab').on('tab:show', handleResize); + $el.parents('.page').on('page:reinit', handleResize); + $el.parents('.panel').on('panel:open', handleResize); + $el.parents('.sheet-modal, .actions-modal, .popup, .popover, .login-screen, .dialog, .toast').on('modal:open', handleResize); + app.on('resize', handleResize); + $el.on('click', handleClick); + $el.on(app.touchEvents.start, handleTouchStart, passiveListener); + app.on('touchmove:active', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + }; + + index.detachEvents = function attachEvents() { + $el.parents('.tab').off('tab:show', handleResize); + $el.parents('.page').off('page:reinit', handleResize); + $el.parents('.panel').off('panel:open', handleResize); + $el.parents('.sheet-modal, .actions-modal, .popup, .popover, .login-screen, .dialog, .toast').off('modal:open', handleResize); + app.off('resize', handleResize); + $el.off('click', handleClick); + $el.off(app.touchEvents.start, handleTouchStart, passiveListener); + app.off('touchmove:active', handleTouchMove); + app.off('touchend:passive', handleTouchEnd); + }; // Init + + + index.init(); + return index || _assertThisInitialized(_this); + } // eslint-disable-next-line + + + var _proto = ListIndex.prototype; + + _proto.scrollListToIndex = function scrollListToIndex(itemContent, itemIndex) { + var index = this; + var $listEl = index.$listEl, + $pageContentEl = index.$pageContentEl, + app = index.app; + if (!$listEl || !$pageContentEl || $pageContentEl.length === 0) return index; + var $scrollToEl; + $listEl.find('.list-group-title, .item-divider').each(function (el) { + if ($scrollToEl) return; + var $el = (0, _dom.default)(el); + + if ($el.text() === itemContent) { + $scrollToEl = $el; + } + }); + if (!$scrollToEl || $scrollToEl.length === 0) return index; + var parentTop = $scrollToEl.parent().offset().top; + var paddingTop = parseInt($pageContentEl.css('padding-top'), 10); + var scrollTop = $pageContentEl[0].scrollTop; + var scrollToElTop = $scrollToEl.offset().top; + + if ($pageContentEl.parents('.page-with-navbar-large').length) { + var navbarInnerEl = app.navbar.getElByPage($pageContentEl.parents('.page-with-navbar-large').eq(0)); + var $titleLargeEl = (0, _dom.default)(navbarInnerEl).find('.title-large'); + + if ($titleLargeEl.length) { + paddingTop -= $titleLargeEl[0].offsetHeight || 0; + } + } + + if (parentTop <= paddingTop) { + $pageContentEl.scrollTop(parentTop + scrollTop - paddingTop); + } else { + $pageContentEl.scrollTop(scrollToElTop + scrollTop - paddingTop); + } + + return index; + }; + + _proto.renderSkipPlaceholder = function renderSkipPlaceholder() { + var index = this; + return index.params.renderSkipPlaceholder.call(index); + }; + + _proto.renderItem = function renderItem(itemContent, itemIndex) { + var index = this; + return index.params.renderItem.call(index, itemContent, itemIndex); + }; + + _proto.render = function render() { + var index = this; + var $ul = index.$ul, + indexes = index.indexes, + skipRate = index.skipRate; + var wasSkipped; + var html = indexes.map(function (itemContent, itemIndex) { + if (itemIndex % skipRate !== 0 && skipRate > 0) { + wasSkipped = true; + return ''; + } + + var itemHtml = index.renderItem(itemContent, itemIndex); + + if (wasSkipped) { + itemHtml = index.renderSkipPlaceholder() + itemHtml; + } + + wasSkipped = false; + return itemHtml; + }).join(''); + $ul.html(html); + return index; + }; + + _proto.calcSize = function calcSize() { + var index = this; + var app = index.app, + params = index.params, + el = index.el, + indexes = index.indexes; + var height = el.offsetHeight; + var itemHeight = params[app.theme + "ItemHeight"]; + var maxItems = Math.floor(height / itemHeight); + var items = indexes.length; + var skipRate = 0; + + if (items > maxItems) { + skipRate = Math.ceil((items * 2 - 1) / maxItems); + } + + index.height = height; + index.skipRate = skipRate; + return index; + }; + + _proto.calcIndexes = function calcIndexes() { + var index = this; + + if (index.params.indexes === 'auto') { + index.indexes = []; + index.$listEl.find('.list-group-title, .item-divider').each(function (el) { + var elContent = (0, _dom.default)(el).text(); + + if (index.indexes.indexOf(elContent) < 0) { + index.indexes.push(elContent); + } + }); + } else { + index.indexes = index.params.indexes; + } + + return index; + }; + + _proto.update = function update() { + var index = this; + index.calcIndexes(); + index.calcSize(); + index.render(); + return index; + }; + + _proto.init = function init() { + var index = this; + index.calcIndexes(); + index.calcSize(); + index.render(); + index.attachEvents(); + }; + + _proto.destroy = function destroy() { + var index = this; + index.$el.trigger('listindex:beforedestroy', index); + index.emit('local::beforeDestroy listIndexBeforeDestroy'); + index.detachEvents(); + + if (index.$el[0]) { + index.$el[0].f7ListIndex = null; + delete index.$el[0].f7ListIndex; + } + + (0, _utils.deleteProps)(index); + index = null; + }; + + return ListIndex; +}(_class.default); + +var _default = ListIndex; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/list-index/list-index.js b/www/assets/framework7/cjs/components/list-index/list-index.js new file mode 100644 index 000000000..cc61581ac --- /dev/null +++ b/www/assets/framework7/cjs/components/list-index/list-index.js @@ -0,0 +1,77 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _listIndexClass = _interopRequireDefault(require("./list-index-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'listIndex', + static: { + ListIndex: _listIndexClass.default + }, + create: function create() { + var app = this; + app.listIndex = (0, _constructorMethods.default)({ + defaultSelector: '.list-index', + constructor: _listIndexClass.default, + app: app, + domProp: 'f7ListIndex' + }); + }, + on: { + tabMounted: function tabMounted(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.list-index-init').each(function (listIndexEl) { + var params = (0, _utils.extend)((0, _dom.default)(listIndexEl).dataset(), { + el: listIndexEl + }); + app.listIndex.create(params); + }); + }, + tabBeforeRemove: function tabBeforeRemove(tabEl) { + (0, _dom.default)(tabEl).find('.list-index-init').each(function (listIndexEl) { + if (listIndexEl.f7ListIndex) listIndexEl.f7ListIndex.destroy(); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.list-index-init').each(function (listIndexEl) { + var params = (0, _utils.extend)((0, _dom.default)(listIndexEl).dataset(), { + el: listIndexEl + }); + app.listIndex.create(params); + }); + }, + pageBeforeRemove: function pageBeforeRemove(page) { + page.$el.find('.list-index-init').each(function (listIndexEl) { + if (listIndexEl.f7ListIndex) listIndexEl.f7ListIndex.destroy(); + }); + } + }, + vnode: { + 'list-index-init': { + insert: function insert(vnode) { + var app = this; + var listIndexEl = vnode.elm; + var params = (0, _utils.extend)((0, _dom.default)(listIndexEl).dataset(), { + el: listIndexEl + }); + app.listIndex.create(params); + }, + destroy: function destroy(vnode) { + var listIndexEl = vnode.elm; + if (listIndexEl.f7ListIndex) listIndexEl.f7ListIndex.destroy(); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/list/list.js b/www/assets/framework7/cjs/components/list/list.js new file mode 100644 index 000000000..e9b433065 --- /dev/null +++ b/www/assets/framework7/cjs/components/list/list.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _default = { + name: 'list' +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/login-screen/login-screen-class.js b/www/assets/framework7/cjs/components/login-screen/login-screen-class.js new file mode 100644 index 000000000..2b03a624a --- /dev/null +++ b/www/assets/framework7/cjs/components/login-screen/login-screen-class.js @@ -0,0 +1,68 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _modalClass = _interopRequireDefault(require("../modal/modal-class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var LoginScreen = /*#__PURE__*/function (_Modal) { + _inheritsLoose(LoginScreen, _Modal); + + function LoginScreen(app, params) { + var _this; + + var extendedParams = (0, _utils.extend)({ + on: {} + }, params); // Extends with open/close Modal methods; + + _this = _Modal.call(this, app, extendedParams) || this; + + var loginScreen = _assertThisInitialized(_this); + + loginScreen.params = extendedParams; // Find Element + + var $el; + + if (!loginScreen.params.el) { + $el = (0, _dom.default)(loginScreen.params.content).filter(function (node) { + return node.nodeType === 1; + }).eq(0); + } else { + $el = (0, _dom.default)(loginScreen.params.el).eq(0); + } + + if ($el && $el.length > 0 && $el[0].f7Modal) { + return $el[0].f7Modal || _assertThisInitialized(_this); + } + + if ($el.length === 0) { + return loginScreen.destroy() || _assertThisInitialized(_this); + } + + (0, _utils.extend)(loginScreen, { + app: app, + $el: $el, + el: $el[0], + type: 'loginScreen' + }); + $el[0].f7Modal = loginScreen; + return loginScreen || _assertThisInitialized(_this); + } + + return LoginScreen; +}(_modalClass.default); + +var _default = LoginScreen; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/login-screen/login-screen.js b/www/assets/framework7/cjs/components/login-screen/login-screen.js new file mode 100644 index 000000000..a5c2a0460 --- /dev/null +++ b/www/assets/framework7/cjs/components/login-screen/login-screen.js @@ -0,0 +1,44 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _loginScreenClass = _interopRequireDefault(require("./login-screen-class")); + +var _modalMethods = _interopRequireDefault(require("../../shared/modal-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'loginScreen', + static: { + LoginScreen: _loginScreenClass.default + }, + create: function create() { + var app = this; + app.loginScreen = (0, _modalMethods.default)({ + app: app, + constructor: _loginScreenClass.default, + defaultSelector: '.login-screen.modal-in' + }); + }, + clicks: { + '.login-screen-open': function openLoginScreen($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.loginScreen.open(data.loginScreen, data.animate, $clickedEl); + }, + '.login-screen-close': function closeLoginScreen($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.loginScreen.close(data.loginScreen, data.animate, $clickedEl); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/menu/menu.js b/www/assets/framework7/cjs/components/menu/menu.js new file mode 100644 index 000000000..1daf0ba2c --- /dev/null +++ b/www/assets/framework7/cjs/components/menu/menu.js @@ -0,0 +1,92 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Menu = { + open: function open(el) { + if (el === void 0) { + el = '.menu-item-dropdown'; + } + + var app = this; + if (!el) return; + var $el = (0, _dom.default)(el).closest('.menu-item-dropdown'); + if (!$el.length) return; + var $menuEl = $el.closest('.menu').eq(0); + + if ($menuEl.length) { + var zIndex = $menuEl.css('z-index'); + var originalZIndex = $menuEl[0].style.zIndex; + $menuEl.css('z-index', parseInt(zIndex || 0, 10) + 1); + $menuEl[0].f7MenuZIndex = originalZIndex; + } + + $el.eq(0).addClass('menu-item-dropdown-opened').trigger('menu:opened'); + app.emit('menuOpened', $el.eq(0)[0]); + }, + close: function close(el) { + if (el === void 0) { + el = '.menu-item-dropdown-opened'; + } + + var app = this; + if (!el) return; + var $el = (0, _dom.default)(el).closest('.menu-item-dropdown-opened'); + if (!$el.length) return; + var $menuEl = $el.closest('.menu').eq(0); + + if ($menuEl.length) { + var zIndex = $menuEl[0].f7MenuZIndex; + $menuEl.css('z-index', zIndex); + delete $menuEl[0].f7MenuZIndex; + } + + $el.eq(0).removeClass('menu-item-dropdown-opened').trigger('menu:closed'); + app.emit('menuClosed', $el.eq(0)[0]); + } +}; +var _default = { + name: 'menu', + create: function create() { + var app = this; + (0, _utils.bindMethods)(app, { + menu: Menu + }); + }, + on: { + click: function click(e) { + var app = this; + var openedMenus = (0, _dom.default)('.menu-item-dropdown-opened'); + if (!openedMenus.length) return; + openedMenus.each(function (el) { + if (!(0, _dom.default)(e.target).closest('.menu-item-dropdown-opened').length) { + app.menu.close(el); + } + }); + } + }, + clicks: { + '.menu-item-dropdown': function onClick($clickedEl, dataset, e) { + var app = this; + + if ($clickedEl.hasClass('menu-item-dropdown-opened')) { + if ((0, _dom.default)(e.target).closest('.menu-dropdown').length) return; + app.menu.close($clickedEl); + } else { + app.menu.open($clickedEl); + } + }, + '.menu-close': function onClick() { + var app = this; + app.menu.close(); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/messagebar/messagebar-class.js b/www/assets/framework7/cjs/components/messagebar/messagebar-class.js new file mode 100644 index 000000000..d5a32b2b0 --- /dev/null +++ b/www/assets/framework7/cjs/components/messagebar/messagebar-class.js @@ -0,0 +1,446 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Messagebar = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(Messagebar, _Framework7Class); + + function Messagebar(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params, [app]) || this; + + var messagebar = _assertThisInitialized(_this); + + var defaults = { + top: false, + topOffset: 0, + bottomOffset: 0, + attachments: [], + renderAttachments: undefined, + renderAttachment: undefined, + maxHeight: null, + resizePage: true + }; // Extend defaults with modules params + + messagebar.useModulesParams(defaults); + messagebar.params = (0, _utils.extend)(defaults, params); // El + + var $el = (0, _dom.default)(messagebar.params.el); + if ($el.length === 0) return messagebar || _assertThisInitialized(_this); + if ($el[0].f7Messagebar) return $el[0].f7Messagebar || _assertThisInitialized(_this); + $el[0].f7Messagebar = messagebar; // Page and PageContent + + var $pageEl = $el.parents('.page').eq(0); + var $pageContentEl = $pageEl.find('.page-content').eq(0); // Area + + var $areaEl = $el.find('.messagebar-area'); // Textarea + + var $textareaEl; + + if (messagebar.params.textareaEl) { + $textareaEl = (0, _dom.default)(messagebar.params.textareaEl); + } else { + $textareaEl = $el.find('textarea'); + } // Attachments & Library + + + var $attachmentsEl = $el.find('.messagebar-attachments'); + var $sheetEl = $el.find('.messagebar-sheet'); + + if (messagebar.params.top) { + $el.addClass('messagebar-top'); + } + + (0, _utils.extend)(messagebar, { + $el: $el, + el: $el[0], + $areaEl: $areaEl, + areaEl: $areaEl[0], + $textareaEl: $textareaEl, + textareaEl: $textareaEl[0], + $attachmentsEl: $attachmentsEl, + attachmentsEl: $attachmentsEl[0], + attachmentsVisible: $attachmentsEl.hasClass('messagebar-attachments-visible'), + $sheetEl: $sheetEl, + sheetEl: $sheetEl[0], + sheetVisible: $sheetEl.hasClass('messagebar-sheet-visible'), + $pageEl: $pageEl, + pageEl: $pageEl[0], + $pageContentEl: $pageContentEl, + pageContentEl: $pageContentEl, + top: $el.hasClass('messagebar-top') || messagebar.params.top, + attachments: [] + }); // Events + + function onAppResize() { + if (messagebar.params.resizePage) { + messagebar.resizePage(); + } + } + + function onSubmit(e) { + e.preventDefault(); + } + + function onAttachmentClick(e) { + var index = (0, _dom.default)(this).index(); + + if ((0, _dom.default)(e.target).closest('.messagebar-attachment-delete').length) { + (0, _dom.default)(this).trigger('messagebar:attachmentdelete', index); + messagebar.emit('local::attachmentDelete messagebarAttachmentDelete', messagebar, this, index); + } else { + (0, _dom.default)(this).trigger('messagebar:attachmentclick', index); + messagebar.emit('local::attachmentClick messagebarAttachmentClick', messagebar, this, index); + } + } + + function onTextareaChange() { + messagebar.checkEmptyState(); + messagebar.$el.trigger('messagebar:change'); + messagebar.emit('local::change messagebarChange', messagebar); + } + + function onTextareaFocus() { + messagebar.sheetHide(); + messagebar.$el.addClass('messagebar-focused'); + messagebar.$el.trigger('messagebar:focus'); + messagebar.emit('local::focus messagebarFocus', messagebar); + } + + function onTextareaBlur() { + messagebar.$el.removeClass('messagebar-focused'); + messagebar.$el.trigger('messagebar:blur'); + messagebar.emit('local::blur messagebarBlur', messagebar); + } + + messagebar.attachEvents = function attachEvents() { + $el.on('textarea:resize', onAppResize); + $el.on('submit', onSubmit); + $el.on('click', '.messagebar-attachment', onAttachmentClick); + $textareaEl.on('change input', onTextareaChange); + $textareaEl.on('focus', onTextareaFocus); + $textareaEl.on('blur', onTextareaBlur); + app.on('resize', onAppResize); + }; + + messagebar.detachEvents = function detachEvents() { + $el.off('textarea:resize', onAppResize); + $el.off('submit', onSubmit); + $el.off('click', '.messagebar-attachment', onAttachmentClick); + $textareaEl.off('change input', onTextareaChange); + $textareaEl.off('focus', onTextareaFocus); + $textareaEl.off('blur', onTextareaBlur); + app.off('resize', onAppResize); + }; // Install Modules + + + messagebar.useModules(); // Init + + messagebar.init(); + return messagebar || _assertThisInitialized(_this); + } + + var _proto = Messagebar.prototype; + + _proto.focus = function focus() { + var messagebar = this; + messagebar.$textareaEl.focus(); + return messagebar; + }; + + _proto.blur = function blur() { + var messagebar = this; + messagebar.$textareaEl.blur(); + return messagebar; + }; + + _proto.clear = function clear() { + var messagebar = this; + messagebar.$textareaEl.val('').trigger('change'); + return messagebar; + }; + + _proto.getValue = function getValue() { + var messagebar = this; + return messagebar.$textareaEl.val().trim(); + }; + + _proto.setValue = function setValue(value) { + var messagebar = this; + messagebar.$textareaEl.val(value).trigger('change'); + return messagebar; + }; + + _proto.setPlaceholder = function setPlaceholder(placeholder) { + var messagebar = this; + messagebar.$textareaEl.attr('placeholder', placeholder); + return messagebar; + }; + + _proto.resizePage = function resizePage() { + var messagebar = this; + var params = messagebar.params, + $el = messagebar.$el, + top = messagebar.top, + $pageEl = messagebar.$pageEl, + $pageContentEl = messagebar.$pageContentEl, + $areaEl = messagebar.$areaEl, + $textareaEl = messagebar.$textareaEl, + $sheetEl = messagebar.$sheetEl, + $attachmentsEl = messagebar.$attachmentsEl; + var elHeight = $el[0].offsetHeight; + var maxHeight = params.maxHeight; + + if (top) { + /* + Disable at the moment + const requiredPaddingTop = elHeight + params.topOffset; + const currentPaddingTop = parseInt($pageContentEl.css('padding-top'), 10); + if (requiredPaddingTop !== currentPaddingTop) { + if (!maxHeight) { + maxHeight = $pageEl[0].offsetHeight - currentPaddingTop - $sheetEl.outerHeight() - $attachmentsEl.outerHeight() - parseInt($areaEl.css('margin-top'), 10) - parseInt($areaEl.css('margin-bottom'), 10); + } + $textareaEl.css('max-height', `${maxHeight}px`); + $pageContentEl.css('padding-top', `${requiredPaddingTop}px`); + $el.trigger('messagebar:resizePage'); + messagebar.emit('local::resizepage messagebarResizePage'); + } + */ + } else { + var currentPaddingBottom = parseInt($pageContentEl.css('padding-bottom'), 10); + var requiredPaddingBottom = elHeight + params.bottomOffset; + + if (requiredPaddingBottom !== currentPaddingBottom && $pageContentEl.length) { + var currentPaddingTop = parseInt($pageContentEl.css('padding-top'), 10); + var pageScrollHeight = $pageContentEl[0].scrollHeight; + var pageOffsetHeight = $pageContentEl[0].offsetHeight; + var pageScrollTop = $pageContentEl[0].scrollTop; + var scrollOnBottom = pageScrollTop === pageScrollHeight - pageOffsetHeight; + + if (!maxHeight) { + maxHeight = $pageEl[0].offsetHeight - currentPaddingTop - $sheetEl.outerHeight() - $attachmentsEl.outerHeight() - parseInt($areaEl.css('margin-top'), 10) - parseInt($areaEl.css('margin-bottom'), 10); + } + + $textareaEl.css('max-height', maxHeight + "px"); + $pageContentEl.css('padding-bottom', requiredPaddingBottom + "px"); + + if (scrollOnBottom) { + $pageContentEl.scrollTop($pageContentEl[0].scrollHeight - pageOffsetHeight); + } + + $el.trigger('messagebar:resizepage'); + messagebar.emit('local::resizePage messagebarResizePage', messagebar); + } + } + }; + + _proto.checkEmptyState = function checkEmptyState() { + var messagebar = this; + var $el = messagebar.$el, + $textareaEl = messagebar.$textareaEl; + var value = $textareaEl.val().trim(); + + if (value && value.length) { + $el.addClass('messagebar-with-value'); + } else { + $el.removeClass('messagebar-with-value'); + } + }; + + _proto.attachmentsCreate = function attachmentsCreate(innerHTML) { + if (innerHTML === void 0) { + innerHTML = ''; + } + + var messagebar = this; + var $attachmentsEl = (0, _dom.default)("
    " + innerHTML + "
    "); + $attachmentsEl.insertBefore(messagebar.$textareaEl); + (0, _utils.extend)(messagebar, { + $attachmentsEl: $attachmentsEl, + attachmentsEl: $attachmentsEl[0] + }); + return messagebar; + }; + + _proto.attachmentsShow = function attachmentsShow(innerHTML) { + if (innerHTML === void 0) { + innerHTML = ''; + } + + var messagebar = this; + messagebar.$attachmentsEl = messagebar.$el.find('.messagebar-attachments'); + + if (messagebar.$attachmentsEl.length === 0) { + messagebar.attachmentsCreate(innerHTML); + } + + messagebar.$el.addClass('messagebar-attachments-visible'); + messagebar.attachmentsVisible = true; + + if (messagebar.params.resizePage) { + messagebar.resizePage(); + } + + return messagebar; + }; + + _proto.attachmentsHide = function attachmentsHide() { + var messagebar = this; + messagebar.$el.removeClass('messagebar-attachments-visible'); + messagebar.attachmentsVisible = false; + + if (messagebar.params.resizePage) { + messagebar.resizePage(); + } + + return messagebar; + }; + + _proto.attachmentsToggle = function attachmentsToggle() { + var messagebar = this; + + if (messagebar.attachmentsVisible) { + messagebar.attachmentsHide(); + } else { + messagebar.attachmentsShow(); + } + + return messagebar; + }; + + _proto.renderAttachment = function renderAttachment(attachment) { + var messagebar = this; + + if (messagebar.params.renderAttachment) { + return messagebar.params.renderAttachment.call(messagebar, attachment); + } + + return "\n
    \n \n \n
    \n "; + }; + + _proto.renderAttachments = function renderAttachments() { + var messagebar = this; + var html; + + if (messagebar.params.renderAttachments) { + html = messagebar.params.renderAttachments.call(messagebar, messagebar.attachments); + } else { + html = "" + messagebar.attachments.map(function (attachment) { + return messagebar.renderAttachment(attachment); + }).join(''); + } + + if (messagebar.$attachmentsEl.length === 0) { + messagebar.attachmentsCreate(html); + } else { + messagebar.$attachmentsEl.html(html); + } + }; + + _proto.sheetCreate = function sheetCreate(innerHTML) { + if (innerHTML === void 0) { + innerHTML = ''; + } + + var messagebar = this; + var $sheetEl = (0, _dom.default)("
    " + innerHTML + "
    "); + messagebar.$el.append($sheetEl); + (0, _utils.extend)(messagebar, { + $sheetEl: $sheetEl, + sheetEl: $sheetEl[0] + }); + return messagebar; + }; + + _proto.sheetShow = function sheetShow(innerHTML) { + if (innerHTML === void 0) { + innerHTML = ''; + } + + var messagebar = this; + messagebar.$sheetEl = messagebar.$el.find('.messagebar-sheet'); + + if (messagebar.$sheetEl.length === 0) { + messagebar.sheetCreate(innerHTML); + } + + messagebar.$el.addClass('messagebar-sheet-visible'); + messagebar.sheetVisible = true; + + if (messagebar.params.resizePage) { + messagebar.resizePage(); + } + + return messagebar; + }; + + _proto.sheetHide = function sheetHide() { + var messagebar = this; + messagebar.$el.removeClass('messagebar-sheet-visible'); + messagebar.sheetVisible = false; + + if (messagebar.params.resizePage) { + messagebar.resizePage(); + } + + return messagebar; + }; + + _proto.sheetToggle = function sheetToggle() { + var messagebar = this; + + if (messagebar.sheetVisible) { + messagebar.sheetHide(); + } else { + messagebar.sheetShow(); + } + + return messagebar; + }; + + _proto.init = function init() { + var messagebar = this; + messagebar.attachEvents(); + messagebar.checkEmptyState(); + return messagebar; + }; + + _proto.destroy = function destroy() { + var messagebar = this; + messagebar.emit('local::beforeDestroy messagebarBeforeDestroy', messagebar); + messagebar.$el.trigger('messagebar:beforedestroy'); + messagebar.detachEvents(); + + if (messagebar.$el[0]) { + messagebar.$el[0].f7Messagebar = null; + delete messagebar.$el[0].f7Messagebar; + } + + (0, _utils.deleteProps)(messagebar); + }; + + return Messagebar; +}(_class.default); + +var _default = Messagebar; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/messagebar/messagebar.js b/www/assets/framework7/cjs/components/messagebar/messagebar.js new file mode 100644 index 000000000..701cda02b --- /dev/null +++ b/www/assets/framework7/cjs/components/messagebar/messagebar.js @@ -0,0 +1,78 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _messagebarClass = _interopRequireDefault(require("./messagebar-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'messagebar', + static: { + Messagebar: _messagebarClass.default + }, + create: function create() { + var app = this; + app.messagebar = (0, _constructorMethods.default)({ + defaultSelector: '.messagebar', + constructor: _messagebarClass.default, + app: app, + domProp: 'f7Messagebar', + addMethods: 'clear getValue setValue setPlaceholder resizePage focus blur attachmentsCreate attachmentsShow attachmentsHide attachmentsToggle renderAttachments sheetCreate sheetShow sheetHide sheetToggle'.split(' ') + }); + }, + on: { + tabBeforeRemove: function tabBeforeRemove(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.messagebar-init').each(function (messagebarEl) { + app.messagebar.destroy(messagebarEl); + }); + }, + tabMounted: function tabMounted(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.messagebar-init').each(function (messagebarEl) { + app.messagebar.create((0, _utils.extend)({ + el: messagebarEl + }, (0, _dom.default)(messagebarEl).dataset())); + }); + }, + pageBeforeRemove: function pageBeforeRemove(page) { + var app = this; + page.$el.find('.messagebar-init').each(function (messagebarEl) { + app.messagebar.destroy(messagebarEl); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.messagebar-init').each(function (messagebarEl) { + app.messagebar.create((0, _utils.extend)({ + el: messagebarEl + }, (0, _dom.default)(messagebarEl).dataset())); + }); + } + }, + vnode: { + 'messagebar-init': { + insert: function insert(vnode) { + var app = this; + var messagebarEl = vnode.elm; + app.messagebar.create((0, _utils.extend)({ + el: messagebarEl + }, (0, _dom.default)(messagebarEl).dataset())); + }, + destroy: function destroy(vnode) { + var app = this; + var messagebarEl = vnode.elm; + app.messagebar.destroy(messagebarEl); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/messages/messages-class.js b/www/assets/framework7/cjs/components/messages/messages-class.js new file mode 100644 index 000000000..b49146763 --- /dev/null +++ b/www/assets/framework7/cjs/components/messages/messages-class.js @@ -0,0 +1,633 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _$jsx = _interopRequireDefault(require("../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Messages = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(Messages, _Framework7Class); + + function Messages(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params, [app]) || this; + + var m = _assertThisInitialized(_this); + + var defaults = { + autoLayout: true, + messages: [], + newMessagesFirst: false, + scrollMessages: true, + scrollMessagesOnEdge: true, + firstMessageRule: undefined, + lastMessageRule: undefined, + tailMessageRule: undefined, + sameNameMessageRule: undefined, + sameHeaderMessageRule: undefined, + sameFooterMessageRule: undefined, + sameAvatarMessageRule: undefined, + customClassMessageRule: undefined, + renderMessage: undefined + }; // Extend defaults with modules params + + m.useModulesParams(defaults); + m.params = (0, _utils.extend)(defaults, params); + var $el = (0, _dom.default)(params.el).eq(0); + if ($el.length === 0) return m || _assertThisInitialized(_this); + if ($el[0].f7Messages) return $el[0].f7Messages || _assertThisInitialized(_this); + $el[0].f7Messages = m; + var $pageContentEl = $el.closest('.page-content').eq(0); + (0, _utils.extend)(m, { + messages: m.params.messages, + $el: $el, + el: $el[0], + $pageContentEl: $pageContentEl, + pageContentEl: $pageContentEl[0] + }); // Install Modules + + m.useModules(); // Init + + m.init(); + return m || _assertThisInitialized(_this); + } // eslint-disable-next-line + + + var _proto = Messages.prototype; + + _proto.getMessageData = function getMessageData(messageEl) { + var $messageEl = (0, _dom.default)(messageEl); + var data = { + name: $messageEl.find('.message-name').html(), + header: $messageEl.find('.message-header').html(), + textHeader: $messageEl.find('.message-text-header').html(), + textFooter: $messageEl.find('.message-text-footer').html(), + footer: $messageEl.find('.message-footer').html(), + isTitle: $messageEl.hasClass('messages-title'), + type: $messageEl.hasClass('message-sent') ? 'sent' : 'received', + text: $messageEl.find('.message-text').html(), + image: $messageEl.find('.message-image').html(), + imageSrc: $messageEl.find('.message-image img').attr('src'), + typing: $messageEl.hasClass('message-typing') + }; + + if (data.isTitle) { + data.text = $messageEl.html(); + } + + if (data.text && data.textHeader) { + data.text = data.text.replace("
    " + data.textHeader + "
    ", ''); + } + + if (data.text && data.textFooter) { + data.text = data.text.replace("
    " + data.textFooter + "
    ", ''); + } + + var avatar = $messageEl.find('.message-avatar').css('background-image'); + if (avatar === 'none' || avatar === '') avatar = undefined; + + if (avatar && typeof avatar === 'string') { + avatar = avatar.replace('url(', '').replace(')', '').replace(/"/g, '').replace(/'/g, ''); + } else { + avatar = undefined; + } + + data.avatar = avatar; + return data; + }; + + _proto.getMessagesData = function getMessagesData() { + var m = this; + var data = []; + m.$el.find('.message, .messages-title').each(function (messageEl) { + data.push(m.getMessageData(messageEl)); + }); + return data; + }; + + _proto.renderMessage = function renderMessage(messageToRender) { + var m = this; + var message = (0, _utils.extend)({ + type: 'sent', + attrs: {} + }, messageToRender); + + if (m.params.renderMessage) { + return m.params.renderMessage.call(m, message); + } + + if (message.isTitle) { + return "
    " + message.text + "
    "; + } + + return (0, _$jsx.default)("div", _extends({ + class: "message message-" + message.type + " " + (message.isTyping ? 'message-typing' : '') + " " + (message.cssClass || '') + }, message.attrs), message.avatar && (0, _$jsx.default)("div", { + class: "message-avatar", + style: "background-image:url(" + message.avatar + ")" + }), (0, _$jsx.default)("div", { + class: "message-content" + }, message.name && (0, _$jsx.default)("div", { + class: "message-name" + }, message.name), message.header && (0, _$jsx.default)("div", { + class: "message-header" + }, message.header), (0, _$jsx.default)("div", { + class: "message-bubble" + }, message.textHeader && (0, _$jsx.default)("div", { + class: "message-text-header" + }, message.textHeader), message.image && (0, _$jsx.default)("div", { + class: "message-image" + }, message.image), message.imageSrc && !message.image && (0, _$jsx.default)("div", { + class: "message-image" + }, (0, _$jsx.default)("img", { + src: message.imageSrc + })), (message.text || message.isTyping) && (0, _$jsx.default)("div", { + class: "message-text" + }, message.text || '', message.isTyping && (0, _$jsx.default)("div", { + class: "message-typing-indicator" + }, (0, _$jsx.default)("div", null), (0, _$jsx.default)("div", null), (0, _$jsx.default)("div", null))), message.textFooter && (0, _$jsx.default)("div", { + class: "message-text-footer" + }, message.textFooter)), message.footer && (0, _$jsx.default)("div", { + class: "message-footer" + }, message.footer))); + }; + + _proto.renderMessages = function renderMessages(messagesToRender, method) { + if (messagesToRender === void 0) { + messagesToRender = this.messages; + } + + if (method === void 0) { + method = this.params.newMessagesFirst ? 'prepend' : 'append'; + } + + var m = this; + var html = messagesToRender.map(function (message) { + return m.renderMessage(message); + }).join(''); + m.$el[method](html); + }; + + _proto.isFirstMessage = function isFirstMessage() { + var _m$params; + + var m = this; + if (m.params.firstMessageRule) return (_m$params = m.params).firstMessageRule.apply(_m$params, arguments); + return false; + }; + + _proto.isLastMessage = function isLastMessage() { + var _m$params2; + + var m = this; + if (m.params.lastMessageRule) return (_m$params2 = m.params).lastMessageRule.apply(_m$params2, arguments); + return false; + }; + + _proto.isTailMessage = function isTailMessage() { + var _m$params3; + + var m = this; + if (m.params.tailMessageRule) return (_m$params3 = m.params).tailMessageRule.apply(_m$params3, arguments); + return false; + }; + + _proto.isSameNameMessage = function isSameNameMessage() { + var _m$params4; + + var m = this; + if (m.params.sameNameMessageRule) return (_m$params4 = m.params).sameNameMessageRule.apply(_m$params4, arguments); + return false; + }; + + _proto.isSameHeaderMessage = function isSameHeaderMessage() { + var _m$params5; + + var m = this; + if (m.params.sameHeaderMessageRule) return (_m$params5 = m.params).sameHeaderMessageRule.apply(_m$params5, arguments); + return false; + }; + + _proto.isSameFooterMessage = function isSameFooterMessage() { + var _m$params6; + + var m = this; + if (m.params.sameFooterMessageRule) return (_m$params6 = m.params).sameFooterMessageRule.apply(_m$params6, arguments); + return false; + }; + + _proto.isSameAvatarMessage = function isSameAvatarMessage() { + var _m$params7; + + var m = this; + if (m.params.sameAvatarMessageRule) return (_m$params7 = m.params).sameAvatarMessageRule.apply(_m$params7, arguments); + return false; + }; + + _proto.isCustomClassMessage = function isCustomClassMessage() { + var _m$params8; + + var m = this; + if (m.params.customClassMessageRule) return (_m$params8 = m.params).customClassMessageRule.apply(_m$params8, arguments); + return undefined; + }; + + _proto.layout = function layout() { + var m = this; + m.$el.find('.message, .messages-title').each(function (messageEl, index) { + var $messageEl = (0, _dom.default)(messageEl); + + if (!m.messages) { + m.messages = m.getMessagesData(); + } + + var classes = []; + var message = m.messages[index]; + var previousMessage = m.messages[index - 1]; + var nextMessage = m.messages[index + 1]; + + if (m.isFirstMessage(message, previousMessage, nextMessage)) { + classes.push('message-first'); + } + + if (m.isLastMessage(message, previousMessage, nextMessage)) { + classes.push('message-last'); + } + + if (m.isTailMessage(message, previousMessage, nextMessage)) { + classes.push('message-tail'); + } + + if (m.isSameNameMessage(message, previousMessage, nextMessage)) { + classes.push('message-same-name'); + } + + if (m.isSameHeaderMessage(message, previousMessage, nextMessage)) { + classes.push('message-same-header'); + } + + if (m.isSameFooterMessage(message, previousMessage, nextMessage)) { + classes.push('message-same-footer'); + } + + if (m.isSameAvatarMessage(message, previousMessage, nextMessage)) { + classes.push('message-same-avatar'); + } + + var customMessageClasses = m.isCustomClassMessage(message, previousMessage, nextMessage); + + if (customMessageClasses && customMessageClasses.length) { + if (typeof customMessageClasses === 'string') { + customMessageClasses = customMessageClasses.split(' '); + } + + customMessageClasses.forEach(function (customClass) { + classes.push(customClass); + }); + } + + $messageEl.removeClass('message-first message-last message-tail message-same-name message-same-header message-same-footer message-same-avatar'); + classes.forEach(function (className) { + $messageEl.addClass(className); + }); + }); + }; + + _proto.clear = function clear() { + var m = this; + m.messages = []; + m.$el.html(''); + }; + + _proto.removeMessage = function removeMessage(messageToRemove, layout) { + if (layout === void 0) { + layout = true; + } + + var m = this; // Index or El + + var index; + var $el; + + if (typeof messageToRemove === 'number') { + index = messageToRemove; + $el = m.$el.find('.message, .messages-title').eq(index); + } else if (m.messages && m.messages.indexOf(messageToRemove) >= 0) { + index = m.messages.indexOf(messageToRemove); + $el = m.$el.children().eq(index); + } else { + $el = (0, _dom.default)(messageToRemove); + index = $el.index(); + } + + if ($el.length === 0) { + return m; + } + + $el.remove(); + m.messages.splice(index, 1); + if (m.params.autoLayout && layout) m.layout(); + return m; + }; + + _proto.removeMessages = function removeMessages(messagesToRemove, layout) { + if (layout === void 0) { + layout = true; + } + + var m = this; + + if (Array.isArray(messagesToRemove)) { + var messagesToRemoveEls = []; + messagesToRemove.forEach(function (messageToRemoveIndex) { + messagesToRemoveEls.push(m.$el.find('.message, .messages-title').eq(messageToRemoveIndex)); + }); + messagesToRemoveEls.forEach(function (messageToRemove) { + m.removeMessage(messageToRemove, false); + }); + } else { + (0, _dom.default)(messagesToRemove).each(function (messageToRemove) { + m.removeMessage(messageToRemove, false); + }); + } + + if (m.params.autoLayout && layout) m.layout(); + return m; + }; + + _proto.addMessage = function addMessage() { + var m = this; + var messageToAdd; + var animate; + var method; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + if (typeof args[1] === 'boolean') { + messageToAdd = args[0]; + animate = args[1]; + method = args[2]; + } else { + messageToAdd = args[0]; + method = args[1]; + animate = args[2]; + } + + if (typeof animate === 'undefined') { + animate = true; + } + + if (typeof method === 'undefined') { + method = m.params.newMessagesFirst ? 'prepend' : 'append'; + } + + return m.addMessages([messageToAdd], animate, method); + }; + + _proto.setScrollData = function setScrollData() { + var m = this; // Define scroll positions before new messages added + + var scrollHeightBefore = m.pageContentEl.scrollHeight; + var heightBefore = m.pageContentEl.offsetHeight; + var scrollBefore = m.pageContentEl.scrollTop; + m.scrollData = { + scrollHeightBefore: scrollHeightBefore, + heightBefore: heightBefore, + scrollBefore: scrollBefore + }; + return { + scrollHeightBefore: scrollHeightBefore, + heightBefore: heightBefore, + scrollBefore: scrollBefore + }; + }; + + _proto.addMessages = function addMessages() { + var m = this; + var messagesToAdd; + var animate; + var method; + + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + if (typeof args[1] === 'boolean') { + messagesToAdd = args[0]; + animate = args[1]; + method = args[2]; + } else { + messagesToAdd = args[0]; + method = args[1]; + animate = args[2]; + } + + if (typeof animate === 'undefined') { + animate = true; + } + + if (typeof method === 'undefined') { + method = m.params.newMessagesFirst ? 'prepend' : 'append'; + } + + var _m$setScrollData = m.setScrollData(), + scrollHeightBefore = _m$setScrollData.scrollHeightBefore, + scrollBefore = _m$setScrollData.scrollBefore; // Add message to DOM and data + + + var messagesHTML = ''; + var typingMessage = m.messages.filter(function (el) { + return el.isTyping; + })[0]; + messagesToAdd.forEach(function (messageToAdd) { + if (typingMessage) { + if (method === 'append') { + m.messages.splice(m.messages.indexOf(typingMessage), 0, messageToAdd); + } else { + m.messages.splice(m.messages.indexOf(typingMessage) + 1, 0, messageToAdd); + } + } else { + m.messages[method === 'append' ? 'push' : 'unshift'](messageToAdd); + } + + messagesHTML += m.renderMessage(messageToAdd); + }); + var $messagesEls = (0, _dom.default)(messagesHTML); + + if (animate) { + if (method === 'append' && !m.params.newMessagesFirst) { + $messagesEls.addClass('message-appear-from-bottom'); + } + + if (method === 'prepend' && m.params.newMessagesFirst) { + $messagesEls.addClass('message-appear-from-top'); + } + } + + if (typingMessage) { + if (method === 'append') { + $messagesEls.insertBefore(m.$el.find('.message-typing')); + } else { + $messagesEls.insertAfter(m.$el.find('.message-typing')); + } + } else { + m.$el[method]($messagesEls); + } // Layout + + + if (m.params.autoLayout) m.layout(); + + if (method === 'prepend' && !typingMessage) { + m.pageContentEl.scrollTop = scrollBefore + (m.pageContentEl.scrollHeight - scrollHeightBefore); + } + + if (m.params.scrollMessages && (method === 'append' && !m.params.newMessagesFirst || method === 'prepend' && m.params.newMessagesFirst && !typingMessage)) { + m.scrollWithEdgeCheck(animate); + } + + return m; + }; + + _proto.showTyping = function showTyping(message) { + if (message === void 0) { + message = {}; + } + + var m = this; + var typingMessage = m.messages.filter(function (el) { + return el.isTyping; + })[0]; + + if (typingMessage) { + m.removeMessage(m.messages.indexOf(typingMessage)); + } + + m.addMessage((0, _utils.extend)({ + type: 'received', + isTyping: true + }, message)); + return m; + }; + + _proto.hideTyping = function hideTyping() { + var m = this; + var typingMessageIndex; + var typingFound; + m.messages.forEach(function (message, index) { + if (message.isTyping) typingMessageIndex = index; + }); + + if (typeof typingMessageIndex !== 'undefined') { + if (m.$el.find('.message').eq(typingMessageIndex).hasClass('message-typing')) { + typingFound = true; + m.removeMessage(typingMessageIndex); + } + } + + if (!typingFound) { + var $typingMessageEl = m.$el.find('.message-typing'); + + if ($typingMessageEl.length) { + m.removeMessage($typingMessageEl); + } + } + + return m; + }; + + _proto.scrollWithEdgeCheck = function scrollWithEdgeCheck(animate) { + var m = this; + var _m$scrollData = m.scrollData, + scrollBefore = _m$scrollData.scrollBefore, + scrollHeightBefore = _m$scrollData.scrollHeightBefore, + heightBefore = _m$scrollData.heightBefore; + + if (m.params.scrollMessagesOnEdge) { + var onEdge = false; + + if (m.params.newMessagesFirst && scrollBefore === 0) { + onEdge = true; + } + + if (!m.params.newMessagesFirst && scrollBefore - (scrollHeightBefore - heightBefore) >= -10) { + onEdge = true; + } + + if (onEdge) m.scroll(animate ? undefined : 0); + } else { + m.scroll(animate ? undefined : 0); + } + }; + + _proto.scroll = function scroll(duration, scrollTop) { + if (duration === void 0) { + duration = 300; + } + + var m = this; + var currentScroll = m.pageContentEl.scrollTop; + var newScrollTop; + if (typeof scrollTop !== 'undefined') newScrollTop = scrollTop;else { + newScrollTop = m.params.newMessagesFirst ? 0 : m.pageContentEl.scrollHeight - m.pageContentEl.offsetHeight; + if (newScrollTop === currentScroll) return m; + } + m.$pageContentEl.scrollTop(newScrollTop, duration); + return m; + }; + + _proto.init = function init() { + var m = this; + + if (!m.messages || m.messages.length === 0) { + m.messages = m.getMessagesData(); + } + + if (m.params.messages && m.params.messages.length) { + m.renderMessages(); + } + + if (m.params.autoLayout) m.layout(); + if (m.params.scrollMessages) m.scroll(0); + }; + + _proto.destroy = function destroy() { + var m = this; + m.emit('local::beforeDestroy messagesBeforeDestroy', m); + m.$el.trigger('messages:beforedestroy'); + + if (m.$el[0]) { + m.$el[0].f7Messages = null; + delete m.$el[0].f7Messages; + } + + (0, _utils.deleteProps)(m); + }; + + return Messages; +}(_class.default); + +var _default = Messages; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/messages/messages.js b/www/assets/framework7/cjs/components/messages/messages.js new file mode 100644 index 000000000..57699124d --- /dev/null +++ b/www/assets/framework7/cjs/components/messages/messages.js @@ -0,0 +1,76 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _messagesClass = _interopRequireDefault(require("./messages-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'messages', + static: { + Messages: _messagesClass.default + }, + create: function create() { + var app = this; + app.messages = (0, _constructorMethods.default)({ + defaultSelector: '.messages', + constructor: _messagesClass.default, + app: app, + domProp: 'f7Messages', + addMethods: 'renderMessages layout scroll clear removeMessage removeMessages addMessage addMessages'.split(' ') + }); + }, + on: { + tabBeforeRemove: function tabBeforeRemove(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.messages-init').each(function (messagesEl) { + app.messages.destroy(messagesEl); + }); + }, + tabMounted: function tabMounted(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.messages-init').each(function (messagesEl) { + app.messages.create({ + el: messagesEl + }); + }); + }, + pageBeforeRemove: function pageBeforeRemove(page) { + var app = this; + page.$el.find('.messages-init').each(function (messagesEl) { + app.messages.destroy(messagesEl); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.messages-init').each(function (messagesEl) { + app.messages.create({ + el: messagesEl + }); + }); + } + }, + vnode: { + 'messages-init': { + insert: function insert(vnode) { + var app = this; + var messagesEl = vnode.elm; + app.messages.create({ + el: messagesEl + }); + }, + destroy: function destroy(vnode) { + var app = this; + var messagesEl = vnode.elm; + app.messages.destroy(messagesEl); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/modal/custom-modal-class.js b/www/assets/framework7/cjs/components/modal/custom-modal-class.js new file mode 100644 index 000000000..1c0b451d5 --- /dev/null +++ b/www/assets/framework7/cjs/components/modal/custom-modal-class.js @@ -0,0 +1,99 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _modalClass = _interopRequireDefault(require("./modal-class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var CustomModal = /*#__PURE__*/function (_Modal) { + _inheritsLoose(CustomModal, _Modal); + + function CustomModal(app, params) { + var _this; + + var extendedParams = (0, _utils.extend)({ + backdrop: true, + closeByBackdropClick: true, + on: {} + }, params); // Extends with open/close Modal methods; + + _this = _Modal.call(this, app, extendedParams) || this; + + var customModal = _assertThisInitialized(_this); + + customModal.params = extendedParams; // Find Element + + var $el; + + if (!customModal.params.el) { + $el = (0, _dom.default)(customModal.params.content); + } else { + $el = (0, _dom.default)(customModal.params.el); + } + + if ($el && $el.length > 0 && $el[0].f7Modal) { + return $el[0].f7Modal || _assertThisInitialized(_this); + } + + if ($el.length === 0) { + return customModal.destroy() || _assertThisInitialized(_this); + } + + var $backdropEl; + + if (customModal.params.backdrop) { + $backdropEl = app.$el.children('.custom-modal-backdrop'); + + if ($backdropEl.length === 0) { + $backdropEl = (0, _dom.default)('
    '); + app.$el.append($backdropEl); + } + } + + function handleClick(e) { + if (!customModal || customModal.destroyed) return; + + if ($backdropEl && e.target === $backdropEl[0]) { + customModal.close(); + } + } + + customModal.on('customModalOpened', function () { + if (customModal.params.closeByBackdropClick && customModal.params.backdrop) { + app.on('click', handleClick); + } + }); + customModal.on('customModalClose', function () { + if (customModal.params.closeByBackdropClick && customModal.params.backdrop) { + app.off('click', handleClick); + } + }); + (0, _utils.extend)(customModal, { + app: app, + $el: $el, + el: $el[0], + $backdropEl: $backdropEl, + backdropEl: $backdropEl && $backdropEl[0], + type: 'customModal' + }); + $el[0].f7Modal = customModal; + return customModal || _assertThisInitialized(_this); + } + + return CustomModal; +}(_modalClass.default); + +var _default = CustomModal; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/modal/modal-class.js b/www/assets/framework7/cjs/components/modal/modal-class.js new file mode 100644 index 000000000..f8a312778 --- /dev/null +++ b/www/assets/framework7/cjs/components/modal/modal-class.js @@ -0,0 +1,277 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var openedModals = []; +var dialogsQueue = []; + +function clearDialogsQueue() { + if (dialogsQueue.length === 0) return; + var dialog = dialogsQueue.shift(); + dialog.open(); +} + +var Modal = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(Modal, _Framework7Class); + + function Modal(app, params) { + var _this; + + _this = _Framework7Class.call(this, params, [app]) || this; + + var modal = _assertThisInitialized(_this); + + var defaults = {}; // Extend defaults with modules params + + modal.useModulesParams(defaults); + modal.params = (0, _utils.extend)(defaults, params); + modal.opened = false; + var $containerEl = modal.params.containerEl ? (0, _dom.default)(modal.params.containerEl).eq(0) : app.$el; + if (!$containerEl.length) $containerEl = app.$el; + modal.$containerEl = $containerEl; + modal.containerEl = $containerEl[0]; // Install Modules + + modal.useModules(); + return _assertThisInitialized(_this) || _assertThisInitialized(_this); + } + + var _proto = Modal.prototype; + + _proto.onOpen = function onOpen() { + var modal = this; + modal.opened = true; + openedModals.push(modal); + (0, _dom.default)('html').addClass("with-modal-" + modal.type.toLowerCase()); + modal.$el.trigger("modal:open " + modal.type.toLowerCase() + ":open"); + modal.emit("local::open modalOpen " + modal.type + "Open", modal); + }; + + _proto.onOpened = function onOpened() { + var modal = this; + modal.$el.trigger("modal:opened " + modal.type.toLowerCase() + ":opened"); + modal.emit("local::opened modalOpened " + modal.type + "Opened", modal); + }; + + _proto.onClose = function onClose() { + var modal = this; + modal.opened = false; + if (!modal.type || !modal.$el) return; + openedModals.splice(openedModals.indexOf(modal), 1); + (0, _dom.default)('html').removeClass("with-modal-" + modal.type.toLowerCase()); + modal.$el.trigger("modal:close " + modal.type.toLowerCase() + ":close"); + modal.emit("local::close modalClose " + modal.type + "Close", modal); + }; + + _proto.onClosed = function onClosed() { + var modal = this; + if (!modal.type || !modal.$el) return; + modal.$el.removeClass('modal-out'); + modal.$el.hide(); + modal.$el.trigger("modal:closed " + modal.type.toLowerCase() + ":closed"); + modal.emit("local::closed modalClosed " + modal.type + "Closed", modal); + }; + + _proto.open = function open(animateModal) { + var modal = this; + var document = (0, _ssrWindow.getDocument)(); + var app = modal.app; + var $el = modal.$el; + var $backdropEl = modal.$backdropEl; + var type = modal.type; + var animate = true; + if (typeof animateModal !== 'undefined') animate = animateModal;else if (typeof modal.params.animate !== 'undefined') { + animate = modal.params.animate; + } + + if (!$el || $el.hasClass('modal-in')) { + if (animateModal === false && $el[0] && type !== 'dialog') { + $el[0].style.display = 'block'; + } + + return modal; + } + + if (type === 'dialog' && app.params.modal.queueDialogs) { + var pushToQueue; + + if ((0, _dom.default)('.dialog.modal-in').length > 0) { + pushToQueue = true; + } else if (openedModals.length > 0) { + openedModals.forEach(function (openedModal) { + if (openedModal.type === 'dialog') pushToQueue = true; + }); + } + + if (pushToQueue) { + dialogsQueue.push(modal); + return modal; + } + } + + var $modalParentEl = $el.parent(); + var wasInDom = $el.parents(document).length > 0; + + if (!$modalParentEl.is(modal.$containerEl)) { + modal.$containerEl.append($el); + modal.once(type + "Closed", function () { + if (wasInDom) { + $modalParentEl.append($el); + } else { + $el.remove(); + } + }); + } // Show Modal + + + $el.show(); + /* eslint no-underscore-dangle: ["error", { "allow": ["_clientLeft"] }] */ + + modal._clientLeft = $el[0].clientLeft; // Modal + + function transitionEnd() { + if ($el.hasClass('modal-out')) { + modal.onClosed(); + } else if ($el.hasClass('modal-in')) { + modal.onOpened(); + } + } + + if (animate) { + if ($backdropEl) { + $backdropEl.removeClass('not-animated'); + $backdropEl.addClass('backdrop-in'); + } + + $el.animationEnd(function () { + transitionEnd(); + }); + $el.transitionEnd(function () { + transitionEnd(); + }); + $el.removeClass('modal-out not-animated').addClass('modal-in'); + modal.onOpen(); + } else { + if ($backdropEl) { + $backdropEl.addClass('backdrop-in not-animated'); + } + + $el.removeClass('modal-out').addClass('modal-in not-animated'); + modal.onOpen(); + modal.onOpened(); + } + + return modal; + }; + + _proto.close = function close(animateModal) { + var modal = this; + var $el = modal.$el; + var $backdropEl = modal.$backdropEl; + var animate = true; + if (typeof animateModal !== 'undefined') animate = animateModal;else if (typeof modal.params.animate !== 'undefined') { + animate = modal.params.animate; + } + + if (!$el || !$el.hasClass('modal-in')) { + if (dialogsQueue.indexOf(modal) >= 0) { + dialogsQueue.splice(dialogsQueue.indexOf(modal), 1); + } + + return modal; + } // backdrop + + + if ($backdropEl) { + var needToHideBackdrop = true; + + if (modal.type === 'popup') { + modal.$el.prevAll('.popup.modal-in').add(modal.$el.nextAll('.popup.modal-in')).each(function (popupEl) { + var popupInstance = popupEl.f7Modal; + if (!popupInstance) return; + + if (popupInstance.params.closeByBackdropClick && popupInstance.params.backdrop && popupInstance.backdropEl === modal.backdropEl) { + needToHideBackdrop = false; + } + }); + } + + if (needToHideBackdrop) { + $backdropEl[animate ? 'removeClass' : 'addClass']('not-animated'); + $backdropEl.removeClass('backdrop-in'); + } + } // Modal + + + $el[animate ? 'removeClass' : 'addClass']('not-animated'); + + function transitionEnd() { + if ($el.hasClass('modal-out')) { + modal.onClosed(); + } else if ($el.hasClass('modal-in')) { + modal.onOpened(); + } + } + + if (animate) { + $el.animationEnd(function () { + transitionEnd(); + }); + $el.transitionEnd(function () { + transitionEnd(); + }); + $el.removeClass('modal-in').addClass('modal-out'); // Emit close + + modal.onClose(); + } else { + $el.addClass('not-animated').removeClass('modal-in').addClass('modal-out'); // Emit close + + modal.onClose(); + modal.onClosed(); + } + + if (modal.type === 'dialog') { + clearDialogsQueue(); + } + + return modal; + }; + + _proto.destroy = function destroy() { + var modal = this; + if (modal.destroyed) return; + modal.emit("local::beforeDestroy modalBeforeDestroy " + modal.type + "BeforeDestroy", modal); + + if (modal.$el) { + modal.$el.trigger("modal:beforedestroy " + modal.type.toLowerCase() + ":beforedestroy"); + + if (modal.$el.length && modal.$el[0].f7Modal) { + delete modal.$el[0].f7Modal; + } + } + + (0, _utils.deleteProps)(modal); + modal.destroyed = true; + }; + + return Modal; +}(_class.default); + +var _default = Modal; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/modal/modal.js b/www/assets/framework7/cjs/components/modal/modal.js new file mode 100644 index 000000000..560b651d9 --- /dev/null +++ b/www/assets/framework7/cjs/components/modal/modal.js @@ -0,0 +1,32 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _modalClass = _interopRequireDefault(require("./modal-class")); + +var _customModalClass = _interopRequireDefault(require("./custom-modal-class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'modal', + static: { + Modal: _modalClass.default, + CustomModal: _customModalClass.default + }, + create: function create() { + var app = this; + app.customModal = { + create: function create(params) { + return new _customModalClass.default(app, params); + } + }; + }, + params: { + modal: { + queueDialogs: true + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/navbar/navbar.js b/www/assets/framework7/cjs/components/navbar/navbar.js new file mode 100644 index 000000000..6973acbd3 --- /dev/null +++ b/www/assets/framework7/cjs/components/navbar/navbar.js @@ -0,0 +1,833 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _getSupport = require("../../shared/get-support"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Navbar = { + size: function size(el) { + var app = this; + var $el = (0, _dom.default)(el); + + if ($el.hasClass('navbars')) { + $el = $el.children('.navbar').each(function (navbarEl) { + app.navbar.size(navbarEl); + }); + return; + } + + var $innerEl = $el.children('.navbar-inner'); + if (!$innerEl.length) return; + var needCenterTitle = $innerEl.hasClass('navbar-inner-centered-title') || app.params.navbar[app.theme + "CenterTitle"]; + var needLeftTitle = app.theme === 'ios' && !app.params.navbar[app.theme + "CenterTitle"]; + if (!needCenterTitle && !needLeftTitle) return; + + if ($el.hasClass('stacked') || $el.parents('.stacked').length > 0 || $el.parents('.tab:not(.tab-active)').length > 0 || $el.parents('.popup:not(.modal-in)').length > 0) { + return; + } + + if (app.theme !== 'ios' && app.params.navbar[app.theme + "CenterTitle"]) { + $innerEl.addClass('navbar-inner-centered-title'); + } + + if (app.theme === 'ios' && !app.params.navbar.iosCenterTitle) { + $innerEl.addClass('navbar-inner-left-title'); + } + + var $viewEl = $el.parents('.view').eq(0); + var left = app.rtl ? $innerEl.children('.right') : $innerEl.children('.left'); + var right = app.rtl ? $innerEl.children('.left') : $innerEl.children('.right'); + var title = $innerEl.children('.title'); + var subnavbar = $innerEl.children('.subnavbar'); + var noLeft = left.length === 0; + var noRight = right.length === 0; + var leftWidth = noLeft ? 0 : left.outerWidth(true); + var rightWidth = noRight ? 0 : right.outerWidth(true); + var titleWidth = title.outerWidth(true); + var navbarStyles = $innerEl.styles(); + var navbarWidth = $innerEl[0].offsetWidth; + var navbarInnerWidth = navbarWidth - parseInt(navbarStyles.paddingLeft, 10) - parseInt(navbarStyles.paddingRight, 10); + var isPrevious = $el.hasClass('navbar-previous'); + var sliding = $innerEl.hasClass('sliding'); + var router; + var dynamicNavbar; + + if ($viewEl.length > 0 && $viewEl[0].f7View) { + router = $viewEl[0].f7View.router; + dynamicNavbar = router && router.dynamicNavbar; + } + + var currLeft; + var diff; + + if (noRight) { + currLeft = navbarInnerWidth - titleWidth; + } + + if (noLeft) { + currLeft = 0; + } + + if (!noLeft && !noRight) { + currLeft = (navbarInnerWidth - rightWidth - titleWidth + leftWidth) / 2; + } + + var requiredLeft = (navbarInnerWidth - titleWidth) / 2; + + if (navbarInnerWidth - leftWidth - rightWidth > titleWidth) { + if (requiredLeft < leftWidth) { + requiredLeft = leftWidth; + } + + if (requiredLeft + titleWidth > navbarInnerWidth - rightWidth) { + requiredLeft = navbarInnerWidth - rightWidth - titleWidth; + } + + diff = requiredLeft - currLeft; + } else { + diff = 0; + } // RTL inverter + + + var inverter = app.rtl ? -1 : 1; + + if (dynamicNavbar && app.theme === 'ios') { + if (title.hasClass('sliding') || title.length > 0 && sliding) { + var titleLeftOffset = -(currLeft + diff) * inverter; + var titleRightOffset = (navbarInnerWidth - currLeft - diff - titleWidth) * inverter; + + if (isPrevious) { + if (router && router.params.iosAnimateNavbarBackIcon) { + var activeNavbarBackLink = $el.parent().find('.navbar-current').children('.left.sliding').find('.back .icon ~ span'); + + if (activeNavbarBackLink.length > 0) { + titleLeftOffset += activeNavbarBackLink[0].offsetLeft; + } + } + } + + title[0].f7NavbarLeftOffset = titleLeftOffset; + title[0].f7NavbarRightOffset = titleRightOffset; + } + + if (!noLeft && (left.hasClass('sliding') || sliding)) { + if (app.rtl) { + left[0].f7NavbarLeftOffset = -(navbarInnerWidth - left[0].offsetWidth) / 2 * inverter; + left[0].f7NavbarRightOffset = leftWidth * inverter; + } else { + left[0].f7NavbarLeftOffset = -leftWidth; + left[0].f7NavbarRightOffset = (navbarInnerWidth - left[0].offsetWidth) / 2; + + if (router && router.params.iosAnimateNavbarBackIcon && left.find('.back .icon').length > 0) { + if (left.find('.back .icon ~ span').length) { + var leftOffset = left[0].f7NavbarLeftOffset; + var rightOffset = left[0].f7NavbarRightOffset; + left[0].f7NavbarLeftOffset = 0; + left[0].f7NavbarRightOffset = 0; + left.find('.back .icon ~ span')[0].f7NavbarLeftOffset = leftOffset; + left.find('.back .icon ~ span')[0].f7NavbarRightOffset = rightOffset - left.find('.back .icon')[0].offsetWidth; + } + } + } + } + + if (!noRight && (right.hasClass('sliding') || sliding)) { + if (app.rtl) { + right[0].f7NavbarLeftOffset = -rightWidth * inverter; + right[0].f7NavbarRightOffset = (navbarInnerWidth - right[0].offsetWidth) / 2 * inverter; + } else { + right[0].f7NavbarLeftOffset = -(navbarInnerWidth - right[0].offsetWidth) / 2; + right[0].f7NavbarRightOffset = rightWidth; + } + } + + if (subnavbar.length && (subnavbar.hasClass('sliding') || sliding)) { + subnavbar[0].f7NavbarLeftOffset = app.rtl ? subnavbar[0].offsetWidth : -subnavbar[0].offsetWidth; + subnavbar[0].f7NavbarRightOffset = -subnavbar[0].f7NavbarLeftOffset; + } + } // Center title + + + if (needCenterTitle) { + var titleLeft = diff; + if (app.rtl && noLeft && noRight && title.length > 0) titleLeft = -titleLeft; + title.css({ + left: titleLeft + "px" + }); + } + }, + hide: function hide(el, animate, hideStatusbar, hideOnlyCurrent) { + if (animate === void 0) { + animate = true; + } + + if (hideStatusbar === void 0) { + hideStatusbar = false; + } + + if (hideOnlyCurrent === void 0) { + hideOnlyCurrent = false; + } + + var app = this; + var $el = (0, _dom.default)(el); + var isDynamic = $el.hasClass('navbar') && $el.parent('.navbars').length && !hideOnlyCurrent; + if (isDynamic) $el = $el.parents('.navbars'); + if (!$el.length) return; + if ($el.hasClass('navbar-hidden')) return; + var className = "navbar-hidden" + (animate ? ' navbar-transitioning' : ''); + var currentIsLarge = isDynamic ? $el.find('.navbar-current .title-large').length : $el.find('.title-large').length; + + if (currentIsLarge) { + className += ' navbar-large-hidden'; + } + + if (hideStatusbar) { + className += ' navbar-hidden-statusbar'; + } + + $el.transitionEnd(function () { + $el.removeClass('navbar-transitioning'); + }); + $el.addClass(className); + + if (isDynamic) { + $el.children('.navbar').each(function (subEl) { + (0, _dom.default)(subEl).trigger('navbar:hide'); + app.emit('navbarHide', subEl); + }); + } else { + $el.trigger('navbar:hide'); + app.emit('navbarHide', $el[0]); + } + }, + show: function show(el, animate, hideOnlyCurrent) { + if (el === void 0) { + el = '.navbar-hidden'; + } + + if (animate === void 0) { + animate = true; + } + + if (hideOnlyCurrent === void 0) { + hideOnlyCurrent = false; + } + + var app = this; + var $el = (0, _dom.default)(el); + var isDynamic = $el.hasClass('navbar') && $el.parent('.navbars').length && !hideOnlyCurrent; + if (isDynamic) $el = $el.parents('.navbars'); + if (!$el.length) return; + if (!$el.hasClass('navbar-hidden')) return; + + if (animate) { + $el.addClass('navbar-transitioning'); + $el.transitionEnd(function () { + $el.removeClass('navbar-transitioning'); + }); + } + + $el.removeClass('navbar-hidden navbar-large-hidden navbar-hidden-statusbar'); + + if (isDynamic) { + $el.children('.navbar').each(function (subEl) { + (0, _dom.default)(subEl).trigger('navbar:show'); + app.emit('navbarShow', subEl); + }); + } else { + $el.trigger('navbar:show'); + app.emit('navbarShow', $el[0]); + } + }, + getElByPage: function getElByPage(page) { + var $pageEl; + var $navbarEl; + var pageData; + + if (page.$navbarEl || page.$el) { + pageData = page; + $pageEl = page.$el; + } else { + $pageEl = (0, _dom.default)(page); + if ($pageEl.length > 0) pageData = $pageEl[0].f7Page; + } + + if (pageData && pageData.$navbarEl && pageData.$navbarEl.length > 0) { + $navbarEl = pageData.$navbarEl; + } else if ($pageEl) { + $navbarEl = $pageEl.children('.navbar'); + } + + if (!$navbarEl || $navbarEl && $navbarEl.length === 0) return undefined; + return $navbarEl[0]; + }, + getPageByEl: function getPageByEl(navbarEl) { + var $navbarEl = (0, _dom.default)(navbarEl); + + if ($navbarEl.parents('.page').length) { + return $navbarEl.parents('.page')[0]; + } + + var pageEl; + $navbarEl.parents('.view').find('.page').each(function (el) { + if (el && el.f7Page && el.f7Page.navbarEl && $navbarEl[0] === el.f7Page.navbarEl) { + pageEl = el; + } + }); + return pageEl; + }, + collapseLargeTitle: function collapseLargeTitle(navbarEl) { + var app = this; + var $navbarEl = (0, _dom.default)(navbarEl); + + if ($navbarEl.hasClass('navbars')) { + $navbarEl = $navbarEl.find('.navbar'); + + if ($navbarEl.length > 1) { + $navbarEl = (0, _dom.default)(navbarEl).find('.navbar-large.navbar-current'); + } + + if ($navbarEl.length > 1 || !$navbarEl.length) { + return; + } + } + + var $pageEl = (0, _dom.default)(app.navbar.getPageByEl($navbarEl)); + $navbarEl.addClass('navbar-large-collapsed'); + $pageEl.eq(0).addClass('page-with-navbar-large-collapsed').trigger('page:navbarlargecollapsed'); + app.emit('pageNavbarLargeCollapsed', $pageEl[0]); + $navbarEl.trigger('navbar:collapse'); + app.emit('navbarCollapse', $navbarEl[0]); + }, + expandLargeTitle: function expandLargeTitle(navbarEl) { + var app = this; + var $navbarEl = (0, _dom.default)(navbarEl); + + if ($navbarEl.hasClass('navbars')) { + $navbarEl = $navbarEl.find('.navbar-large'); + + if ($navbarEl.length > 1) { + $navbarEl = (0, _dom.default)(navbarEl).find('.navbar-large.navbar-current'); + } + + if ($navbarEl.length > 1 || !$navbarEl.length) { + return; + } + } + + var $pageEl = (0, _dom.default)(app.navbar.getPageByEl($navbarEl)); + $navbarEl.removeClass('navbar-large-collapsed'); + $pageEl.eq(0).removeClass('page-with-navbar-large-collapsed').trigger('page:navbarlargeexpanded'); + app.emit('pageNavbarLargeExpanded', $pageEl[0]); + $navbarEl.trigger('navbar:expand'); + app.emit('navbarExpand', $navbarEl[0]); + }, + toggleLargeTitle: function toggleLargeTitle(navbarEl) { + var app = this; + var $navbarEl = (0, _dom.default)(navbarEl); + + if ($navbarEl.hasClass('navbars')) { + $navbarEl = $navbarEl.find('.navbar-large'); + + if ($navbarEl.length > 1) { + $navbarEl = (0, _dom.default)(navbarEl).find('.navbar-large.navbar-current'); + } + + if ($navbarEl.length > 1 || !$navbarEl.length) { + return; + } + } + + if ($navbarEl.hasClass('navbar-large-collapsed')) { + app.navbar.expandLargeTitle($navbarEl); + } else { + app.navbar.collapseLargeTitle($navbarEl); + } + }, + initNavbarOnScroll: function initNavbarOnScroll(pageEl, navbarEl, needHide, needCollapse, needTransparent) { + var app = this; + var support = (0, _getSupport.getSupport)(); + var $pageEl = (0, _dom.default)(pageEl); + var $navbarEl = (0, _dom.default)(navbarEl); + var $titleLargeEl = $navbarEl.find('.title-large'); + var isLarge = $titleLargeEl.length || $navbarEl.hasClass('.navbar-large'); + var navbarHideHeight = 44; + var snapPageScrollToLargeTitle = app.params.navbar.snapPageScrollToLargeTitle; + var snapPageScrollToTransparentNavbar = app.params.navbar.snapPageScrollToTransparentNavbar; + var previousScrollTop; + var currentScrollTop; + var scrollHeight; + var offsetHeight; + var reachEnd; + var action; + var navbarHidden; + var navbarCollapsed; + var navbarTitleLargeHeight; + var navbarOffsetHeight; + + if (needCollapse || needHide && isLarge) { + navbarTitleLargeHeight = $navbarEl.css('--f7-navbar-large-title-height'); + + if (navbarTitleLargeHeight && navbarTitleLargeHeight.indexOf('px') >= 0) { + navbarTitleLargeHeight = parseInt(navbarTitleLargeHeight, 10); + + if (Number.isNaN(navbarTitleLargeHeight) && $titleLargeEl.length) { + navbarTitleLargeHeight = $titleLargeEl[0].offsetHeight; + } else if (Number.isNaN(navbarTitleLargeHeight)) { + if (app.theme === 'ios') navbarTitleLargeHeight = 52;else if (app.theme === 'md') navbarTitleLargeHeight = 48;else if (app.theme === 'aurora') navbarTitleLargeHeight = 38; + } + } else if ($titleLargeEl.length) { + navbarTitleLargeHeight = $titleLargeEl[0].offsetHeight; + } else { + // eslint-disable-next-line + if (app.theme === 'ios') navbarTitleLargeHeight = 52;else if (app.theme === 'md') navbarTitleLargeHeight = 48;else if (app.theme === 'aurora') navbarTitleLargeHeight = 38; + } + } + + if (needHide && isLarge) { + navbarHideHeight += navbarTitleLargeHeight; + } + + var scrollChanged; + var scrollContent; + var scrollTimeoutId; + var touchEndTimeoutId; + var touchSnapTimeout = 70; + var desktopSnapTimeout = 300; + + function calcScrollableDistance() { + $pageEl.find('.page-content').each(function (pageContentEl) { + pageContentEl.f7ScrollableDistance = pageContentEl.scrollHeight - pageContentEl.offsetHeight; + }); + } + + function snapLargeNavbar() { + var inSearchbarExpanded = $navbarEl.hasClass('with-searchbar-expandable-enabled'); + if (inSearchbarExpanded) return; + if (!scrollContent || currentScrollTop < 0) return; + + if (currentScrollTop >= navbarTitleLargeHeight / 2 && currentScrollTop < navbarTitleLargeHeight) { + (0, _dom.default)(scrollContent).scrollTop(navbarTitleLargeHeight, 100); + } else if (currentScrollTop < navbarTitleLargeHeight) { + (0, _dom.default)(scrollContent).scrollTop(0, 200); + } + } + + function snapTransparentNavbar() { + var inSearchbarExpanded = $navbarEl.hasClass('with-searchbar-expandable-enabled'); + if (inSearchbarExpanded) return; + if (!scrollContent || currentScrollTop < 0) return; + + if (currentScrollTop >= navbarOffsetHeight / 2 && currentScrollTop < navbarOffsetHeight) { + (0, _dom.default)(scrollContent).scrollTop(navbarOffsetHeight, 100); + } else if (currentScrollTop < navbarOffsetHeight) { + (0, _dom.default)(scrollContent).scrollTop(0, 200); + } + } + + function handleNavbarTransparent() { + var isHidden = $navbarEl.hasClass('navbar-hidden') || $navbarEl.parent('.navbars').hasClass('navbar-hidden'); + var inSearchbarExpanded = $navbarEl.hasClass('with-searchbar-expandable-enabled'); + if (inSearchbarExpanded || isHidden) return; + + if (!navbarOffsetHeight) { + navbarOffsetHeight = navbarEl.offsetHeight; + } + + var opacity = currentScrollTop / navbarOffsetHeight; + var notTransparent = $navbarEl.hasClass('navbar-transparent-visible'); + opacity = Math.max(Math.min(opacity, 1), 0); + + if (notTransparent && opacity === 1 || !notTransparent && opacity === 0) { + $navbarEl.find('.navbar-bg, .title').css('opacity', ''); + return; + } + + if (notTransparent && opacity === 0) { + $navbarEl.trigger('navbar:transparenthide'); + app.emit('navbarTransparentHide', $navbarEl[0]); + $navbarEl.removeClass('navbar-transparent-visible'); + $navbarEl.find('.navbar-bg, .title').css('opacity', ''); + return; + } + + if (!notTransparent && opacity === 1) { + $navbarEl.trigger('navbar:transparentshow'); + app.emit('navbarTransparentShow', $navbarEl[0]); + $navbarEl.addClass('navbar-transparent-visible'); + $navbarEl.find('.navbar-bg, .title').css('opacity', ''); + return; + } + + $navbarEl.find('.navbar-bg, .title').css('opacity', opacity); + + if (snapPageScrollToTransparentNavbar) { + if (!support.touch) { + clearTimeout(scrollTimeoutId); + scrollTimeoutId = setTimeout(function () { + snapTransparentNavbar(); + }, desktopSnapTimeout); + } else if (touchEndTimeoutId) { + clearTimeout(touchEndTimeoutId); + touchEndTimeoutId = null; + touchEndTimeoutId = setTimeout(function () { + snapTransparentNavbar(); + clearTimeout(touchEndTimeoutId); + touchEndTimeoutId = null; + }, touchSnapTimeout); + } + } + } + + var previousCollapseProgress = null; + var collapseProgress = null; + + function handleLargeNavbarCollapse(pageContentEl) { + var isHidden = $navbarEl.hasClass('navbar-hidden') || $navbarEl.parent('.navbars').hasClass('navbar-hidden'); + if (isHidden) return; + var isLargeTransparent = $navbarEl.hasClass('navbar-large-transparent') || $navbarEl.hasClass('navbar-large') && $navbarEl.hasClass('navbar-transparent'); + previousCollapseProgress = collapseProgress; + var scrollableDistance = Math.min(navbarTitleLargeHeight, pageContentEl.f7ScrollableDistance || navbarTitleLargeHeight); + collapseProgress = Math.min(Math.max(currentScrollTop / scrollableDistance, 0), 1); + var previousCollapseWasInMiddle = previousCollapseProgress > 0 && previousCollapseProgress < 1; + var inSearchbarExpanded = $navbarEl.hasClass('with-searchbar-expandable-enabled'); + if (inSearchbarExpanded) return; + navbarCollapsed = $navbarEl.hasClass('navbar-large-collapsed'); + + if (collapseProgress === 0 && navbarCollapsed) { + app.navbar.expandLargeTitle($navbarEl[0]); + } else if (collapseProgress === 1 && !navbarCollapsed) { + app.navbar.collapseLargeTitle($navbarEl[0]); + } + + if (collapseProgress === 0 && navbarCollapsed || collapseProgress === 0 && previousCollapseWasInMiddle || collapseProgress === 1 && !navbarCollapsed || collapseProgress === 1 && previousCollapseWasInMiddle) { + if (app.theme === 'md') { + $navbarEl.find('.navbar-inner').css('overflow', ''); + } + + $navbarEl.find('.title').css('opacity', ''); + $navbarEl.find('.title-large-text, .subnavbar').css('transform', ''); + + if (isLargeTransparent) { + $navbarEl.find('.navbar-bg').css('opacity', ''); + } else { + $navbarEl.find('.navbar-bg').css('transform', ''); + } + } else if (collapseProgress > 0 && collapseProgress < 1) { + if (app.theme === 'md') { + $navbarEl.find('.navbar-inner').css('overflow', 'visible'); + } + + $navbarEl.find('.title').css('opacity', collapseProgress); + $navbarEl.find('.title-large-text, .subnavbar').css('transform', "translate3d(0px, " + -1 * collapseProgress * navbarTitleLargeHeight + "px, 0)"); + + if (isLargeTransparent) { + $navbarEl.find('.navbar-bg').css('opacity', collapseProgress); + } else { + $navbarEl.find('.navbar-bg').css('transform', "translate3d(0px, " + -1 * collapseProgress * navbarTitleLargeHeight + "px, 0)"); + } + } + + if (snapPageScrollToLargeTitle) { + if (!support.touch) { + clearTimeout(scrollTimeoutId); + scrollTimeoutId = setTimeout(function () { + snapLargeNavbar(); + }, desktopSnapTimeout); + } else if (touchEndTimeoutId) { + clearTimeout(touchEndTimeoutId); + touchEndTimeoutId = null; + touchEndTimeoutId = setTimeout(function () { + snapLargeNavbar(); + clearTimeout(touchEndTimeoutId); + touchEndTimeoutId = null; + }, touchSnapTimeout); + } + } + } + + function handleTitleHideShow() { + if ($pageEl.hasClass('page-with-card-opened')) return; + scrollHeight = scrollContent.scrollHeight; + offsetHeight = scrollContent.offsetHeight; + reachEnd = currentScrollTop + offsetHeight >= scrollHeight; + navbarHidden = $navbarEl.hasClass('navbar-hidden') || $navbarEl.parent('.navbars').hasClass('navbar-hidden'); + + if (reachEnd) { + if (app.params.navbar.showOnPageScrollEnd) { + action = 'show'; + } + } else if (previousScrollTop > currentScrollTop) { + if (app.params.navbar.showOnPageScrollTop || currentScrollTop <= navbarHideHeight) { + action = 'show'; + } else { + action = 'hide'; + } + } else if (currentScrollTop > navbarHideHeight) { + action = 'hide'; + } else { + action = 'show'; + } + + if (action === 'show' && navbarHidden) { + app.navbar.show($navbarEl, true, true); + navbarHidden = false; + } else if (action === 'hide' && !navbarHidden) { + app.navbar.hide($navbarEl, true, false, true); + navbarHidden = true; + } + + previousScrollTop = currentScrollTop; + } + + function handleScroll(e) { + scrollContent = this; + + if (e && e.target && e.target !== scrollContent) { + return; + } + + currentScrollTop = scrollContent.scrollTop; + scrollChanged = currentScrollTop; + + if (needCollapse) { + handleLargeNavbarCollapse(scrollContent); + } else if (needTransparent) { + handleNavbarTransparent(); + } + + if ($pageEl.hasClass('page-previous')) return; + + if (needHide) { + handleTitleHideShow(); + } + } + + function handeTouchStart() { + scrollChanged = false; + } + + function handleTouchEnd() { + clearTimeout(touchEndTimeoutId); + touchEndTimeoutId = null; + touchEndTimeoutId = setTimeout(function () { + if (scrollChanged !== false) { + if (needTransparent && !needCollapse) { + snapTransparentNavbar(); + } else { + snapLargeNavbar(); + } + + clearTimeout(touchEndTimeoutId); + touchEndTimeoutId = null; + } + }, touchSnapTimeout); + } + + $pageEl.on('scroll', '.page-content', handleScroll, true); + + if (support.touch && (needCollapse && snapPageScrollToLargeTitle || needTransparent && snapPageScrollToTransparentNavbar)) { + app.on('touchstart:passive', handeTouchStart); + app.on('touchend:passive', handleTouchEnd); + } + + calcScrollableDistance(); + + if (needCollapse || needTransparent) { + $pageEl.find('.page-content').each(function (pageContentEl) { + if (pageContentEl.scrollTop > 0) handleScroll.call(pageContentEl); + }); + } + + app.on('resize', calcScrollableDistance); + + $pageEl[0].f7DetachNavbarScrollHandlers = function f7DetachNavbarScrollHandlers() { + app.off('resize', calcScrollableDistance); + delete $pageEl[0].f7DetachNavbarScrollHandlers; + $pageEl.off('scroll', '.page-content', handleScroll, true); + + if (support.touch && (needCollapse && snapPageScrollToLargeTitle || needTransparent && snapPageScrollToTransparentNavbar)) { + app.off('touchstart:passive', handeTouchStart); + app.off('touchend:passive', handleTouchEnd); + } + }; + } +}; +var _default = { + name: 'navbar', + create: function create() { + var app = this; + (0, _utils.bindMethods)(app, { + navbar: Navbar + }); + }, + params: { + navbar: { + scrollTopOnTitleClick: true, + iosCenterTitle: true, + mdCenterTitle: false, + auroraCenterTitle: true, + hideOnPageScroll: false, + showOnPageScrollEnd: true, + showOnPageScrollTop: true, + collapseLargeTitleOnScroll: true, + snapPageScrollToLargeTitle: true, + snapPageScrollToTransparentNavbar: true + } + }, + on: { + 'panelBreakpoint panelCollapsedBreakpoint panelResize viewResize resize viewMasterDetailBreakpoint': function onPanelResize() { + var app = this; + (0, _dom.default)('.navbar').each(function (navbarEl) { + app.navbar.size(navbarEl); + }); + }, + pageBeforeRemove: function pageBeforeRemove(page) { + if (page.$el[0].f7DetachNavbarScrollHandlers) { + page.$el[0].f7DetachNavbarScrollHandlers(); + } + }, + pageBeforeIn: function pageBeforeIn(page) { + var app = this; + if (app.theme !== 'ios') return; + var $navbarsEl; + var view = page.$el.parents('.view')[0].f7View; + var navbarEl = app.navbar.getElByPage(page); + + if (!navbarEl) { + $navbarsEl = page.$el.parents('.view').children('.navbars'); + } else { + $navbarsEl = (0, _dom.default)(navbarEl).parents('.navbars'); + } + + if (page.$el.hasClass('no-navbar') || view.router.dynamicNavbar && !navbarEl) { + var animate = !!(page.pageFrom && page.router.history.length > 0); + app.navbar.hide($navbarsEl, animate); + } else { + app.navbar.show($navbarsEl); + } + }, + pageReinit: function pageReinit(page) { + var app = this; + var $navbarEl = (0, _dom.default)(app.navbar.getElByPage(page)); + if (!$navbarEl || $navbarEl.length === 0) return; + app.navbar.size($navbarEl); + }, + pageInit: function pageInit(page) { + var app = this; + var $navbarEl = (0, _dom.default)(app.navbar.getElByPage(page)); + if (!$navbarEl || $navbarEl.length === 0) return; // Size + + app.navbar.size($navbarEl); // Need Collapse On Scroll + + var needCollapseOnScrollHandler; + + if ($navbarEl.find('.title-large').length > 0) { + $navbarEl.addClass('navbar-large'); + } + + if ($navbarEl.hasClass('navbar-large')) { + if (app.params.navbar.collapseLargeTitleOnScroll) needCollapseOnScrollHandler = true; + page.$el.addClass('page-with-navbar-large'); + } // Need transparent on scroll + + + var needTransparentOnScroll; + + if (!needCollapseOnScrollHandler && $navbarEl.hasClass('navbar-transparent')) { + needTransparentOnScroll = true; + } // Need Hide On Scroll + + + var needHideOnScrollHandler; + + if (app.params.navbar.hideOnPageScroll || page.$el.find('.hide-navbar-on-scroll').length || page.$el.hasClass('hide-navbar-on-scroll') || page.$el.find('.hide-bars-on-scroll').length || page.$el.hasClass('hide-bars-on-scroll')) { + if (page.$el.find('.keep-navbar-on-scroll').length || page.$el.hasClass('keep-navbar-on-scroll') || page.$el.find('.keep-bars-on-scroll').length || page.$el.hasClass('keep-bars-on-scroll')) { + needHideOnScrollHandler = false; + } else { + needHideOnScrollHandler = true; + } + } + + if (needCollapseOnScrollHandler || needHideOnScrollHandler || needTransparentOnScroll) { + app.navbar.initNavbarOnScroll(page.el, $navbarEl[0], needHideOnScrollHandler, needCollapseOnScrollHandler, needTransparentOnScroll); + } + }, + 'panelOpen panelSwipeOpen modalOpen': function onPanelModalOpen(instance) { + var app = this; + instance.$el.find('.navbar:not(.navbar-previous):not(.stacked)').each(function (navbarEl) { + app.navbar.size(navbarEl); + }); + }, + tabShow: function tabShow(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.navbar:not(.navbar-previous):not(.stacked)').each(function (navbarEl) { + app.navbar.size(navbarEl); + }); + } + }, + clicks: { + '.navbar .title': function onTitleClick($clickedEl, clickedData, e) { + var app = this; + if (!app.params.navbar.scrollTopOnTitleClick) return; + + if ((0, _dom.default)(e.target).closest('a, button').length > 0) { + return; + } + + var $pageContentEl; // Find active page + + var $navbarEl = $clickedEl.parents('.navbar'); + var $navbarsEl = $navbarEl.parents('.navbars'); // Static Layout + + $pageContentEl = $navbarEl.parents('.page-content'); + + if ($pageContentEl.length === 0) { + // Fixed Layout + if ($navbarEl.parents('.page').length > 0) { + $pageContentEl = $navbarEl.parents('.page').find('.page-content'); + } // Through Layout iOS + + + if ($pageContentEl.length === 0 && $navbarsEl.length) { + if ($navbarsEl.nextAll('.page-current:not(.stacked)').length > 0) { + $pageContentEl = $navbarsEl.nextAll('.page-current:not(.stacked)').find('.page-content'); + } + } // Through Layout + + + if ($pageContentEl.length === 0) { + if ($navbarEl.nextAll('.page-current:not(.stacked)').length > 0) { + $pageContentEl = $navbarEl.nextAll('.page-current:not(.stacked)').find('.page-content'); + } + } + } + + if ($pageContentEl && $pageContentEl.length > 0) { + // Check for tab + if ($pageContentEl.hasClass('tab')) { + $pageContentEl = $pageContentEl.parent('.tabs').children('.page-content.tab-active'); + } + + if ($pageContentEl.length > 0) $pageContentEl.scrollTop(0, 300); + } + } + }, + vnode: { + navbar: { + postpatch: function postpatch(vnode) { + var app = this; + app.navbar.size(vnode.elm); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/notification/notification-class.js b/www/assets/framework7/cjs/components/notification/notification-class.js new file mode 100644 index 000000000..697f687b5 --- /dev/null +++ b/www/assets/framework7/cjs/components/notification/notification-class.js @@ -0,0 +1,269 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _modalClass = _interopRequireDefault(require("../modal/modal-class")); + +var _$jsx = _interopRequireDefault(require("../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Notification = /*#__PURE__*/function (_Modal) { + _inheritsLoose(Notification, _Modal); + + function Notification(app, params) { + var _this; + + var extendedParams = (0, _utils.extend)({ + on: {} + }, app.params.notification, params); // Extends with open/close Modal methods; + + _this = _Modal.call(this, app, extendedParams) || this; + + var notification = _assertThisInitialized(_this); + + notification.app = app; + notification.params = extendedParams; + var _notification$params = notification.params, + icon = _notification$params.icon, + title = _notification$params.title, + titleRightText = _notification$params.titleRightText, + subtitle = _notification$params.subtitle, + text = _notification$params.text, + closeButton = _notification$params.closeButton, + closeTimeout = _notification$params.closeTimeout, + cssClass = _notification$params.cssClass, + closeOnClick = _notification$params.closeOnClick; + var $el; + + if (!notification.params.el) { + // Find Element + var notificationHtml = notification.render({ + icon: icon, + title: title, + titleRightText: titleRightText, + subtitle: subtitle, + text: text, + closeButton: closeButton, + cssClass: cssClass + }); + $el = (0, _dom.default)(notificationHtml); + } else { + $el = (0, _dom.default)(notification.params.el); + } + + if ($el && $el.length > 0 && $el[0].f7Modal) { + return $el[0].f7Modal || _assertThisInitialized(_this); + } + + if ($el.length === 0) { + return notification.destroy() || _assertThisInitialized(_this); + } + + (0, _utils.extend)(notification, { + $el: $el, + el: $el[0], + type: 'notification' + }); + $el[0].f7Modal = notification; + + if (closeButton) { + $el.find('.notification-close-button').on('click', function () { + notification.close(); + }); + } + + $el.on('click', function (e) { + if (closeButton && (0, _dom.default)(e.target).closest('.notification-close-button').length) { + return; + } + + notification.emit('local::click notificationClick', notification); + if (closeOnClick) notification.close(); + }); + notification.on('beforeDestroy', function () { + $el.off('click'); + }); + /* Touch Events */ + + var isTouched; + var isMoved; + var isScrolling; + var touchesDiff; + var touchStartTime; + var notificationHeight; + var touchesStart = {}; + + function handleTouchStart(e) { + if (isTouched) return; + isTouched = true; + isMoved = false; + isScrolling = undefined; + touchStartTime = (0, _utils.now)(); + touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; + touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + } + + function handleTouchMove(e) { + if (!isTouched) return; + var pageX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; + var pageY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; + + if (typeof isScrolling === 'undefined') { + isScrolling = !!(isScrolling || Math.abs(pageY - touchesStart.y) < Math.abs(pageX - touchesStart.x)); + } + + if (isScrolling) { + isTouched = false; + return; + } + + e.preventDefault(); + + if (!isMoved) { + notification.$el.removeClass('notification-transitioning'); + notification.$el.transition(0); + notificationHeight = notification.$el[0].offsetHeight / 2; + } + + isMoved = true; + touchesDiff = pageY - touchesStart.y; + var newTranslate = touchesDiff; + + if (touchesDiff > 0) { + newTranslate = Math.pow(touchesDiff, 0.8); + } + + notification.$el.transform("translate3d(0, " + newTranslate + "px, 0)"); + } + + function handleTouchEnd() { + if (!isTouched || !isMoved) { + isTouched = false; + isMoved = false; + return; + } + + isTouched = false; + isMoved = false; + + if (touchesDiff === 0) { + return; + } + + var timeDiff = (0, _utils.now)() - touchStartTime; + notification.$el.transition(''); + notification.$el.addClass('notification-transitioning'); + notification.$el.transform(''); + + if (touchesDiff < -10 && timeDiff < 300 || -touchesDiff >= notificationHeight / 1) { + notification.close(); + } + } + + function attachTouchEvents() { + notification.$el.on(app.touchEvents.start, handleTouchStart, { + passive: true + }); + app.on('touchmove:active', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + } + + function detachTouchEvents() { + notification.$el.off(app.touchEvents.start, handleTouchStart, { + passive: true + }); + app.off('touchmove:active', handleTouchMove); + app.off('touchend:passive', handleTouchEnd); + } + + var timeoutId; + + function closeOnTimeout() { + timeoutId = (0, _utils.nextTick)(function () { + if (isTouched && isMoved) { + closeOnTimeout(); + return; + } + + notification.close(); + }, closeTimeout); + } + + notification.on('open', function () { + if (notification.params.swipeToClose) { + attachTouchEvents(); + } + + (0, _dom.default)('.notification.modal-in').each(function (openedEl) { + var notificationInstance = app.notification.get(openedEl); + + if (openedEl !== notification.el && notificationInstance) { + notificationInstance.close(); + } + }); + + if (closeTimeout) { + closeOnTimeout(); + } + }); + notification.on('close beforeDestroy', function () { + if (notification.params.swipeToClose) { + detachTouchEvents(); + } + + clearTimeout(timeoutId); + }); + return notification || _assertThisInitialized(_this); + } + + var _proto = Notification.prototype; + + _proto.render = function render() { + var notification = this; + if (notification.params.render) return notification.params.render.call(notification, notification); + var _notification$params2 = notification.params, + icon = _notification$params2.icon, + title = _notification$params2.title, + titleRightText = _notification$params2.titleRightText, + subtitle = _notification$params2.subtitle, + text = _notification$params2.text, + closeButton = _notification$params2.closeButton, + cssClass = _notification$params2.cssClass; + return (0, _$jsx.default)("div", { + class: "notification " + (cssClass || '') + }, (0, _$jsx.default)("div", { + class: "notification-header" + }, icon && (0, _$jsx.default)("div", { + class: "notification-icon" + }, icon), title && (0, _$jsx.default)("div", { + class: "notification-title" + }, title), titleRightText && (0, _$jsx.default)("div", { + class: "notification-title-right-text" + }, titleRightText), closeButton && (0, _$jsx.default)("span", { + class: "notification-close-button" + })), (0, _$jsx.default)("div", { + class: "notification-content" + }, subtitle && (0, _$jsx.default)("div", { + class: "notification-subtitle" + }, subtitle), text && (0, _$jsx.default)("div", { + class: "notification-text" + }, text))); + }; + + return Notification; +}(_modalClass.default); + +var _default = Notification; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/notification/notification.js b/www/assets/framework7/cjs/components/notification/notification.js new file mode 100644 index 000000000..3590ed3ad --- /dev/null +++ b/www/assets/framework7/cjs/components/notification/notification.js @@ -0,0 +1,44 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _utils = require("../../shared/utils"); + +var _notificationClass = _interopRequireDefault(require("./notification-class")); + +var _modalMethods = _interopRequireDefault(require("../../shared/modal-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'notification', + static: { + Notification: _notificationClass.default + }, + create: function create() { + var app = this; + app.notification = (0, _utils.extend)({}, (0, _modalMethods.default)({ + app: app, + constructor: _notificationClass.default, + defaultSelector: '.notification.modal-in' + })); + }, + params: { + notification: { + icon: null, + title: null, + titleRightText: null, + subtitle: null, + text: null, + closeButton: false, + closeTimeout: null, + closeOnClick: false, + swipeToClose: true, + cssClass: null, + render: null, + containerEl: null + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/page/page.js b/www/assets/framework7/cjs/components/page/page.js new file mode 100644 index 000000000..82c3ca0e0 --- /dev/null +++ b/www/assets/framework7/cjs/components/page/page.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _default = { + name: 'page' +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/panel/panel-class.js b/www/assets/framework7/cjs/components/panel/panel-class.js new file mode 100644 index 000000000..0e3a929a4 --- /dev/null +++ b/www/assets/framework7/cjs/components/panel/panel-class.js @@ -0,0 +1,660 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _swipePanel = _interopRequireDefault(require("./swipe-panel")); + +var _resizablePanel = _interopRequireDefault(require("./resizable-panel")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Panel = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(Panel, _Framework7Class); + + function Panel(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + var extendedParams = (0, _utils.extend)({ + on: {} + }, app.params.panel, params); + _this = _Framework7Class.call(this, extendedParams, [app]) || this; + + var panel = _assertThisInitialized(_this); + + panel.params = extendedParams; + panel.$containerEl = panel.params.containerEl ? (0, _dom.default)(panel.params.containerEl).eq(0) : app.$el; + panel.containerEl = panel.$containerEl[0]; + + if (!panel.containerEl) { + panel.$containerEl = app.$el; + panel.containerEl = app.$el[0]; + } + + var $el; + + if (panel.params.el) { + $el = (0, _dom.default)(panel.params.el).eq(0); + } else if (panel.params.content) { + $el = (0, _dom.default)(panel.params.content).filter(function (node) { + return node.nodeType === 1; + }).eq(0); + } + + if ($el.length === 0) return panel || _assertThisInitialized(_this); + if ($el[0].f7Panel) return $el[0].f7Panel || _assertThisInitialized(_this); + $el[0].f7Panel = panel; + var _panel$params = panel.params, + side = _panel$params.side, + effect = _panel$params.effect, + resizable = _panel$params.resizable; + if (typeof side === 'undefined') side = $el.hasClass('panel-left') ? 'left' : 'right'; + if (typeof effect === 'undefined') // eslint-disable-next-line + effect = $el.hasClass('panel-cover') ? 'cover' : $el.hasClass('panel-push') ? 'push' : 'reveal'; + if (typeof resizable === 'undefined') resizable = $el.hasClass('panel-resizable'); + var $backdropEl; + + if (panel.params.backdrop && panel.params.backdropEl) { + $backdropEl = (0, _dom.default)(panel.params.backdropEl); + } else if (panel.params.backdrop) { + $backdropEl = panel.$containerEl.children('.panel-backdrop'); + + if ($backdropEl.length === 0) { + $backdropEl = (0, _dom.default)('
    '); + panel.$containerEl.prepend($backdropEl); + } + } + + (0, _utils.extend)(panel, { + app: app, + side: side, + effect: effect, + resizable: resizable, + $el: $el, + el: $el[0], + opened: false, + $backdropEl: $backdropEl, + backdropEl: $backdropEl && $backdropEl[0] + }); // Install Modules + + panel.useModules(); // Init + + panel.init(); + return panel || _assertThisInitialized(_this); + } + + var _proto = Panel.prototype; + + _proto.getViewEl = function getViewEl() { + var panel = this; + var viewEl; + + if (panel.$containerEl.children('.views').length > 0) { + viewEl = panel.$containerEl.children('.views')[0]; + } else { + viewEl = panel.$containerEl.children('.view')[0]; + } + + return viewEl; + }; + + _proto.setStateClasses = function setStateClasses(state) { + var panel = this; + var side = panel.side, + el = panel.el; + var viewEl = panel.getViewEl(); + var panelInView = viewEl && viewEl.contains(el); + var $targetEl = !viewEl || panelInView ? panel.$containerEl : (0, _dom.default)('html'); + + if (state === 'open') { + $targetEl.addClass("with-panel with-panel-" + panel.side + "-" + panel.effect); + } + + if (state === 'before-closing') { + $targetEl.addClass('with-panel-closing'); + } + + if (state === 'closing') { + $targetEl.addClass('with-panel-closing'); + $targetEl.removeClass("with-panel with-panel-" + panel.side + "-" + panel.effect); + } + + if (state === 'after-closing') { + $targetEl.removeClass('with-panel-closing'); + } + + if (state === 'closed') { + $targetEl.removeClass("with-panel-" + side + "-reveal with-panel-" + side + "-cover with-panel-" + side + "-push with-panel"); + } + }; + + _proto.enableVisibleBreakpoint = function enableVisibleBreakpoint() { + var panel = this; + panel.visibleBreakpointDisabled = false; + panel.setVisibleBreakpoint(); + return panel; + }; + + _proto.disableVisibleBreakpoint = function disableVisibleBreakpoint() { + var panel = this; + panel.visibleBreakpointDisabled = true; + panel.setVisibleBreakpoint(); + return panel; + }; + + _proto.toggleVisibleBreakpoint = function toggleVisibleBreakpoint() { + var panel = this; + panel.visibleBreakpointDisabled = !panel.visibleBreakpointDisabled; + panel.setVisibleBreakpoint(); + return panel; + }; + + _proto.setVisibleBreakpoint = function setVisibleBreakpoint(emitEvents) { + if (emitEvents === void 0) { + emitEvents = true; + } + + var panel = this; + var app = panel.app; + + if (!panel.visibleBreakpointResizeHandler) { + panel.visibleBreakpointResizeHandler = function visibleBreakpointResizeHandler() { + panel.setVisibleBreakpoint(); + }; + + app.on('resize', panel.visibleBreakpointResizeHandler); + } + + var side = panel.side, + $el = panel.$el, + $containerEl = panel.$containerEl, + params = panel.params, + visibleBreakpointDisabled = panel.visibleBreakpointDisabled; + var breakpoint = params.visibleBreakpoint; + var $viewEl = (0, _dom.default)(panel.getViewEl()); + var wasVisible = $el.hasClass('panel-in-breakpoint'); + + if ($containerEl && $containerEl.hasClass('page')) { + $viewEl.add($containerEl.children('.page-content, .tabs, .fab')); + } + + if (app.width >= breakpoint && typeof breakpoint !== 'undefined' && breakpoint !== null && !visibleBreakpointDisabled) { + if (!wasVisible) { + var _$viewEl$css; + + panel.setStateClasses('closed'); + $el.addClass('panel-in-breakpoint').removeClass('panel-in panel-in-collapsed'); + panel.onOpen(false); + panel.onOpened(); + $viewEl.css((_$viewEl$css = {}, _$viewEl$css["margin-" + side] = $el.width() + "px", _$viewEl$css)); + app.allowPanelOpen = true; + + if (emitEvents) { + panel.emit('local::breakpoint panelBreakpoint', panel); + panel.$el.trigger('panel:breakpoint'); + } + } else { + var _$viewEl$css2; + + $viewEl.css((_$viewEl$css2 = {}, _$viewEl$css2["margin-" + side] = $el.width() + "px", _$viewEl$css2)); + } + } else if (wasVisible) { + var _$viewEl$css3; + + $el.removeClass('panel-in-breakpoint panel-in'); + panel.onClose(); + panel.onClosed(); + $viewEl.css((_$viewEl$css3 = {}, _$viewEl$css3["margin-" + side] = '', _$viewEl$css3)); + + if (emitEvents) { + panel.emit('local::breakpoint panelBreakpoint', panel); + panel.$el.trigger('panel:breakpoint'); + } + } + }; + + _proto.enableCollapsedBreakpoint = function enableCollapsedBreakpoint() { + var panel = this; + panel.collapsedBreakpointDisabled = false; + panel.setCollapsedBreakpoint(); + return panel; + }; + + _proto.disableCollapsedBreakpoint = function disableCollapsedBreakpoint() { + var panel = this; + panel.collapsedBreakpointDisabled = true; + panel.setCollapsedBreakpoint(); + return panel; + }; + + _proto.toggleCollapsedBreakpoint = function toggleCollapsedBreakpoint() { + var panel = this; + panel.collapsedBreakpointDisabled = !panel.collapsedBreakpointDisabled; + panel.setCollapsedBreakpoint(); + return panel; + }; + + _proto.setCollapsedBreakpoint = function setCollapsedBreakpoint(emitEvents) { + if (emitEvents === void 0) { + emitEvents = true; + } + + var panel = this; + var app = panel.app; + + if (!panel.collapsedBreakpointResizeHandler) { + panel.collapsedBreakpointResizeHandler = function collapsedBreakpointResizeHandler() { + panel.setCollapsedBreakpoint(); + }; + + app.on('resize', panel.collapsedBreakpointResizeHandler); + } + + var $el = panel.$el, + params = panel.params, + collapsedBreakpointDisabled = panel.collapsedBreakpointDisabled; + if ($el.hasClass('panel-in-breakpoint')) return; + var breakpoint = params.collapsedBreakpoint; + var wasVisible = $el.hasClass('panel-in-collapsed'); + + if (app.width >= breakpoint && typeof breakpoint !== 'undefined' && breakpoint !== null && !collapsedBreakpointDisabled) { + if (!wasVisible) { + panel.setStateClasses('closed'); + $el.addClass('panel-in-collapsed').removeClass('panel-in'); + panel.collapsed = true; + app.allowPanelOpen = true; + + if (emitEvents) { + panel.emit('local::collapsedBreakpoint panelCollapsedBreakpoint', panel); + panel.$el.trigger('panel:collapsedbreakpoint'); + } + } + } else if (wasVisible) { + $el.removeClass('panel-in-collapsed panel-in'); + panel.collapsed = false; + + if (emitEvents) { + panel.emit('local::collapsedBreakpoint panelCollapsedBreakpoint', panel); + panel.$el.trigger('panel:collapsedbreakpoint'); + } + } + }; + + _proto.enableResizable = function enableResizable() { + var panel = this; + + if (panel.resizableInitialized) { + panel.resizable = true; + panel.$el.addClass('panel-resizable'); + } else { + (0, _resizablePanel.default)(panel); + } + + return panel; + }; + + _proto.disableResizable = function disableResizable() { + var panel = this; + panel.resizable = false; + panel.$el.removeClass('panel-resizable'); + return panel; + }; + + _proto.enableSwipe = function enableSwipe() { + var panel = this; + + if (panel.swipeInitialized) { + panel.swipeable = true; + } else { + (0, _swipePanel.default)(panel); + } + + return panel; + }; + + _proto.disableSwipe = function disableSwipe() { + var panel = this; + panel.swipeable = false; + return panel; + }; + + _proto.onOpen = function onOpen(modifyHtmlClasses) { + if (modifyHtmlClasses === void 0) { + modifyHtmlClasses = true; + } + + var panel = this; + var app = panel.app; + panel.opened = true; + app.panel.allowOpen = false; + panel.$el.trigger('panel:beforeopen'); + panel.emit('local::beforeOpen panelBeforeOpen', panel); + + if (modifyHtmlClasses) { + panel.setStateClasses('open'); + } + + panel.$el.trigger('panel:open'); + panel.emit('local::open panelOpen', panel); + }; + + _proto.onOpened = function onOpened() { + var panel = this; + var app = panel.app; + app.panel.allowOpen = true; + panel.$el.trigger('panel:opened'); + panel.emit('local::opened panelOpened', panel); + }; + + _proto.onClose = function onClose() { + var panel = this; + var app = panel.app; + panel.opened = false; + app.panel.allowOpen = false; + panel.$el.trigger('panel:beforeclose'); + panel.emit('local::beforeClose panelBeforeClose', panel); + panel.setStateClasses('closing'); + panel.$el.trigger('panel:close'); + panel.emit('local::close panelClose', panel); + }; + + _proto.onClosed = function onClosed() { + var panel = this; + var app = panel.app; + app.panel.allowOpen = true; + panel.setStateClasses('after-closing'); + panel.$el.removeClass('panel-out'); + + if (panel.$backdropEl) { + var otherPanel = app.panel.get('.panel-in'); + var shouldHideBackdrop = !otherPanel || otherPanel && !otherPanel.$backdropEl; + + if (shouldHideBackdrop) { + panel.$backdropEl.removeClass('panel-backdrop-in'); + } + } + + panel.$el.trigger('panel:closed'); + panel.emit('local::closed panelClosed', panel); + }; + + _proto.toggle = function toggle(animate) { + if (animate === void 0) { + animate = true; + } + + var panel = this; + var breakpoint = panel.params.visibleBreakpoint; + var app = panel.app; + + if (app.width >= breakpoint && typeof breakpoint !== 'undefined' && breakpoint !== null) { + return panel.toggleVisibleBreakpoint(); + } + + if (panel.opened) panel.close(animate);else panel.open(animate); + return panel; + }; + + _proto.insertToRoot = function insertToRoot() { + var panel = this; + var document = (0, _ssrWindow.getDocument)(); + var $el = panel.$el, + $backdropEl = panel.$backdropEl, + $containerEl = panel.$containerEl; + var $panelParentEl = $el.parent(); + var wasInDom = $el.parents(document).length > 0; + + if (!$panelParentEl.is($containerEl) || $el.prevAll('.views, .view').length) { + var $insertBeforeEl = $containerEl.children('.panel, .views, .view').eq(0); + var $insertAfterEl = $containerEl.children('.panel-backdrop').eq(0); + + if ($insertBeforeEl.length) { + $el.insertBefore($insertBeforeEl); + } else if ($insertAfterEl) { + $el.insertBefore($insertAfterEl); + } else { + $containerEl.prepend($el); + } + + if ($backdropEl && $backdropEl.length && (!$backdropEl.parent().is($containerEl) && $backdropEl.nextAll('.panel').length === 0 || $backdropEl.parent().is($containerEl) && $backdropEl.nextAll('.panel').length === 0)) { + $backdropEl.insertBefore($el); + } + + panel.once('panelClosed', function () { + if (wasInDom) { + $panelParentEl.append($el); + } else { + $el.remove(); + } + }); + } + }; + + _proto.open = function open(animate) { + if (animate === void 0) { + animate = true; + } + + var panel = this; + var app = panel.app; + if (!app.panel.allowOpen) return false; + var effect = panel.effect, + $el = panel.$el, + $backdropEl = panel.$backdropEl, + opened = panel.opened, + $containerEl = panel.$containerEl; + + if (!$el || $el.hasClass('panel-in')) { + return panel; + } + + panel.insertToRoot(); // Ignore if opened + + if (opened || $el.hasClass('panel-in-breakpoint') || $el.hasClass('panel-in')) return false; // Close if some panel is opened + + var otherOpenedPanel = app.panel.get('.panel-in'); + + if (otherOpenedPanel && otherOpenedPanel !== panel) { + otherOpenedPanel.close(animate); + } + + $el[animate ? 'removeClass' : 'addClass']('not-animated'); + $el.addClass('panel-in'); + + if ($backdropEl) { + $backdropEl.addClass('panel-backdrop-in'); + $backdropEl[animate ? 'removeClass' : 'addClass']('not-animated'); + } + + if (panel.effect === 'cover' || panel.effect === 'push') { + /* eslint no-underscore-dangle: ["error", { "allow": ["_clientLeft"] }] */ + panel._clientLeft = $el[0].clientLeft; + } // Transitionend + + + var $viewEl = (0, _dom.default)(panel.getViewEl()); + + if ($containerEl && $containerEl.hasClass('page')) { + $viewEl.add($containerEl.children('.page-content, .tabs')); + } + + var transitionEndTarget = effect === 'reveal' ? $viewEl : $el; + + function panelTransitionEnd() { + transitionEndTarget.transitionEnd(function (e) { + if ((0, _dom.default)(e.target).is(transitionEndTarget)) { + if ($el.hasClass('panel-out')) { + panel.onClosed(); + } else { + panel.onOpened(); + } + } else panelTransitionEnd(); + }); + } + + if (animate) { + if ($backdropEl) { + $backdropEl.removeClass('not-animated'); + } + + panelTransitionEnd(); + $el.removeClass('panel-out not-animated').addClass('panel-in'); + panel.onOpen(); + } else { + if ($backdropEl) { + $backdropEl.addClass('not-animated'); + } + + $el.removeClass('panel-out').addClass('panel-in not-animated'); + panel.onOpen(); + panel.onOpened(); + } + + return true; + }; + + _proto.close = function close(animate) { + if (animate === void 0) { + animate = true; + } + + var panel = this; + var effect = panel.effect, + $el = panel.$el, + $backdropEl = panel.$backdropEl, + opened = panel.opened, + $containerEl = panel.$containerEl; + if (!opened || $el.hasClass('panel-in-breakpoint') || !$el.hasClass('panel-in')) return panel; + $el[animate ? 'removeClass' : 'addClass']('not-animated'); + + if ($backdropEl) { + $backdropEl[animate ? 'removeClass' : 'addClass']('not-animated'); + } + + var $viewEl = (0, _dom.default)(panel.getViewEl()); + + if ($containerEl && $containerEl.hasClass('page')) { + $viewEl.add($containerEl.children('.page-content, .tabs')); + } + + var transitionEndTarget = effect === 'reveal' ? $viewEl : $el; + + function transitionEnd() { + if ($el.hasClass('panel-out')) { + panel.onClosed(); + } else if ($el.hasClass('panel-in')) { + panel.onOpened(); + } + + panel.setStateClasses('after-closing'); + } + + if (animate) { + transitionEndTarget.transitionEnd(function () { + transitionEnd(); + }); + $el.removeClass('panel-in').addClass('panel-out'); // Emit close + + panel.onClose(); + } else { + $el.addClass('not-animated').removeClass('panel-in').addClass('panel-out'); // Emit close + + panel.onClose(); + panel.onClosed(); + } + + return panel; + }; + + _proto.init = function init() { + var panel = this; // const app = panel.app; + + if (typeof panel.params.visibleBreakpoint !== 'undefined') { + panel.setVisibleBreakpoint(); + } + + if (typeof panel.params.collapsedBreakpoint !== 'undefined') { + panel.setCollapsedBreakpoint(); + } + + if (panel.params.swipe) { + panel.enableSwipe(); + } + + if (panel.resizable) { + panel.enableResizable(); + } + }; + + _proto.destroy = function destroy() { + var panel = this; + var app = panel.app; + var _panel = panel, + $containerEl = _panel.$containerEl; + + if (!panel.$el) { + // Panel already destroyed + return; + } + + panel.emit('local::beforeDestroy panelBeforeDestroy', panel); + panel.$el.trigger('panel:beforedestroy'); + + if (panel.visibleBreakpointResizeHandler) { + app.off('resize', panel.visibleBreakpointResizeHandler); + } + + if (panel.collapsedBreakpointResizeHandler) { + app.off('resize', panel.collapsedBreakpointResizeHandler); + } + + if (panel.$el.hasClass('panel-in-breakpoint') || panel.$el.hasClass('panel-in-collapsed')) { + var _$viewEl$css4; + + var $viewEl = (0, _dom.default)(panel.getViewEl()); + + if ($containerEl && $containerEl.hasClass('page')) { + $viewEl.add($containerEl.children('.page-content, .tabs')); + } + + panel.$el.removeClass('panel-in-breakpoint panel-in-collapsed panel-in'); + $viewEl.css((_$viewEl$css4 = {}, _$viewEl$css4["margin-" + panel.side] = '', _$viewEl$css4)); + panel.emit('local::breakpoint panelBreakpoint', panel); + panel.$el.trigger('panel:breakpoint'); + } + + panel.$el.trigger('panel:destroy'); + panel.emit('local::destroy panelDestroy', panel); + + if (panel.el) { + panel.el.f7Panel = null; + delete panel.el.f7Panel; + } + + (0, _utils.deleteProps)(panel); + panel = null; + }; + + return Panel; +}(_class.default); + +var _default = Panel; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/panel/panel.js b/www/assets/framework7/cjs/components/panel/panel.js new file mode 100644 index 000000000..12dcedccb --- /dev/null +++ b/www/assets/framework7/cjs/components/panel/panel.js @@ -0,0 +1,219 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _panelClass = _interopRequireDefault(require("./panel-class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'panel', + params: { + panel: { + opened: undefined, + // default based on panel-in class + side: undefined, + // default based on panel class + effect: undefined, + // default based on panel class + resizable: undefined, + // default based on panel-resizable class + backdrop: true, + backdropEl: undefined, + visibleBreakpoint: undefined, + collapsedBreakpoint: undefined, + swipe: false, + // or true + swipeNoFollow: false, + // or true + swipeOnlyClose: false, + swipeActiveArea: 0, + swipeThreshold: 0, + closeByBackdropClick: true, + containerEl: undefined + } + }, + static: { + Panel: _panelClass.default + }, + create: function create() { + var app = this; + (0, _utils.extend)(app, { + panel: { + allowOpen: true, + create: function create(params) { + return new _panelClass.default(app, params); + }, + get: function get(el) { + if (el === void 0) { + el = '.panel'; + } + + if (el instanceof _panelClass.default) return el; + if (el === 'left' || el === 'right') el = ".panel-" + el; // eslint-disable-line + + var $el = (0, _dom.default)(el); + if ($el.length === 0 || $el.length > 1) return undefined; + return $el[0].f7Panel; + }, + destroy: function destroy(el) { + if (el === void 0) { + el = '.panel'; + } + + var panel = app.panel.get(el); + if (panel && panel.destroy) return panel.destroy(); + return undefined; + }, + open: function open(el, animate) { + if (el === void 0) { + el = '.panel'; + } + + if (el === 'left' || el === 'right') el = ".panel-" + el; // eslint-disable-line + + var panel = app.panel.get(el); + if (panel && panel.open) return panel.open(animate); + + if (!panel) { + panel = app.panel.create({ + el: el + }); + return panel.open(animate); + } + + return undefined; + }, + close: function close(el, animate) { + if (el === void 0) { + el = '.panel-in'; + } + + if (el === 'left' || el === 'right') el = ".panel-" + el; // eslint-disable-line + + var panel = app.panel.get(el); + if (panel && panel.open) return panel.close(animate); + + if (!panel) { + panel = app.panel.create({ + el: el + }); + return panel.close(animate); + } + + return undefined; + }, + toggle: function toggle(el, animate) { + if (el === void 0) { + el = '.panel'; + } + + if (el === 'left' || el === 'right') el = ".panel-" + el; // eslint-disable-line + + var panel = app.panel.get(el); + if (panel && panel.toggle) return panel.toggle(animate); + + if (!panel) { + panel = app.panel.create({ + el: el + }); + return panel.toggle(animate); + } + + return undefined; + } + } + }); + }, + on: { + init: function init() { + var app = this; + (0, _dom.default)('.panel-init').each(function (panelEl) { + var params = Object.assign({ + el: panelEl + }, (0, _dom.default)(panelEl).dataset() || {}); + app.panel.create(params); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.panel-init').each(function (panelEl) { + var params = Object.assign({ + el: panelEl + }, (0, _dom.default)(panelEl).dataset() || {}); + app.panel.create(params); + }); + }, + pageBeforeRemove: function pageBeforeRemove(page) { + var app = this; + page.$el.find('.panel-init').each(function (panelEl) { + var panel = app.panel.get(panelEl); + if (panel && panel.destroy) panel.destroy(); + }); + } + }, + vnode: { + 'panel-init': { + insert: function insert(vnode) { + var app = this; + var panelEl = vnode.elm; + var params = Object.assign({ + el: panelEl + }, (0, _dom.default)(panelEl).dataset() || {}); + app.panel.create(params); + }, + destroy: function destroy(vnode) { + var app = this; + var panelEl = vnode.elm; + var panel = app.panel.get(panelEl); + if (panel && panel.destroy) panel.destroy(); + } + } + }, + clicks: { + '.panel-open': function open(clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.panel.open(data.panel, data.animate); + }, + '.panel-close': function close(clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.panel.close(data.panel, data.animate); + }, + '.panel-toggle': function close(clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.panel.toggle(data.panel, data.animate); + }, + '.panel-backdrop': function close() { + var app = this; + var $panelEl = (0, _dom.default)('.panel-in:not(.panel-out)'); + if (!$panelEl.length) return; + var instance = $panelEl[0] && $panelEl[0].f7Panel; + $panelEl.trigger('panel:backdrop-click'); + + if (instance) { + instance.emit('backdropClick', instance); + } + + app.emit('panelBackdropClick', instance || $panelEl[0]); + if (app.params.panel.closeByBackdropClick) app.panel.close(); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/panel/resizable-panel.js b/www/assets/framework7/cjs/components/panel/resizable-panel.js new file mode 100644 index 000000000..638ebd9ab --- /dev/null +++ b/www/assets/framework7/cjs/components/panel/resizable-panel.js @@ -0,0 +1,197 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _getSupport = require("../../shared/get-support"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function resizablePanel(panel) { + var app = panel.app; + var support = (0, _getSupport.getSupport)(); + if (panel.resizableInitialized) return; + (0, _utils.extend)(panel, { + resizable: true, + resizableWidth: null, + resizableInitialized: true + }); + var $htmlEl = (0, _dom.default)('html'); + var $el = panel.$el, + $backdropEl = panel.$backdropEl, + side = panel.side, + effect = panel.effect; + if (!$el) return; + var isTouched; + var isMoved; + var touchesStart = {}; + var touchesDiff; + var panelWidth; + var $viewEl; + var panelMinWidth; + var panelMaxWidth; + var visibleByBreakpoint; + + function transformCSSWidth(v) { + if (!v) return null; + + if (v.indexOf('%') >= 0 || v.indexOf('vw') >= 0) { + return parseInt(v, 10) / 100 * app.width; + } + + var newV = parseInt(v, 10); + if (Number.isNaN(newV)) return null; + return newV; + } + + function isResizable() { + return panel.resizable && $el.hasClass('panel-resizable'); + } + + function handleTouchStart(e) { + if (!isResizable()) return; + touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; + touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + isMoved = false; + isTouched = true; + panelMinWidth = transformCSSWidth($el.css('min-width')); + panelMaxWidth = transformCSSWidth($el.css('max-width')); + visibleByBreakpoint = $el.hasClass('panel-in-breakpoint'); + } + + function handleTouchMove(e) { + if (!isTouched) return; + var pageX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; + + if (!isMoved) { + panelWidth = $el[0].offsetWidth; + $el.transition(0); + $el.addClass('panel-resizing'); + $htmlEl.css('cursor', 'col-resize'); + + if (effect !== 'cover' || visibleByBreakpoint) { + $viewEl = (0, _dom.default)(panel.getViewEl()); + + if (panel.$containerEl && panel.$containerEl.hasClass('page')) { + $viewEl.add(panel.$containerEl.children('.page-content, .tabs, .fab')); + } + } + + if (effect !== 'cover' && !visibleByBreakpoint) { + $backdropEl.transition(0); + $viewEl.transition(0); + } + } + + isMoved = true; + e.preventDefault(); + touchesDiff = pageX - touchesStart.x; + var newPanelWidth = side === 'left' ? panelWidth + touchesDiff : panelWidth - touchesDiff; + + if (panelMinWidth && !Number.isNaN(panelMinWidth)) { + newPanelWidth = Math.max(newPanelWidth, panelMinWidth); + } + + if (panelMaxWidth && !Number.isNaN(panelMaxWidth)) { + newPanelWidth = Math.min(newPanelWidth, panelMaxWidth); + } + + newPanelWidth = Math.min(Math.max(newPanelWidth, 0), app.width); + panel.resizableWidth = newPanelWidth; + $el[0].style.width = newPanelWidth + "px"; + + if (effect !== 'cover' && !visibleByBreakpoint) { + if ($viewEl) { + $viewEl.transform("translate3d(" + (side === 'left' ? newPanelWidth : -newPanelWidth) + "px, 0, 0)"); + } + + if ($backdropEl) { + $backdropEl.transform("translate3d(" + (side === 'left' ? newPanelWidth : -newPanelWidth) + "px, 0, 0)"); + } + } else if (visibleByBreakpoint && $viewEl) { + $viewEl.css("margin-" + side, newPanelWidth + "px"); + } + + $el.trigger('panel:resize', newPanelWidth); + panel.emit('local::resize panelResize', panel, newPanelWidth); + } + + function handleTouchEnd() { + (0, _dom.default)('html').css('cursor', ''); + + if (!isTouched || !isMoved) { + isTouched = false; + isMoved = false; + return; + } + + isTouched = false; + isMoved = false; + $htmlEl[0].style.setProperty("--f7-panel-" + side + "-width", panel.resizableWidth + "px"); + $el[0].style.width = ''; + + if (effect !== 'cover' && !visibleByBreakpoint) { + $viewEl.transform(''); + $backdropEl.transform(''); + } + + $el.removeClass('panel-resizing'); + (0, _utils.nextFrame)(function () { + $el.transition(''); + + if (effect !== 'cover') { + $backdropEl.transition(''); + if ($viewEl) $viewEl.transition(''); + } + }); + } + + function handleResize() { + if (!panel.opened || !panel.resizableWidth) return; + panelMinWidth = transformCSSWidth($el.css('min-width')); + panelMaxWidth = transformCSSWidth($el.css('max-width')); + + if (panelMinWidth && !Number.isNaN(panelMinWidth) && panel.resizableWidth < panelMinWidth) { + panel.resizableWidth = Math.max(panel.resizableWidth, panelMinWidth); + } + + if (panelMaxWidth && !Number.isNaN(panelMaxWidth) && panel.resizableWidth > panelMaxWidth) { + panel.resizableWidth = Math.min(panel.resizableWidth, panelMaxWidth); + } + + panel.resizableWidth = Math.min(Math.max(panel.resizableWidth, 0), app.width); + $htmlEl[0].style.setProperty("--f7-panel-" + side + "-width", panel.resizableWidth + "px"); + } + + if (panel.$el.find('.panel-resize-handler').length === 0) { + panel.$el.append('
    '); + } + + panel.$resizeHandlerEl = panel.$el.children('.panel-resize-handler'); + $el.addClass('panel-resizable'); // Add Events + + var passive = support.passiveListener ? { + passive: true + } : false; + panel.$el.on(app.touchEvents.start, '.panel-resize-handler', handleTouchStart, passive); + app.on('touchmove:active', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + app.on('resize', handleResize); + panel.on('beforeOpen', handleResize); + panel.once('panelDestroy', function () { + $el.removeClass('panel-resizable'); + panel.$resizeHandlerEl.remove(); + panel.$el.off(app.touchEvents.start, '.panel-resize-handler', handleTouchStart, passive); + app.off('touchmove:active', handleTouchMove); + app.off('touchend:passive', handleTouchEnd); + app.off('resize', handleResize); + panel.off('beforeOpen', handleResize); + }); +} + +var _default = resizablePanel; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/panel/swipe-panel.js b/www/assets/framework7/cjs/components/panel/swipe-panel.js new file mode 100644 index 000000000..38649b163 --- /dev/null +++ b/www/assets/framework7/cjs/components/panel/swipe-panel.js @@ -0,0 +1,363 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function swipePanel(panel) { + var app = panel.app; + + if (panel.swipeInitialized) { + return; + } + + (0, _utils.extend)(panel, { + swipeable: true, + swipeInitialized: true + }); + var params = panel.params; + var $el = panel.$el, + $backdropEl = panel.$backdropEl, + side = panel.side, + effect = panel.effect; + var otherPanel; + var isTouched; + var isGestureStarted; + var isMoved; + var isScrolling; + var isInterrupted; + var touchesStart = {}; + var touchStartTime; + var touchesDiff; + var translate; + var backdropOpacity; + var panelWidth; + var direction; + var $viewEl; + var touchMoves = 0; + + function handleTouchStart(e) { + if (!panel.swipeable || isGestureStarted) return; + if (!app.panel.allowOpen || !params.swipe && !params.swipeOnlyClose || isTouched) return; + if ((0, _dom.default)('.modal-in:not(.toast):not(.notification), .photo-browser-in').length > 0) return; + otherPanel = app.panel.get(side === 'left' ? 'right' : 'left') || {}; + var otherPanelOpened = otherPanel.opened && otherPanel.$el && !otherPanel.$el.hasClass('panel-in-breakpoint'); + + if (!panel.opened && otherPanelOpened) { + return; + } + + if (!params.swipeOnlyClose) { + if (otherPanelOpened) return; + } + + if (e.target && e.target.nodeName.toLowerCase() === 'input' && e.target.type === 'range') return; + if ((0, _dom.default)(e.target).closest('.range-slider, .tabs-swipeable-wrap, .calendar-months, .no-swipe-panel, .card-opened').length > 0) return; + touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; + touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + + if (params.swipeOnlyClose && !panel.opened) { + return; + } + + if (params.swipeActiveArea && !panel.opened) { + if (side === 'left') { + if (touchesStart.x > params.swipeActiveArea) return; + } + + if (side === 'right') { + if (touchesStart.x < app.width - params.swipeActiveArea) return; + } + } + + touchMoves = 0; + $viewEl = (0, _dom.default)(panel.getViewEl()); + isMoved = false; + isTouched = true; + isScrolling = undefined; + isInterrupted = false; + touchStartTime = (0, _utils.now)(); + direction = undefined; + } + + function handleTouchMove(e) { + if (!isTouched || isGestureStarted || isInterrupted) return; + touchMoves += 1; + if (touchMoves < 2) return; + + if (e.f7PreventSwipePanel || app.preventSwipePanelBySwipeBack || app.preventSwipePanel) { + isTouched = false; + return; + } + + var pageX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; + var pageY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; + + if (typeof isScrolling === 'undefined') { + isScrolling = !!(isScrolling || Math.abs(pageY - touchesStart.y) > Math.abs(pageX - touchesStart.x)); + } + + if (isScrolling) { + isTouched = false; + return; + } + + if (!direction) { + if (pageX > touchesStart.x) { + direction = 'to-right'; + } else { + direction = 'to-left'; + } + + if (params.swipeActiveArea > 0 && !panel.opened) { + if (side === 'left' && touchesStart.x > params.swipeActiveArea) { + isTouched = false; + return; + } + + if (side === 'right' && touchesStart.x < app.width - params.swipeActiveArea) { + isTouched = false; + return; + } + } + + if ($el.hasClass('panel-in-breakpoint')) { + isTouched = false; + return; + } + + if (side === 'left' && direction === 'to-left' && !$el.hasClass('panel-in') || side === 'right' && direction === 'to-right' && !$el.hasClass('panel-in')) { + isTouched = false; + return; + } + } + + var threshold = panel.opened ? 0 : -params.swipeThreshold; + if (side === 'right') threshold = -threshold; + + if (!isMoved) { + if (!panel.opened) { + panel.insertToRoot(); + $el.addClass('panel-in-swipe'); + $backdropEl.css('visibility', 'visible'); + $el.trigger('panel:swipeopen'); + panel.emit('local::swipeOpen panelSwipeOpen', panel); + } + + panelWidth = $el[0].offsetWidth; + + if (effect === 'reveal' && $el.hasClass('panel-in-collapsed')) { + panelWidth -= parseFloat($viewEl.css("margin-" + side)); + } + + $el.transition(0); + } + + isMoved = true; + + if (e.cancelable) { + e.preventDefault(); + } + + touchesDiff = pageX - touchesStart.x + threshold; + + if (side === 'right') { + if (effect === 'cover' || effect === 'push') { + translate = touchesDiff + (panel.opened ? 0 : panelWidth); + if (translate < 0) translate = 0; + + if (translate > panelWidth) { + translate = panelWidth; + } + } else { + translate = touchesDiff - (panel.opened ? panelWidth : 0); + if (translate > 0) translate = 0; + + if (translate < -panelWidth) { + translate = -panelWidth; + } + } + } else { + translate = touchesDiff + (panel.opened ? panelWidth : 0); + if (translate < 0) translate = 0; + + if (translate > panelWidth) { + translate = panelWidth; + } + } + + var noFollowProgress = Math.abs(translate / panelWidth); + + if (effect === 'reveal') { + if (!params.swipeNoFollow) { + $viewEl.transform("translate3d(" + translate + "px,0,0)").transition(0); + $backdropEl.transform("translate3d(" + translate + "px,0,0)").transition(0); + } + + $el.trigger('panel:swipe', Math.abs(translate / panelWidth)); + panel.emit('local::swipe panelSwipe', panel, Math.abs(translate / panelWidth)); + } else { + if (side === 'left') translate -= panelWidth; + + if (!params.swipeNoFollow) { + $backdropEl.transition(0); + backdropOpacity = 1 - Math.abs(translate / panelWidth); + $backdropEl.css({ + opacity: backdropOpacity + }); + $el.transform("translate3d(" + translate + "px,0,0)").transition(0); + + if (effect === 'push') { + var viewTranslate = side === 'left' ? translate + panelWidth : translate - panelWidth; + $viewEl.transform("translate3d(" + viewTranslate + "px,0,0)").transition(0); + $backdropEl.transform("translate3d(" + viewTranslate + "px,0,0)").transition(0); + } + } + + $el.trigger('panel:swipe', Math.abs(translate / panelWidth)); + panel.emit('local::swipe panelSwipe', panel, Math.abs(translate / panelWidth)); + } + + if (params.swipeNoFollow) { + var stateChanged = panel.opened && noFollowProgress === 0 || !panel.opened && noFollowProgress === 1; + + if (stateChanged) { + isInterrupted = true; // eslint-disable-next-line + + handleTouchEnd(e); + } + } + } + + function handleTouchEnd(e) { + if (!isTouched || !isMoved) { + isTouched = false; + isMoved = false; + return; + } + + var isGesture = e.type === 'gesturestart' || isGestureStarted; + isTouched = false; + isMoved = false; + var timeDiff = new Date().getTime() - touchStartTime; + var action; + var edge = (translate === 0 || Math.abs(translate) === panelWidth) && !params.swipeNoFollow; + var threshold = params.swipeThreshold || 0; + + if (isGesture) { + action = 'reset'; + } else if (!panel.opened) { + if (Math.abs(touchesDiff) < threshold) { + action = 'reset'; + } else if (effect === 'cover' || effect === 'push') { + if (translate === 0) { + action = 'swap'; // open + } else if (timeDiff < 300 && Math.abs(translate) > 0) { + action = 'swap'; // open + } else if (timeDiff >= 300 && Math.abs(translate) < panelWidth / 2) { + action = 'swap'; // open + } else { + action = 'reset'; // close + } + } else if (translate === 0) { + action = 'reset'; + } else if (timeDiff < 300 && Math.abs(translate) > 0 || timeDiff >= 300 && Math.abs(translate) >= panelWidth / 2) { + action = 'swap'; + } else { + action = 'reset'; + } + } else if (effect === 'cover' || effect === 'push') { + if (translate === 0) { + action = 'reset'; // open + } else if (timeDiff < 300 && Math.abs(translate) > 0) { + action = 'swap'; // open + } else if (timeDiff >= 300 && Math.abs(translate) < panelWidth / 2) { + action = 'reset'; // open + } else { + action = 'swap'; // close + } + } else if (translate === -panelWidth) { + action = 'reset'; + } else if (timeDiff < 300 && Math.abs(translate) >= 0 || timeDiff >= 300 && Math.abs(translate) <= panelWidth / 2) { + if (side === 'left' && translate === panelWidth) action = 'reset';else action = 'swap'; + } else { + action = 'reset'; + } + + if (action === 'swap') { + if (panel.opened) { + panel.close(!edge); + } else { + panel.open(!edge); + } + } + + var removePanelInClass = true; + + if (action === 'reset') { + if (!panel.opened) { + if (edge) { + // edge position + $el.removeClass('panel-in-swipe'); + } else { + removePanelInClass = false; + var target = effect === 'reveal' ? $viewEl : $el; + panel.setStateClasses('before-closing'); + target.transitionEnd(function () { + if ($el.hasClass('panel-in')) return; + $el.removeClass('panel-in-swipe'); + panel.setStateClasses('after-closing'); + }); + } + } + } + + if (effect === 'reveal' || effect === 'push') { + (0, _utils.nextFrame)(function () { + $viewEl.transition(''); + $viewEl.transform(''); + }); + } + + if (removePanelInClass) { + $el.removeClass('panel-in-swipe'); + } + + $el.transition('').transform(''); + $backdropEl.transform('').transition('').css({ + opacity: '', + visibility: '' + }); + } + + function handleGestureStart(e) { + isGestureStarted = true; + handleTouchEnd(e); + } + + function handleGestureEnd() { + isGestureStarted = false; + } // Add Events + + + app.on('touchstart:passive', handleTouchStart); + app.on('touchmove:active', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + app.on('gesturestart', handleGestureStart); + app.on('gestureend', handleGestureEnd); + panel.on('panelDestroy', function () { + app.off('touchstart:passive', handleTouchStart); + app.off('touchmove:active', handleTouchMove); + app.off('touchend:passive', handleTouchEnd); + app.off('gesturestart', handleGestureStart); + app.off('gestureend', handleGestureEnd); + }); +} + +var _default = swipePanel; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/photo-browser/photo-browser-class.js b/www/assets/framework7/cjs/components/photo-browser/photo-browser-class.js new file mode 100644 index 000000000..8443eecd2 --- /dev/null +++ b/www/assets/framework7/cjs/components/photo-browser/photo-browser-class.js @@ -0,0 +1,781 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _$jsx = _interopRequireDefault(require("../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var PhotoBrowser = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(PhotoBrowser, _Framework7Class); + + function PhotoBrowser(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params, [app]) || this; + + var pb = _assertThisInitialized(_this); + + pb.app = app; + var defaults = (0, _utils.extend)({ + on: {} + }, app.params.photoBrowser); // Extend defaults with modules params + + pb.useModulesParams(defaults); + pb.params = (0, _utils.extend)(defaults, params); + (0, _utils.extend)(pb, { + exposed: false, + opened: false, + activeIndex: pb.params.swiper.initialSlide, + url: pb.params.url, + swipeToClose: { + allow: true, + isTouched: false, + diff: undefined, + start: undefined, + current: undefined, + started: false, + activeSlide: undefined, + timeStart: undefined + } + }); // Install Modules + + pb.useModules(); // Init + + pb.init(); + return _this; + } + + var _proto = PhotoBrowser.prototype; + + _proto.onSlideChange = function onSlideChange(swiper) { + var pb = this; + pb.activeIndex = swiper.activeIndex; + var current = swiper.activeIndex + 1; + var total = pb.params.virtualSlides ? pb.params.photos.length : swiper.slides.length; + + if (swiper.params.loop) { + total -= 2; + current -= swiper.loopedSlides; + if (current < 1) current = total + current; + if (current > total) current -= total; + } + + var $activeSlideEl = pb.params.virtualSlides ? swiper.$wrapperEl.find(".swiper-slide[data-swiper-slide-index=\"" + swiper.activeIndex + "\"]") : swiper.slides.eq(swiper.activeIndex); + var $previousSlideEl = pb.params.virtualSlides ? swiper.$wrapperEl.find(".swiper-slide[data-swiper-slide-index=\"" + swiper.previousIndex + "\"]") : swiper.slides.eq(swiper.previousIndex); + var $currentEl = pb.$el.find('.photo-browser-current'); + var $totalEl = pb.$el.find('.photo-browser-total'); + var navbarEl; + + if (pb.params.type === 'page' && pb.params.navbar && $currentEl.length === 0 && pb.app.theme === 'ios') { + navbarEl = pb.app.navbar.getElByPage(pb.$el); + + if (navbarEl) { + $currentEl = (0, _dom.default)(navbarEl).find('.photo-browser-current'); + $totalEl = (0, _dom.default)(navbarEl).find('.photo-browser-total'); + } + } + + if ($currentEl.length && $totalEl.length) { + $currentEl.text(current); + $totalEl.text(total); + if (!navbarEl) navbarEl = $currentEl.parents('.navbar')[0]; + + if (navbarEl) { + pb.app.navbar.size(navbarEl); + } + } // Update captions + + + if (pb.captions.length > 0) { + var captionIndex = swiper.params.loop ? $activeSlideEl.attr('data-swiper-slide-index') : pb.activeIndex; + pb.$captionsContainerEl.find('.photo-browser-caption-active').removeClass('photo-browser-caption-active'); + pb.$captionsContainerEl.find("[data-caption-index=\"" + captionIndex + "\"]").addClass('photo-browser-caption-active'); + } // Stop Video + + + var previousSlideVideo = $previousSlideEl.find('video'); + + if (previousSlideVideo.length > 0) { + if ('pause' in previousSlideVideo[0]) previousSlideVideo[0].pause(); + } + }; + + _proto.onTouchStart = function onTouchStart() { + var pb = this; + var swipeToClose = pb.swipeToClose; + if (!swipeToClose.allow) return; + swipeToClose.isTouched = true; + }; + + _proto.onTouchMove = function onTouchMove(e) { + var pb = this; + var swipeToClose = pb.swipeToClose; + if (!swipeToClose.isTouched) return; + + if (!swipeToClose.started) { + swipeToClose.started = true; + swipeToClose.start = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; + + if (pb.params.virtualSlides) { + swipeToClose.activeSlide = pb.swiper.$wrapperEl.children('.swiper-slide-active'); + } else { + swipeToClose.activeSlide = pb.swiper.slides.eq(pb.swiper.activeIndex); + } + + swipeToClose.timeStart = (0, _utils.now)(); + } + + e.preventDefault(); + swipeToClose.current = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; + swipeToClose.diff = swipeToClose.start - swipeToClose.current; + pb.$el.transition(0).transform("translate3d(0," + -swipeToClose.diff + "px,0)"); + }; + + _proto.onTouchEnd = function onTouchEnd() { + var pb = this; + var swipeToClose = pb.swipeToClose; + swipeToClose.isTouched = false; + + if (!swipeToClose.started) { + swipeToClose.started = false; + return; + } + + swipeToClose.started = false; + swipeToClose.allow = false; + var diff = Math.abs(swipeToClose.diff); + var timeDiff = new Date().getTime() - swipeToClose.timeStart; + + if (timeDiff < 300 && diff > 20 || timeDiff >= 300 && diff > 100) { + (0, _utils.nextTick)(function () { + if (pb.$el) { + if (swipeToClose.diff < 0) pb.$el.addClass('swipe-close-to-bottom');else pb.$el.addClass('swipe-close-to-top'); + } + + pb.emit('local::swipeToClose', pb); + pb.$el.transform('').transition(''); + pb.close(); + swipeToClose.allow = true; + }); + return; + } + + if (diff !== 0) { + pb.$el.addClass('photo-browser-transitioning').transitionEnd(function () { + swipeToClose.allow = true; + pb.$el.removeClass('photo-browser-transitioning'); + }); + } else { + swipeToClose.allow = true; + } + + (0, _utils.nextTick)(function () { + pb.$el.transform('').transition(''); + }); + } // Render Functions + ; + + _proto.renderNavbar = function renderNavbar() { + var pb = this; + if (pb.params.renderNavbar) return pb.params.renderNavbar.call(pb); + var iconsColor = pb.params.iconsColor; + if (!pb.params.iconsColor && pb.params.theme === 'dark') iconsColor = 'white'; + var pageBackLinkText = (pb.app.theme === 'ios' || pb.app.theme === 'aurora') && pb.params.pageBackLinkText ? pb.params.pageBackLinkText : ''; + var renderNavbarCount = typeof pb.params.navbarShowCount === 'undefined' ? pb.params.photos.length > 1 : pb.params.navbarShowCount; + var isPopup = pb.params.type !== 'page'; + return (0, _$jsx.default)("div", { + class: "navbar navbar-photo-browser " + (pb.params.theme === 'dark' ? 'navbar-photo-browser-dark' : '') + }, (0, _$jsx.default)("div", { + class: "navbar-bg" + }), (0, _$jsx.default)("div", { + class: "navbar-inner navbar-inner-centered-title sliding" + }, !isPopup && (0, _$jsx.default)("div", { + class: "left" + }, (0, _$jsx.default)("a", { + class: "link " + (!pageBackLinkText ? 'icon-only' : '') + " back" + }, (0, _$jsx.default)("i", { + class: "icon icon-back " + (iconsColor ? "color-" + iconsColor : '') + }), pageBackLinkText && (0, _$jsx.default)("span", null, pageBackLinkText))), renderNavbarCount && (0, _$jsx.default)("div", { + class: "title" + }, (0, _$jsx.default)("span", { + class: "photo-browser-current" + }), (0, _$jsx.default)("span", { + class: "photo-browser-of" + }, pb.params.navbarOfText), (0, _$jsx.default)("span", { + class: "photo-browser-total" + })), isPopup && (0, _$jsx.default)("div", { + class: "right" + }, (0, _$jsx.default)("a", { + class: "link popup-close", + "data-popup": ".photo-browser-popup" + }, (0, _$jsx.default)("span", null, pb.params.popupCloseLinkText))))); + }; + + _proto.renderToolbar = function renderToolbar() { + var pb = this; + if (pb.params.renderToolbar) return pb.params.renderToolbar.call(pb); + var iconsColor = pb.params.iconsColor; + if (!pb.params.iconsColor && pb.params.theme === 'dark') iconsColor = 'white'; + return (0, _$jsx.default)("div", { + class: "toolbar toolbar-bottom tabbar" + }, (0, _$jsx.default)("div", { + class: "toolbar-inner" + }, (0, _$jsx.default)("a", { + class: "link photo-browser-prev" + }, (0, _$jsx.default)("i", { + class: "icon icon-back " + (iconsColor ? "color-" + iconsColor : '') + })), (0, _$jsx.default)("a", { + class: "link photo-browser-next" + }, (0, _$jsx.default)("i", { + class: "icon icon-forward " + (iconsColor ? "color-" + iconsColor : '') + })))); + }; + + _proto.renderCaption = function renderCaption(caption, index) { + var pb = this; + if (pb.params.renderCaption) return pb.params.renderCaption.call(pb, caption, index); + return (0, _$jsx.default)("div", { + class: "photo-browser-caption", + "data-caption-index": index + }, caption); + }; + + _proto.renderObject = function renderObject(photo, index) { + var pb = this; + if (pb.params.renderObject) return pb.params.renderObject.call(pb, photo, index); + return (0, _$jsx.default)("div", { + class: "photo-browser-slide photo-browser-object-slide swiper-slide", + "data-swiper-slide-index": index + }, photo.html ? photo.html : photo); + }; + + _proto.renderLazyPhoto = function renderLazyPhoto(photo, index) { + var pb = this; + if (pb.params.renderLazyPhoto) return pb.params.renderLazyPhoto.call(pb, photo, index); + return (0, _$jsx.default)("div", { + class: "photo-browser-slide photo-browser-slide-lazy swiper-slide", + "data-swiper-slide-index": index + }, (0, _$jsx.default)("div", { + class: "swiper-lazy-preloader" + }), (0, _$jsx.default)("span", { + class: "swiper-zoom-container" + }, (0, _$jsx.default)("img", { + "data-src": photo.url ? photo.url : photo, + class: "swiper-lazy" + }))); + }; + + _proto.renderPhoto = function renderPhoto(photo, index) { + var pb = this; + if (pb.params.renderPhoto) return pb.params.renderPhoto.call(pb, photo, index); + return (0, _$jsx.default)("div", { + class: "photo-browser-slide swiper-slide", + "data-swiper-slide-index": index + }, (0, _$jsx.default)("span", { + class: "swiper-zoom-container" + }, (0, _$jsx.default)("img", { + src: photo.url ? photo.url : photo + }))); + }; + + _proto.render = function render() { + var pb = this; + if (pb.params.render) return pb.params.render.call(pb, pb.params); + return (0, _$jsx.default)("div", { + class: "photo-browser photo-browser-" + pb.params.theme + }, (0, _$jsx.default)("div", { + class: "view" + }, (0, _$jsx.default)("div", { + class: "page photo-browser-page photo-browser-page-" + pb.params.theme + " no-toolbar " + (!pb.params.navbar ? 'no-navbar' : ''), + "data-name": "photo-browser-page" + }, pb.params.navbar && pb.renderNavbar(), pb.params.toolbar && pb.renderToolbar(), (0, _$jsx.default)("div", { + class: "photo-browser-captions photo-browser-captions-" + (pb.params.captionsTheme || pb.params.theme) + }, pb.params.photos.map(function (photo, index) { + if (photo.caption) return pb.renderCaption(photo.caption, index); + return ''; + })), (0, _$jsx.default)("div", { + class: "photo-browser-swiper-container swiper-container" + }, (0, _$jsx.default)("div", { + class: "photo-browser-swiper-wrapper swiper-wrapper" + }, !pb.params.virtualSlides && pb.params.photos.map(function (photo, index) { + if (photo.html || (typeof photo === 'string' || photo instanceof String) && photo.indexOf('<') >= 0 && photo.indexOf('>') >= 0) { + return pb.renderObject(photo, index); + } + + if (pb.params.swiper.lazy === true || pb.params.swiper.lazy && pb.params.swiper.lazy.enabled) { + return pb.renderLazyPhoto(photo, index); + } + + return pb.renderPhoto(photo, index); + })))))); + }; + + _proto.renderStandalone = function renderStandalone() { + var pb = this; + if (pb.params.renderStandalone) return pb.params.renderStandalone.call(pb); + var standaloneHtml = "
    " + pb.render() + "
    "; + return standaloneHtml; + }; + + _proto.renderPage = function renderPage() { + var pb = this; + if (pb.params.renderPage) return pb.params.renderPage.call(pb); + var pageHtml = pb.render(); + return pageHtml; + }; + + _proto.renderPopup = function renderPopup() { + var pb = this; + if (pb.params.renderPopup) return pb.params.renderPopup.call(pb); + var popupHtml = "
    " + pb.render() + "
    "; + return popupHtml; + } // Callbacks + ; + + _proto.onOpen = function onOpen(type, el) { + var pb = this; + var app = pb.app; + var $el = (0, _dom.default)(el); + $el[0].f7PhotoBrowser = pb; + pb.$el = $el; + pb.el = $el[0]; + pb.openedIn = type; + pb.opened = true; + pb.$swiperContainerEl = pb.$el.find('.photo-browser-swiper-container'); + pb.$swiperWrapperEl = pb.$el.find('.photo-browser-swiper-wrapper'); + pb.slides = pb.$el.find('.photo-browser-slide'); + pb.$captionsContainerEl = pb.$el.find('.photo-browser-captions'); + pb.captions = pb.$el.find('.photo-browser-caption'); // Init Swiper + + var clickTimeout; + var swiperParams = (0, _utils.extend)({}, pb.params.swiper, { + initialSlide: pb.activeIndex, + on: { + click: function click(e) { + clearTimeout(clickTimeout); + + if (pb.params.exposition) { + clickTimeout = setTimeout(function () { + pb.expositionToggle(); + }, 350); + } + + pb.emit('local::tap', e); + pb.emit('local::click', e); + }, + doubleClick: function doubleClick(e) { + clearTimeout(clickTimeout); + pb.emit('local::doubleTap', e); + pb.emit('local::doubleClick', e); + }, + slideChange: function slideChange() { + var swiper = this; + pb.onSlideChange(swiper); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + pb.emit.apply(pb, ['local::slideChange'].concat(args)); + }, + transitionStart: function transitionStart() { + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + pb.emit.apply(pb, ['local::transitionStart'].concat(args)); + }, + transitionEnd: function transitionEnd() { + for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + pb.emit.apply(pb, ['local::transitionEnd'].concat(args)); + }, + slideChangeTransitionStart: function slideChangeTransitionStart() { + var swiper = this; + pb.onSlideChange(swiper); + + for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + args[_key4] = arguments[_key4]; + } + + pb.emit.apply(pb, ['local::slideChangeTransitionStart'].concat(args)); + }, + slideChangeTransitionEnd: function slideChangeTransitionEnd() { + for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { + args[_key5] = arguments[_key5]; + } + + pb.emit.apply(pb, ['local::slideChangeTransitionEnd'].concat(args)); + }, + lazyImageLoad: function lazyImageLoad() { + for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { + args[_key6] = arguments[_key6]; + } + + pb.emit.apply(pb, ['local::lazyImageLoad'].concat(args)); + }, + lazyImageReady: function lazyImageReady() { + for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) { + args[_key7] = arguments[_key7]; + } + + var slideEl = args[0]; + (0, _dom.default)(slideEl).removeClass('photo-browser-slide-lazy'); + pb.emit.apply(pb, ['local::lazyImageReady'].concat(args)); + } + } + }); + + if (pb.params.swipeToClose && pb.params.type !== 'page') { + (0, _utils.extend)(swiperParams.on, { + touchStart: function touchStart(swiper, e) { + pb.onTouchStart(e); + pb.emit('local::touchStart', e); + }, + touchMoveOpposite: function touchMoveOpposite(swiper, e) { + pb.onTouchMove(e); + pb.emit('local::touchMoveOpposite', e); + }, + touchEnd: function touchEnd(swiper, e) { + pb.onTouchEnd(e); + pb.emit('local::touchEnd', e); + } + }); + } + + if (pb.params.virtualSlides) { + (0, _utils.extend)(swiperParams, { + virtual: { + slides: pb.params.photos, + renderSlide: function renderSlide(photo, index) { + if (photo.html || (typeof photo === 'string' || photo instanceof String) && photo.indexOf('<') >= 0 && photo.indexOf('>') >= 0) { + return pb.renderObject(photo, index); + } + + if (pb.params.swiper.lazy === true || pb.params.swiper.lazy && pb.params.swiper.lazy.enabled) { + return pb.renderLazyPhoto(photo, index); + } + + return pb.renderPhoto(photo, index); + } + } + }); + } + + var window = (0, _ssrWindow.getWindow)(); + pb.swiper = app.swiper ? app.swiper.create(pb.$swiperContainerEl, swiperParams) : new window.Swiper(pb.$swiperContainerEl, swiperParams); + + if (pb.activeIndex === 0) { + pb.onSlideChange(pb.swiper); + } + + if (pb.$el) { + pb.$el.trigger('photobrowser:open'); + } + + pb.emit('local::open photoBrowserOpen', pb); + }; + + _proto.onOpened = function onOpened() { + var pb = this; + + if (pb.$el && pb.params.type === 'standalone') { + pb.$el.css('animation', 'none'); + } + + if (pb.$el) { + pb.$el.trigger('photobrowser:opened'); + } + + pb.emit('local::opened photoBrowserOpened', pb); + }; + + _proto.onClose = function onClose() { + var pb = this; + if (pb.destroyed) return; // Destroy Swiper + + if (pb.swiper && pb.swiper.destroy) { + pb.swiper.destroy(true, false); + pb.swiper = null; + delete pb.swiper; + } + + if (pb.$el) { + pb.$el.trigger('photobrowser:close'); + } + + pb.emit('local::close photoBrowserClose', pb); + }; + + _proto.onClosed = function onClosed() { + var pb = this; + if (pb.destroyed) return; + pb.opened = false; + pb.$el = null; + pb.el = null; + delete pb.$el; + delete pb.el; + + if (pb.$el) { + pb.$el.trigger('photobrowser:closed'); + } + + pb.emit('local::closed photoBrowserClosed', pb); + } // Open + ; + + _proto.openPage = function openPage() { + var pb = this; + if (pb.opened) return pb; + var pageHtml = pb.renderPage(); + pb.view.router.navigate({ + url: pb.url, + route: { + content: pageHtml, + path: pb.url, + on: { + pageBeforeIn: function pageBeforeIn(e, page) { + pb.view.$el.addClass("with-photo-browser-page with-photo-browser-page-" + pb.params.theme); + pb.onOpen('page', page.el); + }, + pageAfterIn: function pageAfterIn(e, page) { + pb.onOpened('page', page.el); + }, + pageBeforeOut: function pageBeforeOut(e, page) { + pb.view.$el.removeClass("with-photo-browser-page with-photo-browser-page-exposed with-photo-browser-page-" + pb.params.theme); + pb.onClose('page', page.el); + }, + pageAfterOut: function pageAfterOut(e, page) { + pb.onClosed('page', page.el); + } + } + } + }); + return pb; + }; + + _proto.openStandalone = function openStandalone() { + var pb = this; + if (pb.opened) return pb; + var standaloneHtml = pb.renderStandalone(); + var popupParams = { + backdrop: false, + content: standaloneHtml, + on: { + popupOpen: function popupOpen(popup) { + pb.onOpen('popup', popup.el); + }, + popupOpened: function popupOpened(popup) { + pb.onOpened('popup', popup.el); + }, + popupClose: function popupClose(popup) { + pb.onClose('popup', popup.el); + }, + popupClosed: function popupClosed(popup) { + pb.onClosed('popup', popup.el); + } + } + }; + + if (pb.params.routableModals && pb.view) { + pb.view.router.navigate({ + url: pb.url, + route: { + path: pb.url, + popup: popupParams + } + }); + } else { + pb.modal = pb.app.popup.create(popupParams).open(); + } + + return pb; + }; + + _proto.openPopup = function openPopup() { + var pb = this; + if (pb.opened) return pb; + var popupHtml = pb.renderPopup(); + var popupParams = { + content: popupHtml, + push: pb.params.popupPush, + on: { + popupOpen: function popupOpen(popup) { + pb.onOpen('popup', popup.el); + }, + popupOpened: function popupOpened(popup) { + pb.onOpened('popup', popup.el); + }, + popupClose: function popupClose(popup) { + pb.onClose('popup', popup.el); + }, + popupClosed: function popupClosed(popup) { + pb.onClosed('popup', popup.el); + } + } + }; + + if (pb.params.routableModals && pb.view) { + pb.view.router.navigate({ + url: pb.url, + route: { + path: pb.url, + popup: popupParams + } + }); + } else { + pb.modal = pb.app.popup.create(popupParams).open(); + } + + return pb; + } // Exposition + ; + + _proto.expositionEnable = function expositionEnable() { + var pb = this; + + if (pb.params.type === 'page') { + pb.view.$el.addClass('with-photo-browser-page-exposed'); + } + + if (pb.$el) pb.$el.addClass('photo-browser-exposed'); + if (pb.params.expositionHideCaptions) pb.$captionsContainerEl.addClass('photo-browser-captions-exposed'); + pb.exposed = true; + return pb; + }; + + _proto.expositionDisable = function expositionDisable() { + var pb = this; + + if (pb.params.type === 'page') { + pb.view.$el.removeClass('with-photo-browser-page-exposed'); + } + + if (pb.$el) pb.$el.removeClass('photo-browser-exposed'); + if (pb.params.expositionHideCaptions) pb.$captionsContainerEl.removeClass('photo-browser-captions-exposed'); + pb.exposed = false; + return pb; + }; + + _proto.expositionToggle = function expositionToggle() { + var pb = this; + + if (pb.params.type === 'page') { + pb.view.$el.toggleClass('with-photo-browser-page-exposed'); + } + + if (pb.$el) pb.$el.toggleClass('photo-browser-exposed'); + if (pb.params.expositionHideCaptions) pb.$captionsContainerEl.toggleClass('photo-browser-captions-exposed'); + pb.exposed = !pb.exposed; + return pb; + }; + + _proto.open = function open(index) { + var pb = this; + var type = pb.params.type; + + if (pb.opened) { + if (pb.swiper && typeof index !== 'undefined') { + pb.swiper.slideTo(parseInt(index, 10)); + } + + return pb; + } + + if (typeof index !== 'undefined') { + pb.activeIndex = index; + } + + if (type === 'standalone') { + pb.openStandalone(); + } + + if (type === 'page') { + pb.openPage(); + } + + if (type === 'popup') { + pb.openPopup(); + } + + return pb; + }; + + _proto.close = function close() { + var pb = this; + if (!pb.opened) return pb; + + if (pb.params.routableModals && pb.view || pb.openedIn === 'page') { + pb.view.router.back(); + } else { + pb.modal.once('modalClosed', function () { + (0, _utils.nextTick)(function () { + if (pb.destroyed) return; + pb.modal.destroy(); + delete pb.modal; + }); + }); + pb.modal.close(); + } + + return pb; + } // eslint-disable-next-line + ; + + _proto.init = function init() {}; + + _proto.destroy = function destroy() { + var pb = this; + pb.emit('local::beforeDestroy photoBrowserBeforeDestroy', pb); + + if (pb.$el) { + pb.$el.trigger('photobrowser:beforedestroy'); + pb.$el[0].f7PhotoBrowser = null; + delete pb.$el[0].f7PhotoBrowser; + } + + (0, _utils.deleteProps)(pb); + pb.destroyed = true; + pb = null; + }; + + _createClass(PhotoBrowser, [{ + key: "view", + get: function get() { + var params = this.params, + app = this.app; + return params.view || app.views.main; + } + }]); + + return PhotoBrowser; +}(_class.default); + +var _default = PhotoBrowser; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/photo-browser/photo-browser.js b/www/assets/framework7/cjs/components/photo-browser/photo-browser.js new file mode 100644 index 000000000..061bcdeb9 --- /dev/null +++ b/www/assets/framework7/cjs/components/photo-browser/photo-browser.js @@ -0,0 +1,78 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _photoBrowserClass = _interopRequireDefault(require("./photo-browser-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'photoBrowser', + params: { + photoBrowser: { + photos: [], + exposition: true, + expositionHideCaptions: false, + type: 'standalone', + navbar: true, + toolbar: true, + theme: 'light', + captionsTheme: undefined, + iconsColor: undefined, + popupPush: false, + swipeToClose: true, + pageBackLinkText: 'Back', + popupCloseLinkText: 'Close', + navbarOfText: 'of', + navbarShowCount: undefined, + view: undefined, + url: 'photos/', + routableModals: false, + virtualSlides: true, + renderNavbar: undefined, + renderToolbar: undefined, + renderCaption: undefined, + renderObject: undefined, + renderLazyPhoto: undefined, + renderPhoto: undefined, + renderPage: undefined, + renderPopup: undefined, + renderStandalone: undefined, + swiper: { + initialSlide: 0, + spaceBetween: 20, + speed: 300, + loop: false, + preloadImages: true, + navigation: { + nextEl: '.photo-browser-next', + prevEl: '.photo-browser-prev' + }, + zoom: { + enabled: true, + maxRatio: 3, + minRatio: 1 + }, + lazy: { + enabled: true + } + } + } + }, + create: function create() { + var app = this; + app.photoBrowser = (0, _constructorMethods.default)({ + defaultSelector: '.photo-browser-popup, .photo-browser-page', + constructor: _photoBrowserClass.default, + app: app, + domProp: 'f7PhotoBrowser' + }); + }, + static: { + PhotoBrowser: _photoBrowserClass.default + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/picker/picker-class.js b/www/assets/framework7/cjs/components/picker/picker-class.js new file mode 100644 index 000000000..4ea48fb3d --- /dev/null +++ b/www/assets/framework7/cjs/components/picker/picker-class.js @@ -0,0 +1,704 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _getDevice = require("../../shared/get-device"); + +var _pickerColumn = _interopRequireDefault(require("./picker-column")); + +var _$jsx = _interopRequireDefault(require("../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Picker = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(Picker, _Framework7Class); + + function Picker(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params, [app]) || this; + + var picker = _assertThisInitialized(_this); + + var device = (0, _getDevice.getDevice)(); + var window = (0, _ssrWindow.getWindow)(); + picker.params = (0, _utils.extend)({}, app.params.picker, params); + var $containerEl; + + if (picker.params.containerEl) { + $containerEl = (0, _dom.default)(picker.params.containerEl); + if ($containerEl.length === 0) return picker || _assertThisInitialized(_this); + } + + var $inputEl; + + if (picker.params.inputEl) { + $inputEl = (0, _dom.default)(picker.params.inputEl); + } + + var $scrollToEl = picker.params.scrollToInput ? $inputEl : undefined; + + if (picker.params.scrollToEl) { + var scrollToEl = (0, _dom.default)(picker.params.scrollToEl); + + if (scrollToEl.length > 0) { + $scrollToEl = scrollToEl; + } + } + + (0, _utils.extend)(picker, { + app: app, + $containerEl: $containerEl, + containerEl: $containerEl && $containerEl[0], + inline: $containerEl && $containerEl.length > 0, + needsOriginFix: device.ios || window.navigator.userAgent.toLowerCase().indexOf('safari') >= 0 && window.navigator.userAgent.toLowerCase().indexOf('chrome') < 0 && !device.android, + cols: [], + $inputEl: $inputEl, + inputEl: $inputEl && $inputEl[0], + $scrollToEl: $scrollToEl, + initialized: false, + opened: false, + url: picker.params.url + }); + + function onResize() { + picker.resizeCols(); + } + + function onInputClick() { + picker.open(); + } + + function onInputFocus(e) { + e.preventDefault(); + } + + var htmlTouchStartTarget = null; + + function onHtmlTouchStart(e) { + htmlTouchStartTarget = e.target; + } + + function onHtmlClick(e) { + if (picker.destroyed || !picker.params) return; + var $targetEl = (0, _dom.default)(e.target); + if (picker.isPopover()) return; + if (!picker.opened || picker.closing) return; + if ($targetEl.closest('[class*="backdrop"]').length) return; + + if ($inputEl && $inputEl.length > 0) { + if (htmlTouchStartTarget === e.target && $targetEl[0] !== $inputEl[0] && $targetEl.closest('.sheet-modal').length === 0) { + picker.close(); + } + } else if ((0, _dom.default)(e.target).closest('.sheet-modal').length === 0) { + picker.close(); + } + } // Events + + + (0, _utils.extend)(picker, { + attachResizeEvent: function attachResizeEvent() { + app.on('resize', onResize); + }, + detachResizeEvent: function detachResizeEvent() { + app.off('resize', onResize); + }, + attachInputEvents: function attachInputEvents() { + picker.$inputEl.on('click', onInputClick); + + if (picker.params.inputReadOnly) { + picker.$inputEl.on('focus mousedown', onInputFocus); + + if (picker.$inputEl[0]) { + picker.$inputEl[0].f7ValidateReadonly = true; + } + } + }, + detachInputEvents: function detachInputEvents() { + picker.$inputEl.off('click', onInputClick); + + if (picker.params.inputReadOnly) { + picker.$inputEl.off('focus mousedown', onInputFocus); + + if (picker.$inputEl[0]) { + delete picker.$inputEl[0].f7ValidateReadonly; + } + } + }, + attachHtmlEvents: function attachHtmlEvents() { + app.on('click', onHtmlClick); + app.on('touchstart', onHtmlTouchStart); + }, + detachHtmlEvents: function detachHtmlEvents() { + app.off('click', onHtmlClick); + app.off('touchstart', onHtmlTouchStart); + } + }); + picker.init(); + return picker || _assertThisInitialized(_this); + } + + var _proto = Picker.prototype; + + _proto.initInput = function initInput() { + var picker = this; + if (!picker.$inputEl) return; + if (picker.params.inputReadOnly) picker.$inputEl.prop('readOnly', true); + }; + + _proto.resizeCols = function resizeCols() { + var picker = this; + if (!picker.opened) return; + + for (var i = 0; i < picker.cols.length; i += 1) { + if (!picker.cols[i].divider) { + picker.cols[i].calcSize(); + picker.cols[i].setValue(picker.cols[i].value, 0, false); + } + } + }; + + _proto.isPopover = function isPopover() { + var picker = this; + var app = picker.app, + modal = picker.modal, + params = picker.params; + var device = (0, _getDevice.getDevice)(); + if (params.openIn === 'sheet') return false; + if (modal && modal.type !== 'popover') return false; + + if (!picker.inline && picker.inputEl) { + if (params.openIn === 'popover') return true; + + if (device.ios) { + return !!device.ipad; + } + + if (app.width >= 768) { + return true; + } + + if (device.desktop && app.theme === 'aurora') { + return true; + } + } + + return false; + }; + + _proto.formatValue = function formatValue() { + var picker = this; + var value = picker.value, + displayValue = picker.displayValue; + + if (picker.params.formatValue) { + return picker.params.formatValue.call(picker, value, displayValue); + } + + return value.join(' '); + }; + + _proto.setValue = function setValue(values, transition) { + var picker = this; + var valueIndex = 0; + + if (picker.cols.length === 0) { + picker.value = values; + picker.updateValue(values); + return; + } + + for (var i = 0; i < picker.cols.length; i += 1) { + if (picker.cols[i] && !picker.cols[i].divider) { + picker.cols[i].setValue(values[valueIndex], transition); + valueIndex += 1; + } + } + }; + + _proto.getValue = function getValue() { + var picker = this; + return picker.value; + }; + + _proto.updateValue = function updateValue(forceValues) { + var picker = this; + var newValue = forceValues || []; + var newDisplayValue = []; + var column; + + if (picker.cols.length === 0) { + var noDividerColumns = picker.params.cols.filter(function (c) { + return !c.divider; + }); + + for (var i = 0; i < noDividerColumns.length; i += 1) { + column = noDividerColumns[i]; + + if (column.displayValues !== undefined && column.values !== undefined && column.values.indexOf(newValue[i]) !== -1) { + newDisplayValue.push(column.displayValues[column.values.indexOf(newValue[i])]); + } else { + newDisplayValue.push(newValue[i]); + } + } + } else { + for (var _i = 0; _i < picker.cols.length; _i += 1) { + if (!picker.cols[_i].divider) { + newValue.push(picker.cols[_i].value); + newDisplayValue.push(picker.cols[_i].displayValue); + } + } + } + + if (newValue.indexOf(undefined) >= 0) { + return; + } + + picker.value = newValue; + picker.displayValue = newDisplayValue; + picker.emit('local::change pickerChange', picker, picker.value, picker.displayValue); + + if (picker.inputEl) { + picker.$inputEl.val(picker.formatValue()); + picker.$inputEl.trigger('change'); + } + }; + + _proto.initColumn = function initColumn(colEl, updateItems) { + var picker = this; + + _pickerColumn.default.call(picker, colEl, updateItems); + } // eslint-disable-next-line + ; + + _proto.destroyColumn = function destroyColumn(colEl) { + var picker = this; + var $colEl = (0, _dom.default)(colEl); + var index = $colEl.index(); + + if (picker.cols[index] && picker.cols[index].destroy) { + picker.cols[index].destroy(); + } + }; + + _proto.renderToolbar = function renderToolbar() { + var picker = this; + if (picker.params.renderToolbar) return picker.params.renderToolbar.call(picker, picker); + return (0, _$jsx.default)("div", { + class: "toolbar toolbar-top no-shadow" + }, (0, _$jsx.default)("div", { + class: "toolbar-inner" + }, (0, _$jsx.default)("div", { + class: "left" + }), (0, _$jsx.default)("div", { + class: "right" + }, (0, _$jsx.default)("a", { + class: "link sheet-close popover-close" + }, picker.params.toolbarCloseText)))); + } // eslint-disable-next-line + ; + + _proto.renderColumn = function renderColumn(col, onlyItems) { + var colClasses = "picker-column " + (col.textAlign ? "picker-column-" + col.textAlign : '') + " " + (col.cssClass || ''); + var columnHtml; + var columnItemsHtml; + + if (col.divider) { + // prettier-ignore + columnHtml = "\n
    " + col.content + "
    \n "; + } else { + // prettier-ignore + columnItemsHtml = col.values.map(function (value, index) { + return "\n
    \n " + (col.displayValues ? col.displayValues[index] : value) + "\n
    \n "; + }).join(''); // prettier-ignore + + columnHtml = "\n
    \n
    " + columnItemsHtml + "
    \n
    \n "; + } + + return onlyItems ? columnItemsHtml.trim() : columnHtml.trim(); + }; + + _proto.renderInline = function renderInline() { + var picker = this; + var _picker$params = picker.params, + rotateEffect = _picker$params.rotateEffect, + cssClass = _picker$params.cssClass, + toolbar = _picker$params.toolbar; + var inlineHtml = (0, _$jsx.default)("div", { + class: "picker picker-inline " + (rotateEffect ? 'picker-3d' : '') + " " + (cssClass || '') + }, toolbar && picker.renderToolbar(), (0, _$jsx.default)("div", { + class: "picker-columns" + }, picker.cols.map(function (col) { + return picker.renderColumn(col); + }), (0, _$jsx.default)("div", { + class: "picker-center-highlight" + }))); + return inlineHtml; + }; + + _proto.renderSheet = function renderSheet() { + var picker = this; + var _picker$params2 = picker.params, + rotateEffect = _picker$params2.rotateEffect, + cssClass = _picker$params2.cssClass, + toolbar = _picker$params2.toolbar; + var sheetHtml = (0, _$jsx.default)("div", { + class: "sheet-modal picker picker-sheet " + (rotateEffect ? 'picker-3d' : '') + " " + (cssClass || '') + }, toolbar && picker.renderToolbar(), (0, _$jsx.default)("div", { + class: "sheet-modal-inner picker-columns" + }, picker.cols.map(function (col) { + return picker.renderColumn(col); + }), (0, _$jsx.default)("div", { + class: "picker-center-highlight" + }))); + return sheetHtml; + }; + + _proto.renderPopover = function renderPopover() { + var picker = this; + var _picker$params3 = picker.params, + rotateEffect = _picker$params3.rotateEffect, + cssClass = _picker$params3.cssClass, + toolbar = _picker$params3.toolbar; + var popoverHtml = (0, _$jsx.default)("div", { + class: "popover picker-popover" + }, (0, _$jsx.default)("div", { + class: "popover-inner" + }, (0, _$jsx.default)("div", { + class: "picker " + (rotateEffect ? 'picker-3d' : '') + " " + (cssClass || '') + }, toolbar && picker.renderToolbar(), (0, _$jsx.default)("div", { + class: "picker-columns" + }, picker.cols.map(function (col) { + return picker.renderColumn(col); + }), (0, _$jsx.default)("div", { + class: "picker-center-highlight" + }))))); + return popoverHtml; + }; + + _proto.render = function render() { + var picker = this; + if (picker.params.render) return picker.params.render.call(picker); + + if (!picker.inline) { + if (picker.isPopover()) return picker.renderPopover(); + return picker.renderSheet(); + } + + return picker.renderInline(); + }; + + _proto.onOpen = function onOpen() { + var picker = this; + var initialized = picker.initialized, + $el = picker.$el, + app = picker.app, + $inputEl = picker.$inputEl, + inline = picker.inline, + value = picker.value, + params = picker.params; + picker.opened = true; + picker.closing = false; + picker.opening = true; // Init main events + + picker.attachResizeEvent(); // Init cols + + $el.find('.picker-column').each(function (colEl) { + var updateItems = true; + + if (!initialized && params.value || initialized && value) { + updateItems = false; + } + + picker.initColumn(colEl, updateItems); + }); // Set value + + if (!initialized) { + if (value) picker.setValue(value, 0);else if (params.value) { + picker.setValue(params.value, 0); + } + } else if (value) { + picker.setValue(value, 0); + } // Extra focus + + + if (!inline && $inputEl && $inputEl.length && app.theme === 'md') { + $inputEl.trigger('focus'); + } + + picker.initialized = true; // Trigger events + + if ($el) { + $el.trigger('picker:open'); + } + + if ($inputEl) { + $inputEl.trigger('picker:open'); + } + + picker.emit('local::open pickerOpen', picker); + }; + + _proto.onOpened = function onOpened() { + var picker = this; + picker.opening = false; + + if (picker.$el) { + picker.$el.trigger('picker:opened'); + } + + if (picker.$inputEl) { + picker.$inputEl.trigger('picker:opened'); + } + + picker.emit('local::opened pickerOpened', picker); + }; + + _proto.onClose = function onClose() { + var picker = this; + var app = picker.app; + picker.opening = false; + picker.closing = true; // Detach events + + picker.detachResizeEvent(); + picker.cols.forEach(function (col) { + if (col.destroy) col.destroy(); + }); + + if (picker.$inputEl) { + if (app.theme === 'md') { + picker.$inputEl.trigger('blur'); + } else { + var validate = picker.$inputEl.attr('validate'); + var required = picker.$inputEl.attr('required'); + + if (validate && required) { + app.input.validate(picker.$inputEl); + } + } + } + + if (picker.$el) { + picker.$el.trigger('picker:close'); + } + + if (picker.$inputEl) { + picker.$inputEl.trigger('picker:close'); + } + + picker.emit('local::close pickerClose', picker); + }; + + _proto.onClosed = function onClosed() { + var picker = this; + picker.opened = false; + picker.closing = false; + + if (!picker.inline) { + (0, _utils.nextTick)(function () { + if (picker.modal && picker.modal.el && picker.modal.destroy) { + if (!picker.params.routableModals) { + picker.modal.destroy(); + } + } + + delete picker.modal; + }); + } + + if (picker.$el) { + picker.$el.trigger('picker:closed'); + } + + if (picker.$inputEl) { + picker.$inputEl.trigger('picker:closed'); + } + + picker.emit('local::closed pickerClosed', picker); + }; + + _proto.open = function open() { + var picker = this; + var app = picker.app, + opened = picker.opened, + inline = picker.inline, + $inputEl = picker.$inputEl, + $scrollToEl = picker.$scrollToEl, + params = picker.params; + if (opened) return; + + if (picker.cols.length === 0 && params.cols.length) { + params.cols.forEach(function (col) { + picker.cols.push(col); + }); + } + + if (inline) { + picker.$el = (0, _dom.default)(picker.render()); + picker.$el[0].f7Picker = picker; + picker.$containerEl.append(picker.$el); + picker.onOpen(); + picker.onOpened(); + return; + } + + var isPopover = picker.isPopover(); + var modalType = isPopover ? 'popover' : 'sheet'; + var modalParams = { + targetEl: $inputEl, + scrollToEl: $scrollToEl, + content: picker.render(), + backdrop: typeof params.backdrop !== 'undefined' ? params.backdrop : isPopover, + on: { + open: function open() { + var modal = this; + picker.modal = modal; + picker.$el = isPopover ? modal.$el.find('.picker') : modal.$el; + picker.$el[0].f7Picker = picker; + picker.onOpen(); + }, + opened: function opened() { + picker.onOpened(); + }, + close: function close() { + picker.onClose(); + }, + closed: function closed() { + picker.onClosed(); + } + } + }; + + if (modalType === 'sheet') { + modalParams.push = params.sheetPush; + modalParams.swipeToClose = params.sheetSwipeToClose; + } + + if (params.routableModals && picker.view) { + var _route; + + picker.view.router.navigate({ + url: picker.url, + route: (_route = { + path: picker.url + }, _route[modalType] = modalParams, _route) + }); + } else { + picker.modal = app[modalType].create(modalParams); + picker.modal.open(); + } + }; + + _proto.close = function close() { + var picker = this; + var opened = picker.opened, + inline = picker.inline; + if (!opened) return; + + if (inline) { + picker.onClose(); + picker.onClosed(); + return; + } + + if (picker.params.routableModals && picker.view) { + picker.view.router.back(); + } else { + picker.modal.close(); + } + }; + + _proto.init = function init() { + var picker = this; + picker.initInput(); + + if (picker.inline) { + picker.open(); + picker.emit('local::init pickerInit', picker); + return; + } + + if (!picker.initialized && picker.params.value) { + picker.setValue(picker.params.value); + } // Attach input Events + + + if (picker.$inputEl) { + picker.attachInputEvents(); + } + + if (picker.params.closeByOutsideClick) { + picker.attachHtmlEvents(); + } + + picker.emit('local::init pickerInit', picker); + }; + + _proto.destroy = function destroy() { + var picker = this; + if (picker.destroyed) return; + var $el = picker.$el; + picker.emit('local::beforeDestroy pickerBeforeDestroy', picker); + if ($el) $el.trigger('picker:beforedestroy'); + picker.close(); // Detach Events + + if (picker.$inputEl) { + picker.detachInputEvents(); + } + + if (picker.params.closeByOutsideClick) { + picker.detachHtmlEvents(); + } + + if ($el && $el.length) delete picker.$el[0].f7Picker; + (0, _utils.deleteProps)(picker); + picker.destroyed = true; + }; + + _createClass(Picker, [{ + key: "view", + get: function get() { + var app = this.app, + params = this.params, + $inputEl = this.$inputEl; + var view; + + if (params.view) { + view = params.view; + } else if ($inputEl) { + view = $inputEl.parents('.view').length && $inputEl.parents('.view')[0].f7View; + } + + if (!view) view = app.views.main; + return view; + } + }]); + + return Picker; +}(_class.default); + +var _default = Picker; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/picker/picker-column.js b/www/assets/framework7/cjs/components/picker/picker-column.js new file mode 100644 index 000000000..9dd68dd21 --- /dev/null +++ b/www/assets/framework7/cjs/components/picker/picker-column.js @@ -0,0 +1,389 @@ +"use strict"; + +exports.__esModule = true; +exports.default = pickerColumn; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _getSupport = require("../../shared/get-support"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function pickerColumn(colEl, updateItems) { + var picker = this; + var app = picker.app; + var $colEl = (0, _dom.default)(colEl); + var colIndex = $colEl.index(); + var col = picker.cols[colIndex]; + if (col.divider) return; + col.$el = $colEl; + col.el = $colEl[0]; + col.$itemsEl = col.$el.find('.picker-items'); + col.items = col.$itemsEl.find('.picker-item'); + var itemHeight; + var itemsHeight; + var minTranslate; + var maxTranslate; + var animationFrameId; + + function updateDuringScroll() { + animationFrameId = (0, _utils.requestAnimationFrame)(function () { + col.updateItems(undefined, undefined, 0); + updateDuringScroll(); + }); + } + + col.replaceValues = function replaceColValues(values, displayValues) { + col.detachEvents(); + col.values = values; + col.displayValues = displayValues; + col.$itemsEl.html(picker.renderColumn(col, true)); + col.items = col.$itemsEl.find('.picker-item'); + col.calcSize(); + col.setValue(col.values[0], 0, true); + col.attachEvents(); + }; + + col.calcSize = function calcColSize() { + if (picker.params.rotateEffect) { + col.$el.removeClass('picker-column-absolute'); + if (!col.width) col.$el.css({ + width: '' + }); + } + + var colWidth = 0; + var colHeight = col.$el[0].offsetHeight; + itemHeight = col.items[0].offsetHeight; + itemsHeight = itemHeight * col.items.length; + minTranslate = colHeight / 2 - itemsHeight + itemHeight / 2; + maxTranslate = colHeight / 2 - itemHeight / 2; + + if (col.width) { + colWidth = col.width; + if (parseInt(colWidth, 10) === colWidth) colWidth += 'px'; + col.$el.css({ + width: colWidth + }); + } + + if (picker.params.rotateEffect) { + if (!col.width) { + col.items.each(function (itemEl) { + var item = (0, _dom.default)(itemEl).children('span'); + colWidth = Math.max(colWidth, item[0].offsetWidth); + }); + col.$el.css({ + width: colWidth + 2 + "px" + }); + } + + col.$el.addClass('picker-column-absolute'); + } + }; + + col.setValue = function setColValue(newValue, transition, valueCallbacks) { + if (transition === void 0) { + transition = ''; + } + + var newActiveIndex = col.$itemsEl.find(".picker-item[data-picker-value=\"" + newValue + "\"]").index(); + + if (typeof newActiveIndex === 'undefined' || newActiveIndex === -1) { + return; + } + + var newTranslate = -newActiveIndex * itemHeight + maxTranslate; // Update wrapper + + col.$itemsEl.transition(transition); + col.$itemsEl.transform("translate3d(0," + newTranslate + "px,0)"); // Watch items + + if (picker.params.updateValuesOnMomentum && col.activeIndex && col.activeIndex !== newActiveIndex) { + cancelAnimationFrame(animationFrameId); + col.$itemsEl.transitionEnd(function () { + cancelAnimationFrame(animationFrameId); + }); + updateDuringScroll(); + } // Update items + + + col.updateItems(newActiveIndex, newTranslate, transition, valueCallbacks); + }; + + col.updateItems = function updateColItems(activeIndex, translate, transition, valueCallbacks) { + if (typeof translate === 'undefined') { + // eslint-disable-next-line + translate = (0, _utils.getTranslate)(col.$itemsEl[0], 'y'); + } + + if (typeof activeIndex === 'undefined') // eslint-disable-next-line + activeIndex = -Math.round((translate - maxTranslate) / itemHeight); // eslint-disable-next-line + + if (activeIndex < 0) activeIndex = 0; // eslint-disable-next-line + + if (activeIndex >= col.items.length) activeIndex = col.items.length - 1; + var previousActiveIndex = col.activeIndex; + col.activeIndex = activeIndex; + col.$itemsEl.find('.picker-item-selected').removeClass('picker-item-selected'); + col.items.transition(transition); + var selectedItem = col.items.eq(activeIndex).addClass('picker-item-selected').transform(''); // Set 3D rotate effect + + if (picker.params.rotateEffect) { + col.items.each(function (itemEl) { + var $itemEl = (0, _dom.default)(itemEl); + var itemOffsetTop = $itemEl.index() * itemHeight; + var translateOffset = maxTranslate - translate; + var itemOffset = itemOffsetTop - translateOffset; + var percentage = itemOffset / itemHeight; + var itemsFit = Math.ceil(col.height / itemHeight / 2) + 1; + var angle = -18 * percentage; + if (angle > 180) angle = 180; + if (angle < -180) angle = -180; + + if (Math.abs(percentage) > itemsFit) { + $itemEl.addClass('picker-item-far'); + } else { + $itemEl.removeClass('picker-item-far'); + } + + $itemEl.transform("translate3d(0, " + (-translate + maxTranslate) + "px, " + (picker.needsOriginFix ? -110 : 0) + "px) rotateX(" + angle + "deg)"); + }); + } + + if (valueCallbacks || typeof valueCallbacks === 'undefined') { + // Update values + col.value = selectedItem.attr('data-picker-value'); + col.displayValue = col.displayValues ? col.displayValues[activeIndex] : col.value; // On change callback + + if (previousActiveIndex !== activeIndex) { + if (col.onChange) { + col.onChange(picker, col.value, col.displayValue); + } + + picker.updateValue(); + } + } + }; + + var allowItemClick = true; + var isTouched; + var isMoved; + var touchStartY; + var touchCurrentY; + var touchStartTime; + var touchEndTime; + var startTranslate; + var returnTo; + var currentTranslate; + var prevTranslate; + var velocityTranslate; + + function handleTouchStart(e) { + if (isMoved || isTouched) return; + e.preventDefault(); + isTouched = true; + touchStartY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + touchCurrentY = touchStartY; + touchStartTime = new Date().getTime(); + allowItemClick = true; + startTranslate = (0, _utils.getTranslate)(col.$itemsEl[0], 'y'); + currentTranslate = startTranslate; + } + + function handleTouchMove(e) { + if (!isTouched) return; + e.preventDefault(); + allowItemClick = false; + touchCurrentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; + + if (!isMoved) { + // First move + cancelAnimationFrame(animationFrameId); + isMoved = true; + startTranslate = (0, _utils.getTranslate)(col.$itemsEl[0], 'y'); + currentTranslate = startTranslate; + col.$itemsEl.transition(0); + } + + var diff = touchCurrentY - touchStartY; + currentTranslate = startTranslate + diff; + returnTo = undefined; // Normalize translate + + if (currentTranslate < minTranslate) { + currentTranslate = minTranslate - Math.pow(minTranslate - currentTranslate, 0.8); + returnTo = 'min'; + } + + if (currentTranslate > maxTranslate) { + currentTranslate = maxTranslate + Math.pow(currentTranslate - maxTranslate, 0.8); + returnTo = 'max'; + } // Transform wrapper + + + col.$itemsEl.transform("translate3d(0," + currentTranslate + "px,0)"); // Update items + + col.updateItems(undefined, currentTranslate, 0, picker.params.updateValuesOnTouchmove); // Calc velocity + + velocityTranslate = currentTranslate - prevTranslate || currentTranslate; + prevTranslate = currentTranslate; + } + + function handleTouchEnd() { + if (!isTouched || !isMoved) { + isTouched = false; + isMoved = false; + return; + } + + isTouched = false; + isMoved = false; + col.$itemsEl.transition(''); + + if (returnTo) { + if (returnTo === 'min') { + col.$itemsEl.transform("translate3d(0," + minTranslate + "px,0)"); + } else { + col.$itemsEl.transform("translate3d(0," + maxTranslate + "px,0)"); + } + } + + touchEndTime = new Date().getTime(); + var newTranslate; + + if (touchEndTime - touchStartTime > 300) { + newTranslate = currentTranslate; + } else { + newTranslate = currentTranslate + velocityTranslate * picker.params.momentumRatio; + } + + newTranslate = Math.max(Math.min(newTranslate, maxTranslate), minTranslate); // Active Index + + var activeIndex = Math.round(Math.abs((newTranslate - maxTranslate) / itemHeight)); // Normalize translate + + if (!picker.params.freeMode) newTranslate = -activeIndex * itemHeight + maxTranslate; // Transform wrapper + + col.$itemsEl.transform("translate3d(0," + parseInt(newTranslate, 10) + "px,0)"); // Update items + + col.updateItems(activeIndex, newTranslate, '', true); // Watch items + + if (picker.params.updateValuesOnMomentum) { + updateDuringScroll(); + col.$itemsEl.transitionEnd(function () { + cancelAnimationFrame(animationFrameId); + }); + } // Allow click + + + setTimeout(function () { + allowItemClick = true; + }, 100); + } + + var mousewheelTimeout; + + function handleMouseWheel(e) { + var deltaX = e.deltaX, + deltaY = e.deltaY; + if (Math.abs(deltaX) > Math.abs(deltaY)) return; + clearTimeout(mousewheelTimeout); + e.preventDefault(); + cancelAnimationFrame(animationFrameId); + startTranslate = (0, _utils.getTranslate)(col.$itemsEl[0], 'y'); + col.$itemsEl.transition(0); + currentTranslate = startTranslate - deltaY; + returnTo = undefined; // Normalize translate + + if (currentTranslate < minTranslate) { + currentTranslate = minTranslate; + returnTo = 'min'; + } + + if (currentTranslate > maxTranslate) { + currentTranslate = maxTranslate; + returnTo = 'max'; + } // Transform wrapper + + + col.$itemsEl.transform("translate3d(0," + currentTranslate + "px,0)"); // Update items + + col.updateItems(undefined, currentTranslate, 0, picker.params.updateValuesOnMousewheel); // On end + + mousewheelTimeout = setTimeout(function () { + col.$itemsEl.transition(''); + + if (returnTo) { + if (returnTo === 'min') { + col.$itemsEl.transform("translate3d(0," + minTranslate + "px,0)"); + } else { + col.$itemsEl.transform("translate3d(0," + maxTranslate + "px,0)"); + } + } + + touchEndTime = new Date().getTime(); + var newTranslate = currentTranslate; + newTranslate = Math.max(Math.min(newTranslate, maxTranslate), minTranslate); // Active Index + + var activeIndex = Math.round(Math.abs((newTranslate - maxTranslate) / itemHeight)); // Normalize translate + + if (!picker.params.freeMode) newTranslate = -activeIndex * itemHeight + maxTranslate; // Transform wrapper + + col.$itemsEl.transform("translate3d(0," + parseInt(newTranslate, 10) + "px,0)"); // Update items + + col.updateItems(activeIndex, newTranslate, '', true); + }, 200); + } + + function handleClick() { + if (!allowItemClick) return; + cancelAnimationFrame(animationFrameId); + var value = (0, _dom.default)(this).attr('data-picker-value'); + col.setValue(value); + } + + var activeListener = (0, _getSupport.getSupport)().passiveListener ? { + passive: false, + capture: false + } : false; + + col.attachEvents = function attachColEvents() { + col.$el.on(app.touchEvents.start, handleTouchStart, activeListener); + app.on('touchmove:active', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + + if (picker.params.mousewheel) { + col.$el.on('wheel', handleMouseWheel); + } + + col.items.on('click', handleClick); + }; + + col.detachEvents = function detachColEvents() { + col.$el.off(app.touchEvents.start, handleTouchStart, activeListener); + app.off('touchmove:active', handleTouchMove); + app.off('touchend:passive', handleTouchEnd); + + if (picker.params.mousewheel) { + col.$el.off('wheel', handleMouseWheel); + } + + col.items.off('click', handleClick); + }; + + col.init = function initCol() { + col.calcSize(); + col.$itemsEl.transform("translate3d(0," + maxTranslate + "px,0)").transition(0); + if (colIndex === 0) col.$el.addClass('picker-column-first'); + if (colIndex === picker.cols.length - 1) col.$el.addClass('picker-column-last'); // Update items on init + + if (updateItems) col.updateItems(0, maxTranslate, 0); + col.attachEvents(); + }; + + col.destroy = function destroyCol() { + col.detachEvents(); + }; + + col.init(); +} \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/picker/picker.js b/www/assets/framework7/cjs/components/picker/picker.js new file mode 100644 index 000000000..55eba762b --- /dev/null +++ b/www/assets/framework7/cjs/components/picker/picker.js @@ -0,0 +1,77 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +var _pickerClass = _interopRequireDefault(require("./picker-class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'picker', + static: { + Picker: _pickerClass.default + }, + create: function create() { + var app = this; + app.picker = (0, _constructorMethods.default)({ + defaultSelector: '.picker', + constructor: _pickerClass.default, + app: app, + domProp: 'f7Picker' + }); + + app.picker.close = function close(el) { + if (el === void 0) { + el = '.picker'; + } + + var $el = (0, _dom.default)(el); + if ($el.length === 0) return; + var picker = $el[0].f7Picker; + if (!picker || picker && !picker.opened) return; + picker.close(); + }; + }, + params: { + picker: { + // Picker settings + updateValuesOnMomentum: false, + updateValuesOnTouchmove: true, + updateValuesOnMousewheel: true, + mousewheel: true, + rotateEffect: false, + momentumRatio: 7, + freeMode: false, + cols: [], + // Common opener settings + containerEl: null, + openIn: 'auto', + // or 'popover' or 'sheet' + sheetPush: false, + sheetSwipeToClose: undefined, + backdrop: undefined, + // uses Popover or Sheet defaults + formatValue: null, + inputEl: null, + inputReadOnly: true, + closeByOutsideClick: true, + scrollToInput: true, + scrollToEl: undefined, + toolbar: true, + toolbarCloseText: 'Done', + cssClass: null, + routableModals: false, + view: null, + url: 'select/', + // Render functions + renderToolbar: null, + render: null + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/pie-chart/pie-chart-class.js b/www/assets/framework7/cjs/components/pie-chart/pie-chart-class.js new file mode 100644 index 000000000..5d30a9664 --- /dev/null +++ b/www/assets/framework7/cjs/components/pie-chart/pie-chart-class.js @@ -0,0 +1,290 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _$jsx = _interopRequireDefault(require("../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var PieChart = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(PieChart, _Framework7Class); + + function PieChart(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params, [app]) || this; + + var self = _assertThisInitialized(_this); + + var defaults = (0, _utils.extend)({}, app.params.pieChart); // Extend defaults with modules params + + self.useModulesParams(defaults); + self.params = (0, _utils.extend)(defaults, params); + var el = self.params.el; + if (!el) return self || _assertThisInitialized(_this); + var $el = (0, _dom.default)(el); + if ($el.length === 0) return self || _assertThisInitialized(_this); + if ($el[0].f7PieChart) return $el[0].f7PieChart || _assertThisInitialized(_this); + (0, _utils.extend)(self, { + app: app, + $el: $el, + el: $el && $el[0], + currentIndex: null, + f7Tooltip: null + }); + $el[0].f7PieChart = self; // Install Modules + + self.useModules(); + self.showTooltip = self.showTooltip.bind(_assertThisInitialized(_this)); + self.hideTooltip = self.hideTooltip.bind(_assertThisInitialized(_this)); + self.init(); + return self || _assertThisInitialized(_this); + } + + var _proto = PieChart.prototype; + + _proto.getSummValue = function getSummValue() { + var datasets = this.params.datasets; + var summ = 0; + datasets.map(function (d) { + return d.value || 0; + }).forEach(function (value) { + summ += value; + }); + return summ; + }; + + _proto.getPaths = function getPaths() { + var _this2 = this; + + var _this$params = this.params, + datasets = _this$params.datasets, + size = _this$params.size; + var paths = []; + var cumulativePercentage = 0; + + function getCoordinatesForPercentage(percentage) { + var x = Math.cos(2 * Math.PI * percentage) * (size / 3); + var y = Math.sin(2 * Math.PI * percentage) * (size / 3); + return [x, y]; + } + + datasets.forEach(function (_ref) { + var value = _ref.value, + label = _ref.label, + color = _ref.color; + + var percentage = value / _this2.getSummValue(); + + var _getCoordinatesForPer = getCoordinatesForPercentage(cumulativePercentage), + startX = _getCoordinatesForPer[0], + startY = _getCoordinatesForPer[1]; + + cumulativePercentage += percentage; + + var _getCoordinatesForPer2 = getCoordinatesForPercentage(cumulativePercentage), + endX = _getCoordinatesForPer2[0], + endY = _getCoordinatesForPer2[1]; + + var largeArcFlag = percentage > 0.5 ? 1 : 0; + var points = ["M " + startX + " " + startY, // Move + "A " + size / 3 + " " + size / 3 + " 0 " + largeArcFlag + " 1 " + endX + " " + endY, // Arc + 'L 0 0' // Line + ].join(' '); + paths.push({ + points: points, + label: label, + color: color + }); + }); + return paths; + }; + + _proto.formatTooltipText = function formatTooltipText() { + var datasets = this.params.datasets; + var currentIndex = this.currentIndex; + if (currentIndex === null) return ''; + var _datasets$currentInde = datasets[currentIndex], + value = _datasets$currentInde.value, + label = _datasets$currentInde.label, + color = _datasets$currentInde.color; + var percentage = value / this.getSummValue() * 100; + + var round = function round(v) { + if (parseInt(v, 10) === v) return v; + return Math.round(v * 100) / 100; + }; + + if (this.params.formatTooltip) { + return this.params.formatTooltip.call(this, { + index: currentIndex, + value: value, + label: label, + color: color, + percentage: percentage + }); + } + + var tooltipText = "" + (label ? label + ": " : '') + round(value) + " (" + round(percentage) + "%)"; + return "\n
    \n " + tooltipText + "\n
    \n "; + }; + + _proto.setTooltip = function setTooltip() { + var self = this; + var currentIndex = self.currentIndex, + el = self.el, + app = self.app, + params = self.params; + var tooltip = params.tooltip; + if (currentIndex === null && !self.f7Tooltip) return; + if (!tooltip || !el) return; + + if (currentIndex !== null && !self.f7Tooltip) { + self.f7Tooltip = app.tooltip.create({ + trigger: 'manual', + containerEl: el, + targetEl: el.querySelector("path[data-index=\"" + currentIndex + "\"]"), + text: self.formatTooltipText(), + cssClass: 'pie-chart-tooltip' + }); + self.f7Tooltip.show(); + return; + } + + if (!self.f7Tooltip) return; + + if (currentIndex !== null) { + self.f7Tooltip.setText(self.formatTooltipText()); + self.f7Tooltip.setTargetEl(el.querySelector("path[data-index=\"" + currentIndex + "\"]")); + self.f7Tooltip.show(); + } else { + self.f7Tooltip.hide(); + } + }; + + _proto.render = function render() { + var self = this; + var size = self.params.size; + var paths = self.getPaths(); + return (0, _$jsx.default)("svg", { + xmlns: "http://www.w3.org/2000/svg", + width: size, + viewBox: "-" + size / 3 + " -" + size / 3 + " " + size * 2 / 3 + " " + size * 2 / 3, + style: "transform: rotate(-90deg)" + }, paths.map(function (path, index) { + return (0, _$jsx.default)("path", { + d: path.points, + fill: path.color, + "data-index": index + }); + })); + }; + + _proto.update = function update(newParams) { + if (newParams === void 0) { + newParams = {}; + } + + var self = this; + var params = self.params; + Object.keys(newParams).forEach(function (param) { + if (typeof newParams[param] !== 'undefined') { + params[param] = newParams[param]; + } + }); + if (self.$svgEl.length === 0) return self; + self.$svgEl.remove(); + delete self.$svgEl.f7PieChart; + var $svgEl = (0, _dom.default)(self.render()).eq(0); + $svgEl.f7PieChart = self; + (0, _utils.extend)(self, { + $svgEl: $svgEl, + svgEl: $svgEl && $svgEl[0] + }); + self.$el.append($svgEl); + return self; + }; + + _proto.setCurrentIndex = function setCurrentIndex(index) { + var self = this; + if (index === self.currentIndex) return; + var datasets = self.params.datasets; + self.currentIndex = index; + self.$el.trigger('piechart:select', { + index: index, + dataset: datasets[index] + }); + self.emit('local::select pieChartSelect', self, index, datasets[index]); + }; + + _proto.showTooltip = function showTooltip(e) { + var _this3 = this; + + var newIndex = parseInt(e.target.getAttribute('data-index'), 10); + this.setCurrentIndex(newIndex); + this.$svgEl.find('path').removeClass('pie-chart-hidden').forEach(function (el, index) { + if (index !== _this3.currentIndex) (0, _dom.default)(el).addClass('pie-chart-hidden'); + }); + this.setTooltip(); + }; + + _proto.hideTooltip = function hideTooltip() { + this.setCurrentIndex(null); + this.$svgEl.find('path').removeClass('pie-chart-hidden'); + this.setTooltip(); + }; + + _proto.init = function init() { + var self = this; + var $svgEl = (0, _dom.default)(self.render()).eq(0); + $svgEl.f7PieChart = self; + (0, _utils.extend)(self, { + $svgEl: $svgEl, + svgEl: $svgEl && $svgEl[0] + }); + self.$el.append($svgEl); + self.$el.on('click mouseenter', 'path', self.showTooltip, true); + self.$el.on('mouseleave', 'path', self.hideTooltip, true); + return self; + }; + + _proto.destroy = function destroy() { + var self = this; + if (!self.$el || self.destroyed) return; + self.$el.trigger('piechart:beforedestroy'); + self.emit('local::beforeDestroy pieChartBeforeDestroy', self); + self.$el.off('click mouseenter', 'path', self.showTooltip, true); + self.$el.off('mouseleave', 'path', self.hideTooltip, true); + self.$svgEl.remove(); + + if (self.f7Tooltip && self.f7Tooltip.destroy) { + self.f7Tooltip.destroy(); + } + + delete self.$el[0].f7PieChart; + (0, _utils.deleteProps)(self); + self.destroyed = true; + }; + + return PieChart; +}(_class.default); + +var _default = PieChart; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/pie-chart/pie-chart.js b/www/assets/framework7/cjs/components/pie-chart/pie-chart.js new file mode 100644 index 000000000..a15f6a81c --- /dev/null +++ b/www/assets/framework7/cjs/components/pie-chart/pie-chart.js @@ -0,0 +1,44 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _pieChartClass = _interopRequireDefault(require("./pie-chart-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'pieChart', + params: { + pieChart: { + el: null, + datasets: [], + size: 320, + tooltip: false, + formatTooltip: null + } + }, + create: function create() { + var app = this; + app.pieChart = (0, _constructorMethods.default)({ + defaultSelector: '.pie-chart', + constructor: _pieChartClass.default, + app: app, + domProp: 'f7PieChart' + }); + + app.pieChart.update = function update(el, newParams) { + var $el = (0, _dom.default)(el); + if ($el.length === 0) return undefined; + var pieChart = app.pieChart.get(el); + if (!pieChart) return undefined; + pieChart.update(newParams); + return pieChart; + }; + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/popover/popover-class.js b/www/assets/framework7/cjs/components/popover/popover-class.js new file mode 100644 index 000000000..c07e51acc --- /dev/null +++ b/www/assets/framework7/cjs/components/popover/popover-class.js @@ -0,0 +1,365 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _getDevice = require("../../shared/get-device"); + +var _modalClass = _interopRequireDefault(require("../modal/modal-class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Popover = /*#__PURE__*/function (_Modal) { + _inheritsLoose(Popover, _Modal); + + function Popover(app, params) { + var _this; + + var extendedParams = (0, _utils.extend)({ + on: {} + }, app.params.popover, params); // Extends with open/close Modal methods; + + _this = _Modal.call(this, app, extendedParams) || this; + + var popover = _assertThisInitialized(_this); + + var device = (0, _getDevice.getDevice)(); + var window = (0, _ssrWindow.getWindow)(); + var document = (0, _ssrWindow.getDocument)(); + popover.params = extendedParams; // Find Element + + var $el; + + if (!popover.params.el) { + $el = (0, _dom.default)(popover.params.content).filter(function (node) { + return node.nodeType === 1; + }).eq(0); + } else { + $el = (0, _dom.default)(popover.params.el).eq(0); + } + + if ($el && $el.length > 0 && $el[0].f7Modal) { + return $el[0].f7Modal || _assertThisInitialized(_this); + } // Find Target + + + var $targetEl = (0, _dom.default)(popover.params.targetEl).eq(0); + + if ($el.length === 0) { + return popover.destroy() || _assertThisInitialized(_this); + } // Backdrop + + + var $backdropEl; + + if (popover.params.backdrop && popover.params.backdropEl) { + $backdropEl = (0, _dom.default)(popover.params.backdropEl); + } else if (popover.params.backdrop) { + $backdropEl = popover.$containerEl.children('.popover-backdrop'); + + if ($backdropEl.length === 0) { + $backdropEl = (0, _dom.default)('
    '); + popover.$containerEl.append($backdropEl); + } + } // Find Angle + + + var $angleEl; + + if ($el.find('.popover-angle').length === 0) { + $angleEl = (0, _dom.default)('
    '); + $el.prepend($angleEl); + } else { + $angleEl = $el.find('.popover-angle'); + } // Open + + + var originalOpen = popover.open; + (0, _utils.extend)(popover, { + app: app, + $el: $el, + el: $el[0], + $targetEl: $targetEl, + targetEl: $targetEl[0], + $angleEl: $angleEl, + angleEl: $angleEl[0], + $backdropEl: $backdropEl, + backdropEl: $backdropEl && $backdropEl[0], + type: 'popover', + open: function open() { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var targetEl = args[0], + animate = args[1]; + + if (typeof args[0] === 'boolean') { + animate = args[0]; + targetEl = args[1]; + } + + if (targetEl) { + popover.$targetEl = (0, _dom.default)(targetEl); + popover.targetEl = popover.$targetEl[0]; + } + + return originalOpen.call(popover, animate); + } + }); + + function handleResize() { + popover.resize(); + } + + popover.on('popoverOpen', function () { + popover.resize(); + app.on('resize', handleResize); + (0, _dom.default)(window).on('keyboardDidShow keyboardDidHide', handleResize); + popover.on('popoverClose popoverBeforeDestroy', function () { + app.off('resize', handleResize); + (0, _dom.default)(window).off('keyboardDidShow keyboardDidHide', handleResize); + }); + }); + var touchStartTarget = null; + + function handleTouchStart(e) { + touchStartTarget = e.target; + } + + function handleClick(e) { + var target = e.target; + var $target = (0, _dom.default)(target); + var keyboardOpened = !device.desktop && device.cordova && (window.Keyboard && window.Keyboard.isVisible || window.cordova.plugins && window.cordova.plugins.Keyboard && window.cordova.plugins.Keyboard.isVisible); + if (keyboardOpened) return; + + if ($target.closest(popover.el).length === 0) { + if (popover.params.closeByBackdropClick && popover.params.backdrop && popover.backdropEl && popover.backdropEl === target && touchStartTarget === target) { + popover.close(); + } else if (popover.params.closeByOutsideClick && touchStartTarget === target) { + popover.close(); + } + } + } + + function onKeyDown(e) { + var keyCode = e.keyCode; + + if (keyCode === 27 && popover.params.closeOnEscape) { + popover.close(); + } + } + + if (popover.params.closeOnEscape) { + popover.on('popoverOpen', function () { + (0, _dom.default)(document).on('keydown', onKeyDown); + }); + popover.on('popoverClose', function () { + (0, _dom.default)(document).off('keydown', onKeyDown); + }); + } + + popover.on('popoverOpened', function () { + if (popover.params.closeByOutsideClick || popover.params.closeByBackdropClick) { + app.on('touchstart', handleTouchStart); + app.on('click', handleClick); + } + }); + popover.on('popoverClose', function () { + if (popover.params.closeByOutsideClick || popover.params.closeByBackdropClick) { + app.off('touchstart', handleTouchStart); + app.off('click', handleClick); + } + }); + $el[0].f7Modal = popover; + return popover || _assertThisInitialized(_this); + } + + var _proto = Popover.prototype; + + _proto.resize = function resize() { + var popover = this; + var app = popover.app, + $el = popover.$el, + $targetEl = popover.$targetEl, + $angleEl = popover.$angleEl; + var _popover$params = popover.params, + targetX = _popover$params.targetX, + targetY = _popover$params.targetY; + $el.css({ + left: '', + top: '' + }); + var _ref = [$el.width(), $el.height()], + width = _ref[0], + height = _ref[1]; + var angleSize = 0; + var angleLeft; + var angleTop; + + if (app.theme === 'ios' || app.theme === 'aurora') { + $angleEl.removeClass('on-left on-right on-top on-bottom').css({ + left: '', + top: '' + }); + angleSize = $angleEl.width() / 2; + } else { + $el.removeClass('popover-on-left popover-on-right popover-on-top popover-on-bottom popover-on-middle').css({ + left: '', + top: '' + }); + } + + var targetWidth; + var targetHeight; + var targetOffsetLeft; + var targetOffsetTop; + var safeAreaTop = parseInt((0, _dom.default)('html').css('--f7-safe-area-top'), 10); + var safeAreaLeft = parseInt((0, _dom.default)('html').css('--f7-safe-area-left'), 10); + var safeAreaRight = parseInt((0, _dom.default)('html').css('--f7-safe-area-right'), 10); + if (Number.isNaN(safeAreaTop)) safeAreaTop = 0; + if (Number.isNaN(safeAreaLeft)) safeAreaLeft = 0; + if (Number.isNaN(safeAreaRight)) safeAreaRight = 0; + + if ($targetEl && $targetEl.length > 0) { + targetWidth = $targetEl.outerWidth(); + targetHeight = $targetEl.outerHeight(); + var targetOffset = $targetEl.offset(); + targetOffsetLeft = targetOffset.left - app.left; + targetOffsetTop = targetOffset.top - app.top; + var targetParentPage = $targetEl.parents('.page'); + + if (targetParentPage.length > 0) { + targetOffsetTop -= targetParentPage[0].scrollTop; + } + } else if (typeof targetX !== 'undefined' && targetY !== 'undefined') { + targetOffsetLeft = targetX; + targetOffsetTop = targetY; + targetWidth = popover.params.targetWidth || 0; + targetHeight = popover.params.targetHeight || 0; + } + + var left = 0, + top = 0, + diff = 0; // Top Position + + var position = app.theme === 'md' ? 'bottom' : 'top'; + + if (app.theme === 'md') { + if (height < app.height - targetOffsetTop - targetHeight) { + // On bottom + position = 'bottom'; + top = targetOffsetTop + targetHeight; + } else if (height < targetOffsetTop - safeAreaTop) { + // On top + top = targetOffsetTop - height; + position = 'top'; + } else { + // On middle + position = 'middle'; + top = targetHeight / 2 + targetOffsetTop - height / 2; + } + + top = Math.max(8, Math.min(top, app.height - height - 8)); // Horizontal Position + + var hPosition; + + if (targetOffsetLeft < app.width / 2) { + hPosition = 'right'; + left = position === 'middle' ? targetOffsetLeft + targetWidth : targetOffsetLeft; + } else { + hPosition = 'left'; + left = position === 'middle' ? targetOffsetLeft - width : targetOffsetLeft + targetWidth - width; + } + + left = Math.max(8, Math.min(left, app.width - width - 8 - safeAreaRight), safeAreaLeft); + $el.addClass("popover-on-" + position + " popover-on-" + hPosition); + } else { + // ios and aurora + if (height + angleSize < targetOffsetTop - safeAreaTop) { + // On top + top = targetOffsetTop - height - angleSize; + } else if (height + angleSize < app.height - targetOffsetTop - targetHeight) { + // On bottom + position = 'bottom'; + top = targetOffsetTop + targetHeight + angleSize; + } else { + // On middle + position = 'middle'; + top = targetHeight / 2 + targetOffsetTop - height / 2; + diff = top; + top = Math.max(5, Math.min(top, app.height - height - 5)); + diff -= top; + } // Horizontal Position + + + if (position === 'top' || position === 'bottom') { + left = targetWidth / 2 + targetOffsetLeft - width / 2; + diff = left; + left = Math.max(5, Math.min(left, app.width - width - 5)); + + if (safeAreaLeft) { + left = Math.max(left, safeAreaLeft); + } + + if (safeAreaRight && left + width > app.width - 5 - safeAreaRight) { + left = app.width - 5 - safeAreaRight - width; + } + + if (position === 'top') { + $angleEl.addClass('on-bottom'); + } + + if (position === 'bottom') { + $angleEl.addClass('on-top'); + } + + diff -= left; + angleLeft = width / 2 - angleSize + diff; + angleLeft = Math.max(Math.min(angleLeft, width - angleSize * 2 - 13), 13); + $angleEl.css({ + left: angleLeft + "px" + }); + } else if (position === 'middle') { + left = targetOffsetLeft - width - angleSize; + $angleEl.addClass('on-right'); + + if (left < 5 || left + width + safeAreaRight > app.width || left < safeAreaLeft) { + if (left < 5) left = targetOffsetLeft + targetWidth + angleSize; + if (left + width + safeAreaRight > app.width) left = app.width - width - 5 - safeAreaRight; + if (left < safeAreaLeft) left = safeAreaLeft; + $angleEl.removeClass('on-right').addClass('on-left'); + } + + angleTop = height / 2 - angleSize + diff; + angleTop = Math.max(Math.min(angleTop, height - angleSize * 2 - 13), 13); + $angleEl.css({ + top: angleTop + "px" + }); + } + } // Apply Styles + + + $el.css({ + top: top + "px", + left: left + "px" + }); + }; + + return Popover; +}(_modalClass.default); + +var _default = Popover; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/popover/popover.js b/www/assets/framework7/cjs/components/popover/popover.js new file mode 100644 index 000000000..9bb6fb27c --- /dev/null +++ b/www/assets/framework7/cjs/components/popover/popover.js @@ -0,0 +1,93 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _popoverClass = _interopRequireDefault(require("./popover-class")); + +var _modalMethods = _interopRequireDefault(require("../../shared/modal-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'popover', + params: { + popover: { + backdrop: true, + backdropEl: undefined, + closeByBackdropClick: true, + closeByOutsideClick: true, + closeOnEscape: false, + containerEl: null + } + }, + static: { + Popover: _popoverClass.default + }, + create: function create() { + var app = this; + app.popover = (0, _utils.extend)((0, _modalMethods.default)({ + app: app, + constructor: _popoverClass.default, + defaultSelector: '.popover.modal-in' + }), { + open: function open(popoverEl, targetEl, animate) { + var $popoverEl = (0, _dom.default)(popoverEl); + + if ($popoverEl.length > 1) { + // check if same popover in other page + var $targetPage = (0, _dom.default)(targetEl).parents('.page'); + + if ($targetPage.length) { + $popoverEl.each(function (el) { + var $el = (0, _dom.default)(el); + + if ($el.parents($targetPage)[0] === $targetPage[0]) { + $popoverEl = $el; + } + }); + } + } + + if ($popoverEl.length > 1) { + $popoverEl = $popoverEl.eq($popoverEl.length - 1); + } + + var popover = $popoverEl[0].f7Modal; + var data = $popoverEl.dataset(); + + if (!popover) { + popover = new _popoverClass.default(app, Object.assign({ + el: $popoverEl, + targetEl: targetEl + }, data)); + } + + return popover.open(targetEl, animate); + } + }); + }, + clicks: { + '.popover-open': function openPopover($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.popover.open(data.popover, $clickedEl, data.animate); + }, + '.popover-close': function closePopover($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.popover.close(data.popover, data.animate, $clickedEl); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/popup/popup-class.js b/www/assets/framework7/cjs/components/popup/popup-class.js new file mode 100644 index 000000000..c16832d80 --- /dev/null +++ b/www/assets/framework7/cjs/components/popup/popup-class.js @@ -0,0 +1,416 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _getSupport = require("../../shared/get-support"); + +var _getDevice = require("../../shared/get-device"); + +var _modalClass = _interopRequireDefault(require("../modal/modal-class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Popup = /*#__PURE__*/function (_Modal) { + _inheritsLoose(Popup, _Modal); + + function Popup(app, params) { + var _this; + + var extendedParams = (0, _utils.extend)({ + on: {} + }, app.params.popup, params); // Extends with open/close Modal methods; + + _this = _Modal.call(this, app, extendedParams) || this; + + var popup = _assertThisInitialized(_this); + + var window = (0, _ssrWindow.getWindow)(); + var document = (0, _ssrWindow.getDocument)(); + var support = (0, _getSupport.getSupport)(); + var device = (0, _getDevice.getDevice)(); + popup.params = extendedParams; // Find Element + + var $el; + + if (!popup.params.el) { + $el = (0, _dom.default)(popup.params.content).filter(function (node) { + return node.nodeType === 1; + }).eq(0); + } else { + $el = (0, _dom.default)(popup.params.el).eq(0); + } + + if ($el && $el.length > 0 && $el[0].f7Modal) { + return $el[0].f7Modal || _assertThisInitialized(_this); + } + + if ($el.length === 0) { + return popup.destroy() || _assertThisInitialized(_this); + } + + var $backdropEl; + + if (popup.params.backdrop && popup.params.backdropEl) { + $backdropEl = (0, _dom.default)(popup.params.backdropEl); + } else if (popup.params.backdrop) { + $backdropEl = popup.$containerEl.children('.popup-backdrop'); + + if ($backdropEl.length === 0) { + $backdropEl = (0, _dom.default)(''); + popup.$containerEl.append($backdropEl); + } + } + + (0, _utils.extend)(popup, { + app: app, + push: $el.hasClass('popup-push') || popup.params.push, + $el: $el, + el: $el[0], + $backdropEl: $backdropEl, + backdropEl: $backdropEl && $backdropEl[0], + type: 'popup', + $htmlEl: (0, _dom.default)('html') + }); + + if (popup.params.push) { + $el.addClass('popup-push'); + } + + function handleClick(e) { + var target = e.target; + var $target = (0, _dom.default)(target); + var keyboardOpened = !device.desktop && device.cordova && (window.Keyboard && window.Keyboard.isVisible || window.cordova.plugins && window.cordova.plugins.Keyboard && window.cordova.plugins.Keyboard.isVisible); + if (keyboardOpened) return; + + if ($target.closest(popup.el).length === 0) { + if (popup.params && popup.params.closeByBackdropClick && popup.params.backdrop && popup.backdropEl && popup.backdropEl === target) { + var needToClose = true; + popup.$el.nextAll('.popup.modal-in').each(function (popupEl) { + var popupInstance = popupEl.f7Modal; + if (!popupInstance) return; + + if (popupInstance.params.closeByBackdropClick && popupInstance.params.backdrop && popupInstance.backdropEl === popup.backdropEl) { + needToClose = false; + } + }); + + if (needToClose) { + popup.close(); + } + } + } + } + + function onKeyDown(e) { + var keyCode = e.keyCode; + + if (keyCode === 27 && popup.params.closeOnEscape) { + popup.close(); + } + } + + var pushOffset; + var isPush; + + function pushViewScale(offset) { + return (app.height - offset * 2) / app.height; + } + + var allowSwipeToClose = true; + var isTouched = false; + var startTouch; + var currentTouch; + var isScrolling; + var touchStartTime; + var touchesDiff; + var isMoved = false; + var pageContentEl; + var pageContentScrollTop; + var pageContentOffsetHeight; + var pageContentScrollHeight; + var popupHeight; + var $pushEl; + + function handleTouchStart(e) { + if (isTouched || !allowSwipeToClose || !popup.params.swipeToClose) return; + + if (popup.params.swipeHandler && (0, _dom.default)(e.target).closest(popup.params.swipeHandler).length === 0) { + return; + } + + isTouched = true; + isMoved = false; + startTouch = { + x: e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX, + y: e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY + }; + touchStartTime = (0, _utils.now)(); + isScrolling = undefined; + + if (!popup.params.swipeHandler && e.type === 'touchstart') { + pageContentEl = (0, _dom.default)(e.target).closest('.page-content')[0]; + } + } + + function handleTouchMove(e) { + if (!isTouched) return; + currentTouch = { + x: e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX, + y: e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY + }; + + if (typeof isScrolling === 'undefined') { + isScrolling = !!(isScrolling || Math.abs(currentTouch.x - startTouch.x) > Math.abs(currentTouch.y - startTouch.y)); + } + + if (isScrolling) { + isTouched = false; + isMoved = false; + return; + } + + touchesDiff = startTouch.y - currentTouch.y; + + if (isPush && pushOffset && touchesDiff > 0) { + touchesDiff = 0; + } + + var direction = touchesDiff < 0 ? 'to-bottom' : 'to-top'; + $el.transition(0); + + if (typeof popup.params.swipeToClose === 'string' && direction !== popup.params.swipeToClose) { + $el.transform(''); + $el.transition(''); + return; + } + + if (!isMoved) { + if (isPush && pushOffset) { + popupHeight = $el[0].offsetHeight; + $pushEl = $el.prevAll('.popup.modal-in').eq(0); + + if ($pushEl.length === 0) { + $pushEl = app.$el.children('.view, .views'); + } + } + + if (pageContentEl) { + pageContentScrollTop = pageContentEl.scrollTop; + pageContentScrollHeight = pageContentEl.scrollHeight; + pageContentOffsetHeight = pageContentEl.offsetHeight; + + if (!(pageContentScrollHeight === pageContentOffsetHeight) && !(direction === 'to-bottom' && pageContentScrollTop === 0) && !(direction === 'to-top' && pageContentScrollTop === pageContentScrollHeight - pageContentOffsetHeight)) { + $el.transform(''); + $el.transition(''); + isTouched = false; + isMoved = false; + return; + } + } + + isMoved = true; + popup.emit('local::swipeStart popupSwipeStart', popup); + popup.$el.trigger('popup:swipestart'); + } else { + popup.emit('local::swipeMove popupSwipeMove', popup); + popup.$el.trigger('popup:swipemove'); + } + + e.preventDefault(); + + if (isPush && pushOffset) { + var pushProgress = 1 - Math.abs(touchesDiff / popupHeight); + var scale = 1 - (1 - pushViewScale(pushOffset)) * pushProgress; + + if ($pushEl.hasClass('popup')) { + if ($pushEl.hasClass('popup-push')) { + $pushEl.transition(0).forEach(function (el) { + el.style.setProperty('transform', "translate3d(0, calc(-1 * " + pushProgress + " * (var(--f7-popup-push-offset) + 10px)) , 0px) scale(" + scale + ")", 'important'); + }); + } else { + $pushEl.transition(0).forEach(function (el) { + el.style.setProperty('transform', "translate3d(0, 0px , 0px) scale(" + scale + ")", 'important'); + }); + } + } else { + $pushEl.transition(0).forEach(function (el) { + el.style.setProperty('transform', "translate3d(0,0,0) scale(" + scale + ")", 'important'); + }); + } + } + + $el.transition(0).transform("translate3d(0," + -touchesDiff + "px,0)"); + } + + function handleTouchEnd() { + isTouched = false; + + if (!isMoved) { + return; + } + + popup.emit('local::swipeEnd popupSwipeEnd', popup); + popup.$el.trigger('popup:swipeend'); + isMoved = false; + allowSwipeToClose = false; + $el.transition(''); + + if (isPush && pushOffset) { + $pushEl.transition('').transform(''); + } + + var direction = touchesDiff <= 0 ? 'to-bottom' : 'to-top'; + + if (typeof popup.params.swipeToClose === 'string' && direction !== popup.params.swipeToClose) { + $el.transform(''); + allowSwipeToClose = true; + return; + } + + var diff = Math.abs(touchesDiff); + var timeDiff = new Date().getTime() - touchStartTime; + + if (timeDiff < 300 && diff > 20 || timeDiff >= 300 && diff > 100) { + (0, _utils.nextTick)(function () { + if (direction === 'to-bottom') { + $el.addClass('swipe-close-to-bottom'); + } else { + $el.addClass('swipe-close-to-top'); + } + + $el.transform(''); + popup.emit('local::swipeclose popupSwipeClose', popup); + popup.$el.trigger('popup:swipeclose'); + popup.close(); + allowSwipeToClose = true; + }); + return; + } + + allowSwipeToClose = true; + $el.transform(''); + } + + var passive = support.passiveListener ? { + passive: true + } : false; + + if (popup.params.swipeToClose) { + $el.on(app.touchEvents.start, handleTouchStart, passive); + app.on('touchmove', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + popup.once('popupDestroy', function () { + $el.off(app.touchEvents.start, handleTouchStart, passive); + app.off('touchmove', handleTouchMove); + app.off('touchend:passive', handleTouchEnd); + }); + } + + var hasPreviousPushPopup; + + var updatePushOffset = function updatePushOffset() { + var wasPush = isPush; + + if (popup.push) { + isPush = popup.push && (app.width < 630 || app.height < 630 || $el.hasClass('popup-tablet-fullscreen')); + } + + if (isPush && !wasPush) { + // eslint-disable-next-line + setPushOffset(); + } else if (isPush && wasPush) { + popup.$htmlEl[0].style.setProperty('--f7-popup-push-scale', pushViewScale(pushOffset)); + } else if (!isPush && wasPush) { + popup.$htmlEl.removeClass('with-modal-popup-push'); + popup.$htmlEl[0].style.removeProperty('--f7-popup-push-scale'); + } + }; + + var setPushOffset = function setPushOffset() { + app.off('resize', updatePushOffset); + + if (popup.push) { + isPush = popup.push && (app.width < 630 || app.height < 630 || $el.hasClass('popup-tablet-fullscreen')); + } + + if (isPush) { + pushOffset = parseInt($el.css('--f7-popup-push-offset'), 10); + if (Number.isNaN(pushOffset)) pushOffset = 0; + + if (pushOffset) { + $el.addClass('popup-push'); + popup.$htmlEl.addClass('with-modal-popup-push'); + popup.$htmlEl[0].style.setProperty('--f7-popup-push-scale', pushViewScale(pushOffset)); + } + } + + app.on('resize', updatePushOffset); + }; + + popup.on('open', function () { + hasPreviousPushPopup = false; + + if (popup.params.closeOnEscape) { + (0, _dom.default)(document).on('keydown', onKeyDown); + } + + $el.prevAll('.popup.modal-in').addClass('popup-behind'); + setPushOffset(); + }); + popup.on('opened', function () { + $el.removeClass('swipe-close-to-bottom swipe-close-to-top'); + + if (popup.params.closeByBackdropClick) { + app.on('click', handleClick); + } + }); + popup.on('close', function () { + hasPreviousPushPopup = popup.$el.prevAll('.popup-push.modal-in').length > 0; + + if (popup.params.closeOnEscape) { + (0, _dom.default)(document).off('keydown', onKeyDown); + } + + if (popup.params.closeByBackdropClick) { + app.off('click', handleClick); + } + + $el.prevAll('.popup.modal-in').eq(0).removeClass('popup-behind'); + + if (isPush && pushOffset && !hasPreviousPushPopup) { + popup.$htmlEl.removeClass('with-modal-popup-push'); + popup.$htmlEl.addClass('with-modal-popup-push-closing'); + } + + app.off('resize', updatePushOffset); + }); + popup.on('closed', function () { + $el.removeClass('popup-behind'); + + if (isPush && pushOffset && !hasPreviousPushPopup) { + popup.$htmlEl.removeClass('with-modal-popup-push-closing'); + popup.$htmlEl[0].style.removeProperty('--f7-popup-push-scale'); + } + }); + $el[0].f7Modal = popup; + return popup || _assertThisInitialized(_this); + } + + return Popup; +}(_modalClass.default); + +var _default = Popup; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/popup/popup.js b/www/assets/framework7/cjs/components/popup/popup.js new file mode 100644 index 000000000..92c8cd0c8 --- /dev/null +++ b/www/assets/framework7/cjs/components/popup/popup.js @@ -0,0 +1,57 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _popupClass = _interopRequireDefault(require("./popup-class")); + +var _modalMethods = _interopRequireDefault(require("../../shared/modal-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'popup', + params: { + popup: { + backdrop: true, + backdropEl: undefined, + closeByBackdropClick: true, + closeOnEscape: false, + swipeToClose: false, + swipeHandler: null, + push: false, + containerEl: null + } + }, + static: { + Popup: _popupClass.default + }, + create: function create() { + var app = this; + app.popup = (0, _modalMethods.default)({ + app: app, + constructor: _popupClass.default, + defaultSelector: '.popup.modal-in', + parentSelector: '.popup' + }); + }, + clicks: { + '.popup-open': function openPopup($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.popup.open(data.popup, data.animate, $clickedEl); + }, + '.popup-close': function closePopup($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.popup.close(data.popup, data.animate, $clickedEl); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/preloader/preloader.js b/www/assets/framework7/cjs/components/preloader/preloader.js new file mode 100644 index 000000000..9e3aad6d9 --- /dev/null +++ b/www/assets/framework7/cjs/components/preloader/preloader.js @@ -0,0 +1,111 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Preloader = { + init: function init(el) { + var app = this; + var preloaders = { + iosPreloaderContent: _utils.iosPreloaderContent, + mdPreloaderContent: _utils.mdPreloaderContent, + auroraPreloaderContent: _utils.auroraPreloaderContent + }; + var $el = (0, _dom.default)(el); + if ($el.length === 0 || $el.children('.preloader-inner').length > 0 || $el.children('.preloader-inner-line').length > 0) return; + $el.append(preloaders[app.theme + "PreloaderContent"]); + }, + // Modal + visible: false, + show: function show(color) { + if (color === void 0) { + color = 'white'; + } + + var app = this; + if (Preloader.visible) return; + var preloaders = { + iosPreloaderContent: _utils.iosPreloaderContent, + mdPreloaderContent: _utils.mdPreloaderContent, + auroraPreloaderContent: _utils.auroraPreloaderContent + }; + var preloaderInner = preloaders[app.theme + "PreloaderContent"] || ''; + (0, _dom.default)('html').addClass('with-modal-preloader'); // prettier-ignore + + app.$el.append("\n
    \n
    \n
    " + preloaderInner + "
    \n
    \n "); + Preloader.visible = true; + }, + showIn: function showIn(el, color) { + if (color === void 0) { + color = 'white'; + } + + var app = this; + var preloaders = { + iosPreloaderContent: _utils.iosPreloaderContent, + mdPreloaderContent: _utils.mdPreloaderContent, + auroraPreloaderContent: _utils.auroraPreloaderContent + }; + var preloaderInner = preloaders[app.theme + "PreloaderContent"] || ''; + (0, _dom.default)(el || 'html').addClass('with-modal-preloader'); // prettier-ignore + + (0, _dom.default)(el || app.$el).append("\n
    \n
    \n
    " + preloaderInner + "
    \n
    \n "); + }, + hide: function hide() { + var app = this; + if (!Preloader.visible) return; + (0, _dom.default)('html').removeClass('with-modal-preloader'); + app.$el.find('.preloader-backdrop, .preloader-modal').remove(); + Preloader.visible = false; + }, + hideIn: function hideIn(el) { + var app = this; + (0, _dom.default)(el || 'html').removeClass('with-modal-preloader'); + (0, _dom.default)(el || app.$el).find('.preloader-backdrop, .preloader-modal').remove(); + } +}; +var _default = { + name: 'preloader', + create: function create() { + var app = this; + (0, _utils.bindMethods)(app, { + preloader: Preloader + }); + }, + on: { + photoBrowserOpen: function photoBrowserOpen(pb) { + var app = this; + pb.$el.find('.preloader').each(function (preloaderEl) { + app.preloader.init(preloaderEl); + }); + }, + tabMounted: function tabMounted(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.preloader').each(function (preloaderEl) { + app.preloader.init(preloaderEl); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.preloader').each(function (preloaderEl) { + app.preloader.init(preloaderEl); + }); + } + }, + vnode: { + preloader: { + insert: function insert(vnode) { + var app = this; + var preloaderEl = vnode.elm; + app.preloader.init(preloaderEl); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/progressbar/progressbar.js b/www/assets/framework7/cjs/components/progressbar/progressbar.js new file mode 100644 index 000000000..8606aebee --- /dev/null +++ b/www/assets/framework7/cjs/components/progressbar/progressbar.js @@ -0,0 +1,185 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Progressbar = { + set: function set() { + var app = this; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var el = args[0], + progress = args[1], + duration = args[2]; + + if (typeof args[0] === 'number') { + progress = args[0]; + duration = args[1]; + el = app.$el; + } + + if (typeof progress === 'undefined' || progress === null) return el; + if (!progress) progress = 0; + var $el = (0, _dom.default)(el || app.$el); + + if ($el.length === 0) { + return el; + } + + var progressNormalized = Math.min(Math.max(progress, 0), 100); + var $progressbarEl; + if ($el.hasClass('progressbar')) $progressbarEl = $el.eq(0);else { + $progressbarEl = $el.children('.progressbar'); + } + + if ($progressbarEl.length === 0 || $progressbarEl.hasClass('progressbar-infinite')) { + return $progressbarEl; + } + + var $progressbarLine = $progressbarEl.children('span'); + + if ($progressbarLine.length === 0) { + $progressbarLine = (0, _dom.default)(''); + $progressbarEl.append($progressbarLine); + } + + $progressbarLine.transition(typeof duration !== 'undefined' ? duration : '').transform("translate3d(" + (-100 + progressNormalized) * (app.rtl ? -1 : 1) + "%,0,0)"); + return $progressbarEl[0]; + }, + show: function show() { + var app = this; // '.page', 50, 'multi' + + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var el = args[0], + progress = args[1], + color = args[2]; + var type = 'determined'; + + if (args.length === 2) { + if ((typeof args[0] === 'string' || typeof args[0] === 'object') && typeof args[1] === 'string') { + // '.page', 'multi' + el = args[0]; + color = args[1]; + progress = args[2]; + type = 'infinite'; + } else if (typeof args[0] === 'number' && typeof args[1] === 'string') { + // 50, 'multi' + progress = args[0]; + color = args[1]; + el = app.$el; + } + } else if (args.length === 1) { + if (typeof args[0] === 'number') { + el = app.$el; + progress = args[0]; + } else if (typeof args[0] === 'string') { + type = 'infinite'; + el = app.$el; + color = args[0]; + } + } else if (args.length === 0) { + type = 'infinite'; + el = app.$el; + } + + var $el = (0, _dom.default)(el); + if ($el.length === 0) return undefined; + var $progressbarEl; + + if ($el.hasClass('progressbar') || $el.hasClass('progressbar-infinite')) { + $progressbarEl = $el; + } else { + $progressbarEl = $el.children('.progressbar:not(.progressbar-out), .progressbar-infinite:not(.progressbar-out)'); + + if ($progressbarEl.length === 0) { + $progressbarEl = (0, _dom.default)("\n \n " + (type === 'infinite' ? '' : '') + "\n "); + $el.append($progressbarEl); + } + } + + if (typeof progress !== 'undefined') { + app.progressbar.set($progressbarEl, progress); + } + + return $progressbarEl[0]; + }, + hide: function hide(el, removeAfterHide) { + if (removeAfterHide === void 0) { + removeAfterHide = true; + } + + var app = this; + var $el = (0, _dom.default)(el || app.$el); + if ($el.length === 0) return undefined; + var $progressbarEl; + + if ($el.hasClass('progressbar') || $el.hasClass('progressbar-infinite')) { + $progressbarEl = $el; + } else { + $progressbarEl = $el.children('.progressbar, .progressbar-infinite'); + } + + if ($progressbarEl.length === 0 || !$progressbarEl.hasClass('progressbar-in') || $progressbarEl.hasClass('progressbar-out')) { + return $progressbarEl; + } + + $progressbarEl.removeClass('progressbar-in').addClass('progressbar-out').animationEnd(function () { + if (removeAfterHide) { + $progressbarEl.remove(); + } + }); + return $progressbarEl; + } +}; +var _default = { + name: 'progressbar', + create: function create() { + var app = this; + (0, _utils.bindMethods)(app, { + progressbar: Progressbar + }); + }, + on: { + tabMounted: function tabMounted(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.progressbar').each(function (progressbarEl) { + var $progressbarEl = (0, _dom.default)(progressbarEl); + app.progressbar.set($progressbarEl, $progressbarEl.attr('data-progress')); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.progressbar').each(function (progressbarEl) { + var $progressbarEl = (0, _dom.default)(progressbarEl); + app.progressbar.set($progressbarEl, $progressbarEl.attr('data-progress')); + }); + } + }, + vnode: { + progressbar: { + insert: function insert(vnode) { + var app = this; + var el = vnode.elm; + app.progressbar.set(el, el.getAttribute('data-progress')); + }, + update: function update(vnode) { + var app = this; + var el = vnode.elm; + app.progressbar.set(el, el.getAttribute('data-progress')); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/pull-to-refresh/pull-to-refresh-class.js b/www/assets/framework7/cjs/components/pull-to-refresh/pull-to-refresh-class.js new file mode 100644 index 000000000..7b892ba48 --- /dev/null +++ b/www/assets/framework7/cjs/components/pull-to-refresh/pull-to-refresh-class.js @@ -0,0 +1,627 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _getSupport = require("../../shared/get-support"); + +var _getDevice = require("../../shared/get-device"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var PullToRefresh = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(PullToRefresh, _Framework7Class); + + function PullToRefresh(app, el) { + var _this; + + _this = _Framework7Class.call(this, {}, [app]) || this; + + var ptr = _assertThisInitialized(_this); + + var device = (0, _getDevice.getDevice)(); + var support = (0, _getSupport.getSupport)(); + var $el = (0, _dom.default)(el); + var $preloaderEl = $el.find('.ptr-preloader'); + ptr.$el = $el; + ptr.el = $el[0]; + ptr.app = app; + ptr.bottom = ptr.$el.hasClass('ptr-bottom'); // Extend defaults with modules params + + ptr.useModulesParams({}); + var isMaterial = app.theme === 'md'; + var isIos = app.theme === 'ios'; + var isAurora = app.theme === 'aurora'; // Done + + ptr.done = function done() { + var $transitionTarget = isMaterial ? $preloaderEl : $el; + + var onTranstionEnd = function onTranstionEnd(e) { + if ((0, _dom.default)(e.target).closest($preloaderEl).length) return; + $el.removeClass('ptr-transitioning ptr-pull-up ptr-pull-down ptr-closing'); + $el.trigger('ptr:done'); + ptr.emit('local::done ptrDone', $el[0]); + $transitionTarget.off('transitionend', onTranstionEnd); + }; + + $transitionTarget.on('transitionend', onTranstionEnd); + $el.removeClass('ptr-refreshing').addClass('ptr-transitioning ptr-closing'); + return ptr; + }; + + ptr.refresh = function refresh() { + if ($el.hasClass('ptr-refreshing')) return ptr; + $el.addClass('ptr-transitioning ptr-refreshing'); + $el.trigger('ptr:refresh', ptr.done); + ptr.emit('local::refresh ptrRefresh', $el[0], ptr.done); + return ptr; + }; // Mousewheel + + + ptr.mousewheel = $el.attr('data-ptr-mousewheel') === 'true'; // Events handling + + var touchId; + var isTouched; + var isMoved; + var touchesStart = {}; + var isScrolling; + var touchesDiff; + var refresh = false; + var useTranslate = false; + var forceUseTranslate = false; + var startTranslate = 0; + var translate; + var scrollTop; + var wasScrolled; + var triggerDistance; + var dynamicTriggerDistance; + var pullStarted; + var hasNavbar = false; + var scrollHeight; + var offsetHeight; + var maxScrollTop; + var $pageEl = $el.parents('.page'); + if ($pageEl.find('.navbar').length > 0 || $pageEl.parents('.view').children('.navbars').length > 0) hasNavbar = true; + if ($pageEl.hasClass('no-navbar')) hasNavbar = false; + + if (!ptr.bottom) { + var pageNavbarEl = app.navbar.getElByPage($pageEl[0]); + + if (pageNavbarEl) { + var $pageNavbarEl = (0, _dom.default)(pageNavbarEl); + var isLargeTransparent = $pageNavbarEl.hasClass('navbar-large-transparent') || $pageNavbarEl.hasClass('navbar-large') && $pageNavbarEl.hasClass('navbar-transparent'); + var isTransparent = $pageNavbarEl.hasClass('navbar-transparent') && !$pageNavbarEl.hasClass('navbar-large'); + + if (isLargeTransparent) { + $el.addClass('ptr-with-navbar-large-transparent'); + } else if (isTransparent) { + $el.addClass('ptr-with-navbar-transparent'); + } + } + } + + if (!hasNavbar && !ptr.bottom) $el.addClass('ptr-no-navbar'); // Define trigger distance + + if ($el.attr('data-ptr-distance')) { + dynamicTriggerDistance = true; + } else if (isMaterial) { + triggerDistance = 66; + } else if (isIos) { + triggerDistance = 44; + } else if (isAurora) { + triggerDistance = 38; + } + + function setPreloaderProgress(progress) { + if (progress === void 0) { + progress = 0; + } + + var $bars = $preloaderEl.find('.preloader-inner-line'); + var perBarProgress = 1 / $bars.length; + $bars.forEach(function (barEl, barIndex) { + var barProgress = (progress - barIndex * perBarProgress) / perBarProgress; + barEl.style.opacity = Math.max(Math.min(barProgress, 1), 0) * 0.27; + }); + } + + function unsetPreloaderProgress() { + $preloaderEl.find('.preloader-inner-line').css('opacity', ''); + } + + function handleTouchStart(e) { + if (isTouched) { + if (device.os === 'android') { + if ('targetTouches' in e && e.targetTouches.length > 1) return; + } else return; + } + + if ($el.hasClass('ptr-refreshing')) { + return; + } + + if ((0, _dom.default)(e.target).closest('.sortable-handler, .ptr-ignore, .card-expandable.card-opened').length) return; + isMoved = false; + pullStarted = false; + isTouched = true; + isScrolling = undefined; + wasScrolled = undefined; + if (e.type === 'touchstart') touchId = e.targetTouches[0].identifier; + touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; + touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + } + + function handleTouchMove(e) { + if (!isTouched) return; + var pageX; + var pageY; + var touch; + + if (e.type === 'touchmove') { + if (touchId && e.touches) { + for (var i = 0; i < e.touches.length; i += 1) { + if (e.touches[i].identifier === touchId) { + touch = e.touches[i]; + } + } + } + + if (!touch) touch = e.targetTouches[0]; + pageX = touch.pageX; + pageY = touch.pageY; + } else { + pageX = e.pageX; + pageY = e.pageY; + } + + if (!pageX || !pageY) return; + + if (typeof isScrolling === 'undefined') { + isScrolling = !!(isScrolling || Math.abs(pageY - touchesStart.y) > Math.abs(pageX - touchesStart.x)); + } + + if (!isScrolling) { + isTouched = false; + return; + } + + scrollTop = $el[0].scrollTop; + + if (!isMoved) { + $el.removeClass('ptr-transitioning'); + + if (isIos) { + setPreloaderProgress(0); + } + + var targetIsScrollable; + scrollHeight = $el[0].scrollHeight; + offsetHeight = $el[0].offsetHeight; + + if (ptr.bottom) { + maxScrollTop = scrollHeight - offsetHeight; + } + + if (scrollTop > scrollHeight) { + isTouched = false; + return; + } + + var $ptrWatchScrollable = (0, _dom.default)(e.target).closest('.ptr-watch-scroll'); + + if ($ptrWatchScrollable.length) { + $ptrWatchScrollable.each(function (ptrScrollableEl) { + if (ptrScrollableEl === el) return; + + if (ptrScrollableEl.scrollHeight > ptrScrollableEl.offsetHeight && (0, _dom.default)(ptrScrollableEl).css('overflow') === 'auto' && (!ptr.bottom && ptrScrollableEl.scrollTop > 0 || ptr.bottom && ptrScrollableEl.scrollTop < ptrScrollableEl.scrollHeight - ptrScrollableEl.offsetHeight)) { + targetIsScrollable = true; + } + }); + } + + if (targetIsScrollable) { + isTouched = false; + return; + } + + if (dynamicTriggerDistance) { + triggerDistance = $el.attr('data-ptr-distance'); + if (triggerDistance.indexOf('%') >= 0) triggerDistance = scrollHeight * parseInt(triggerDistance, 10) / 100; + } + + startTranslate = $el.hasClass('ptr-refreshing') ? triggerDistance : 0; + + if (scrollHeight === offsetHeight || device.os !== 'ios' || isMaterial) { + useTranslate = true; + } else { + useTranslate = false; + } + + forceUseTranslate = false; + } + + isMoved = true; + touchesDiff = pageY - touchesStart.y; + if (typeof wasScrolled === 'undefined' && (ptr.bottom ? scrollTop !== maxScrollTop : scrollTop !== 0)) wasScrolled = true; + var ptrStarted = ptr.bottom ? touchesDiff < 0 && scrollTop >= maxScrollTop || scrollTop > maxScrollTop : touchesDiff > 0 && scrollTop <= 0 || scrollTop < 0; + + if (ptrStarted) { + // iOS 8 fix + if (device.os === 'ios' && parseInt(device.osVersion.split('.')[0], 10) > 7) { + if (!ptr.bottom && scrollTop === 0 && !wasScrolled) useTranslate = true; + if (ptr.bottom && scrollTop === maxScrollTop && !wasScrolled) useTranslate = true; + } + + if (!useTranslate && ptr.bottom && !isMaterial) { + $el.css('-webkit-overflow-scrolling', 'auto'); + $el.scrollTop(maxScrollTop); + forceUseTranslate = true; + } + + if (useTranslate || forceUseTranslate) { + if (e.cancelable) { + e.preventDefault(); + } + + translate = (ptr.bottom ? -1 * Math.pow(Math.abs(touchesDiff), 0.85) : Math.pow(touchesDiff, 0.85)) + startTranslate; + + if (isMaterial) { + $preloaderEl.transform("translate3d(0," + translate + "px,0)").find('.ptr-arrow').transform("rotate(" + (180 * (Math.abs(touchesDiff) / 66) + 100) + "deg)"); + } else { + // eslint-disable-next-line + if (ptr.bottom || isIos) { + $el.children().transform("translate3d(0," + translate + "px,0)"); + } else { + // eslint-disable-next-line + $el.transform("translate3d(0," + translate + "px,0)"); + } + + if (isIos) { + $preloaderEl.transform("translate3d(0,0px,0)"); + } + } + } else if (isIos && !ptr.bottom) { + $preloaderEl.transform("translate3d(0," + scrollTop + "px,0)"); + } + + var progress; + + if (isIos && !refresh) { + progress = useTranslate || forceUseTranslate ? Math.pow(Math.abs(touchesDiff), 0.85) / triggerDistance : Math.abs(touchesDiff) / (triggerDistance * 2); + setPreloaderProgress(progress); + } + + if ((useTranslate || forceUseTranslate) && Math.pow(Math.abs(touchesDiff), 0.85) > triggerDistance || !useTranslate && Math.abs(touchesDiff) >= triggerDistance * 2) { + refresh = true; + $el.addClass('ptr-pull-up').removeClass('ptr-pull-down'); + unsetPreloaderProgress(); + } else { + refresh = false; + $el.removeClass('ptr-pull-up').addClass('ptr-pull-down'); + } + + if (!pullStarted) { + $el.trigger('ptr:pullstart'); + ptr.emit('local::pullStart ptrPullStart', $el[0]); + pullStarted = true; + } + + $el.trigger('ptr:pullmove', { + event: e, + scrollTop: scrollTop, + translate: translate, + touchesDiff: touchesDiff + }); + ptr.emit('local::pullMove ptrPullMove', $el[0], { + event: e, + scrollTop: scrollTop, + translate: translate, + touchesDiff: touchesDiff + }); + } else { + pullStarted = false; + $el.removeClass('ptr-pull-up ptr-pull-down'); + refresh = false; + } + } + + function handleTouchEnd(e) { + if (e.type === 'touchend' && e.changedTouches && e.changedTouches.length > 0 && touchId) { + if (e.changedTouches[0].identifier !== touchId) { + isTouched = false; + isScrolling = false; + isMoved = false; + touchId = null; + return; + } + } + + if (!isTouched || !isMoved) { + isTouched = false; + isMoved = false; + return; + } + + if (translate) { + $el.addClass('ptr-transitioning'); + translate = 0; + } + + if (isMaterial) { + $preloaderEl.transform('').find('.ptr-arrow').transform(''); + } else { + $preloaderEl.transform(''); + + if (ptr.bottom || isIos) { + $el.children().transform(''); + } else { + $el.transform(''); + } + } + + if (!useTranslate && ptr.bottom && !isMaterial) { + $el.css('-webkit-overflow-scrolling', ''); + } + + if (refresh) { + $el.addClass('ptr-refreshing'); + $el.trigger('ptr:refresh', ptr.done); + ptr.emit('local::refresh ptrRefresh', $el[0], ptr.done); + } else { + $el.removeClass('ptr-pull-down'); + } + + isTouched = false; + isMoved = false; + + if (pullStarted) { + $el.trigger('ptr:pullend'); + ptr.emit('local::pullEnd ptrPullEnd', $el[0]); + } + } + + var mousewheelTimeout; + var mousewheelMoved; + var mousewheelAllow = true; + var mousewheelTranslate = 0; + + function handleMouseWheelRelease() { + mousewheelAllow = true; + mousewheelMoved = false; + mousewheelTranslate = 0; + + if (translate) { + $el.addClass('ptr-transitioning'); + translate = 0; + } + + if (isMaterial) { + $preloaderEl.transform('').find('.ptr-arrow').transform(''); + } else { + $preloaderEl.transform(''); + + if (ptr.bottom) { + $el.children().transform(''); + } else { + $el.transform(''); + } + } + + if (refresh) { + $el.addClass('ptr-refreshing'); + $el.trigger('ptr:refresh', ptr.done); + ptr.emit('local::refresh ptrRefresh', $el[0], ptr.done); + } else { + $el.removeClass('ptr-pull-down'); + } + + if (pullStarted) { + $el.trigger('ptr:pullend'); + ptr.emit('local::pullEnd ptrPullEnd', $el[0]); + } + } + + function handleMouseWheel(e) { + if (!mousewheelAllow) return; + var deltaX = e.deltaX, + deltaY = e.deltaY; + if (Math.abs(deltaX) > Math.abs(deltaY)) return; + + if ($el.hasClass('ptr-refreshing')) { + return; + } + + if ((0, _dom.default)(e.target).closest('.sortable-handler, .ptr-ignore, .card-expandable.card-opened').length) return; + clearTimeout(mousewheelTimeout); + scrollTop = $el[0].scrollTop; + + if (!mousewheelMoved) { + $el.removeClass('ptr-transitioning'); + + if (isIos) { + setPreloaderProgress(0); + } + + var targetIsScrollable; + scrollHeight = $el[0].scrollHeight; + offsetHeight = $el[0].offsetHeight; + + if (ptr.bottom) { + maxScrollTop = scrollHeight - offsetHeight; + } + + if (scrollTop > scrollHeight) { + mousewheelAllow = false; + return; + } + + var $ptrWatchScrollable = (0, _dom.default)(e.target).closest('.ptr-watch-scroll'); + + if ($ptrWatchScrollable.length) { + $ptrWatchScrollable.each(function (ptrScrollableEl) { + if (ptrScrollableEl === el) return; + + if (ptrScrollableEl.scrollHeight > ptrScrollableEl.offsetHeight && (0, _dom.default)(ptrScrollableEl).css('overflow') === 'auto' && (!ptr.bottom && ptrScrollableEl.scrollTop > 0 || ptr.bottom && ptrScrollableEl.scrollTop < ptrScrollableEl.scrollHeight - ptrScrollableEl.offsetHeight)) { + targetIsScrollable = true; + } + }); + } + + if (targetIsScrollable) { + mousewheelAllow = false; + return; + } + + if (dynamicTriggerDistance) { + triggerDistance = $el.attr('data-ptr-distance'); + if (triggerDistance.indexOf('%') >= 0) triggerDistance = scrollHeight * parseInt(triggerDistance, 10) / 100; + } + } + + isMoved = true; + mousewheelTranslate -= deltaY; + touchesDiff = mousewheelTranslate; // pageY - touchesStart.y; + + if (typeof wasScrolled === 'undefined' && (ptr.bottom ? scrollTop !== maxScrollTop : scrollTop !== 0)) wasScrolled = true; + var ptrStarted = ptr.bottom ? touchesDiff < 0 && scrollTop >= maxScrollTop || scrollTop > maxScrollTop : touchesDiff > 0 && scrollTop <= 0 || scrollTop < 0; + + if (ptrStarted) { + if (e.cancelable) { + e.preventDefault(); + } + + translate = touchesDiff; + + if (Math.abs(translate) > triggerDistance) { + translate = triggerDistance + Math.pow(Math.abs(translate) - triggerDistance, 0.7); + if (ptr.bottom) translate = -translate; + } + + if (isMaterial) { + $preloaderEl.transform("translate3d(0," + translate + "px,0)").find('.ptr-arrow').transform("rotate(" + (180 * (Math.abs(touchesDiff) / 66) + 100) + "deg)"); + } else { + // eslint-disable-next-line + if (ptr.bottom) { + $el.children().transform("translate3d(0," + translate + "px,0)"); + } else { + $el.transform("translate3d(0," + translate + "px,0)"); + + if (isIos) { + $preloaderEl.transform("translate3d(0," + -translate + "px,0)"); + } + } + } + + var progress; + + if (isIos && !refresh) { + progress = Math.abs(translate) / triggerDistance; + setPreloaderProgress(progress); + } + + if (Math.abs(translate) > triggerDistance) { + refresh = true; + $el.addClass('ptr-pull-up').removeClass('ptr-pull-down'); + unsetPreloaderProgress(); + } else { + refresh = false; + $el.removeClass('ptr-pull-up').addClass('ptr-pull-down'); + } + + if (!pullStarted) { + $el.trigger('ptr:pullstart'); + ptr.emit('local::pullStart ptrPullStart', $el[0]); + pullStarted = true; + } + + $el.trigger('ptr:pullmove', { + event: e, + scrollTop: scrollTop, + translate: translate, + touchesDiff: touchesDiff + }); + ptr.emit('local::pullMove ptrPullMove', $el[0], { + event: e, + scrollTop: scrollTop, + translate: translate, + touchesDiff: touchesDiff + }); + } else { + pullStarted = false; + $el.removeClass('ptr-pull-up ptr-pull-down'); + refresh = false; + } + + mousewheelTimeout = setTimeout(handleMouseWheelRelease, 300); + } + + if (!$pageEl.length || !$el.length) return ptr || _assertThisInitialized(_this); + $el[0].f7PullToRefresh = ptr; // Events + + ptr.attachEvents = function attachEvents() { + var passive = support.passiveListener ? { + passive: true + } : false; + $el.on(app.touchEvents.start, handleTouchStart, passive); + app.on('touchmove:active', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + + if (ptr.mousewheel && !ptr.bottom) { + $el.on('wheel', handleMouseWheel); + } + }; + + ptr.detachEvents = function detachEvents() { + var passive = support.passiveListener ? { + passive: true + } : false; + $el.off(app.touchEvents.start, handleTouchStart, passive); + app.off('touchmove:active', handleTouchMove); + app.off('touchend:passive', handleTouchEnd); + + if (ptr.mousewheel && !ptr.bottom) { + $el.off('wheel', handleMouseWheel); + } + }; // Install Modules + + + ptr.useModules(); // Init + + ptr.init(); + return ptr || _assertThisInitialized(_this); + } + + var _proto = PullToRefresh.prototype; + + _proto.init = function init() { + var ptr = this; + ptr.attachEvents(); + }; + + _proto.destroy = function destroy() { + var ptr = this; + ptr.emit('local::beforeDestroy ptrBeforeDestroy', ptr); + ptr.$el.trigger('ptr:beforedestroy'); + delete ptr.el.f7PullToRefresh; + ptr.detachEvents(); + (0, _utils.deleteProps)(ptr); + ptr = null; + }; + + return PullToRefresh; +}(_class.default); + +var _default = PullToRefresh; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/pull-to-refresh/pull-to-refresh.js b/www/assets/framework7/cjs/components/pull-to-refresh/pull-to-refresh.js new file mode 100644 index 000000000..9fa8a11e5 --- /dev/null +++ b/www/assets/framework7/cjs/components/pull-to-refresh/pull-to-refresh.js @@ -0,0 +1,74 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _pullToRefreshClass = _interopRequireDefault(require("./pull-to-refresh-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'pullToRefresh', + create: function create() { + var app = this; + app.ptr = (0, _utils.extend)((0, _constructorMethods.default)({ + defaultSelector: '.ptr-content', + constructor: _pullToRefreshClass.default, + app: app, + domProp: 'f7PullToRefresh' + }), { + done: function done(el) { + var ptr = app.ptr.get(el); + if (ptr) return ptr.done(); + return undefined; + }, + refresh: function refresh(el) { + var ptr = app.ptr.get(el); + if (ptr) return ptr.refresh(); + return undefined; + } + }); + }, + static: { + PullToRefresh: _pullToRefreshClass.default + }, + on: { + tabMounted: function tabMounted(tabEl) { + var app = this; + var $tabEl = (0, _dom.default)(tabEl); + var $ptrEls = $tabEl.find('.ptr-content'); + if ($tabEl.is('.ptr-content')) $ptrEls.add($tabEl); + $ptrEls.each(function (el) { + app.ptr.create(el); + }); + }, + tabBeforeRemove: function tabBeforeRemove(tabEl) { + var $tabEl = (0, _dom.default)(tabEl); + var app = this; + var $ptrEls = $tabEl.find('.ptr-content'); + if ($tabEl.is('.ptr-content')) $ptrEls.add($tabEl); + $ptrEls.each(function (el) { + app.ptr.destroy(el); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.ptr-content').each(function (el) { + app.ptr.create(el); + }); + }, + pageBeforeRemove: function pageBeforeRemove(page) { + var app = this; + page.$el.find('.ptr-content').each(function (el) { + app.ptr.destroy(el); + }); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/radio/radio.js b/www/assets/framework7/cjs/components/radio/radio.js new file mode 100644 index 000000000..c65da6ea1 --- /dev/null +++ b/www/assets/framework7/cjs/components/radio/radio.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _default = { + name: 'radio' +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/range/range-class.js b/www/assets/framework7/cjs/components/range/range-class.js new file mode 100644 index 000000000..96671556f --- /dev/null +++ b/www/assets/framework7/cjs/components/range/range-class.js @@ -0,0 +1,674 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _getSupport = require("../../shared/get-support"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Range = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(Range, _Framework7Class); + + function Range(app, params) { + var _this; + + _this = _Framework7Class.call(this, params, [app]) || this; + + var range = _assertThisInitialized(_this); + + var support = (0, _getSupport.getSupport)(); + var defaults = { + el: null, + inputEl: null, + dual: false, + step: 1, + label: false, + min: 0, + max: 100, + value: 0, + draggableBar: true, + vertical: false, + verticalReversed: false, + formatLabel: null, + scale: false, + scaleSteps: 5, + scaleSubSteps: 0, + formatScaleLabel: null, + limitKnobPosition: app.theme === 'ios' + }; // Extend defaults with modules params + + range.useModulesParams(defaults); + range.params = (0, _utils.extend)(defaults, params); + var el = range.params.el; + if (!el) return range || _assertThisInitialized(_this); + var $el = (0, _dom.default)(el); + if ($el.length === 0) return range || _assertThisInitialized(_this); + if ($el[0].f7Range) return $el[0].f7Range || _assertThisInitialized(_this); + var dataset = $el.dataset(); + 'step min max value scaleSteps scaleSubSteps'.split(' ').forEach(function (paramName) { + if (typeof params[paramName] === 'undefined' && typeof dataset[paramName] !== 'undefined') { + range.params[paramName] = parseFloat(dataset[paramName]); + } + }); + 'dual label vertical verticalReversed scale'.split(' ').forEach(function (paramName) { + if (typeof params[paramName] === 'undefined' && typeof dataset[paramName] !== 'undefined') { + range.params[paramName] = dataset[paramName]; + } + }); + + if (!range.params.value) { + if (typeof dataset.value !== 'undefined') range.params.value = dataset.value; + + if (typeof dataset.valueLeft !== 'undefined' && typeof dataset.valueRight !== 'undefined') { + range.params.value = [parseFloat(dataset.valueLeft), parseFloat(dataset.valueRight)]; + } + } + + var $inputEl; + + if (!range.params.dual) { + if (range.params.inputEl) { + $inputEl = (0, _dom.default)(range.params.inputEl); + } else if ($el.find('input[type="range"]').length) { + $inputEl = $el.find('input[type="range"]').eq(0); + } + } + + var _range$params = range.params, + dual = _range$params.dual, + step = _range$params.step, + label = _range$params.label, + min = _range$params.min, + max = _range$params.max, + value = _range$params.value, + vertical = _range$params.vertical, + verticalReversed = _range$params.verticalReversed, + scale = _range$params.scale, + scaleSteps = _range$params.scaleSteps, + scaleSubSteps = _range$params.scaleSubSteps, + limitKnobPosition = _range$params.limitKnobPosition; + (0, _utils.extend)(range, { + app: app, + $el: $el, + el: $el[0], + $inputEl: $inputEl, + inputEl: $inputEl ? $inputEl[0] : undefined, + dual: dual, + step: step, + label: label, + min: min, + max: max, + value: value, + previousValue: value, + vertical: vertical, + verticalReversed: verticalReversed, + scale: scale, + scaleSteps: scaleSteps, + scaleSubSteps: scaleSubSteps, + limitKnobPosition: limitKnobPosition + }); + + if ($inputEl) { + 'step min max'.split(' ').forEach(function (paramName) { + if (!params[paramName] && $inputEl.attr(paramName)) { + range.params[paramName] = parseFloat($inputEl.attr(paramName)); + range[paramName] = parseFloat($inputEl.attr(paramName)); + } + }); + + if (typeof $inputEl.val() !== 'undefined') { + range.params.value = parseFloat($inputEl.val()); + range.value = parseFloat($inputEl.val()); + } + } // Dual + + + if (range.dual) { + $el.addClass('range-slider-dual'); + } + + if (range.label) { + $el.addClass('range-slider-label'); + } // Vertical + + + if (range.vertical) { + $el.addClass('range-slider-vertical'); + + if (range.verticalReversed) { + $el.addClass('range-slider-vertical-reversed'); + } + } else { + $el.addClass('range-slider-horizontal'); + } // Check for layout + + + var $barEl = (0, _dom.default)('
    '); + var $barActiveEl = (0, _dom.default)('
    '); + $barEl.append($barActiveEl); // Create Knobs + // prettier-ignore + + var knobHTML = "\n
    \n
    \n " + (range.label ? '
    ' : '') + "\n
    \n "; + var knobs = [(0, _dom.default)(knobHTML)]; + + if (range.dual) { + knobs.push((0, _dom.default)(knobHTML)); + } + + $el.append($barEl); + knobs.forEach(function ($knobEl) { + $el.append($knobEl); + }); // Labels + + var labels = []; + + if (range.label) { + labels.push(knobs[0].find('.range-knob-label')); + + if (range.dual) { + labels.push(knobs[1].find('.range-knob-label')); + } + } // Scale + + + var $scaleEl; + + if (range.scale && range.scaleSteps >= 1) { + $scaleEl = (0, _dom.default)("\n
    \n " + range.renderScale() + "\n
    \n "); + $el.append($scaleEl); + } + + (0, _utils.extend)(range, { + knobs: knobs, + labels: labels, + $barEl: $barEl, + $barActiveEl: $barActiveEl, + $scaleEl: $scaleEl + }); + $el[0].f7Range = range; // Touch Events + + var isTouched; + var touchesStart = {}; + var isScrolling; + var rangeOffset; + var rangeOffsetLeft; + var rangeOffsetTop; + var $touchedKnobEl; + var dualValueIndex; + var valueChangedByTouch; + var targetTouchIdentifier; + + function onTouchChange() { + valueChangedByTouch = true; + } + + function handleTouchStart(e) { + if (isTouched) return; + + if (!range.params.draggableBar) { + if ((0, _dom.default)(e.target).closest('.range-knob').length === 0) { + return; + } + } + + valueChangedByTouch = false; + touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; + touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + + if (e.type === 'touchstart') { + targetTouchIdentifier = e.targetTouches[0].identifier; + } + + isTouched = true; + isScrolling = undefined; + rangeOffset = $el.offset(); + rangeOffsetLeft = rangeOffset.left; + rangeOffsetTop = rangeOffset.top; + var progress; + + if (range.vertical) { + progress = (touchesStart.y - rangeOffsetTop) / range.rangeHeight; + if (!range.verticalReversed) progress = 1 - progress; + } else if (range.app.rtl) { + progress = (rangeOffsetLeft + range.rangeWidth - touchesStart.x) / range.rangeWidth; + } else { + progress = (touchesStart.x - rangeOffsetLeft) / range.rangeWidth; + } + + var newValue = progress * (range.max - range.min) + range.min; + + if (range.dual) { + if (Math.abs(range.value[0] - newValue) < Math.abs(range.value[1] - newValue)) { + dualValueIndex = 0; + $touchedKnobEl = range.knobs[0]; + newValue = [newValue, range.value[1]]; + } else { + dualValueIndex = 1; + $touchedKnobEl = range.knobs[1]; + newValue = [range.value[0], newValue]; + } + } else { + $touchedKnobEl = range.knobs[0]; + newValue = progress * (range.max - range.min) + range.min; + } + + (0, _utils.nextTick)(function () { + if (isTouched) $touchedKnobEl.addClass('range-knob-active-state'); + }, 70); + range.on('change', onTouchChange); + range.setValue(newValue, true); + } + + function handleTouchMove(e) { + if (!isTouched) return; + var pageX; + var pageY; + + if (e.type === 'touchmove') { + for (var i = 0; i < e.targetTouches.length; i += 1) { + if (e.targetTouches[i].identifier === targetTouchIdentifier) { + pageX = e.targetTouches[i].pageX; + pageY = e.targetTouches[i].pageY; + } + } + } else { + pageX = e.pageX; + pageY = e.pageY; + } + + if (typeof pageX === 'undefined' && typeof pageY === 'undefined') return; + + if (typeof isScrolling === 'undefined' && !range.vertical) { + isScrolling = !!(isScrolling || Math.abs(pageY - touchesStart.y) > Math.abs(pageX - touchesStart.x)); + } + + if (isScrolling) { + isTouched = false; + return; + } + + e.preventDefault(); + var progress; + + if (range.vertical) { + progress = (pageY - rangeOffsetTop) / range.rangeHeight; + if (!range.verticalReversed) progress = 1 - progress; + } else if (range.app.rtl) { + progress = (rangeOffsetLeft + range.rangeWidth - pageX) / range.rangeWidth; + } else { + progress = (pageX - rangeOffsetLeft) / range.rangeWidth; + } + + var newValue = progress * (range.max - range.min) + range.min; + + if (range.dual) { + var leftValue; + var rightValue; + + if (dualValueIndex === 0) { + leftValue = newValue; + rightValue = range.value[1]; + + if (leftValue > rightValue) { + rightValue = leftValue; + } + } else { + leftValue = range.value[0]; + rightValue = newValue; + + if (rightValue < leftValue) { + leftValue = rightValue; + } + } + + newValue = [leftValue, rightValue]; + } + + range.setValue(newValue, true); + } + + function handleTouchEnd(e) { + if (e.type === 'touchend') { + var touchEnded; + + for (var i = 0; i < e.changedTouches.length; i += 1) { + if (e.changedTouches[i].identifier === targetTouchIdentifier) touchEnded = true; + } + + if (!touchEnded) return; + } + + if (!isTouched) { + if (isScrolling) $touchedKnobEl.removeClass('range-knob-active-state'); + isTouched = false; + return; + } + + range.off('change', onTouchChange); + isTouched = false; + $touchedKnobEl.removeClass('range-knob-active-state'); + + if (valueChangedByTouch && range.$inputEl && !range.dual) { + range.$inputEl.trigger('change'); + } + + valueChangedByTouch = false; + + if (typeof range.previousValue !== 'undefined') { + if (range.dual && (range.previousValue[0] !== range.value[0] || range.previousValue[1] !== range.value[1]) || !range.dual && range.previousValue !== range.value) { + range.$el.trigger('range:changed', range.value); + range.emit('local::changed rangeChanged', range, range.value); + } + } + } + + function handleResize() { + range.calcSize(); + range.layout(); + } + + var parentModals; + var parentPanel; + var parentPage; + + range.attachEvents = function attachEvents() { + var passive = support.passiveListener ? { + passive: true + } : false; + range.$el.on(app.touchEvents.start, handleTouchStart, passive); + app.on('touchmove', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + app.on('tabShow', handleResize); + app.on('resize', handleResize); + parentModals = range.$el.parents('.sheet-modal, .actions-modal, .popup, .popover, .login-screen, .dialog, .toast'); + parentModals.on('modal:open', handleResize); + parentPanel = range.$el.parents('.panel'); + parentPanel.on('panel:open panel:resize', handleResize); + parentPage = range.$el.parents('.page').eq(0); + parentPage.on('page:reinit', handleResize); + }; + + range.detachEvents = function detachEvents() { + var passive = support.passiveListener ? { + passive: true + } : false; + range.$el.off(app.touchEvents.start, handleTouchStart, passive); + app.off('touchmove', handleTouchMove); + app.off('touchend:passive', handleTouchEnd); + app.off('tabShow', handleResize); + app.off('resize', handleResize); + + if (parentModals) { + parentModals.off('modal:open', handleResize); + } + + if (parentPanel) { + parentPanel.off('panel:open panel:resize', handleResize); + } + + if (parentPage) { + parentPage.off('page:reinit', handleResize); + } + + parentModals = null; + parentPanel = null; + parentPage = null; + }; // Install Modules + + + range.useModules(); // Init + + range.init(); + return range || _assertThisInitialized(_this); + } + + var _proto = Range.prototype; + + _proto.calcSize = function calcSize() { + var range = this; + + if (range.vertical) { + var height = range.$el.outerHeight(); + if (height === 0) return; + range.rangeHeight = height; + range.knobHeight = range.knobs[0].outerHeight(); + } else { + var width = range.$el.outerWidth(); + if (width === 0) return; + range.rangeWidth = width; + range.knobWidth = range.knobs[0].outerWidth(); + } + }; + + _proto.layout = function layout() { + var range = this; + var app = range.app, + knobWidth = range.knobWidth, + knobHeight = range.knobHeight, + rangeWidth = range.rangeWidth, + rangeHeight = range.rangeHeight, + min = range.min, + max = range.max, + knobs = range.knobs, + $barActiveEl = range.$barActiveEl, + value = range.value, + label = range.label, + labels = range.labels, + vertical = range.vertical, + verticalReversed = range.verticalReversed, + limitKnobPosition = range.limitKnobPosition; + var knobSize = vertical ? knobHeight : knobWidth; + var rangeSize = vertical ? rangeHeight : rangeWidth; // eslint-disable-next-line + + var positionProperty = vertical ? verticalReversed ? 'top' : 'bottom' : app.rtl ? 'right' : 'left'; + + if (range.dual) { + var _$barActiveEl$css; + + var progress = [(value[0] - min) / (max - min), (value[1] - min) / (max - min)]; + $barActiveEl.css((_$barActiveEl$css = {}, _$barActiveEl$css[positionProperty] = progress[0] * 100 + "%", _$barActiveEl$css[vertical ? 'height' : 'width'] = (progress[1] - progress[0]) * 100 + "%", _$barActiveEl$css)); + knobs.forEach(function ($knobEl, knobIndex) { + var startPos = rangeSize * progress[knobIndex]; + + if (limitKnobPosition) { + var realStartPos = rangeSize * progress[knobIndex] - knobSize / 2; + if (realStartPos < 0) startPos = knobSize / 2; + if (realStartPos + knobSize > rangeSize) startPos = rangeSize - knobSize / 2; + } + + $knobEl.css(positionProperty, startPos + "px"); + if (label) labels[knobIndex].text(range.formatLabel(value[knobIndex], labels[knobIndex][0])); + }); + } else { + var _progress = (value - min) / (max - min); + + $barActiveEl.css(vertical ? 'height' : 'width', _progress * 100 + "%"); + var startPos = rangeSize * _progress; + + if (limitKnobPosition) { + var realStartPos = rangeSize * _progress - knobSize / 2; + if (realStartPos < 0) startPos = knobSize / 2; + if (realStartPos + knobSize > rangeSize) startPos = rangeSize - knobSize / 2; + } + + knobs[0].css(positionProperty, startPos + "px"); + if (label) labels[0].text(range.formatLabel(value, labels[0][0])); + } + + if (range.dual && value.indexOf(min) >= 0 || !range.dual && value === min) { + range.$el.addClass('range-slider-min'); + } else { + range.$el.removeClass('range-slider-min'); + } + + if (range.dual && value.indexOf(max) >= 0 || !range.dual && value === max) { + range.$el.addClass('range-slider-max'); + } else { + range.$el.removeClass('range-slider-max'); + } + }; + + _proto.setValue = function setValue(newValue, byTouchMove) { + var range = this; + var step = range.step, + min = range.min, + max = range.max; + var valueChanged; + var oldValue; + + if (range.dual) { + oldValue = [range.value[0], range.value[1]]; + var newValues = newValue; + if (!Array.isArray(newValues)) newValues = [newValue, newValue]; + + if (newValue[0] > newValue[1]) { + newValues = [newValues[0], newValues[0]]; + } + + newValues = newValues.map(function (value) { + return Math.max(Math.min(Math.round(value / step) * step, max), min); + }); + + if (newValues[0] === range.value[0] && newValues[1] === range.value[1]) { + return range; + } + + newValues.forEach(function (value, valueIndex) { + range.value[valueIndex] = value; + }); + valueChanged = oldValue[0] !== newValues[0] || oldValue[1] !== newValues[1]; + range.layout(); + } else { + oldValue = range.value; + var value = Math.max(Math.min(Math.round(newValue / step) * step, max), min); + range.value = value; + range.layout(); + valueChanged = oldValue !== value; + } + + if (valueChanged) { + range.previousValue = oldValue; + } // Events + + + if (!valueChanged) return range; + range.$el.trigger('range:change', range.value); + + if (range.$inputEl && !range.dual) { + range.$inputEl.val(range.value); + + if (!byTouchMove) { + range.$inputEl.trigger('input change'); + } else { + range.$inputEl.trigger('input'); + } + } + + if (!byTouchMove) { + range.$el.trigger('range:changed', range.value); + range.emit('local::changed rangeChanged', range, range.value); + } + + range.emit('local::change rangeChange', range, range.value); + return range; + }; + + _proto.getValue = function getValue() { + return this.value; + }; + + _proto.formatLabel = function formatLabel(value, labelEl) { + var range = this; + if (range.params.formatLabel) return range.params.formatLabel.call(range, value, labelEl); + return value; + }; + + _proto.formatScaleLabel = function formatScaleLabel(value) { + var range = this; + if (range.params.formatScaleLabel) return range.params.formatScaleLabel.call(range, value); + return value; + }; + + _proto.renderScale = function renderScale() { + var range = this; + var app = range.app, + verticalReversed = range.verticalReversed, + vertical = range.vertical; // eslint-disable-next-line + + var positionProperty = vertical ? verticalReversed ? 'top' : 'bottom' : app.rtl ? 'right' : 'left'; + var html = ''; + Array.from({ + length: range.scaleSteps + 1 + }).forEach(function (scaleEl, index) { + var scaleStepValue = (range.max - range.min) / range.scaleSteps; + var scaleValue = range.min + scaleStepValue * index; + var progress = (scaleValue - range.min) / (range.max - range.min); + html += "
    " + range.formatScaleLabel(scaleValue) + "
    "; + + if (range.scaleSubSteps && range.scaleSubSteps > 1 && index < range.scaleSteps) { + Array.from({ + length: range.scaleSubSteps - 1 + }).forEach(function (subStepEl, subIndex) { + var subStep = scaleStepValue / range.scaleSubSteps; + var scaleSubValue = scaleValue + subStep * (subIndex + 1); + var subProgress = (scaleSubValue - range.min) / (range.max - range.min); + html += "
    "; + }); + } + }); + return html; + }; + + _proto.updateScale = function updateScale() { + var range = this; + + if (!range.scale || range.scaleSteps < 1) { + if (range.$scaleEl) range.$scaleEl.remove(); + delete range.$scaleEl; + return; + } + + if (!range.$scaleEl) { + range.$scaleEl = (0, _dom.default)('
    '); + range.$el.append(range.$scaleEl); + } + + range.$scaleEl.html(range.renderScale()); + }; + + _proto.init = function init() { + var range = this; + range.calcSize(); + range.layout(); + range.attachEvents(); + return range; + }; + + _proto.destroy = function destroy() { + var range = this; + range.$el.trigger('range:beforedestroy'); + range.emit('local::beforeDestroy rangeBeforeDestroy', range); + delete range.$el[0].f7Range; + range.detachEvents(); + (0, _utils.deleteProps)(range); + range = null; + }; + + return Range; +}(_class.default); + +var _default = Range; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/range/range.js b/www/assets/framework7/cjs/components/range/range.js new file mode 100644 index 000000000..1d88de516 --- /dev/null +++ b/www/assets/framework7/cjs/components/range/range.js @@ -0,0 +1,93 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _rangeClass = _interopRequireDefault(require("./range-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'range', + create: function create() { + var app = this; + app.range = (0, _utils.extend)((0, _constructorMethods.default)({ + defaultSelector: '.range-slider', + constructor: _rangeClass.default, + app: app, + domProp: 'f7Range' + }), { + getValue: function getValue(el) { + if (el === void 0) { + el = '.range-slider'; + } + + var range = app.range.get(el); + if (range) return range.getValue(); + return undefined; + }, + setValue: function setValue(el, value) { + if (el === void 0) { + el = '.range-slider'; + } + + var range = app.range.get(el); + if (range) return range.setValue(value); + return undefined; + } + }); + }, + static: { + Range: _rangeClass.default + }, + on: { + tabMounted: function tabMounted(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.range-slider-init').each(function (rangeEl) { + return new _rangeClass.default(app, { + el: rangeEl + }); + }); + }, + tabBeforeRemove: function tabBeforeRemove(tabEl) { + (0, _dom.default)(tabEl).find('.range-slider-init').each(function (rangeEl) { + if (rangeEl.f7Range) rangeEl.f7Range.destroy(); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.range-slider-init').each(function (rangeEl) { + return new _rangeClass.default(app, { + el: rangeEl + }); + }); + }, + pageBeforeRemove: function pageBeforeRemove(page) { + page.$el.find('.range-slider-init').each(function (rangeEl) { + if (rangeEl.f7Range) rangeEl.f7Range.destroy(); + }); + } + }, + vnode: { + 'range-slider-init': { + insert: function insert(vnode) { + var rangeEl = vnode.elm; + var app = this; + app.range.create({ + el: rangeEl + }); + }, + destroy: function destroy(vnode) { + var rangeEl = vnode.elm; + if (rangeEl.f7Range) rangeEl.f7Range.destroy(); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/searchbar/remove-diacritics.js b/www/assets/framework7/cjs/components/searchbar/remove-diacritics.js new file mode 100644 index 000000000..62b874a97 --- /dev/null +++ b/www/assets/framework7/cjs/components/searchbar/remove-diacritics.js @@ -0,0 +1,283 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +/* eslint no-control-regex: "off" */ +var defaultDiacriticsRemovalap = [{ + base: 'A', + letters: "A\u24B6\uFF21\xC0\xC1\xC2\u1EA6\u1EA4\u1EAA\u1EA8\xC3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\xC4\u01DE\u1EA2\xC5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F" +}, { + base: 'AA', + letters: "\uA732" +}, { + base: 'AE', + letters: "\xC6\u01FC\u01E2" +}, { + base: 'AO', + letters: "\uA734" +}, { + base: 'AU', + letters: "\uA736" +}, { + base: 'AV', + letters: "\uA738\uA73A" +}, { + base: 'AY', + letters: "\uA73C" +}, { + base: 'B', + letters: "B\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181" +}, { + base: 'C', + letters: "C\u24B8\uFF23\u0106\u0108\u010A\u010C\xC7\u1E08\u0187\u023B\uA73E" +}, { + base: 'D', + letters: "D\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779" +}, { + base: 'DZ', + letters: "\u01F1\u01C4" +}, { + base: 'Dz', + letters: "\u01F2\u01C5" +}, { + base: 'E', + letters: "E\u24BA\uFF25\xC8\xC9\xCA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\xCB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E" +}, { + base: 'F', + letters: "F\u24BB\uFF26\u1E1E\u0191\uA77B" +}, { + base: 'G', + letters: "G\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E" +}, { + base: 'H', + letters: "H\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D" +}, { + base: 'I', + letters: "I\u24BE\uFF29\xCC\xCD\xCE\u0128\u012A\u012C\u0130\xCF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197" +}, { + base: 'J', + letters: "J\u24BF\uFF2A\u0134\u0248" +}, { + base: 'K', + letters: "K\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2" +}, { + base: 'L', + letters: "L\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780" +}, { + base: 'LJ', + letters: "\u01C7" +}, { + base: 'Lj', + letters: "\u01C8" +}, { + base: 'M', + letters: "M\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C" +}, { + base: 'N', + letters: "N\u24C3\uFF2E\u01F8\u0143\xD1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4" +}, { + base: 'NJ', + letters: "\u01CA" +}, { + base: 'Nj', + letters: "\u01CB" +}, { + base: 'O', + letters: "O\u24C4\uFF2F\xD2\xD3\xD4\u1ED2\u1ED0\u1ED6\u1ED4\xD5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\xD6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\xD8\u01FE\u0186\u019F\uA74A\uA74C" +}, { + base: 'OI', + letters: "\u01A2" +}, { + base: 'OO', + letters: "\uA74E" +}, { + base: 'OU', + letters: "\u0222" +}, { + base: 'OE', + letters: "\x8C\u0152" +}, { + base: 'oe', + letters: "\x9C\u0153" +}, { + base: 'P', + letters: "P\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754" +}, { + base: 'Q', + letters: "Q\u24C6\uFF31\uA756\uA758\u024A" +}, { + base: 'R', + letters: "R\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782" +}, { + base: 'S', + letters: "S\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784" +}, { + base: 'T', + letters: "T\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786" +}, { + base: 'TZ', + letters: "\uA728" +}, { + base: 'U', + letters: "U\u24CA\uFF35\xD9\xDA\xDB\u0168\u1E78\u016A\u1E7A\u016C\xDC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244" +}, { + base: 'V', + letters: "V\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245" +}, { + base: 'VY', + letters: "\uA760" +}, { + base: 'W', + letters: "W\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72" +}, { + base: 'X', + letters: "X\u24CD\uFF38\u1E8A\u1E8C" +}, { + base: 'Y', + letters: "Y\u24CE\uFF39\u1EF2\xDD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE" +}, { + base: 'Z', + letters: "Z\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762" +}, { + base: 'a', + letters: "a\u24D0\uFF41\u1E9A\xE0\xE1\xE2\u1EA7\u1EA5\u1EAB\u1EA9\xE3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\xE4\u01DF\u1EA3\xE5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250" +}, { + base: 'aa', + letters: "\uA733" +}, { + base: 'ae', + letters: "\xE6\u01FD\u01E3" +}, { + base: 'ao', + letters: "\uA735" +}, { + base: 'au', + letters: "\uA737" +}, { + base: 'av', + letters: "\uA739\uA73B" +}, { + base: 'ay', + letters: "\uA73D" +}, { + base: 'b', + letters: "b\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253" +}, { + base: 'c', + letters: "c\u24D2\uFF43\u0107\u0109\u010B\u010D\xE7\u1E09\u0188\u023C\uA73F\u2184" +}, { + base: 'd', + letters: "d\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A" +}, { + base: 'dz', + letters: "\u01F3\u01C6" +}, { + base: 'e', + letters: "e\u24D4\uFF45\xE8\xE9\xEA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\xEB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD" +}, { + base: 'f', + letters: "f\u24D5\uFF46\u1E1F\u0192\uA77C" +}, { + base: 'g', + letters: "g\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F" +}, { + base: 'h', + letters: "h\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265" +}, { + base: 'hv', + letters: "\u0195" +}, { + base: 'i', + letters: "i\u24D8\uFF49\xEC\xED\xEE\u0129\u012B\u012D\xEF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131" +}, { + base: 'j', + letters: "j\u24D9\uFF4A\u0135\u01F0\u0249" +}, { + base: 'k', + letters: "k\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3" +}, { + base: 'l', + letters: "l\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747" +}, { + base: 'lj', + letters: "\u01C9" +}, { + base: 'm', + letters: "m\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F" +}, { + base: 'n', + letters: "n\u24DD\uFF4E\u01F9\u0144\xF1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5" +}, { + base: 'nj', + letters: "\u01CC" +}, { + base: 'o', + letters: "o\u24DE\uFF4F\xF2\xF3\xF4\u1ED3\u1ED1\u1ED7\u1ED5\xF5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\xF6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\xF8\u01FF\u0254\uA74B\uA74D\u0275" +}, { + base: 'oi', + letters: "\u01A3" +}, { + base: 'ou', + letters: "\u0223" +}, { + base: 'oo', + letters: "\uA74F" +}, { + base: 'p', + letters: "p\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755" +}, { + base: 'q', + letters: "q\u24E0\uFF51\u024B\uA757\uA759" +}, { + base: 'r', + letters: "r\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783" +}, { + base: 's', + letters: "s\u24E2\uFF53\xDF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B" +}, { + base: 't', + letters: "t\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787" +}, { + base: 'tz', + letters: "\uA729" +}, { + base: 'u', + letters: "u\u24E4\uFF55\xF9\xFA\xFB\u0169\u1E79\u016B\u1E7B\u016D\xFC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289" +}, { + base: 'v', + letters: "v\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C" +}, { + base: 'vy', + letters: "\uA761" +}, { + base: 'w', + letters: "w\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73" +}, { + base: 'x', + letters: "x\u24E7\uFF58\u1E8B\u1E8D" +}, { + base: 'y', + letters: "y\u24E8\uFF59\u1EF3\xFD\u0177\u1EF9\u0233\u1E8F\xFF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF" +}, { + base: 'z', + letters: "z\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763" +}]; +var diacriticsMap = {}; + +for (var i = 0; i < defaultDiacriticsRemovalap.length; i += 1) { + var letters = defaultDiacriticsRemovalap[i].letters; + + for (var j = 0; j < letters.length; j += 1) { + diacriticsMap[letters[j]] = defaultDiacriticsRemovalap[i].base; + } +} + +function removeDiacritics(str) { + return str.replace(/[^\u0000-\u007E]/g, function (a) { + return diacriticsMap[a] || a; + }); +} + +var _default = removeDiacritics; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/searchbar/searchbar-class.js b/www/assets/framework7/cjs/components/searchbar/searchbar-class.js new file mode 100644 index 000000000..64a830f29 --- /dev/null +++ b/www/assets/framework7/cjs/components/searchbar/searchbar-class.js @@ -0,0 +1,739 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _getDevice = require("../../shared/get-device"); + +var _removeDiacritics = _interopRequireDefault(require("./remove-diacritics")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Searchbar = /*#__PURE__*/function (_FrameworkClass) { + _inheritsLoose(Searchbar, _FrameworkClass); + + function Searchbar(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _FrameworkClass.call(this, params, [app]) || this; + + var sb = _assertThisInitialized(_this); + + var defaults = { + el: undefined, + inputEl: undefined, + inputEvents: 'change input compositionend', + disableButton: true, + disableButtonEl: undefined, + backdropEl: undefined, + searchContainer: undefined, + // container to search, HTMLElement or CSS selector + searchItem: 'li', + // single item selector, CSS selector + searchIn: undefined, + // where to search in item, CSS selector + searchGroup: '.list-group', + searchGroupTitle: '.item-divider, .list-group-title', + ignore: '.searchbar-ignore', + foundEl: '.searchbar-found', + notFoundEl: '.searchbar-not-found', + hideOnEnableEl: '.searchbar-hide-on-enable', + hideOnSearchEl: '.searchbar-hide-on-search', + backdrop: undefined, + removeDiacritics: true, + customSearch: false, + hideDividers: true, + hideGroups: true, + disableOnBackdropClick: true, + expandable: false, + inline: false + }; // Extend defaults with modules params + + sb.useModulesParams(defaults); + sb.params = (0, _utils.extend)(defaults, params); + var $el = (0, _dom.default)(sb.params.el); + if ($el.length === 0) return sb || _assertThisInitialized(_this); + if ($el[0].f7Searchbar) return $el[0].f7Searchbar || _assertThisInitialized(_this); + $el[0].f7Searchbar = sb; + var $pageEl; + var $navbarEl = $el.parents('.navbar'); + + if ($el.parents('.page').length > 0) { + $pageEl = $el.parents('.page'); + } else if ($navbarEl.length > 0) { + $pageEl = (0, _dom.default)(app.navbar.getPageByEl($navbarEl[0])); + + if (!$pageEl.length) { + var $currentPageEl = $el.parents('.view').find('.page-current'); + + if ($currentPageEl[0] && $currentPageEl[0].f7Page && $currentPageEl[0].f7Page.navbarEl === $navbarEl[0]) { + $pageEl = $currentPageEl; + } + } + } + + var $foundEl; + + if (params.foundEl) { + $foundEl = (0, _dom.default)(params.foundEl); + } else if (typeof sb.params.foundEl === 'string' && $pageEl) { + $foundEl = $pageEl.find(sb.params.foundEl); + } + + var $notFoundEl; + + if (params.notFoundEl) { + $notFoundEl = (0, _dom.default)(params.notFoundEl); + } else if (typeof sb.params.notFoundEl === 'string' && $pageEl) { + $notFoundEl = $pageEl.find(sb.params.notFoundEl); + } + + var $hideOnEnableEl; + + if (params.hideOnEnableEl) { + $hideOnEnableEl = (0, _dom.default)(params.hideOnEnableEl); + } else if (typeof sb.params.hideOnEnableEl === 'string' && $pageEl) { + $hideOnEnableEl = $pageEl.find(sb.params.hideOnEnableEl); + } + + var $hideOnSearchEl; + + if (params.hideOnSearchEl) { + $hideOnSearchEl = (0, _dom.default)(params.hideOnSearchEl); + } else if (typeof sb.params.hideOnSearchEl === 'string' && $pageEl) { + $hideOnSearchEl = $pageEl.find(sb.params.hideOnSearchEl); + } + + var expandable = sb.params.expandable || $el.hasClass('searchbar-expandable'); + var inline = sb.params.inline || $el.hasClass('searchbar-inline'); + + if (typeof sb.params.backdrop === 'undefined') { + if (!inline) sb.params.backdrop = app.theme !== 'aurora';else sb.params.backdrop = false; + } + + var $backdropEl; + + if (sb.params.backdrop) { + if (sb.params.backdropEl) { + $backdropEl = (0, _dom.default)(sb.params.backdropEl); + } else if ($pageEl && $pageEl.length > 0) { + $backdropEl = $pageEl.find('.searchbar-backdrop'); + } else { + $backdropEl = $el.siblings('.searchbar-backdrop'); + } + + if ($backdropEl.length === 0) { + $backdropEl = (0, _dom.default)('
    '); + + if ($pageEl && $pageEl.length) { + if ($el.parents($pageEl).length > 0 && $navbarEl && $el.parents($navbarEl).length === 0) { + $backdropEl.insertBefore($el); + } else { + $backdropEl.insertBefore($pageEl.find('.page-content').eq(0)); + } + } else { + $backdropEl.insertBefore($el); + } + } + } + + var $searchContainer; + + if (sb.params.searchContainer) { + $searchContainer = (0, _dom.default)(sb.params.searchContainer); + } + + var $inputEl; + + if (sb.params.inputEl) { + $inputEl = (0, _dom.default)(sb.params.inputEl); + } else { + $inputEl = $el.find('input[type="search"]').eq(0); + } + + var $disableButtonEl; + + if (sb.params.disableButton) { + if (sb.params.disableButtonEl) { + $disableButtonEl = (0, _dom.default)(sb.params.disableButtonEl); + } else { + $disableButtonEl = $el.find('.searchbar-disable-button'); + } + } + + (0, _utils.extend)(sb, { + app: app, + view: app.views.get($el.parents('.view')), + $el: $el, + el: $el[0], + $backdropEl: $backdropEl, + backdropEl: $backdropEl && $backdropEl[0], + $searchContainer: $searchContainer, + searchContainer: $searchContainer && $searchContainer[0], + $inputEl: $inputEl, + inputEl: $inputEl[0], + $disableButtonEl: $disableButtonEl, + disableButtonEl: $disableButtonEl && $disableButtonEl[0], + disableButtonHasMargin: false, + $pageEl: $pageEl, + pageEl: $pageEl && $pageEl[0], + $navbarEl: $navbarEl, + navbarEl: $navbarEl && $navbarEl[0], + $foundEl: $foundEl, + foundEl: $foundEl && $foundEl[0], + $notFoundEl: $notFoundEl, + notFoundEl: $notFoundEl && $notFoundEl[0], + $hideOnEnableEl: $hideOnEnableEl, + hideOnEnableEl: $hideOnEnableEl && $hideOnEnableEl[0], + $hideOnSearchEl: $hideOnSearchEl, + hideOnSearchEl: $hideOnSearchEl && $hideOnSearchEl[0], + previousQuery: '', + query: '', + isVirtualList: $searchContainer && $searchContainer.hasClass('virtual-list'), + virtualList: undefined, + enabled: false, + expandable: expandable, + inline: inline + }); // Events + + function preventSubmit(e) { + e.preventDefault(); + } + + function onInputFocus(e) { + sb.enable(e); + sb.$el.addClass('searchbar-focused'); + } + + function onInputBlur() { + sb.$el.removeClass('searchbar-focused'); + + if (app.theme === 'aurora' && (!$disableButtonEl || !$disableButtonEl.length || !sb.params.disableButton) && !sb.query) { + sb.disable(); + } + } + + function onInputChange() { + var value = sb.$inputEl.val().trim(); + + if (sb.$searchContainer && sb.$searchContainer.length > 0 && (sb.params.searchIn || sb.isVirtualList || sb.params.searchIn === sb.params.searchItem) || sb.params.customSearch) { + sb.search(value, true); + } + } + + function onInputClear(e, previousValue) { + sb.$el.trigger('searchbar:clear', previousValue); + sb.emit('local::clear searchbarClear', sb, previousValue); + } + + function disableOnClick(e) { + sb.disable(e); + } + + function onPageBeforeOut() { + if (!sb || sb && !sb.$el) return; + + if (sb.enabled) { + sb.$el.removeClass('searchbar-enabled'); + + if (sb.expandable) { + sb.$el.parents('.navbar').removeClass('with-searchbar-expandable-enabled with-searchbar-expandable-enabled-no-transition'); + } + } + } + + function onPageBeforeIn() { + if (!sb || sb && !sb.$el) return; + + if (sb.enabled) { + sb.$el.addClass('searchbar-enabled'); + + if (sb.expandable) { + sb.$el.parents('.navbar').addClass('with-searchbar-expandable-enabled-no-transition'); + } + } + } + + sb.attachEvents = function attachEvents() { + $el.on('submit', preventSubmit); + + if (sb.params.disableButton) { + sb.$disableButtonEl.on('click', disableOnClick); + } + + if (sb.params.disableOnBackdropClick && sb.$backdropEl) { + sb.$backdropEl.on('click', disableOnClick); + } + + if (sb.expandable && app.theme === 'ios' && sb.view && $navbarEl.length && sb.$pageEl) { + sb.$pageEl.on('page:beforeout', onPageBeforeOut); + sb.$pageEl.on('page:beforein', onPageBeforeIn); + } + + sb.$inputEl.on('focus', onInputFocus); + sb.$inputEl.on('blur', onInputBlur); + sb.$inputEl.on(sb.params.inputEvents, onInputChange); + sb.$inputEl.on('input:clear', onInputClear); + }; + + sb.detachEvents = function detachEvents() { + $el.off('submit', preventSubmit); + + if (sb.params.disableButton) { + sb.$disableButtonEl.off('click', disableOnClick); + } + + if (sb.params.disableOnBackdropClick && sb.$backdropEl) { + sb.$backdropEl.off('click', disableOnClick); + } + + if (sb.expandable && app.theme === 'ios' && sb.view && $navbarEl.length && sb.$pageEl) { + sb.$pageEl.off('page:beforeout', onPageBeforeOut); + sb.$pageEl.off('page:beforein', onPageBeforeIn); + } + + sb.$inputEl.off('focus', onInputFocus); + sb.$inputEl.off('blur', onInputBlur); + sb.$inputEl.off(sb.params.inputEvents, onInputChange); + sb.$inputEl.off('input:clear', onInputClear); + }; // Install Modules + + + sb.useModules(); // Init + + sb.init(); + return sb || _assertThisInitialized(_this); + } + + var _proto = Searchbar.prototype; + + _proto.clear = function clear(e) { + var sb = this; + + if (!sb.query && e && (0, _dom.default)(e.target).hasClass('searchbar-clear')) { + sb.disable(); + return sb; + } + + var previousQuery = sb.value; + sb.$inputEl.val('').trigger('change').focus(); + sb.$el.trigger('searchbar:clear', previousQuery); + sb.emit('local::clear searchbarClear', sb, previousQuery); + return sb; + }; + + _proto.setDisableButtonMargin = function setDisableButtonMargin() { + var sb = this; + if (sb.expandable) return; + var app = sb.app; + sb.$disableButtonEl.transition(0).show(); + sb.$disableButtonEl.css("margin-" + (app.rtl ? 'left' : 'right'), -sb.disableButtonEl.offsetWidth + "px"); + /* eslint no-underscore-dangle: ["error", { "allow": ["_clientLeft"] }] */ + + sb._clientLeft = sb.$disableButtonEl[0].clientLeft; + sb.$disableButtonEl.transition(''); + sb.disableButtonHasMargin = true; + }; + + _proto.enable = function enable(setFocus) { + var sb = this; + if (sb.enabled) return sb; + var app = sb.app; + var document = (0, _ssrWindow.getDocument)(); + var device = (0, _getDevice.getDevice)(); + sb.enabled = true; + + function enable() { + if (sb.$backdropEl && (sb.$searchContainer && sb.$searchContainer.length || sb.params.customSearch) && !sb.$el.hasClass('searchbar-enabled') && !sb.query) { + sb.backdropShow(); + } + + sb.$el.addClass('searchbar-enabled'); + + if (!sb.$disableButtonEl || sb.$disableButtonEl && sb.$disableButtonEl.length === 0) { + sb.$el.addClass('searchbar-enabled-no-disable-button'); + } + + if (!sb.expandable && sb.$disableButtonEl && sb.$disableButtonEl.length > 0 && app.theme !== 'md') { + if (!sb.disableButtonHasMargin) { + sb.setDisableButtonMargin(); + } + + sb.$disableButtonEl.css("margin-" + (app.rtl ? 'left' : 'right'), '0px'); + } + + if (sb.expandable) { + var $navbarEl = sb.$el.parents('.navbar'); + + if ($navbarEl.hasClass('navbar-large') && sb.$pageEl) { + var $pageContentEl = sb.$pageEl.find('.page-content'); + var $titleLargeEl = $navbarEl.find('.title-large'); + $pageContentEl.addClass('with-searchbar-expandable-enabled'); + + if ($navbarEl.hasClass('navbar-large') && $navbarEl.hasClass('navbar-large-collapsed') && $titleLargeEl.length && $pageContentEl.length) { + $pageContentEl.transition(0); + $pageContentEl[0].scrollTop -= $titleLargeEl[0].offsetHeight; + setTimeout(function () { + $pageContentEl.transition(''); + }, 200); + } + } + + if (app.theme === 'md' && $navbarEl.length) { + $navbarEl.addClass('with-searchbar-expandable-enabled'); + } else { + $navbarEl.addClass('with-searchbar-expandable-enabled'); + + if ($navbarEl.hasClass('navbar-large')) { + $navbarEl.addClass('navbar-large-collapsed'); + } + } + } + + if (sb.$hideOnEnableEl) sb.$hideOnEnableEl.addClass('hidden-by-searchbar'); + sb.$el.trigger('searchbar:enable'); + sb.emit('local::enable searchbarEnable', sb); + } + + var needsFocus = false; + + if (setFocus === true) { + if (document.activeElement !== sb.inputEl) { + needsFocus = true; + } + } + + var isIos = device.ios && app.theme === 'ios'; + + if (isIos) { + if (sb.expandable) { + if (needsFocus) sb.$inputEl.focus(); + enable(); + } else { + if (needsFocus) sb.$inputEl.focus(); + + if (setFocus && (setFocus.type === 'focus' || setFocus === true)) { + (0, _utils.nextTick)(function () { + enable(); + }, 400); + } else { + enable(); + } + } + } else { + if (needsFocus) sb.$inputEl.focus(); + + if (app.theme === 'md' && sb.expandable) { + sb.$el.parents('.page, .view, .navbar-inner, .navbar').scrollLeft(app.rtl ? 100 : 0); + } + + enable(); + } + + return sb; + }; + + _proto.disable = function disable() { + var sb = this; + if (!sb.enabled) return sb; + var app = sb.app; + sb.$inputEl.val('').trigger('change'); + sb.$el.removeClass('searchbar-enabled searchbar-focused searchbar-enabled-no-disable-button'); + + if (sb.expandable) { + var $navbarEl = sb.$el.parents('.navbar'); + var $pageContentEl = sb.$pageEl && sb.$pageEl.find('.page-content'); + + if ($navbarEl.hasClass('navbar-large') && $pageContentEl.length) { + var $titleLargeEl = $navbarEl.find('.title-large'); + sb.$el.transitionEnd(function () { + $pageContentEl.removeClass('with-searchbar-expandable-closing'); + }); + + if ($navbarEl.hasClass('navbar-large') && $navbarEl.hasClass('navbar-large-collapsed') && $titleLargeEl.length) { + var scrollTop = $pageContentEl[0].scrollTop; + var titleLargeHeight = $titleLargeEl[0].offsetHeight; + + if (scrollTop > titleLargeHeight) { + $pageContentEl.transition(0); + $pageContentEl[0].scrollTop = scrollTop + titleLargeHeight; + setTimeout(function () { + $pageContentEl.transition(''); + }, 200); + } + } + + $pageContentEl.removeClass('with-searchbar-expandable-enabled').addClass('with-searchbar-expandable-closing'); + } + + if (app.theme === 'md' && $navbarEl.length) { + $navbarEl.removeClass('with-searchbar-expandable-enabled with-searchbar-expandable-enabled-no-transition').addClass('with-searchbar-expandable-closing'); + sb.$el.transitionEnd(function () { + $navbarEl.removeClass('with-searchbar-expandable-closing'); + }); + } else { + $navbarEl.removeClass('with-searchbar-expandable-enabled with-searchbar-expandable-enabled-no-transition').addClass('with-searchbar-expandable-closing'); + sb.$el.transitionEnd(function () { + $navbarEl.removeClass('with-searchbar-expandable-closing'); + }); + + if (sb.$pageEl) { + sb.$pageEl.find('.page-content').trigger('scroll'); + } + } + } + + if (!sb.expandable && sb.$disableButtonEl && sb.$disableButtonEl.length > 0 && app.theme !== 'md') { + sb.$disableButtonEl.css("margin-" + (app.rtl ? 'left' : 'right'), -sb.disableButtonEl.offsetWidth + "px"); + } + + if (sb.$backdropEl && (sb.$searchContainer && sb.$searchContainer.length || sb.params.customSearch)) { + sb.backdropHide(); + } + + sb.enabled = false; + sb.$inputEl.blur(); + if (sb.$hideOnEnableEl) sb.$hideOnEnableEl.removeClass('hidden-by-searchbar'); + sb.$el.trigger('searchbar:disable'); + sb.emit('local::disable searchbarDisable', sb); + return sb; + }; + + _proto.toggle = function toggle() { + var sb = this; + if (sb.enabled) sb.disable();else sb.enable(true); + return sb; + }; + + _proto.backdropShow = function backdropShow() { + var sb = this; + + if (sb.$backdropEl) { + sb.$backdropEl.addClass('searchbar-backdrop-in'); + } + + return sb; + }; + + _proto.backdropHide = function backdropHide() { + var sb = this; + + if (sb.$backdropEl) { + sb.$backdropEl.removeClass('searchbar-backdrop-in'); + } + + return sb; + }; + + _proto.search = function search(query, internal) { + var sb = this; + sb.previousQuery = sb.query || ''; + if (query === sb.previousQuery) return sb; + + if (!internal) { + if (!sb.enabled) { + sb.enable(); + } + + sb.$inputEl.val(query); + sb.$inputEl.trigger('input'); + } + + sb.query = query; + sb.value = query; + var $searchContainer = sb.$searchContainer, + $el = sb.$el, + $foundEl = sb.$foundEl, + $notFoundEl = sb.$notFoundEl, + $hideOnSearchEl = sb.$hideOnSearchEl, + isVirtualList = sb.isVirtualList; // Hide on search element + + if (query.length > 0 && $hideOnSearchEl) { + $hideOnSearchEl.addClass('hidden-by-searchbar'); + } else if ($hideOnSearchEl) { + $hideOnSearchEl.removeClass('hidden-by-searchbar'); + } // Add active/inactive classes on overlay + + + if ($searchContainer && $searchContainer.length && $el.hasClass('searchbar-enabled') || sb.params.customSearch && $el.hasClass('searchbar-enabled')) { + if (query.length === 0) { + sb.backdropShow(); + } else { + sb.backdropHide(); + } + } + + if (sb.params.customSearch) { + $el.trigger('searchbar:search', { + query: query, + previousQuery: sb.previousQuery + }); + sb.emit('local::search searchbarSearch', sb, query, sb.previousQuery); + return sb; + } + + var foundItems = []; + var vlQuery; + + if (isVirtualList) { + sb.virtualList = $searchContainer[0].f7VirtualList; + + if (query.trim() === '') { + sb.virtualList.resetFilter(); + if ($notFoundEl) $notFoundEl.hide(); + if ($foundEl) $foundEl.show(); + $el.trigger('searchbar:search', { + query: query, + previousQuery: sb.previousQuery + }); + sb.emit('local::search searchbarSearch', sb, query, sb.previousQuery); + return sb; + } + + vlQuery = sb.params.removeDiacritics ? (0, _removeDiacritics.default)(query) : query; + + if (sb.virtualList.params.searchAll) { + foundItems = sb.virtualList.params.searchAll(vlQuery, sb.virtualList.items) || []; + } else if (sb.virtualList.params.searchByItem) { + for (var i = 0; i < sb.virtualList.items.length; i += 1) { + if (sb.virtualList.params.searchByItem(vlQuery, sb.virtualList.items[i], i)) { + foundItems.push(i); + } + } + } + } else { + var values; + if (sb.params.removeDiacritics) values = (0, _removeDiacritics.default)(query.trim().toLowerCase()).split(' ');else { + values = query.trim().toLowerCase().split(' '); + } + $searchContainer.find(sb.params.searchItem).removeClass('hidden-by-searchbar').each(function (itemEl) { + var $itemEl = (0, _dom.default)(itemEl); + var compareWithText = []; + var $searchIn = sb.params.searchIn ? $itemEl.find(sb.params.searchIn) : $itemEl; + + if (sb.params.searchIn === sb.params.searchItem) { + $searchIn = $itemEl; + } + + $searchIn.each(function (searchInEl) { + var itemText = (0, _dom.default)(searchInEl).text().trim().toLowerCase(); + if (sb.params.removeDiacritics) itemText = (0, _removeDiacritics.default)(itemText); + compareWithText.push(itemText); + }); + compareWithText = compareWithText.join(' '); + var wordsMatch = 0; + + for (var _i = 0; _i < values.length; _i += 1) { + if (compareWithText.indexOf(values[_i]) >= 0) wordsMatch += 1; + } + + if (wordsMatch !== values.length && !(sb.params.ignore && $itemEl.is(sb.params.ignore))) { + $itemEl.addClass('hidden-by-searchbar'); + } else { + foundItems.push($itemEl[0]); + } + }); + + if (sb.params.hideDividers) { + $searchContainer.find(sb.params.searchGroupTitle).each(function (titleEl) { + var $titleEl = (0, _dom.default)(titleEl); + var $nextElements = $titleEl.nextAll(sb.params.searchItem); + var hide = true; + + for (var _i2 = 0; _i2 < $nextElements.length; _i2 += 1) { + var $nextEl = $nextElements.eq(_i2); + if ($nextEl.is(sb.params.searchGroupTitle)) break; + + if (!$nextEl.hasClass('hidden-by-searchbar')) { + hide = false; + } + } + + var ignore = sb.params.ignore && $titleEl.is(sb.params.ignore); + if (hide && !ignore) $titleEl.addClass('hidden-by-searchbar');else $titleEl.removeClass('hidden-by-searchbar'); + }); + } + + if (sb.params.hideGroups) { + $searchContainer.find(sb.params.searchGroup).each(function (groupEl) { + var $groupEl = (0, _dom.default)(groupEl); + var ignore = sb.params.ignore && $groupEl.is(sb.params.ignore); // eslint-disable-next-line + + var notHidden = $groupEl.find(sb.params.searchItem).filter(function (el) { + return !(0, _dom.default)(el).hasClass('hidden-by-searchbar'); + }); + + if (notHidden.length === 0 && !ignore) { + $groupEl.addClass('hidden-by-searchbar'); + } else { + $groupEl.removeClass('hidden-by-searchbar'); + } + }); + } + } + + if (foundItems.length === 0) { + if ($notFoundEl) $notFoundEl.show(); + if ($foundEl) $foundEl.hide(); + } else { + if ($notFoundEl) $notFoundEl.hide(); + if ($foundEl) $foundEl.show(); + } + + if (isVirtualList && sb.virtualList) { + sb.virtualList.filterItems(foundItems); + } + + $el.trigger('searchbar:search', { + query: query, + previousQuery: sb.previousQuery, + foundItems: foundItems + }); + sb.emit('local::search searchbarSearch', sb, query, sb.previousQuery, foundItems); + return sb; + }; + + _proto.init = function init() { + var sb = this; + if (sb.expandable && sb.$el) sb.$el.addClass('searchbar-expandable'); + if (sb.inline && sb.$el) sb.$el.addClass('searchbar-inline'); + sb.attachEvents(); + }; + + _proto.destroy = function destroy() { + var sb = this; + sb.emit('local::beforeDestroy searchbarBeforeDestroy', sb); + sb.$el.trigger('searchbar:beforedestroy'); + sb.detachEvents(); + + if (sb.$el[0]) { + sb.$el[0].f7Searchbar = null; + delete sb.$el[0].f7Searchbar; + } + + (0, _utils.deleteProps)(sb); + }; + + return Searchbar; +}(_class.default); + +var _default = Searchbar; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/searchbar/searchbar.js b/www/assets/framework7/cjs/components/searchbar/searchbar.js new file mode 100644 index 000000000..2f1d2205b --- /dev/null +++ b/www/assets/framework7/cjs/components/searchbar/searchbar.js @@ -0,0 +1,141 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _searchbarClass = _interopRequireDefault(require("./searchbar-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'searchbar', + static: { + Searchbar: _searchbarClass.default + }, + create: function create() { + var app = this; + app.searchbar = (0, _constructorMethods.default)({ + defaultSelector: '.searchbar', + constructor: _searchbarClass.default, + app: app, + domProp: 'f7Searchbar', + addMethods: 'clear enable disable toggle search'.split(' ') + }); + }, + on: { + tabMounted: function tabMounted(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.searchbar-init').each(function (searchbarEl) { + var $searchbarEl = (0, _dom.default)(searchbarEl); + app.searchbar.create((0, _utils.extend)($searchbarEl.dataset(), { + el: searchbarEl + })); + }); + }, + tabBeforeRemove: function tabBeforeRemove(tabEl) { + (0, _dom.default)(tabEl).find('.searchbar-init').each(function (searchbarEl) { + if (searchbarEl.f7Searchbar && searchbarEl.f7Searchbar.destroy) { + searchbarEl.f7Searchbar.destroy(); + } + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.searchbar-init').each(function (searchbarEl) { + var $searchbarEl = (0, _dom.default)(searchbarEl); + app.searchbar.create((0, _utils.extend)($searchbarEl.dataset(), { + el: searchbarEl + })); + }); + + if (app.theme === 'ios' && page.view && page.view.router.dynamicNavbar && page.$navbarEl && page.$navbarEl.length > 0) { + page.$navbarEl.find('.searchbar-init').each(function (searchbarEl) { + var $searchbarEl = (0, _dom.default)(searchbarEl); + app.searchbar.create((0, _utils.extend)($searchbarEl.dataset(), { + el: searchbarEl + })); + }); + } + }, + pageBeforeRemove: function pageBeforeRemove(page) { + var app = this; + page.$el.find('.searchbar-init').each(function (searchbarEl) { + if (searchbarEl.f7Searchbar && searchbarEl.f7Searchbar.destroy) { + searchbarEl.f7Searchbar.destroy(); + } + }); + + if (app.theme === 'ios' && page.view && page.view.router.dynamicNavbar && page.$navbarEl && page.$navbarEl.length > 0) { + page.$navbarEl.find('.searchbar-init').each(function (searchbarEl) { + if (searchbarEl.f7Searchbar && searchbarEl.f7Searchbar.destroy) { + searchbarEl.f7Searchbar.destroy(); + } + }); + } + } + }, + clicks: { + '.searchbar-clear': function clear($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + var sb = app.searchbar.get(data.searchbar); + if (sb) sb.clear(); + }, + '.searchbar-enable': function enable($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + var sb = app.searchbar.get(data.searchbar); + if (sb) sb.enable(true); + }, + '.searchbar-disable': function disable($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + var sb = app.searchbar.get(data.searchbar); + if (sb) sb.disable(); + }, + '.searchbar-toggle': function toggle($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + var sb = app.searchbar.get(data.searchbar); + if (sb) sb.toggle(); + } + }, + vnode: { + 'searchbar-init': { + insert: function insert(vnode) { + var app = this; + var searchbarEl = vnode.elm; + var $searchbarEl = (0, _dom.default)(searchbarEl); + app.searchbar.create((0, _utils.extend)($searchbarEl.dataset(), { + el: searchbarEl + })); + }, + destroy: function destroy(vnode) { + var searchbarEl = vnode.elm; + + if (searchbarEl.f7Searchbar && searchbarEl.f7Searchbar.destroy) { + searchbarEl.f7Searchbar.destroy(); + } + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/sheet/sheet-class.js b/www/assets/framework7/cjs/components/sheet/sheet-class.js new file mode 100644 index 000000000..af8e3e580 --- /dev/null +++ b/www/assets/framework7/cjs/components/sheet/sheet-class.js @@ -0,0 +1,593 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _getSupport = require("../../shared/get-support"); + +var _getDevice = require("../../shared/get-device"); + +var _modalClass = _interopRequireDefault(require("../modal/modal-class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Sheet = /*#__PURE__*/function (_Modal) { + _inheritsLoose(Sheet, _Modal); + + function Sheet(app, params) { + var _this; + + var extendedParams = (0, _utils.extend)({ + on: {} + }, app.params.sheet, params); // Extends with open/close Modal methods; + + _this = _Modal.call(this, app, extendedParams) || this; + + var sheet = _assertThisInitialized(_this); + + var window = (0, _ssrWindow.getWindow)(); + var document = (0, _ssrWindow.getDocument)(); + var support = (0, _getSupport.getSupport)(); + var device = (0, _getDevice.getDevice)(); + sheet.params = extendedParams; + + if (typeof sheet.params.backdrop === 'undefined') { + sheet.params.backdrop = app.theme !== 'ios'; + } // Find Element + + + var $el; + + if (!sheet.params.el) { + $el = (0, _dom.default)(sheet.params.content).filter(function (node) { + return node.nodeType === 1; + }).eq(0); + } else { + $el = (0, _dom.default)(sheet.params.el).eq(0); + } + + if ($el && $el.length > 0 && $el[0].f7Modal) { + return $el[0].f7Modal || _assertThisInitialized(_this); + } + + if ($el.length === 0) { + return sheet.destroy() || _assertThisInitialized(_this); + } + + var $backdropEl; + + if (sheet.params.backdrop && sheet.params.backdropEl) { + $backdropEl = (0, _dom.default)(sheet.params.backdropEl); + } else if (sheet.params.backdrop) { + $backdropEl = sheet.$containerEl.children('.sheet-backdrop'); + + if ($backdropEl.length === 0) { + $backdropEl = (0, _dom.default)('
    '); + sheet.$containerEl.append($backdropEl); + } + } + + (0, _utils.extend)(sheet, { + app: app, + push: $el.hasClass('sheet-modal-push') || sheet.params.push, + $el: $el, + el: $el[0], + $backdropEl: $backdropEl, + backdropEl: $backdropEl && $backdropEl[0], + type: 'sheet', + $htmlEl: (0, _dom.default)('html') + }); + + if (sheet.params.push) { + $el.addClass('sheet-modal-push'); + } + + var $pageContentEl; + + function scrollToElementOnOpen() { + var $scrollEl = (0, _dom.default)(sheet.params.scrollToEl).eq(0); + if ($scrollEl.length === 0) return; + $pageContentEl = $scrollEl.parents('.page-content'); + if ($pageContentEl.length === 0) return; + var paddingTop = parseInt($pageContentEl.css('padding-top'), 10); + var paddingBottom = parseInt($pageContentEl.css('padding-bottom'), 10); + var pageHeight = $pageContentEl[0].offsetHeight - paddingTop - $el.height(); + var pageScrollHeight = $pageContentEl[0].scrollHeight - paddingTop - $el.height(); + var pageScroll = $pageContentEl.scrollTop(); + var newPaddingBottom; + var scrollElTop = $scrollEl.offset().top - paddingTop + $scrollEl[0].offsetHeight; + + if (scrollElTop > pageHeight) { + var scrollTop = pageScroll + scrollElTop - pageHeight; + + if (scrollTop + pageHeight > pageScrollHeight) { + newPaddingBottom = scrollTop + pageHeight - pageScrollHeight + paddingBottom; + + if (pageHeight === pageScrollHeight) { + newPaddingBottom = $el.height(); + } + + $pageContentEl.css({ + 'padding-bottom': newPaddingBottom + "px" + }); + } + + $pageContentEl.scrollTop(scrollTop, 300); + } + } + + function scrollToElementOnClose() { + if ($pageContentEl && $pageContentEl.length > 0) { + $pageContentEl.css({ + 'padding-bottom': '' + }); + } + } + + function handleClick(e) { + var target = e.target; + var $target = (0, _dom.default)(target); + var keyboardOpened = !device.desktop && device.cordova && (window.Keyboard && window.Keyboard.isVisible || window.cordova.plugins && window.cordova.plugins.Keyboard && window.cordova.plugins.Keyboard.isVisible); + if (keyboardOpened) return; + + if ($target.closest(sheet.el).length === 0) { + if (sheet.params.closeByBackdropClick && sheet.params.backdrop && sheet.backdropEl && sheet.backdropEl === target) { + sheet.close(); + } else if (sheet.params.closeByOutsideClick) { + sheet.close(); + } + } + } + + function onKeyDown(e) { + var keyCode = e.keyCode; + + if (keyCode === 27 && sheet.params.closeOnEscape) { + sheet.close(); + } + } + + var pushOffset; + + function pushViewScale(offset) { + return (app.height - offset * 2) / app.height; + } + + var isTouched = false; + var startTouch; + var currentTouch; + var isScrolling; + var touchStartTime; + var touchesDiff; + var isMoved = false; + var isTopSheetModal; + var swipeStepTranslate; + var startTranslate; + var currentTranslate; + var sheetElOffsetHeight; + var minTranslate; + var maxTranslate; + var $pushViewEl; + var pushBorderRadius; + var sheetPageContentEl; + var sheetPageContentScrollTop; + var sheetPageContentScrollHeight; + var sheetPageContentOffsetHeight; + + function handleTouchStart(e) { + if (isTouched || !(sheet.params.swipeToClose || sheet.params.swipeToStep)) return; + + if (sheet.params.swipeHandler && (0, _dom.default)(e.target).closest(sheet.params.swipeHandler).length === 0) { + return; + } + + isTouched = true; + isMoved = false; + startTouch = { + x: e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX, + y: e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY + }; + touchStartTime = (0, _utils.now)(); + isScrolling = undefined; + isTopSheetModal = $el.hasClass('sheet-modal-top'); + + if (!sheet.params.swipeHandler && e.type === 'touchstart') { + sheetPageContentEl = (0, _dom.default)(e.target).closest('.page-content')[0]; + } + } + + function handleTouchMove(e) { + if (!isTouched) return; + currentTouch = { + x: e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX, + y: e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY + }; + + if (typeof isScrolling === 'undefined') { + isScrolling = !!(isScrolling || Math.abs(currentTouch.x - startTouch.x) > Math.abs(currentTouch.y - startTouch.y)); + } + + if (isScrolling) { + isTouched = false; + isMoved = false; + return; + } + + touchesDiff = startTouch.y - currentTouch.y; + var direction = touchesDiff < 0 ? 'to-bottom' : 'to-top'; + + if (!isMoved) { + if (sheetPageContentEl && !$el.hasClass('modal-in-swipe-step')) { + sheetPageContentScrollTop = sheetPageContentEl.scrollTop; + sheetPageContentScrollHeight = sheetPageContentEl.scrollHeight; + sheetPageContentOffsetHeight = sheetPageContentEl.offsetHeight; + + if (!(sheetPageContentScrollHeight === sheetPageContentOffsetHeight) && !(direction === 'to-bottom' && sheetPageContentScrollTop === 0) && !(direction === 'to-top' && sheetPageContentScrollTop === sheetPageContentScrollHeight - sheetPageContentOffsetHeight)) { + $el.transform(''); + isTouched = false; + isMoved = false; + return; + } + } + + if (sheet.push && pushOffset) { + $pushViewEl = app.$el.children('.view, .views'); + } + + sheetElOffsetHeight = $el[0].offsetHeight; + startTranslate = (0, _utils.getTranslate)($el[0], 'y'); + + if (isTopSheetModal) { + minTranslate = sheet.params.swipeToClose ? -sheetElOffsetHeight : -swipeStepTranslate; + maxTranslate = 0; + } else { + minTranslate = 0; + maxTranslate = sheet.params.swipeToClose ? sheetElOffsetHeight : swipeStepTranslate; + } + + isMoved = true; + } + + currentTranslate = startTranslate - touchesDiff; + currentTranslate = Math.min(Math.max(currentTranslate, minTranslate), maxTranslate); + e.preventDefault(); + + if (sheet.push && pushOffset) { + var progress = (currentTranslate - startTranslate) / sheetElOffsetHeight; + + if (sheet.params.swipeToStep) { + if (isTopSheetModal) { + progress = currentTranslate / swipeStepTranslate; + } else { + progress = 1 - (swipeStepTranslate - currentTranslate) / swipeStepTranslate; + } + } + + progress = Math.abs(progress); + progress = Math.min(Math.max(progress, 0), 1); + var pushProgress = 1 - progress; + var scale = 1 - (1 - pushViewScale(pushOffset)) * pushProgress; + $pushViewEl.transition(0).forEach(function (el) { + el.style.setProperty('transform', "translate3d(0,0,0) scale(" + scale + ")", 'important'); + }); + + if (sheet.params.swipeToStep) { + $pushViewEl.css('border-radius', pushBorderRadius * pushProgress + "px"); + } + } + + $el.transition(0).transform("translate3d(0," + currentTranslate + "px,0)"); + + if (sheet.params.swipeToStep) { + var _progress; + + if (isTopSheetModal) { + _progress = 1 - currentTranslate / swipeStepTranslate; + } else { + _progress = (swipeStepTranslate - currentTranslate) / swipeStepTranslate; + } + + _progress = Math.min(Math.max(_progress, 0), 1); + $el.trigger('sheet:stepprogress', _progress); + sheet.emit('local::stepProgress sheetStepProgress', sheet, _progress); + } + } + + function handleTouchEnd() { + isTouched = false; + + if (!isMoved) { + return; + } + + isMoved = false; + $el.transform('').transition(''); + + if (sheet.push && pushOffset) { + $pushViewEl.transition('').transform(''); + $pushViewEl.css('border-radius', ''); + } + + var direction = touchesDiff < 0 ? 'to-bottom' : 'to-top'; + var diff = Math.abs(touchesDiff); + if (diff === 0 || currentTranslate === startTranslate) return; + var timeDiff = new Date().getTime() - touchStartTime; + + if (!sheet.params.swipeToStep) { + if (direction !== (isTopSheetModal ? 'to-top' : 'to-bottom')) { + return; + } + + if (timeDiff < 300 && diff > 20 || timeDiff >= 300 && diff > sheetElOffsetHeight / 2) { + sheet.close(); + } + + return; + } + + var openDirection = isTopSheetModal ? 'to-bottom' : 'to-top'; + var closeDirection = isTopSheetModal ? 'to-top' : 'to-bottom'; + var absCurrentTranslate = Math.abs(currentTranslate); + var absSwipeStepTranslate = Math.abs(swipeStepTranslate); + + if (timeDiff < 300 && diff > 10) { + if (direction === openDirection && absCurrentTranslate < absSwipeStepTranslate) { + // open step + $el.removeClass('modal-in-swipe-step'); + $el.trigger('sheet:stepprogress', 1); + sheet.emit('local::stepProgress sheetStepProgress', sheet, 1); + sheet.emit('local::_swipeStep', false); + $el.trigger('sheet:stepopen'); + sheet.emit('local::stepOpen sheetStepOpen', sheet); + + if (sheet.push && pushOffset) { + sheet.$htmlEl[0].style.setProperty('--f7-sheet-push-scale', pushViewScale(pushOffset)); + $pushViewEl.css('border-radius', ''); + } + } + + if (direction === closeDirection && absCurrentTranslate > absSwipeStepTranslate) { + // close sheet + if (sheet.params.swipeToClose) { + sheet.close(); + } else { + // close step + $el.addClass('modal-in-swipe-step'); + $el.trigger('sheet:stepprogress', 0); + sheet.emit('local::stepProgress sheetStepProgress', sheet, 0); + sheet.emit('local::_swipeStep', true); + $el.trigger('sheet:stepclose'); + sheet.emit('local::stepClose sheetStepClose', sheet); + + if (sheet.push && pushOffset) { + sheet.$htmlEl[0].style.removeProperty('--f7-sheet-push-scale'); + $pushViewEl.css('border-radius', '0px'); + } + } + } + + if (direction === closeDirection && absCurrentTranslate <= absSwipeStepTranslate) { + // close step + $el.addClass('modal-in-swipe-step'); + $el.trigger('sheet:stepprogress', 0); + sheet.emit('local::stepProgress sheetStepProgress', sheet, 0); + sheet.emit('local::_swipeStep', true); + $el.trigger('sheet:stepclose'); + sheet.emit('local::stepClose sheetStepClose', sheet); + + if (sheet.push && pushOffset) { + sheet.$htmlEl[0].style.removeProperty('--f7-sheet-push-scale'); + $pushViewEl.css('border-radius', '0px'); + } + } + + return; + } + + if (timeDiff >= 300) { + var stepOpened = !$el.hasClass('modal-in-swipe-step'); + + if (!stepOpened) { + if (absCurrentTranslate < absSwipeStepTranslate / 2) { + // open step + $el.removeClass('modal-in-swipe-step'); + $el.trigger('sheet:stepprogress', 1); + sheet.emit('local::stepProgress sheetStepProgress', sheet, 1); + sheet.emit('local::_swipeStep', false); + $el.trigger('sheet:stepopen'); + sheet.emit('local::stepOpen sheetStepOpen', sheet); + + if (sheet.push && pushOffset) { + sheet.$htmlEl[0].style.setProperty('--f7-sheet-push-scale', pushViewScale(pushOffset)); + $pushViewEl.css('border-radius', ''); + } + } else if (absCurrentTranslate - absSwipeStepTranslate > (sheetElOffsetHeight - absSwipeStepTranslate) / 2) { + // close sheet + if (sheet.params.swipeToClose) sheet.close(); + } + } else if (stepOpened) { + if (absCurrentTranslate > absSwipeStepTranslate + (sheetElOffsetHeight - absSwipeStepTranslate) / 2) { + // close sheet + if (sheet.params.swipeToClose) sheet.close(); + } else if (absCurrentTranslate > absSwipeStepTranslate / 2) { + // close step + $el.addClass('modal-in-swipe-step'); + $el.trigger('sheet:stepprogress', 0); + sheet.emit('local::stepProgress sheetStepProgress', sheet, 0); + sheet.emit('local::_swipeStep', true); + $el.trigger('sheet:stepclose'); + sheet.emit('local::stepClose sheetStepClose', sheet); + + if (sheet.push && pushOffset) { + sheet.$htmlEl[0].style.removeProperty('--f7-sheet-push-scale'); + $pushViewEl.css('border-radius', '0px'); + } + } + } + } + } + + sheet.setSwipeStep = function setSwipeStep(byResize) { + if (byResize === void 0) { + byResize = true; + } + + var $swipeStepEl = $el.find('.sheet-modal-swipe-step').eq(0); + if (!$swipeStepEl.length) return; + + if ($el.hasClass('sheet-modal-top')) { + swipeStepTranslate = -($swipeStepEl.offset().top - $el.offset().top + $swipeStepEl[0].offsetHeight); + } else { + swipeStepTranslate = $el[0].offsetHeight - ($swipeStepEl.offset().top - $el.offset().top + $swipeStepEl[0].offsetHeight); + } + + $el[0].style.setProperty('--f7-sheet-swipe-step', swipeStepTranslate + "px"); + + if (!byResize) { + $el.addClass('modal-in-swipe-step'); + sheet.emit('local::_swipeStep', true); + } + }; + + function onResize() { + sheet.setSwipeStep(true); + } + + var passive = support.passiveListener ? { + passive: true + } : false; + + if (sheet.params.swipeToClose || sheet.params.swipeToStep) { + $el.on(app.touchEvents.start, handleTouchStart, passive); + app.on('touchmove', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + sheet.once('sheetDestroy', function () { + $el.off(app.touchEvents.start, handleTouchStart, passive); + app.off('touchmove', handleTouchMove); + app.off('touchend:passive', handleTouchEnd); + }); + } + + sheet.on('open', function () { + if (sheet.params.closeOnEscape) { + (0, _dom.default)(document).on('keydown', onKeyDown); + } + + $el.prevAll('.popup.modal-in').addClass('popup-behind'); + + if (sheet.params.swipeToStep) { + sheet.setSwipeStep(false); + app.on('resize', onResize); + } + + if (sheet.params.scrollToEl) { + scrollToElementOnOpen(); + } + + if (sheet.push) { + pushOffset = parseInt($el.css('--f7-sheet-push-offset'), 10); + if (Number.isNaN(pushOffset)) pushOffset = 0; + + if (pushOffset) { + $el.addClass('sheet-modal-push'); + sheet.$htmlEl.addClass('with-modal-sheet-push'); + + if (!sheet.params.swipeToStep) { + sheet.$htmlEl[0].style.setProperty('--f7-sheet-push-scale', pushViewScale(pushOffset)); + } else { + $pushViewEl = app.$el.children('.view, .views'); + pushBorderRadius = parseFloat($el.css("border-" + (isTopSheetModal ? 'bottom' : 'top') + "-left-radius")); + $pushViewEl.css('border-radius', '0px'); + } + } + } + }); + sheet.on('opened', function () { + if (sheet.params.closeByOutsideClick || sheet.params.closeByBackdropClick) { + app.on('click', handleClick); + } + }); + sheet.on('close', function () { + if (sheet.params.swipeToStep) { + $el.removeClass('modal-in-swipe-step'); + sheet.emit('local::_swipeStep', false); + app.off('resize', onResize); + } + + if (sheet.params.closeOnEscape) { + (0, _dom.default)(document).off('keydown', onKeyDown); + } + + if (sheet.params.scrollToEl) { + scrollToElementOnClose(); + } + + if (sheet.params.closeByOutsideClick || sheet.params.closeByBackdropClick) { + app.off('click', handleClick); + } + + $el.prevAll('.popup.modal-in').eq(0).removeClass('popup-behind'); + + if (sheet.push && pushOffset) { + sheet.$htmlEl.removeClass('with-modal-sheet-push'); + sheet.$htmlEl.addClass('with-modal-sheet-push-closing'); + } + }); + sheet.on('closed', function () { + if (sheet.push && pushOffset) { + sheet.$htmlEl.removeClass('with-modal-sheet-push-closing'); + sheet.$htmlEl[0].style.removeProperty('--f7-sheet-push-scale'); + } + }); + + sheet.stepOpen = function stepOpen() { + $el.removeClass('modal-in-swipe-step'); + sheet.emit('local::_swipeStep', false); + + if (sheet.push) { + if (!pushOffset) { + pushOffset = parseInt($el.css('--f7-sheet-push-offset'), 10); + if (Number.isNaN(pushOffset)) pushOffset = 0; + } + + if (pushOffset) { + sheet.$htmlEl[0].style.setProperty('--f7-sheet-push-scale', pushViewScale(pushOffset)); + } + } + }; + + sheet.stepClose = function stepClose() { + $el.addClass('modal-in-swipe-step'); + sheet.emit('local::_swipeStep', true); + + if (sheet.push) { + sheet.$htmlEl[0].style.removeProperty('--f7-sheet-push-scale'); + } + }; + + sheet.stepToggle = function stepToggle() { + $el.toggleClass('modal-in-swipe-step'); + sheet.emit('local::_swipeStep', $el.hasClass('modal-in-swipe-step')); + }; + + $el[0].f7Modal = sheet; + return sheet || _assertThisInitialized(_this); + } + + return Sheet; +}(_modalClass.default); + +var _default = Sheet; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/sheet/sheet.js b/www/assets/framework7/cjs/components/sheet/sheet.js new file mode 100644 index 000000000..4d7254c7f --- /dev/null +++ b/www/assets/framework7/cjs/components/sheet/sheet.js @@ -0,0 +1,83 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _sheetClass = _interopRequireDefault(require("./sheet-class")); + +var _modalMethods = _interopRequireDefault(require("../../shared/modal-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'sheet', + params: { + sheet: { + push: false, + backdrop: undefined, + backdropEl: undefined, + closeByBackdropClick: true, + closeByOutsideClick: false, + closeOnEscape: false, + swipeToClose: false, + swipeToStep: false, + swipeHandler: null, + containerEl: null + } + }, + static: { + Sheet: _sheetClass.default + }, + create: function create() { + var app = this; + app.sheet = (0, _utils.extend)({}, (0, _modalMethods.default)({ + app: app, + constructor: _sheetClass.default, + defaultSelector: '.sheet-modal.modal-in' + }), { + stepOpen: function stepOpen(sheet) { + var sheetInstance = app.sheet.get(sheet); + if (sheetInstance && sheetInstance.stepOpen) return sheetInstance.stepOpen(); + return undefined; + }, + stepClose: function stepClose(sheet) { + var sheetInstance = app.sheet.get(sheet); + if (sheetInstance && sheetInstance.stepClose) return sheetInstance.stepClose(); + return undefined; + }, + stepToggle: function stepToggle(sheet) { + var sheetInstance = app.sheet.get(sheet); + if (sheetInstance && sheetInstance.stepToggle) return sheetInstance.stepToggle(); + return undefined; + } + }); + }, + clicks: { + '.sheet-open': function openSheet($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + + if ((0, _dom.default)('.sheet-modal.modal-in').length > 0 && data.sheet && (0, _dom.default)(data.sheet)[0] !== (0, _dom.default)('.sheet-modal.modal-in')[0]) { + app.sheet.close('.sheet-modal.modal-in'); + } + + app.sheet.open(data.sheet, data.animate, $clickedEl); + }, + '.sheet-close': function closeSheet($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.sheet.close(data.sheet, data.animate, $clickedEl); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/skeleton/skeleton.js b/www/assets/framework7/cjs/components/skeleton/skeleton.js new file mode 100644 index 000000000..051a99657 --- /dev/null +++ b/www/assets/framework7/cjs/components/skeleton/skeleton.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _default = { + name: 'skeleton' +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/smart-select/smart-select-class.js b/www/assets/framework7/cjs/components/smart-select/smart-select-class.js new file mode 100644 index 000000000..a01d78df2 --- /dev/null +++ b/www/assets/framework7/cjs/components/smart-select/smart-select-class.js @@ -0,0 +1,1005 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _$jsx = _interopRequireDefault(require("../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var SmartSelect = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(SmartSelect, _Framework7Class); + + function SmartSelect(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params, [app]) || this; + + var ss = _assertThisInitialized(_this); + + var defaults = (0, _utils.extend)({ + on: {} + }, app.params.smartSelect); + + if (typeof defaults.searchbarDisableButton === 'undefined') { + defaults.searchbarDisableButton = app.theme !== 'aurora'; + } // Extend defaults with modules params + + + ss.useModulesParams(defaults); + ss.params = (0, _utils.extend)({}, defaults, params); + ss.app = app; + var $el = (0, _dom.default)(ss.params.el).eq(0); + if ($el.length === 0) return ss || _assertThisInitialized(_this); + if ($el[0].f7SmartSelect) return $el[0].f7SmartSelect || _assertThisInitialized(_this); + var $selectEl = $el.find('select').eq(0); + if ($selectEl.length === 0) return ss || _assertThisInitialized(_this); + var $valueEl; + + if (ss.params.setValueText) { + $valueEl = (0, _dom.default)(ss.params.valueEl); + + if ($valueEl.length === 0) { + $valueEl = $el.find('.item-after'); + } + + if ($valueEl.length === 0) { + $valueEl = (0, _dom.default)('
    '); + $valueEl.insertAfter($el.find('.item-title')); + } + } // Url + + + var url = params.url; + + if (!url) { + if ($el.attr('href') && $el.attr('href') !== '#') url = $el.attr('href');else if ($selectEl.attr('name')) url = $selectEl.attr('name').toLowerCase() + "-select/"; + } + + if (!url) url = ss.params.url; + var multiple = $selectEl[0].multiple; + var inputType = multiple ? 'checkbox' : 'radio'; + var selectId = (0, _utils.id)(); + (0, _utils.extend)(ss, { + $el: $el, + el: $el[0], + $selectEl: $selectEl, + selectEl: $selectEl[0], + $valueEl: $valueEl, + valueEl: $valueEl && $valueEl[0], + url: url, + multiple: multiple, + inputType: inputType, + id: selectId, + inputName: inputType + "-" + selectId, + selectName: $selectEl.attr('name'), + maxLength: $selectEl.attr('maxlength') || params.maxLength + }); + $el[0].f7SmartSelect = ss; // Events + + function onClick() { + ss.open(); + } + + function onChange() { + var value = ss.$selectEl.val(); + ss.$el.trigger('smartselect:change', value); + ss.emit('local::change smartSelectChange', ss, value); + + if (ss.vl) { + ss.vl.clearCache(); + } + + ss.setValueText(); + } + + ss.attachEvents = function attachEvents() { + $el.on('click', onClick); + $el.on('change', 'select', onChange); + }; + + ss.detachEvents = function detachEvents() { + $el.off('click', onClick); + $el.off('change', 'select', onChange); + }; + + function handleInputChange() { + var optionEl; + var text; + var inputEl = this; + var value = inputEl.value; + var optionText = []; + var displayAs; + + if (inputEl.type === 'checkbox') { + for (var i = 0; i < ss.selectEl.options.length; i += 1) { + optionEl = ss.selectEl.options[i]; + + if (optionEl.value === value) { + optionEl.selected = inputEl.checked; + } + + if (optionEl.selected) { + displayAs = optionEl.dataset ? optionEl.dataset.displayAs : (0, _dom.default)(optionEl).data('display-value-as'); + text = displayAs && typeof displayAs !== 'undefined' ? displayAs : optionEl.textContent; + optionText.push(text.trim()); + } + } + + if (ss.maxLength) { + ss.checkMaxLength(); + } + } else { + optionEl = ss.$selectEl.find("option[value=\"" + value + "\"]")[0]; + + if (!optionEl) { + optionEl = ss.$selectEl.find('option').filter(function (optEl) { + return optEl.value === value; + })[0]; + } + + displayAs = optionEl.dataset ? optionEl.dataset.displayAs : (0, _dom.default)(optionEl).data('display-as'); + text = displayAs && typeof displayAs !== 'undefined' ? displayAs : optionEl.textContent; + optionText = [text]; + ss.selectEl.value = value; + } + + ss.$selectEl.trigger('change'); + + if (ss.params.setValueText) { + ss.$valueEl.text(ss.formatValueText(optionText)); + } + + if (ss.params.closeOnSelect && ss.inputType === 'radio') { + ss.close(); + } + } + + ss.attachInputsEvents = function attachInputsEvents() { + ss.$containerEl.on('change', 'input[type="checkbox"], input[type="radio"]', handleInputChange); + }; + + ss.detachInputsEvents = function detachInputsEvents() { + ss.$containerEl.off('change', 'input[type="checkbox"], input[type="radio"]', handleInputChange); + }; // Install Modules + + + ss.useModules(); // Init + + ss.init(); + return ss || _assertThisInitialized(_this); + } + + var _proto = SmartSelect.prototype; + + _proto.setValue = function setValue(value) { + var ss = this; + var newValue = value; + var optionText = []; + var optionEl; + var displayAs; + var text; + + if (ss.multiple) { + if (!Array.isArray(newValue)) newValue = [newValue]; + + for (var i = 0; i < ss.selectEl.options.length; i += 1) { + optionEl = ss.selectEl.options[i]; + + if (newValue.indexOf(optionEl.value) >= 0) { + optionEl.selected = true; + } else { + optionEl.selected = false; + } + + if (optionEl.selected) { + displayAs = optionEl.dataset ? optionEl.dataset.displayAs : (0, _dom.default)(optionEl).data('display-value-as'); + text = displayAs && typeof displayAs !== 'undefined' ? displayAs : optionEl.textContent; + optionText.push(text.trim()); + } + } + } else { + optionEl = ss.$selectEl.find("option[value=\"" + newValue + "\"]")[0]; + + if (optionEl) { + displayAs = optionEl.dataset ? optionEl.dataset.displayAs : (0, _dom.default)(optionEl).data('display-as'); + text = displayAs && typeof displayAs !== 'undefined' ? displayAs : optionEl.textContent; + optionText = [text]; + } + + ss.selectEl.value = newValue; + } + + if (ss.params.setValueText) { + ss.$valueEl.text(ss.formatValueText(optionText)); + } + + ss.$selectEl.trigger('change'); + return ss; + }; + + _proto.unsetValue = function unsetValue() { + var ss = this; + + if (ss.params.setValueText) { + ss.$valueEl.text(ss.formatValueText([])); + } + + ss.$selectEl.find('option').each(function (optionEl) { + optionEl.selected = false; + optionEl.checked = false; + }); + ss.$selectEl[0].value = null; + + if (ss.$containerEl) { + ss.$containerEl.find("input[name=\"" + ss.inputName + "\"][type=\"checkbox\"], input[name=\"" + ss.inputName + "\"][type=\"radio\"]").prop('checked', false); + } + + ss.$selectEl.trigger('change'); + }; + + _proto.getValue = function getValue() { + var ss = this; + return ss.$selectEl.val(); + }; + + _proto.checkMaxLength = function checkMaxLength() { + var ss = this; + var $containerEl = ss.$containerEl; + + if (ss.selectEl.selectedOptions.length >= ss.maxLength) { + $containerEl.find('input[type="checkbox"]').each(function (inputEl) { + if (!inputEl.checked) { + (0, _dom.default)(inputEl).parents('li').addClass('disabled'); + } else { + (0, _dom.default)(inputEl).parents('li').removeClass('disabled'); + } + }); + } else { + $containerEl.find('.disabled').removeClass('disabled'); + } + }; + + _proto.formatValueText = function formatValueText(values) { + var ss = this; + var textValue; + + if (ss.params.formatValueText) { + textValue = ss.params.formatValueText.call(ss, values, ss); + } else { + textValue = values.join(', '); + } + + return textValue; + }; + + _proto.setValueText = function setValueText(value) { + var ss = this; + var valueArray = []; + + if (typeof value !== 'undefined') { + if (Array.isArray(value)) { + valueArray = value; + } else { + valueArray = [value]; + } + } else { + ss.$selectEl.find('option').each(function (optionEl) { + var $optionEl = (0, _dom.default)(optionEl); + + if (optionEl.selected) { + var displayAs = optionEl.dataset ? optionEl.dataset.displayAs : $optionEl.data('display-value-as'); + + if (displayAs && typeof displayAs !== 'undefined') { + valueArray.push(displayAs); + } else { + valueArray.push(optionEl.textContent.trim()); + } + } + }); + } + + if (ss.params.setValueText) { + ss.$valueEl.text(ss.formatValueText(valueArray)); + } + }; + + _proto.getItemsData = function getItemsData() { + var ss = this; + var theme = ss.app.theme; + var items = []; + var previousGroupEl; + ss.$selectEl.find('option').each(function (optionEl) { + var $optionEl = (0, _dom.default)(optionEl); + var optionData = $optionEl.dataset(); + var optionImage = optionData.optionImage || ss.params.optionImage; + var optionIcon = optionData.optionIcon || ss.params.optionIcon; + var optionIconIos = theme === 'ios' && (optionData.optionIconIos || ss.params.optionIconIos); + var optionIconMd = theme === 'md' && (optionData.optionIconMd || ss.params.optionIconMd); + var optionIconAurora = theme === 'aurora' && (optionData.optionIconAurora || ss.params.optionIconAurora); + var optionHasMedia = optionImage || optionIcon || optionIconIos || optionIconMd || optionIconAurora; + var optionColor = optionData.optionColor; + var optionClassName = optionData.optionClass || ''; + if ($optionEl[0].disabled) optionClassName += ' disabled'; + var optionGroupEl = $optionEl.parent('optgroup')[0]; + var optionGroupLabel = optionGroupEl && optionGroupEl.label; + var optionIsLabel = false; + + if (optionGroupEl && optionGroupEl !== previousGroupEl) { + optionIsLabel = true; + previousGroupEl = optionGroupEl; + items.push({ + groupLabel: optionGroupLabel, + isLabel: optionIsLabel + }); + } + + items.push({ + value: $optionEl[0].value, + text: $optionEl[0].textContent.trim(), + selected: $optionEl[0].selected, + groupEl: optionGroupEl, + groupLabel: optionGroupLabel, + image: optionImage, + icon: optionIcon, + iconIos: optionIconIos, + iconMd: optionIconMd, + iconAurora: optionIconAurora, + color: optionColor, + className: optionClassName, + disabled: $optionEl[0].disabled, + id: ss.id, + hasMedia: optionHasMedia, + checkbox: ss.inputType === 'checkbox', + radio: ss.inputType === 'radio', + inputName: ss.inputName, + inputType: ss.inputType + }); + }); + ss.items = items; + return items; + }; + + _proto.renderSearchbar = function renderSearchbar() { + var ss = this; + if (ss.params.renderSearchbar) return ss.params.renderSearchbar.call(ss); + return (0, _$jsx.default)("form", { + class: "searchbar" + }, (0, _$jsx.default)("div", { + class: "searchbar-inner" + }, (0, _$jsx.default)("div", { + class: "searchbar-input-wrap" + }, (0, _$jsx.default)("input", { + type: "search", + spellcheck: ss.params.searchbarSpellcheck || 'false', + placeholder: ss.params.searchbarPlaceholder + }), (0, _$jsx.default)("i", { + class: "searchbar-icon" + }), (0, _$jsx.default)("span", { + class: "input-clear-button" + })), ss.params.searchbarDisableButton && (0, _$jsx.default)("span", { + class: "searchbar-disable-button" + }, ss.params.searchbarDisableText))); + }; + + _proto.renderItem = function renderItem(item, index) { + var ss = this; + if (ss.params.renderItem) return ss.params.renderItem.call(ss, item, index); + + function getIconContent(iconValue) { + if (iconValue === void 0) { + iconValue = ''; + } + + if (iconValue.indexOf(':') >= 0) { + return iconValue.split(':')[1]; + } + + return ''; + } + + function getIconClass(iconValue) { + if (iconValue === void 0) { + iconValue = ''; + } + + if (iconValue.indexOf(':') >= 0) { + var className = iconValue.split(':')[0]; + if (className === 'f7') className = 'f7-icons'; + if (className === 'material') className = 'material-icons'; + return className; + } + + return iconValue; + } + + var itemHtml; + + if (item.isLabel) { + itemHtml = "
  • " + item.groupLabel + "
  • "; + } else { + var selected = item.selected; + var disabled; + + if (ss.params.virtualList) { + var ssValue = ss.getValue(); + selected = ss.multiple ? ssValue.indexOf(item.value) >= 0 : ssValue === item.value; + + if (ss.multiple) { + disabled = ss.multiple && !selected && ssValue.length === parseInt(ss.maxLength, 10); + } + } + + var icon = item.icon, + iconIos = item.iconIos, + iconMd = item.iconMd, + iconAurora = item.iconAurora; + var hasIcon = icon || iconIos || iconMd || iconAurora; + var iconContent = getIconContent(icon || iconIos || iconMd || iconAurora || ''); + var iconClass = getIconClass(icon || iconIos || iconMd || iconAurora || ''); + itemHtml = (0, _$jsx.default)("li", { + class: "" + (item.className || '') + (disabled ? ' disabled' : '') + }, (0, _$jsx.default)("label", { + class: "item-" + item.inputType + " item-content" + }, (0, _$jsx.default)("input", { + type: item.inputType, + name: item.inputName, + value: item.value, + _checked: selected + }), (0, _$jsx.default)("i", { + class: "icon icon-" + item.inputType + }), item.hasMedia && (0, _$jsx.default)("div", { + class: "item-media" + }, hasIcon && (0, _$jsx.default)("i", { + class: "icon " + iconClass + }, iconContent), item.image && (0, _$jsx.default)("img", { + src: item.image + })), (0, _$jsx.default)("div", { + class: "item-inner" + }, (0, _$jsx.default)("div", { + class: "item-title" + (item.color ? " text-color-" + item.color : '') + }, item.text)))); + } + + return itemHtml; + }; + + _proto.renderItems = function renderItems() { + var ss = this; + if (ss.params.renderItems) return ss.params.renderItems.call(ss, ss.items); + var itemsHtml = "\n " + ss.items.map(function (item, index) { + return "" + ss.renderItem(item, index); + }).join('') + "\n "; + return itemsHtml; + }; + + _proto.renderPage = function renderPage() { + var ss = this; + if (ss.params.renderPage) return ss.params.renderPage.call(ss, ss.items); + var pageTitle = ss.params.pageTitle; + + if (typeof pageTitle === 'undefined') { + var $itemTitleEl = ss.$el.find('.item-title'); + pageTitle = $itemTitleEl.length ? $itemTitleEl.text().trim() : ''; + } + + var cssClass = ss.params.cssClass; + return (0, _$jsx.default)("div", { + class: "page smart-select-page " + cssClass, + "data-name": "smart-select-page", + "data-select-name": ss.selectName + }, (0, _$jsx.default)("div", { + class: "navbar " + (ss.params.navbarColorTheme ? "color-" + ss.params.navbarColorTheme : '') + }, (0, _$jsx.default)("div", { + class: "navbar-bg" + }), (0, _$jsx.default)("div", { + class: "navbar-inner sliding " + (ss.params.navbarColorTheme ? "color-" + ss.params.navbarColorTheme : '') + }, (0, _$jsx.default)("div", { + class: "left" + }, (0, _$jsx.default)("a", { + class: "link back" + }, (0, _$jsx.default)("i", { + class: "icon icon-back" + }), (0, _$jsx.default)("span", { + class: "if-not-md" + }, ss.params.pageBackLinkText))), pageTitle && (0, _$jsx.default)("div", { + class: "title" + }, pageTitle), ss.params.searchbar && (0, _$jsx.default)("div", { + class: "subnavbar" + }, ss.renderSearchbar()))), ss.params.searchbar && (0, _$jsx.default)("div", { + class: "searchbar-backdrop" + }), (0, _$jsx.default)("div", { + class: "page-content" + }, (0, _$jsx.default)("div", { + class: "list smart-select-list-" + ss.id + " " + (ss.params.virtualList ? ' virtual-list' : '') + " " + (ss.params.formColorTheme ? "color-" + ss.params.formColorTheme : '') + }, (0, _$jsx.default)("ul", null, !ss.params.virtualList && ss.renderItems(ss.items))))); + }; + + _proto.renderPopup = function renderPopup() { + var ss = this; + if (ss.params.renderPopup) return ss.params.renderPopup.call(ss, ss.items); + var pageTitle = ss.params.pageTitle; + + if (typeof pageTitle === 'undefined') { + var $itemTitleEl = ss.$el.find('.item-title'); + pageTitle = $itemTitleEl.length ? $itemTitleEl.text().trim() : ''; + } + + var cssClass = ss.params.cssClass || ''; + return (0, _$jsx.default)("div", { + class: "popup smart-select-popup " + cssClass + " " + (ss.params.popupTabletFullscreen ? 'popup-tablet-fullscreen' : ''), + "data-select-name": ss.selectName + }, (0, _$jsx.default)("div", { + class: "view" + }, (0, _$jsx.default)("div", { + class: "page smart-select-page " + (ss.params.searchbar ? 'page-with-subnavbar' : ''), + "data-name": "smart-select-page" + }, (0, _$jsx.default)("div", { + class: "navbar " + (ss.params.navbarColorTheme ? "color-" + ss.params.navbarColorTheme : '') + }, (0, _$jsx.default)("div", { + class: "navbar-bg" + }), (0, _$jsx.default)("div", { + class: "navbar-inner sliding" + }, pageTitle && (0, _$jsx.default)("div", { + class: "title" + }, pageTitle), (0, _$jsx.default)("div", { + class: "right" + }, (0, _$jsx.default)("a", { + class: "link popup-close", + "data-popup": ".smart-select-popup[data-select-name='" + ss.selectName + "']" + }, ss.params.popupCloseLinkText)), ss.params.searchbar && (0, _$jsx.default)("div", { + class: "subnavbar" + }, ss.renderSearchbar()))), ss.params.searchbar && (0, _$jsx.default)("div", { + class: "searchbar-backdrop" + }), (0, _$jsx.default)("div", { + class: "page-content" + }, (0, _$jsx.default)("div", { + class: "list smart-select-list-" + ss.id + " " + (ss.params.virtualList ? ' virtual-list' : '') + " " + (ss.params.formColorTheme ? "color-" + ss.params.formColorTheme : '') + }, (0, _$jsx.default)("ul", null, !ss.params.virtualList && ss.renderItems(ss.items))))))); + }; + + _proto.renderSheet = function renderSheet() { + var ss = this; + if (ss.params.renderSheet) return ss.params.renderSheet.call(ss, ss.items); + var cssClass = ss.params.cssClass; // prettier-ignore + + return (0, _$jsx.default)("div", { + class: "sheet-modal smart-select-sheet " + cssClass, + "data-select-name": ss.selectName + }, (0, _$jsx.default)("div", { + class: "toolbar toolbar-top " + (ss.params.toolbarColorTheme ? "color-" + ss.params.toolbarColorTheme : '') + }, (0, _$jsx.default)("div", { + class: "toolbar-inner" + }, (0, _$jsx.default)("div", { + class: "left" + }), (0, _$jsx.default)("div", { + class: "right" + }, (0, _$jsx.default)("a", { + class: "link sheet-close" + }, ss.params.sheetCloseLinkText)))), (0, _$jsx.default)("div", { + class: "sheet-modal-inner" + }, (0, _$jsx.default)("div", { + class: "page-content" + }, (0, _$jsx.default)("div", { + class: "list smart-select-list-" + ss.id + " " + (ss.params.virtualList ? ' virtual-list' : '') + " " + (ss.params.formColorTheme ? "color-" + ss.params.formColorTheme : '') + }, (0, _$jsx.default)("ul", null, !ss.params.virtualList && ss.renderItems(ss.items)))))); + }; + + _proto.renderPopover = function renderPopover() { + var ss = this; + if (ss.params.renderPopover) return ss.params.renderPopover.call(ss, ss.items); + var cssClass = ss.params.cssClass; // prettier-ignore + + return (0, _$jsx.default)("div", { + class: "popover smart-select-popover " + cssClass, + "data-select-name": ss.selectName + }, (0, _$jsx.default)("div", { + class: "popover-inner" + }, (0, _$jsx.default)("div", { + class: "list smart-select-list-" + ss.id + " " + (ss.params.virtualList ? ' virtual-list' : '') + " " + (ss.params.formColorTheme ? "color-" + ss.params.formColorTheme : '') + }, (0, _$jsx.default)("ul", null, !ss.params.virtualList && ss.renderItems(ss.items))))); + }; + + _proto.scrollToSelectedItem = function scrollToSelectedItem() { + var ss = this; + var params = ss.params, + $containerEl = ss.$containerEl; + if (!ss.opened) return ss; + + if (params.virtualList) { + var selectedIndex; + ss.vl.items.forEach(function (item, index) { + if (typeof selectedIndex === 'undefined' && item.selected) { + selectedIndex = index; + } + }); + + if (typeof selectedIndex !== 'undefined') { + ss.vl.scrollToItem(selectedIndex); + } + } else { + var $selectedItemEl = $containerEl.find('input:checked').parents('li'); + if (!$selectedItemEl.length) return ss; + var $scrollableEl = $containerEl.find('.page-content, .popover-inner'); + if (!$scrollableEl.length) return ss; + $scrollableEl.scrollTop($selectedItemEl.offset().top - $scrollableEl.offset().top - parseInt($scrollableEl.css('padding-top'), 10)); + } + + return ss; + }; + + _proto.onOpen = function onOpen(type, containerEl) { + var ss = this; + var app = ss.app; + var $containerEl = (0, _dom.default)(containerEl); + ss.$containerEl = $containerEl; + ss.openedIn = type; + ss.opened = true; // Init VL + + if (ss.params.virtualList) { + ss.vl = app.virtualList.create({ + el: $containerEl.find('.virtual-list'), + items: ss.items, + renderItem: ss.renderItem.bind(ss), + height: ss.params.virtualListHeight, + searchByItem: function searchByItem(query, item) { + if (item.text && item.text.toLowerCase().indexOf(query.trim().toLowerCase()) >= 0) return true; + return false; + } + }); + } + + if (ss.params.scrollToSelectedItem) { + ss.scrollToSelectedItem(); + } // Init SB + + + if (ss.params.searchbar) { + var $searchbarEl = $containerEl.find('.searchbar'); + + if (type === 'page' && app.theme === 'ios') { + $searchbarEl = (0, _dom.default)(app.navbar.getElByPage($containerEl)).find('.searchbar'); + } + + if (ss.params.appendSearchbarNotFound && (type === 'page' || type === 'popup')) { + var $notFoundEl = null; + + if (typeof ss.params.appendSearchbarNotFound === 'string') { + $notFoundEl = (0, _dom.default)("
    " + ss.params.appendSearchbarNotFound + "
    "); + } else if (typeof ss.params.appendSearchbarNotFound === 'boolean') { + $notFoundEl = (0, _dom.default)('
    Nothing found
    '); + } else { + $notFoundEl = ss.params.appendSearchbarNotFound; + } + + if ($notFoundEl) { + $containerEl.find('.page-content').append($notFoundEl[0]); + } + } + + var searchbarParams = (0, _utils.extend)({ + el: $searchbarEl, + backdropEl: $containerEl.find('.searchbar-backdrop'), + searchContainer: ".smart-select-list-" + ss.id, + searchIn: '.item-title' + }, typeof ss.params.searchbar === 'object' ? ss.params.searchbar : {}); + ss.searchbar = app.searchbar.create(searchbarParams); + } // Check for max length + + + if (ss.maxLength) { + ss.checkMaxLength(); + } // Close on select + + + if (ss.params.closeOnSelect) { + ss.$containerEl.find("input[type=\"radio\"][name=\"" + ss.inputName + "\"]:checked").parents('label').once('click', function () { + ss.close(); + }); + } // Attach input events + + + ss.attachInputsEvents(); + ss.$el.trigger('smartselect:open'); + ss.emit('local::open smartSelectOpen', ss); + }; + + _proto.onOpened = function onOpened() { + var ss = this; + ss.$el.trigger('smartselect:opened'); + ss.emit('local::opened smartSelectOpened', ss); + }; + + _proto.onClose = function onClose() { + var ss = this; + if (ss.destroyed) return; // Destroy VL + + if (ss.vl && ss.vl.destroy) { + ss.vl.destroy(); + ss.vl = null; + delete ss.vl; + } // Destroy SB + + + if (ss.searchbar && ss.searchbar.destroy) { + ss.searchbar.destroy(); + ss.searchbar = null; + delete ss.searchbar; + } // Detach events + + + ss.detachInputsEvents(); + ss.$el.trigger('smartselect:close'); + ss.emit('local::close smartSelectClose', ss); + }; + + _proto.onClosed = function onClosed() { + var ss = this; + if (ss.destroyed) return; + ss.opened = false; + ss.$containerEl = null; + delete ss.$containerEl; + ss.$el.trigger('smartselect:closed'); + ss.emit('local::closed smartSelectClosed', ss); + }; + + _proto.openPage = function openPage() { + var ss = this; + if (ss.opened) return ss; + ss.getItemsData(); + var pageHtml = ss.renderPage(ss.items); + ss.view.router.navigate({ + url: ss.url, + route: { + content: pageHtml, + path: ss.url, + on: { + pageBeforeIn: function pageBeforeIn(e, page) { + ss.onOpen('page', page.el); + }, + pageAfterIn: function pageAfterIn(e, page) { + ss.onOpened('page', page.el); + }, + pageBeforeOut: function pageBeforeOut(e, page) { + ss.onClose('page', page.el); + }, + pageAfterOut: function pageAfterOut(e, page) { + ss.onClosed('page', page.el); + } + } + } + }); + return ss; + }; + + _proto.openPopup = function openPopup() { + var ss = this; + if (ss.opened) return ss; + ss.getItemsData(); + var popupHtml = ss.renderPopup(ss.items); + var popupParams = { + content: popupHtml, + push: ss.params.popupPush, + swipeToClose: ss.params.popupSwipeToClose, + on: { + popupOpen: function popupOpen(popup) { + ss.onOpen('popup', popup.el); + }, + popupOpened: function popupOpened(popup) { + ss.onOpened('popup', popup.el); + }, + popupClose: function popupClose(popup) { + ss.onClose('popup', popup.el); + }, + popupClosed: function popupClosed(popup) { + ss.onClosed('popup', popup.el); + } + } + }; + + if (ss.params.routableModals && ss.view) { + ss.view.router.navigate({ + url: ss.url, + route: { + path: ss.url, + popup: popupParams + } + }); + } else { + ss.modal = ss.app.popup.create(popupParams).open(); + } + + return ss; + }; + + _proto.openSheet = function openSheet() { + var ss = this; + if (ss.opened) return ss; + ss.getItemsData(); + var sheetHtml = ss.renderSheet(ss.items); + var sheetParams = { + content: sheetHtml, + backdrop: ss.params.sheetBackdrop, + scrollToEl: ss.$el, + closeByOutsideClick: true, + push: ss.params.sheetPush, + swipeToClose: ss.params.sheetSwipeToClose, + on: { + sheetOpen: function sheetOpen(sheet) { + ss.onOpen('sheet', sheet.el); + }, + sheetOpened: function sheetOpened(sheet) { + ss.onOpened('sheet', sheet.el); + }, + sheetClose: function sheetClose(sheet) { + ss.onClose('sheet', sheet.el); + }, + sheetClosed: function sheetClosed(sheet) { + ss.onClosed('sheet', sheet.el); + } + } + }; + + if (ss.params.routableModals && ss.view) { + ss.view.router.navigate({ + url: ss.url, + route: { + path: ss.url, + sheet: sheetParams + } + }); + } else { + ss.modal = ss.app.sheet.create(sheetParams).open(); + } + + return ss; + }; + + _proto.openPopover = function openPopover() { + var ss = this; + if (ss.opened) return ss; + ss.getItemsData(); + var popoverHtml = ss.renderPopover(ss.items); + var popoverParams = { + content: popoverHtml, + targetEl: ss.$el, + on: { + popoverOpen: function popoverOpen(popover) { + ss.onOpen('popover', popover.el); + }, + popoverOpened: function popoverOpened(popover) { + ss.onOpened('popover', popover.el); + }, + popoverClose: function popoverClose(popover) { + ss.onClose('popover', popover.el); + }, + popoverClosed: function popoverClosed(popover) { + ss.onClosed('popover', popover.el); + } + } + }; + + if (ss.params.routableModals && ss.view) { + ss.view.router.navigate({ + url: ss.url, + route: { + path: ss.url, + popover: popoverParams + } + }); + } else { + ss.modal = ss.app.popover.create(popoverParams).open(); + } + + return ss; + }; + + _proto.open = function open(type) { + var ss = this; + if (ss.opened) return ss; + var prevented = false; + + function prevent() { + prevented = true; + } + + if (ss.$el) { + ss.$el.trigger('smartselect:beforeopen', { + prevent: prevent + }); + } + + ss.emit('local::beforeOpen smartSelectBeforeOpen', ss, prevent); + if (prevented) return ss; + var openIn = type || ss.params.openIn; + ss["open" + openIn.split('').map(function (el, index) { + if (index === 0) return el.toUpperCase(); + return el; + }).join('')](); + return ss; + }; + + _proto.close = function close() { + var ss = this; + if (!ss.opened) return ss; + + if (ss.params.routableModals && ss.view || ss.openedIn === 'page') { + ss.view.router.back(); + } else { + ss.modal.once('modalClosed', function () { + (0, _utils.nextTick)(function () { + if (ss.destroyed) return; + ss.modal.destroy(); + delete ss.modal; + }); + }); + ss.modal.close(); + } + + return ss; + }; + + _proto.init = function init() { + var ss = this; + ss.attachEvents(); + ss.setValueText(); + }; + + _proto.destroy = function destroy() { + var ss = this; + ss.emit('local::beforeDestroy smartSelectBeforeDestroy', ss); + ss.$el.trigger('smartselect:beforedestroy'); + ss.detachEvents(); + delete ss.$el[0].f7SmartSelect; + (0, _utils.deleteProps)(ss); + ss.destroyed = true; + }; + + _createClass(SmartSelect, [{ + key: "view", + get: function get() { + var params = this.params, + $el = this.$el; + var view; + + if (params.view) { + view = params.view; + } + + if (!view) { + view = $el.parents('.view').length && $el.parents('.view')[0].f7View; + } + + if (!view && params.openIn === 'page') { + throw Error('Smart Select requires initialized View'); + } + + return view; + } + }]); + + return SmartSelect; +}(_class.default); + +var _default = SmartSelect; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/smart-select/smart-select.js b/www/assets/framework7/cjs/components/smart-select/smart-select.js new file mode 100644 index 000000000..01105e3c1 --- /dev/null +++ b/www/assets/framework7/cjs/components/smart-select/smart-select.js @@ -0,0 +1,151 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _smartSelectClass = _interopRequireDefault(require("./smart-select-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'smartSelect', + params: { + smartSelect: { + el: undefined, + valueEl: undefined, + setValueText: true, + formatValueText: null, + openIn: 'page', + // or 'popup' or 'sheet' or 'popover' + popupPush: false, + popupSwipeToClose: undefined, + // defaults to app + sheetPush: false, + sheetSwipeToClose: undefined, + // defaults to app + sheetBackdrop: false, + pageTitle: undefined, + pageBackLinkText: 'Back', + popupCloseLinkText: 'Close', + popupTabletFullscreen: false, + sheetCloseLinkText: 'Done', + searchbar: false, + searchbarPlaceholder: 'Search', + searchbarDisableText: 'Cancel', + searchbarDisableButton: undefined, + searchbarSpellcheck: false, + closeOnSelect: false, + virtualList: false, + virtualListHeight: undefined, + scrollToSelectedItem: false, + formColorTheme: undefined, + navbarColorTheme: undefined, + routableModals: false, + url: 'select/', + cssClass: '', + + /* + Custom render functions + */ + renderPage: undefined, + renderPopup: undefined, + renderSheet: undefined, + renderPopover: undefined, + renderItems: undefined, + renderItem: undefined, + renderSearchbar: undefined + } + }, + static: { + SmartSelect: _smartSelectClass.default + }, + create: function create() { + var app = this; + app.smartSelect = (0, _utils.extend)((0, _constructorMethods.default)({ + defaultSelector: '.smart-select', + constructor: _smartSelectClass.default, + app: app, + domProp: 'f7SmartSelect' + }), { + open: function open(smartSelectEl) { + var ss = app.smartSelect.get(smartSelectEl); + if (ss && ss.open) return ss.open(); + return undefined; + }, + close: function close(smartSelectEl) { + var ss = app.smartSelect.get(smartSelectEl); + if (ss && ss.close) return ss.close(); + return undefined; + } + }); + }, + on: { + tabMounted: function tabMounted(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.smart-select-init').each(function (smartSelectEl) { + app.smartSelect.create((0, _utils.extend)({ + el: smartSelectEl + }, (0, _dom.default)(smartSelectEl).dataset())); + }); + }, + tabBeforeRemove: function tabBeforeRemove(tabEl) { + (0, _dom.default)(tabEl).find('.smart-select-init').each(function (smartSelectEl) { + if (smartSelectEl.f7SmartSelect && smartSelectEl.f7SmartSelect.destroy) { + smartSelectEl.f7SmartSelect.destroy(); + } + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.smart-select-init').each(function (smartSelectEl) { + app.smartSelect.create((0, _utils.extend)({ + el: smartSelectEl + }, (0, _dom.default)(smartSelectEl).dataset())); + }); + }, + pageBeforeRemove: function pageBeforeRemove(page) { + page.$el.find('.smart-select-init').each(function (smartSelectEl) { + if (smartSelectEl.f7SmartSelect && smartSelectEl.f7SmartSelect.destroy) { + smartSelectEl.f7SmartSelect.destroy(); + } + }); + } + }, + clicks: { + '.smart-select': function open($clickedEl, data) { + var app = this; + + if (!$clickedEl[0].f7SmartSelect) { + var ss = app.smartSelect.create((0, _utils.extend)({ + el: $clickedEl + }, data)); + ss.open(); + } + } + }, + vnode: { + 'smart-select-init': { + insert: function insert(vnode) { + var app = this; + var smartSelectEl = vnode.elm; + app.smartSelect.create((0, _utils.extend)({ + el: smartSelectEl + }, (0, _dom.default)(smartSelectEl).dataset())); + }, + destroy: function destroy(vnode) { + var smartSelectEl = vnode.elm; + + if (smartSelectEl.f7SmartSelect && smartSelectEl.f7SmartSelect.destroy) { + smartSelectEl.f7SmartSelect.destroy(); + } + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/sortable/sortable.js b/www/assets/framework7/cjs/components/sortable/sortable.js new file mode 100644 index 000000000..b263519e5 --- /dev/null +++ b/www/assets/framework7/cjs/components/sortable/sortable.js @@ -0,0 +1,335 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _getSupport = require("../../shared/get-support"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Sortable = { + init: function init() { + var app = this; + var document = (0, _ssrWindow.getDocument)(); + var isTouched; + var isMoved; + var touchStartY; + var touchesDiff; + var $sortingEl; + var $sortingItems; + var $sortableContainer; + var sortingElHeight; + var minTop; + var maxTop; + var $insertAfterEl; + var $insertBeforeEl; + var indexFrom; + var $pageEl; + var $pageContentEl; + var pageHeight; + var pageOffset; + var sortingElOffsetLocal; + var sortingElOffsetTop; + var initialScrollTop; + var wasTapHold; + + function handleTouchStart(e, isTapHold) { + isMoved = false; + isTouched = true; + wasTapHold = false; + touchStartY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + $sortingEl = (0, _dom.default)(e.target).closest('li').eq(0); + indexFrom = $sortingEl.index(); + $sortableContainer = $sortingEl.parents('.sortable'); + var $listGroup = $sortingEl.parents('.list-group'); + + if ($listGroup.length && $listGroup.parents($sortableContainer).length) { + $sortableContainer = $listGroup; + } + + $sortingItems = $sortableContainer.children('ul').children('li:not(.disallow-sorting):not(.no-sorting)'); + if (app.panel) app.panel.allowOpen = false; + if (app.swipeout) app.swipeout.allow = false; + + if (isTapHold) { + $sortingEl.addClass('sorting'); + $sortableContainer.addClass('sortable-sorting'); + wasTapHold = true; + } + } + + function handleTouchMove(e) { + if (!isTouched || !$sortingEl) return; + var pageY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; + + if (!isMoved) { + $pageEl = $sortingEl.parents('.page'); + $pageContentEl = $sortingEl.parents('.page-content'); + var paddingTop = parseInt($pageContentEl.css('padding-top'), 10); + var paddingBottom = parseInt($pageContentEl.css('padding-bottom'), 10); + initialScrollTop = $pageContentEl[0].scrollTop; + pageOffset = $pageEl.offset().top + paddingTop; + pageHeight = $pageEl.height() - paddingTop - paddingBottom; + $sortingEl.addClass('sorting'); + $sortableContainer.addClass('sortable-sorting'); + sortingElOffsetLocal = $sortingEl[0].offsetTop; + minTop = $sortingEl[0].offsetTop; + maxTop = $sortingEl.parent().height() - sortingElOffsetLocal - $sortingEl.height(); + sortingElHeight = $sortingEl[0].offsetHeight; + sortingElOffsetTop = $sortingEl.offset().top; + } + + isMoved = true; + e.preventDefault(); + e.f7PreventSwipePanel = true; + touchesDiff = pageY - touchStartY; + var translateScrollOffset = $pageContentEl[0].scrollTop - initialScrollTop; + var translate = Math.min(Math.max(touchesDiff + translateScrollOffset, -minTop), maxTop); + $sortingEl.transform("translate3d(0," + translate + "px,0)"); + var scrollAddition = 44; + var allowScroll = true; + + if (touchesDiff + translateScrollOffset + scrollAddition < -minTop) { + allowScroll = false; + } + + if (touchesDiff + translateScrollOffset - scrollAddition > maxTop) { + allowScroll = false; + } + + $insertBeforeEl = undefined; + $insertAfterEl = undefined; + var scrollDiff; + + if (allowScroll) { + if (sortingElOffsetTop + touchesDiff + sortingElHeight + scrollAddition > pageOffset + pageHeight) { + // To Bottom + scrollDiff = sortingElOffsetTop + touchesDiff + sortingElHeight + scrollAddition - (pageOffset + pageHeight); + } + + if (sortingElOffsetTop + touchesDiff < pageOffset + scrollAddition) { + // To Top + scrollDiff = sortingElOffsetTop + touchesDiff - pageOffset - scrollAddition; + } + + if (scrollDiff) { + $pageContentEl[0].scrollTop += scrollDiff; + } + } + + $sortingItems.each(function (el) { + var $currentEl = (0, _dom.default)(el); + if ($currentEl[0] === $sortingEl[0]) return; + var currentElOffset = $currentEl[0].offsetTop; + var currentElHeight = $currentEl.height(); + var sortingElOffset = sortingElOffsetLocal + translate; + var currentTranslate; + var prevTranslate = $currentEl[0].f7Translate; + + if (sortingElOffset >= currentElOffset - currentElHeight / 2 && $sortingEl.index() < $currentEl.index()) { + currentTranslate = -sortingElHeight; + $currentEl.transform("translate3d(0, " + currentTranslate + "px,0)"); + $insertAfterEl = $currentEl; + $insertBeforeEl = undefined; + } else if (sortingElOffset <= currentElOffset + currentElHeight / 2 && $sortingEl.index() > $currentEl.index()) { + currentTranslate = sortingElHeight; + $currentEl[0].f7Translate = currentTranslate; + $currentEl.transform("translate3d(0, " + currentTranslate + "px,0)"); + $insertAfterEl = undefined; + if (!$insertBeforeEl) $insertBeforeEl = $currentEl; + } else { + currentTranslate = undefined; + $currentEl.transform('translate3d(0, 0%,0)'); + } + + if (prevTranslate !== currentTranslate) { + $currentEl.trigger('sortable:move'); + app.emit('sortableMove', $currentEl[0], $sortableContainer[0]); + } + + $currentEl[0].f7Translate = currentTranslate; + }); + } + + function handleTouchEnd() { + if (!isTouched || !isMoved) { + if (isTouched && !isMoved) { + if (app.panel) app.panel.allowOpen = true; + if (app.swipeout) app.swipeout.allow = true; + + if (wasTapHold) { + $sortingEl.removeClass('sorting'); + $sortableContainer.removeClass('sortable-sorting'); + } + } + + isTouched = false; + isMoved = false; + return; + } + + if (app.panel) app.panel.allowOpen = true; + if (app.swipeout) app.swipeout.allow = true; + $sortingItems.transform(''); + $sortingEl.removeClass('sorting'); + $sortableContainer.removeClass('sortable-sorting'); + var indexTo; + if ($insertAfterEl) indexTo = $insertAfterEl.index();else if ($insertBeforeEl) indexTo = $insertBeforeEl.index(); + var moveElements = $sortableContainer.dataset().sortableMoveElements; + + if (typeof moveElements === 'undefined') { + moveElements = app.params.sortable.moveElements; + } + + if (moveElements) { + if ($insertAfterEl) { + $sortingEl.insertAfter($insertAfterEl); + } + + if ($insertBeforeEl) { + $sortingEl.insertBefore($insertBeforeEl); + } + } + + if (($insertAfterEl || $insertBeforeEl) && $sortableContainer.hasClass('virtual-list')) { + indexFrom = $sortingEl[0].f7VirtualListIndex; + if (typeof indexFrom === 'undefined') indexFrom = $sortingEl.attr('data-virtual-list-index'); + + if ($insertBeforeEl) { + indexTo = $insertBeforeEl[0].f7VirtualListIndex; + if (typeof indexTo === 'undefined') indexTo = $insertBeforeEl.attr('data-virtual-list-index'); + } else { + indexTo = $insertAfterEl[0].f7VirtualListIndex; + if (typeof indexTo === 'undefined') indexTo = $insertAfterEl.attr('data-virtual-list-index'); + } + + if (indexTo !== null) indexTo = parseInt(indexTo, 10);else indexTo = undefined; + var virtualList = $sortableContainer[0].f7VirtualList; + if (indexFrom) indexFrom = parseInt(indexFrom, 10); + if (indexTo) indexTo = parseInt(indexTo, 10); + if (virtualList) virtualList.moveItem(indexFrom, indexTo); + } + + if (typeof indexTo !== 'undefined' && !Number.isNaN(indexTo) && indexTo !== indexFrom) { + $sortingEl.trigger('sortable:sort', { + from: indexFrom, + to: indexTo + }); + app.emit('sortableSort', $sortingEl[0], { + from: indexFrom, + to: indexTo, + el: $sortingEl[0] + }, $sortableContainer[0]); + } + + $insertBeforeEl = undefined; + $insertAfterEl = undefined; + isTouched = false; + isMoved = false; + } + + var activeListener = (0, _getSupport.getSupport)().passiveListener ? { + passive: false, + capture: false + } : false; + (0, _dom.default)(document).on(app.touchEvents.start, '.list.sortable .sortable-handler', handleTouchStart, activeListener); + app.on('touchmove:active', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + (0, _dom.default)(document).on('taphold', '.sortable-tap-hold', function (e, pointerEvent) { + handleTouchStart(pointerEvent, true); + }); + }, + enable: function enable(el) { + if (el === void 0) { + el = '.list.sortable'; + } + + var app = this; + var $el = (0, _dom.default)(el); + if ($el.length === 0) return; + $el.addClass('sortable-enabled'); + $el.trigger('sortable:enable'); + app.emit('sortableEnable', $el[0]); + }, + disable: function disable(el) { + if (el === void 0) { + el = '.list.sortable'; + } + + var app = this; + var $el = (0, _dom.default)(el); + if ($el.length === 0) return; + $el.removeClass('sortable-enabled'); + $el.trigger('sortable:disable'); + app.emit('sortableDisable', $el[0]); + }, + toggle: function toggle(el) { + if (el === void 0) { + el = '.list.sortable'; + } + + var app = this; + var $el = (0, _dom.default)(el); + if ($el.length === 0) return; + + if ($el.hasClass('sortable-enabled')) { + app.sortable.disable($el); + } else { + app.sortable.enable($el); + } + } +}; +var _default = { + name: 'sortable', + params: { + sortable: { + moveElements: true + } + }, + create: function create() { + var app = this; + (0, _utils.bindMethods)(app, { + sortable: Sortable + }); + }, + on: { + init: function init() { + var app = this; + if (!app.params.sortable) return; + app.sortable.init(); + } + }, + clicks: { + '.sortable-enable': function enable($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.sortable.enable(data.sortable); + }, + '.sortable-disable': function disable($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.sortable.disable(data.sortable); + }, + '.sortable-toggle': function toggle($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.sortable.toggle(data.sortable); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/statusbar/statusbar.js b/www/assets/framework7/cjs/components/statusbar/statusbar.js new file mode 100644 index 000000000..7bad9e388 --- /dev/null +++ b/www/assets/framework7/cjs/components/statusbar/statusbar.js @@ -0,0 +1,226 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _getDevice = require("../../shared/get-device"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var isCapacitor = function isCapacitor() { + var window = (0, _ssrWindow.getWindow)(); + return window.Capacitor && window.Capacitor.isNative && window.Capacitor.Plugins && window.Capacitor.Plugins.StatusBar; +}; + +var Statusbar = { + hide: function hide() { + var window = (0, _ssrWindow.getWindow)(); + var device = (0, _getDevice.getDevice)(); + + if (device.cordova && window.StatusBar) { + window.StatusBar.hide(); + } + + if (isCapacitor()) { + window.Capacitor.Plugins.StatusBar.hide(); + } + }, + show: function show() { + var window = (0, _ssrWindow.getWindow)(); + var device = (0, _getDevice.getDevice)(); + + if (device.cordova && window.StatusBar) { + window.StatusBar.show(); + } + + if (isCapacitor()) { + window.Capacitor.Plugins.StatusBar.show(); + } + }, + onClick: function onClick() { + var app = this; + var pageContent; + + if ((0, _dom.default)('.popup.modal-in').length > 0) { + // Check for opened popup + pageContent = (0, _dom.default)('.popup.modal-in').find('.page:not(.page-previous):not(.page-next):not(.cached)').find('.page-content'); + } else if ((0, _dom.default)('.panel.panel-in').length > 0) { + // Check for opened panel + pageContent = (0, _dom.default)('.panel.panel-in').find('.page:not(.page-previous):not(.page-next):not(.cached)').find('.page-content'); + } else if ((0, _dom.default)('.views > .view.tab-active').length > 0) { + // View in tab bar app layout + pageContent = (0, _dom.default)('.views > .view.tab-active').find('.page:not(.page-previous):not(.page-next):not(.cached)').find('.page-content'); + } else if ((0, _dom.default)('.views').length > 0) { + pageContent = (0, _dom.default)('.views').find('.page:not(.page-previous):not(.page-next):not(.cached)').find('.page-content'); + } else { + pageContent = app.$el.children('.view').find('.page:not(.page-previous):not(.page-next):not(.cached)').find('.page-content'); + } + + if (pageContent && pageContent.length > 0) { + // Check for tab + if (pageContent.hasClass('tab')) { + pageContent = pageContent.parent('.tabs').children('.page-content.tab-active'); + } + + if (pageContent.length > 0) pageContent.scrollTop(0, 300); + } + }, + setTextColor: function setTextColor(color) { + var window = (0, _ssrWindow.getWindow)(); + var device = (0, _getDevice.getDevice)(); + + if (device.cordova && window.StatusBar) { + if (color === 'white') { + window.StatusBar.styleLightContent(); + } else { + window.StatusBar.styleDefault(); + } + } + + if (isCapacitor()) { + if (color === 'white') { + window.Capacitor.Plugins.StatusBar.setStyle({ + style: 'DARK' + }); + } else { + window.Capacitor.Plugins.StatusBar.setStyle({ + style: 'LIGHT' + }); + } + } + }, + setBackgroundColor: function setBackgroundColor(color) { + var window = (0, _ssrWindow.getWindow)(); + var device = (0, _getDevice.getDevice)(); + + if (device.cordova && window.StatusBar) { + window.StatusBar.backgroundColorByHexString(color); + } + + if (isCapacitor()) { + window.Capacitor.Plugins.StatusBar.setBackgroundColor({ + color: color + }); + } + }, + isVisible: function isVisible() { + var window = (0, _ssrWindow.getWindow)(); + var device = (0, _getDevice.getDevice)(); + return new Promise(function (resolve) { + if (device.cordova && window.StatusBar) { + resolve(window.StatusBar.isVisible); + } + + if (isCapacitor()) { + window.Capacitor.Plugins.StatusBar.getInfo().then(function (info) { + resolve(info.visible); + }); + } + + resolve(false); + }); + }, + overlaysWebView: function overlaysWebView(overlays) { + if (overlays === void 0) { + overlays = true; + } + + var window = (0, _ssrWindow.getWindow)(); + var device = (0, _getDevice.getDevice)(); + + if (device.cordova && window.StatusBar) { + window.StatusBar.overlaysWebView(overlays); + } + + if (isCapacitor()) { + window.Capacitor.Plugins.StatusBar.setOverlaysWebView({ + overlay: overlays + }); + } + }, + init: function init() { + var app = this; + var window = (0, _ssrWindow.getWindow)(); + var device = (0, _getDevice.getDevice)(); + var params = app.params.statusbar; + if (!params.enabled) return; + var isCordova = device.cordova && window.StatusBar; + var isCap = isCapacitor(); + + if (isCordova || isCap) { + if (params.scrollTopOnClick) { + (0, _dom.default)(window).on('statusTap', Statusbar.onClick.bind(app)); + } + + if (device.ios) { + if (params.iosOverlaysWebView) { + Statusbar.overlaysWebView(true); + } else { + Statusbar.overlaysWebView(false); + } + + if (params.iosTextColor === 'white') { + Statusbar.setTextColor('white'); + } else { + Statusbar.setTextColor('black'); + } + } + + if (device.android) { + if (params.androidOverlaysWebView) { + Statusbar.overlaysWebView(true); + } else { + Statusbar.overlaysWebView(false); + } + + if (params.androidTextColor === 'white') { + Statusbar.setTextColor('white'); + } else { + Statusbar.setTextColor('black'); + } + } + } + + if (params.iosBackgroundColor && device.ios) { + Statusbar.setBackgroundColor(params.iosBackgroundColor); + } + + if (params.androidBackgroundColor && device.android) { + Statusbar.setBackgroundColor(params.androidBackgroundColor); + } + } +}; +var _default = { + name: 'statusbar', + params: { + statusbar: { + enabled: true, + scrollTopOnClick: true, + iosOverlaysWebView: true, + iosTextColor: 'black', + iosBackgroundColor: null, + androidOverlaysWebView: false, + androidTextColor: 'black', + androidBackgroundColor: null + } + }, + create: function create() { + var app = this; + (0, _utils.bindMethods)(app, { + statusbar: Statusbar + }); + }, + on: { + init: function init() { + var app = this; + Statusbar.init.call(app); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/stepper/stepper-class.js b/www/assets/framework7/cjs/components/stepper/stepper-class.js new file mode 100644 index 000000000..ab053259b --- /dev/null +++ b/www/assets/framework7/cjs/components/stepper/stepper-class.js @@ -0,0 +1,497 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Stepper = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(Stepper, _Framework7Class); + + function Stepper(app, params) { + var _this; + + _this = _Framework7Class.call(this, params, [app]) || this; + + var stepper = _assertThisInitialized(_this); + + var defaults = { + el: null, + inputEl: null, + valueEl: null, + value: 0, + formatValue: null, + step: 1, + min: 0, + max: 100, + watchInput: true, + autorepeat: false, + autorepeatDynamic: false, + wraps: false, + manualInputMode: false, + decimalPoint: 4, + buttonsEndInputMode: true + }; // Extend defaults with modules params + + stepper.useModulesParams(defaults); + stepper.params = (0, _utils.extend)(defaults, params); + + if (stepper.params.value < stepper.params.min) { + stepper.params.value = stepper.params.min; + } + + if (stepper.params.value > stepper.params.max) { + stepper.params.value = stepper.params.max; + } + + var el = stepper.params.el; + if (!el) return stepper || _assertThisInitialized(_this); + var $el = (0, _dom.default)(el); + if ($el.length === 0) return stepper || _assertThisInitialized(_this); + if ($el[0].f7Stepper) return $el[0].f7Stepper || _assertThisInitialized(_this); + var $inputEl; + + if (stepper.params.inputEl) { + $inputEl = (0, _dom.default)(stepper.params.inputEl); + } else if ($el.find('.stepper-input-wrap').find('input, textarea').length) { + $inputEl = $el.find('.stepper-input-wrap').find('input, textarea').eq(0); + } + + if ($inputEl && $inputEl.length) { + 'step min max'.split(' ').forEach(function (paramName) { + if (!params[paramName] && $inputEl.attr(paramName)) { + stepper.params[paramName] = parseFloat($inputEl.attr(paramName)); + } + }); + + var _decimalPoint = parseInt(stepper.params.decimalPoint, 10); + + if (Number.isNaN(_decimalPoint)) { + stepper.params.decimalPoint = 0; + } else { + stepper.params.decimalPoint = _decimalPoint; + } + + var inputValue = parseFloat($inputEl.val()); + + if (typeof params.value === 'undefined' && !Number.isNaN(inputValue) && (inputValue || inputValue === 0)) { + stepper.params.value = inputValue; + } + } + + var $valueEl; + + if (stepper.params.valueEl) { + $valueEl = (0, _dom.default)(stepper.params.valueEl); + } else if ($el.find('.stepper-value').length) { + $valueEl = $el.find('.stepper-value').eq(0); + } + + var $buttonPlusEl = $el.find('.stepper-button-plus'); + var $buttonMinusEl = $el.find('.stepper-button-minus'); + var _stepper$params = stepper.params, + step = _stepper$params.step, + min = _stepper$params.min, + max = _stepper$params.max, + value = _stepper$params.value, + decimalPoint = _stepper$params.decimalPoint; + (0, _utils.extend)(stepper, { + app: app, + $el: $el, + el: $el[0], + $buttonPlusEl: $buttonPlusEl, + buttonPlusEl: $buttonPlusEl[0], + $buttonMinusEl: $buttonMinusEl, + buttonMinusEl: $buttonMinusEl[0], + $inputEl: $inputEl, + inputEl: $inputEl ? $inputEl[0] : undefined, + $valueEl: $valueEl, + valueEl: $valueEl ? $valueEl[0] : undefined, + step: step, + min: min, + max: max, + value: value, + decimalPoint: decimalPoint, + typeModeChanged: false + }); + $el[0].f7Stepper = stepper; // Handle Events + + var touchesStart = {}; + var isTouched; + var isScrolling; + var preventButtonClick; + var intervalId; + var timeoutId; + var autorepeatAction = null; + var autorepeatInAction = false; + var manualInput = false; + + function dynamicRepeat(current, progressions, startsIn, progressionStep, repeatEvery, action) { + clearTimeout(timeoutId); + timeoutId = setTimeout(function () { + if (current === 1) { + preventButtonClick = true; + autorepeatInAction = true; + } + + clearInterval(intervalId); + action(); + intervalId = setInterval(function () { + action(); + }, repeatEvery); + + if (current < progressions) { + dynamicRepeat(current + 1, progressions, startsIn, progressionStep, repeatEvery / 2, action); + } + }, current === 1 ? startsIn : progressionStep); + } + + function onTouchStart(e) { + if (isTouched) return; + + if (manualInput) { + return; + } + + if ((0, _dom.default)(e.target).closest($buttonPlusEl).length) { + autorepeatAction = 'increment'; + } else if ((0, _dom.default)(e.target).closest($buttonMinusEl).length) { + autorepeatAction = 'decrement'; + } + + if (!autorepeatAction) return; + touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; + touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + isTouched = true; + isScrolling = undefined; + var progressions = stepper.params.autorepeatDynamic ? 4 : 1; + dynamicRepeat(1, progressions, 500, 1000, 300, function () { + stepper[autorepeatAction](); + }); + } + + function onTouchMove(e) { + if (!isTouched) return; + + if (manualInput) { + return; + } + + var pageX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; + var pageY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; + + if (typeof isScrolling === 'undefined' && !autorepeatInAction) { + isScrolling = !!(isScrolling || Math.abs(pageY - touchesStart.y) > Math.abs(pageX - touchesStart.x)); + } + + var distance = Math.pow(Math.pow(pageX - touchesStart.x, 2) + Math.pow(pageY - touchesStart.y, 2), 0.5); + + if (isScrolling || distance > 20) { + isTouched = false; + clearTimeout(timeoutId); + clearInterval(intervalId); + } + } + + function onTouchEnd() { + clearTimeout(timeoutId); + clearInterval(intervalId); + autorepeatAction = null; + autorepeatInAction = false; + isTouched = false; + } + + function onMinusClick() { + if (manualInput) { + if (stepper.params.buttonsEndInputMode) { + manualInput = false; + stepper.endTypeMode(true); + } + + return; + } + + if (preventButtonClick) { + preventButtonClick = false; + return; + } + + stepper.decrement(true); + } + + function onPlusClick() { + if (manualInput) { + if (stepper.params.buttonsEndInputMode) { + manualInput = false; + stepper.endTypeMode(true); + } + + return; + } + + if (preventButtonClick) { + preventButtonClick = false; + return; + } + + stepper.increment(true); + } + + function onInputClick(e) { + if (!e.target.readOnly && stepper.params.manualInputMode) { + manualInput = true; + + if (typeof e.target.selectionStart === 'number') { + e.target.selectionStart = e.target.value.length; + e.target.selectionEnd = e.target.value.length; + } + } + } + + function onInputKey(e) { + if (e.keyCode === 13 || e.which === 13) { + e.preventDefault(); + manualInput = false; + stepper.endTypeMode(); + } + } + + function onInputBlur() { + manualInput = false; + stepper.endTypeMode(true); + } + + function onInput(e) { + if (manualInput) { + stepper.typeValue(e.target.value); + return; + } + + if (e.detail && e.detail.sentByF7Stepper) return; + stepper.setValue(e.target.value, true); + } + + stepper.attachEvents = function attachEvents() { + $buttonMinusEl.on('click', onMinusClick); + $buttonPlusEl.on('click', onPlusClick); + + if (stepper.params.watchInput && $inputEl && $inputEl.length) { + $inputEl.on('input', onInput); + $inputEl.on('click', onInputClick); + $inputEl.on('blur', onInputBlur); + $inputEl.on('keyup', onInputKey); + } + + if (stepper.params.autorepeat) { + app.on('touchstart:passive', onTouchStart); + app.on('touchmove:active', onTouchMove); + app.on('touchend:passive', onTouchEnd); + } + }; + + stepper.detachEvents = function detachEvents() { + $buttonMinusEl.off('click', onMinusClick); + $buttonPlusEl.off('click', onPlusClick); + + if (stepper.params.watchInput && $inputEl && $inputEl.length) { + $inputEl.off('input', onInput); + $inputEl.off('click', onInputClick); + $inputEl.off('blur', onInputBlur); + $inputEl.off('keyup', onInputKey); + } + }; // Install Modules + + + stepper.useModules(); // Init + + stepper.init(); + return stepper || _assertThisInitialized(_this); + } + + var _proto = Stepper.prototype; + + _proto.minus = function minus() { + return this.decrement(); + }; + + _proto.plus = function plus() { + return this.increment(); + }; + + _proto.decrement = function decrement() { + var stepper = this; + return stepper.setValue(stepper.value - stepper.step, false, true); + }; + + _proto.increment = function increment() { + var stepper = this; + return stepper.setValue(stepper.value + stepper.step, false, true); + }; + + _proto.setValue = function setValue(newValue, forceUpdate, withWraps) { + var stepper = this; + var step = stepper.step, + min = stepper.min, + max = stepper.max; + var oldValue = stepper.value; + var value = Math.round(newValue / step) * step; + + if (stepper.params.wraps && withWraps) { + if (value > max) value = min; + if (value < min) value = max; + } else { + value = Math.max(Math.min(value, max), min); + } + + if (Number.isNaN(value)) { + value = oldValue; + } + + stepper.value = value; + var valueChanged = oldValue !== value; // Events + + if (!valueChanged && !forceUpdate) return stepper; + stepper.$el.trigger('stepper:change', stepper.value); + var formattedValue = stepper.formatValue(stepper.value); + + if (stepper.$inputEl && stepper.$inputEl.length) { + stepper.$inputEl.val(formattedValue); + stepper.$inputEl.trigger('input change', { + sentByF7Stepper: true + }); + } + + if (stepper.$valueEl && stepper.$valueEl.length) { + stepper.$valueEl.html(formattedValue); + } + + stepper.emit('local::change stepperChange', stepper, stepper.value); + return stepper; + }; + + _proto.endTypeMode = function endTypeMode(noBlur) { + var stepper = this; + var min = stepper.min, + max = stepper.max; + var value = parseFloat(stepper.value); + if (Number.isNaN(value)) value = 0; + value = Math.max(Math.min(value, max), min); + stepper.value = value; + + if (!stepper.typeModeChanged) { + if (stepper.$inputEl && stepper.$inputEl.length && !noBlur) { + stepper.$inputEl.blur(); + } + + return stepper; + } + + stepper.typeModeChanged = false; + stepper.$el.trigger('stepper:change', stepper.value); + var formattedValue = stepper.formatValue(stepper.value); + + if (stepper.$inputEl && stepper.$inputEl.length) { + stepper.$inputEl.val(formattedValue); + stepper.$inputEl.trigger('input change', { + sentByF7Stepper: true + }); + if (!noBlur) stepper.$inputEl.blur(); + } + + if (stepper.$valueEl && stepper.$valueEl.length) { + stepper.$valueEl.html(formattedValue); + } + + stepper.emit('local::change stepperChange', stepper, stepper.value); + return stepper; + }; + + _proto.typeValue = function typeValue(value) { + var stepper = this; + stepper.typeModeChanged = true; + var inputTxt = String(value); + if (inputTxt.length === 1 && inputTxt === '-') return stepper; + + if (inputTxt.lastIndexOf('.') + 1 === inputTxt.length || inputTxt.lastIndexOf(',') + 1 === inputTxt.length) { + if (inputTxt.lastIndexOf('.') !== inputTxt.indexOf('.') || inputTxt.lastIndexOf(',') !== inputTxt.indexOf(',')) { + inputTxt = inputTxt.slice(0, -1); + stepper.value = inputTxt; + stepper.$inputEl.val(stepper.value); + return stepper; + } + } else { + var newValue = parseFloat(inputTxt.replace(',', '.')); + + if (newValue === 0) { + stepper.value = inputTxt.replace(',', '.'); + stepper.$inputEl.val(stepper.value); + return stepper; + } + + if (Number.isNaN(newValue)) { + stepper.value = 0; + stepper.$inputEl.val(stepper.value); + return stepper; + } + + var powVal = Math.pow(10, stepper.params.decimalPoint); + newValue = Math.round(newValue * powVal).toFixed(stepper.params.decimalPoint + 1) / powVal; + stepper.value = parseFloat(String(newValue).replace(',', '.')); + stepper.$inputEl.val(stepper.value); + return stepper; + } + + stepper.value = inputTxt; + stepper.$inputEl.val(inputTxt); + return stepper; + }; + + _proto.getValue = function getValue() { + return this.value; + }; + + _proto.formatValue = function formatValue(value) { + var stepper = this; + if (!stepper.params.formatValue) return value; + return stepper.params.formatValue.call(stepper, value); + }; + + _proto.init = function init() { + var stepper = this; + stepper.attachEvents(); + + if (stepper.$valueEl && stepper.$valueEl.length) { + var formattedValue = stepper.formatValue(stepper.value); + stepper.$valueEl.html(formattedValue); + } + + return stepper; + }; + + _proto.destroy = function destroy() { + var stepper = this; + stepper.$el.trigger('stepper:beforedestroy'); + stepper.emit('local::beforeDestroy stepperBeforeDestroy', stepper); + delete stepper.$el[0].f7Stepper; + stepper.detachEvents(); + (0, _utils.deleteProps)(stepper); + stepper = null; + }; + + return Stepper; +}(_class.default); + +var _default = Stepper; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/stepper/stepper.js b/www/assets/framework7/cjs/components/stepper/stepper.js new file mode 100644 index 000000000..9afdea4db --- /dev/null +++ b/www/assets/framework7/cjs/components/stepper/stepper.js @@ -0,0 +1,96 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _stepperClass = _interopRequireDefault(require("./stepper-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'stepper', + create: function create() { + var app = this; + app.stepper = (0, _utils.extend)((0, _constructorMethods.default)({ + defaultSelector: '.stepper', + constructor: _stepperClass.default, + app: app, + domProp: 'f7Stepper' + }), { + getValue: function getValue(el) { + if (el === void 0) { + el = '.stepper'; + } + + var stepper = app.stepper.get(el); + if (stepper) return stepper.getValue(); + return undefined; + }, + setValue: function setValue(el, value) { + if (el === void 0) { + el = '.stepper'; + } + + var stepper = app.stepper.get(el); + if (stepper) return stepper.setValue(value); + return undefined; + } + }); + }, + static: { + Stepper: _stepperClass.default + }, + on: { + tabMounted: function tabMounted(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.stepper-init').each(function (stepperEl) { + var dataset = (0, _dom.default)(stepperEl).dataset(); + app.stepper.create((0, _utils.extend)({ + el: stepperEl + }, dataset || {})); + }); + }, + tabBeforeRemove: function tabBeforeRemove(tabEl) { + (0, _dom.default)(tabEl).find('.stepper-init').each(function (stepperEl) { + if (stepperEl.f7Stepper) stepperEl.f7Stepper.destroy(); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.stepper-init').each(function (stepperEl) { + var dataset = (0, _dom.default)(stepperEl).dataset(); + app.stepper.create((0, _utils.extend)({ + el: stepperEl + }, dataset || {})); + }); + }, + pageBeforeRemove: function pageBeforeRemove(page) { + page.$el.find('.stepper-init').each(function (stepperEl) { + if (stepperEl.f7Stepper) stepperEl.f7Stepper.destroy(); + }); + } + }, + vnode: { + 'stepper-init': { + insert: function insert(vnode) { + var app = this; + var stepperEl = vnode.elm; + var dataset = (0, _dom.default)(stepperEl).dataset(); + app.stepper.create((0, _utils.extend)({ + el: stepperEl + }, dataset || {})); + }, + destroy: function destroy(vnode) { + var stepperEl = vnode.elm; + if (stepperEl.f7Stepper) stepperEl.f7Stepper.destroy(); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/subnavbar/subnavbar.js b/www/assets/framework7/cjs/components/subnavbar/subnavbar.js new file mode 100644 index 000000000..fcdebde57 --- /dev/null +++ b/www/assets/framework7/cjs/components/subnavbar/subnavbar.js @@ -0,0 +1,28 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'subnavbar', + on: { + pageInit: function pageInit(page) { + if (page.$navbarEl && page.$navbarEl.length && page.$navbarEl.find('.subnavbar').length) { + page.$el.addClass('page-with-subnavbar'); + } + + var $innerSubnavbars = page.$el.find('.subnavbar').filter(function (subnavbarEl) { + return (0, _dom.default)(subnavbarEl).parents('.page')[0] === page.$el[0]; + }); + + if ($innerSubnavbars.length) { + page.$el.addClass('page-with-subnavbar'); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/swipeout/swipeout.js b/www/assets/framework7/cjs/components/swipeout/swipeout.js new file mode 100644 index 000000000..07b81b0b3 --- /dev/null +++ b/www/assets/framework7/cjs/components/swipeout/swipeout.js @@ -0,0 +1,618 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _getSupport = require("../../shared/get-support"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Swipeout = { + init: function init() { + var app = this; + var document = (0, _ssrWindow.getDocument)(); + var touchesStart = {}; + var isTouched; + var isMoved; + var isScrolling; + var touchStartTime; + var touchesDiff; + var $swipeoutEl; + var $swipeoutContent; + var $actionsRight; + var $actionsLeft; + var actionsLeftWidth; + var actionsRightWidth; + var translate; + var opened; + var openedActionsSide; + var $leftButtons; + var $rightButtons; + var direction; + var $overswipeLeftButton; + var $overswipeRightButton; + var overswipeLeft; + var overswipeRight; + + function handleTouchStart(e) { + if (!app.swipeout.allow) return; + isMoved = false; + isTouched = true; + isScrolling = undefined; + touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; + touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + touchStartTime = new Date().getTime(); + $swipeoutEl = (0, _dom.default)(this); + } + + function handleTouchMove(e) { + if (!isTouched) return; + var pageX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; + var pageY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; + + if (typeof isScrolling === 'undefined') { + isScrolling = !!(isScrolling || Math.abs(pageY - touchesStart.y) > Math.abs(pageX - touchesStart.x)); + } + + if (isScrolling) { + isTouched = false; + return; + } + + if (!isMoved) { + if ((0, _dom.default)('.list.sortable-opened').length > 0) return; + $swipeoutContent = $swipeoutEl.find('.swipeout-content'); + $actionsRight = $swipeoutEl.find('.swipeout-actions-right'); + $actionsLeft = $swipeoutEl.find('.swipeout-actions-left'); + actionsLeftWidth = null; + actionsRightWidth = null; + $leftButtons = null; + $rightButtons = null; + $overswipeRightButton = null; + $overswipeLeftButton = null; + + if ($actionsLeft.length > 0) { + actionsLeftWidth = $actionsLeft.outerWidth(); + $leftButtons = $actionsLeft.children('a'); + $overswipeLeftButton = $actionsLeft.find('.swipeout-overswipe'); + } + + if ($actionsRight.length > 0) { + actionsRightWidth = $actionsRight.outerWidth(); + $rightButtons = $actionsRight.children('a'); + $overswipeRightButton = $actionsRight.find('.swipeout-overswipe'); + } + + opened = $swipeoutEl.hasClass('swipeout-opened'); + + if (opened) { + openedActionsSide = $swipeoutEl.find('.swipeout-actions-left.swipeout-actions-opened').length > 0 ? 'left' : 'right'; + } + + $swipeoutEl.removeClass('swipeout-transitioning'); + + if (!app.params.swipeout.noFollow) { + $swipeoutEl.find('.swipeout-actions-opened').removeClass('swipeout-actions-opened'); + $swipeoutEl.removeClass('swipeout-opened'); + } + } + + isMoved = true; + + if (e.cancelable) { + e.preventDefault(); + } + + touchesDiff = pageX - touchesStart.x; + translate = touchesDiff; + + if (opened) { + if (openedActionsSide === 'right') translate -= actionsRightWidth;else translate += actionsLeftWidth; + } + + if (translate > 0 && $actionsLeft.length === 0 || translate < 0 && $actionsRight.length === 0) { + if (!opened) { + isTouched = false; + isMoved = false; + $swipeoutContent.transform(''); + + if ($rightButtons && $rightButtons.length > 0) { + $rightButtons.transform(''); + } + + if ($leftButtons && $leftButtons.length > 0) { + $leftButtons.transform(''); + } + + return; + } + + translate = 0; + } + + if (translate < 0) direction = 'to-left';else if (translate > 0) direction = 'to-right';else if (!direction) direction = 'to-left'; + var buttonOffset; + var progress; + e.f7PreventSwipePanel = true; + + if (app.params.swipeout.noFollow) { + if (opened) { + if (openedActionsSide === 'right' && touchesDiff > 0) { + app.swipeout.close($swipeoutEl); + } + + if (openedActionsSide === 'left' && touchesDiff < 0) { + app.swipeout.close($swipeoutEl); + } + } else { + if (touchesDiff < 0 && $actionsRight.length > 0) { + app.swipeout.open($swipeoutEl, 'right'); + } + + if (touchesDiff > 0 && $actionsLeft.length > 0) { + app.swipeout.open($swipeoutEl, 'left'); + } + } + + isTouched = false; + isMoved = false; + return; + } + + overswipeLeft = false; + overswipeRight = false; + + if ($actionsRight.length > 0) { + // Show right actions + var buttonTranslate = translate; + progress = buttonTranslate / actionsRightWidth; + + if (buttonTranslate < -actionsRightWidth) { + var ratio = buttonTranslate / -actionsRightWidth; + buttonTranslate = -actionsRightWidth - Math.pow(-buttonTranslate - actionsRightWidth, 0.8); + translate = buttonTranslate; + + if ($overswipeRightButton.length > 0 && ratio > app.params.swipeout.overswipeRatio) { + overswipeRight = true; + } + } + + if (direction !== 'to-left') { + progress = 0; + buttonTranslate = 0; + } + + $rightButtons.each(function (buttonEl) { + var $buttonEl = (0, _dom.default)(buttonEl); + + if (typeof buttonEl.f7SwipeoutButtonOffset === 'undefined') { + $buttonEl[0].f7SwipeoutButtonOffset = buttonEl.offsetLeft; + } + + buttonOffset = buttonEl.f7SwipeoutButtonOffset; + + if ($overswipeRightButton.length > 0 && $buttonEl.hasClass('swipeout-overswipe') && direction === 'to-left') { + $buttonEl.css({ + left: (overswipeRight ? -buttonOffset : 0) + "px" + }); + + if (overswipeRight) { + if (!$buttonEl.hasClass('swipeout-overswipe-active')) { + $swipeoutEl.trigger('swipeout:overswipeenter'); + app.emit('swipeoutOverswipeEnter', $swipeoutEl[0]); + } + + $buttonEl.addClass('swipeout-overswipe-active'); + } else { + if ($buttonEl.hasClass('swipeout-overswipe-active')) { + $swipeoutEl.trigger('swipeout:overswipeexit'); + app.emit('swipeoutOverswipeExit', $swipeoutEl[0]); + } + + $buttonEl.removeClass('swipeout-overswipe-active'); + } + } + + $buttonEl.transform("translate3d(" + (buttonTranslate - buttonOffset * (1 + Math.max(progress, -1))) + "px,0,0)"); + }); + } + + if ($actionsLeft.length > 0) { + // Show left actions + var _buttonTranslate = translate; + progress = _buttonTranslate / actionsLeftWidth; + + if (_buttonTranslate > actionsLeftWidth) { + var _ratio = _buttonTranslate / actionsRightWidth; + + _buttonTranslate = actionsLeftWidth + Math.pow(_buttonTranslate - actionsLeftWidth, 0.8); + translate = _buttonTranslate; + + if ($overswipeLeftButton.length > 0 && _ratio > app.params.swipeout.overswipeRatio) { + overswipeLeft = true; + } + } + + if (direction !== 'to-right') { + _buttonTranslate = 0; + progress = 0; + } + + $leftButtons.each(function (buttonEl, index) { + var $buttonEl = (0, _dom.default)(buttonEl); + + if (typeof buttonEl.f7SwipeoutButtonOffset === 'undefined') { + $buttonEl[0].f7SwipeoutButtonOffset = actionsLeftWidth - buttonEl.offsetLeft - buttonEl.offsetWidth; + } + + buttonOffset = buttonEl.f7SwipeoutButtonOffset; + + if ($overswipeLeftButton.length > 0 && $buttonEl.hasClass('swipeout-overswipe') && direction === 'to-right') { + $buttonEl.css({ + left: (overswipeLeft ? buttonOffset : 0) + "px" + }); + + if (overswipeLeft) { + if (!$buttonEl.hasClass('swipeout-overswipe-active')) { + $swipeoutEl.trigger('swipeout:overswipeenter'); + app.emit('swipeoutOverswipeEnter', $swipeoutEl[0]); + } + + $buttonEl.addClass('swipeout-overswipe-active'); + } else { + if ($buttonEl.hasClass('swipeout-overswipe-active')) { + $swipeoutEl.trigger('swipeout:overswipeexit'); + app.emit('swipeoutOverswipeExit', $swipeoutEl[0]); + } + + $buttonEl.removeClass('swipeout-overswipe-active'); + } + } + + if ($leftButtons.length > 1) { + $buttonEl.css('z-index', $leftButtons.length - index); + } + + $buttonEl.transform("translate3d(" + (_buttonTranslate + buttonOffset * (1 - Math.min(progress, 1))) + "px,0,0)"); + }); + } + + $swipeoutEl.trigger('swipeout', progress); + app.emit('swipeout', $swipeoutEl[0], progress); + $swipeoutContent.transform("translate3d(" + translate + "px,0,0)"); + } + + function handleTouchEnd() { + if (!isTouched || !isMoved) { + isTouched = false; + isMoved = false; + return; + } + + isTouched = false; + isMoved = false; + var timeDiff = new Date().getTime() - touchStartTime; + var $actions = direction === 'to-left' ? $actionsRight : $actionsLeft; + var actionsWidth = direction === 'to-left' ? actionsRightWidth : actionsLeftWidth; + var action; + var $buttons; + var i; + + if (timeDiff < 300 && (touchesDiff < -10 && direction === 'to-left' || touchesDiff > 10 && direction === 'to-right') || timeDiff >= 300 && Math.abs(translate) > actionsWidth / 2) { + action = 'open'; + } else { + action = 'close'; + } + + if (timeDiff < 300) { + if (Math.abs(translate) === 0) action = 'close'; + if (Math.abs(translate) === actionsWidth) action = 'open'; + } + + if (action === 'open') { + Swipeout.el = $swipeoutEl[0]; + $swipeoutEl.trigger('swipeout:open'); + app.emit('swipeoutOpen', $swipeoutEl[0]); + $swipeoutEl.addClass('swipeout-opened swipeout-transitioning'); + var newTranslate = direction === 'to-left' ? -actionsWidth : actionsWidth; + $swipeoutContent.transform("translate3d(" + newTranslate + "px,0,0)"); + $actions.addClass('swipeout-actions-opened'); + $buttons = direction === 'to-left' ? $rightButtons : $leftButtons; + + if ($buttons) { + for (i = 0; i < $buttons.length; i += 1) { + (0, _dom.default)($buttons[i]).transform("translate3d(" + newTranslate + "px,0,0)"); + } + } + + if (overswipeRight) { + $actionsRight.find('.swipeout-overswipe').trigger('click', 'f7Overswipe'); + } + + if (overswipeLeft) { + $actionsLeft.find('.swipeout-overswipe').trigger('click', 'f7Overswipe'); + } + } else { + $swipeoutEl.trigger('swipeout:close'); + app.emit('swipeoutClose', $swipeoutEl[0]); + Swipeout.el = undefined; + $swipeoutEl.addClass('swipeout-transitioning').removeClass('swipeout-opened'); + $swipeoutContent.transform(''); + $actions.removeClass('swipeout-actions-opened'); + } + + var buttonOffset; + + if ($leftButtons && $leftButtons.length > 0 && $leftButtons !== $buttons) { + $leftButtons.each(function (buttonEl) { + var $buttonEl = (0, _dom.default)(buttonEl); + buttonOffset = buttonEl.f7SwipeoutButtonOffset; + + if (typeof buttonOffset === 'undefined') { + $buttonEl[0].f7SwipeoutButtonOffset = actionsLeftWidth - buttonEl.offsetLeft - buttonEl.offsetWidth; + } + + $buttonEl.transform("translate3d(" + buttonOffset + "px,0,0)"); + }); + } + + if ($rightButtons && $rightButtons.length > 0 && $rightButtons !== $buttons) { + $rightButtons.each(function (buttonEl) { + var $buttonEl = (0, _dom.default)(buttonEl); + buttonOffset = buttonEl.f7SwipeoutButtonOffset; + + if (typeof buttonOffset === 'undefined') { + $buttonEl[0].f7SwipeoutButtonOffset = buttonEl.offsetLeft; + } + + $buttonEl.transform("translate3d(" + -buttonOffset + "px,0,0)"); + }); + } + + $swipeoutContent.transitionEnd(function () { + if (opened && action === 'open' || !opened && action === 'close') return; + $swipeoutEl.trigger(action === 'open' ? 'swipeout:opened' : 'swipeout:closed'); + app.emit(action === 'open' ? 'swipeoutOpened' : 'swipeoutClosed', $swipeoutEl[0]); + $swipeoutEl.removeClass('swipeout-transitioning'); + + if (opened && action === 'close') { + if ($actionsRight.length > 0) { + $rightButtons.transform(''); + } + + if ($actionsLeft.length > 0) { + $leftButtons.transform(''); + } + } + }); + } + + var passiveListener = (0, _getSupport.getSupport)().passiveListener ? { + passive: true + } : false; + app.on('touchstart', function (e) { + if (Swipeout.el) { + var $targetEl = (0, _dom.default)(e.target); + + if (!((0, _dom.default)(Swipeout.el).is($targetEl[0]) || $targetEl.parents('.swipeout').is(Swipeout.el) || $targetEl.hasClass('modal-in') || ($targetEl.attr('class') || '').indexOf('-backdrop') > 0 || $targetEl.hasClass('actions-modal') || $targetEl.parents('.actions-modal.modal-in, .dialog.modal-in').length > 0)) { + app.swipeout.close(Swipeout.el); + } + } + }); + (0, _dom.default)(document).on(app.touchEvents.start, 'li.swipeout', handleTouchStart, passiveListener); + app.on('touchmove:active', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + }, + allow: true, + el: undefined, + open: function open() { + var app = this; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var el = args[0], + side = args[1], + callback = args[2]; + + if (typeof args[1] === 'function') { + el = args[0]; + callback = args[1]; + side = args[2]; + } + + var $el = (0, _dom.default)(el).eq(0); + if ($el.length === 0) return; + if (!$el.hasClass('swipeout') || $el.hasClass('swipeout-opened')) return; + + if (!side) { + if ($el.find('.swipeout-actions-right').length > 0) side = 'right';else side = 'left'; + } + + var $swipeoutActions = $el.find(".swipeout-actions-" + side); + var $swipeoutContent = $el.find('.swipeout-content'); + if ($swipeoutActions.length === 0) return; + $el.trigger('swipeout:open').addClass('swipeout-opened').removeClass('swipeout-transitioning'); + app.emit('swipeoutOpen', $el[0]); + $swipeoutActions.addClass('swipeout-actions-opened'); + var $buttons = $swipeoutActions.children('a'); + var swipeoutActionsWidth = $swipeoutActions.outerWidth(); + var translate = side === 'right' ? -swipeoutActionsWidth : swipeoutActionsWidth; + + if ($buttons.length > 1) { + $buttons.each(function (buttonEl, buttonIndex) { + var $buttonEl = (0, _dom.default)(buttonEl); + + if (side === 'right') { + $buttonEl.transform("translate3d(" + -buttonEl.offsetLeft + "px,0,0)"); + } else { + $buttonEl.css('z-index', $buttons.length - buttonIndex).transform("translate3d(" + (swipeoutActionsWidth - buttonEl.offsetWidth - buttonEl.offsetLeft) + "px,0,0)"); + } + }); + } + + $el.addClass('swipeout-transitioning'); + $swipeoutContent.transitionEnd(function () { + $el.trigger('swipeout:opened'); + app.emit('swipeoutOpened', $el[0]); + if (callback) callback.call($el[0]); + }); + (0, _utils.nextFrame)(function () { + $buttons.transform("translate3d(" + translate + "px,0,0)"); + $swipeoutContent.transform("translate3d(" + translate + "px,0,0)"); + }); + Swipeout.el = $el[0]; + }, + close: function close(el, callback) { + var app = this; + var $el = (0, _dom.default)(el).eq(0); + if ($el.length === 0) return; + if (!$el.hasClass('swipeout-opened')) return; + var side = $el.find('.swipeout-actions-opened').hasClass('swipeout-actions-right') ? 'right' : 'left'; + var $swipeoutActions = $el.find('.swipeout-actions-opened').removeClass('swipeout-actions-opened'); + var $buttons = $swipeoutActions.children('a'); + var swipeoutActionsWidth = $swipeoutActions.outerWidth(); + app.swipeout.allow = false; + $el.trigger('swipeout:close'); + app.emit('swipeoutClose', $el[0]); + $el.removeClass('swipeout-opened').addClass('swipeout-transitioning'); + var closeTimeout; + + function onSwipeoutClose() { + app.swipeout.allow = true; + if ($el.hasClass('swipeout-opened')) return; + $el.removeClass('swipeout-transitioning'); + $buttons.transform(''); + $el.trigger('swipeout:closed'); + app.emit('swipeoutClosed', $el[0]); + if (callback) callback.call($el[0]); + if (closeTimeout) clearTimeout(closeTimeout); + } + + $el.find('.swipeout-content').transform('').transitionEnd(onSwipeoutClose); + closeTimeout = setTimeout(onSwipeoutClose, 500); + $buttons.each(function (buttonEl) { + var $buttonEl = (0, _dom.default)(buttonEl); + + if (side === 'right') { + $buttonEl.transform("translate3d(" + -buttonEl.offsetLeft + "px,0,0)"); + } else { + $buttonEl.transform("translate3d(" + (swipeoutActionsWidth - buttonEl.offsetWidth - buttonEl.offsetLeft) + "px,0,0)"); + } + + $buttonEl.css({ + left: '0px' + }).removeClass('swipeout-overswipe-active'); + }); + if (Swipeout.el && Swipeout.el === $el[0]) Swipeout.el = undefined; + }, + delete: function _delete(el, callback) { + var app = this; + var $el = (0, _dom.default)(el).eq(0); + if ($el.length === 0) return; + Swipeout.el = undefined; + $el.trigger('swipeout:delete'); + app.emit('swipeoutDelete', $el[0]); + $el.css({ + height: $el.outerHeight() + "px" + }); + $el.transitionEnd(function () { + $el.trigger('swipeout:deleted'); + app.emit('swipeoutDeleted', $el[0]); + if (callback) callback.call($el[0]); + + if ($el.parents('.virtual-list').length > 0) { + var virtualList = $el.parents('.virtual-list')[0].f7VirtualList; + var virtualIndex = $el[0].f7VirtualListIndex; + if (virtualList && typeof virtualIndex !== 'undefined') virtualList.deleteItem(virtualIndex); + } else if (app.params.swipeout.removeElements) { + if (app.params.swipeout.removeElementsWithTimeout) { + setTimeout(function () { + $el.remove(); + }, app.params.swipeout.removeElementsTimeout); + } else { + $el.remove(); + } + } else { + $el.removeClass('swipeout-deleting swipeout-transitioning'); + } + }); // eslint-disable-next-line + // $el[0]._clientLeft = $el[0].clientLeft; + + (0, _utils.nextFrame)(function () { + $el.addClass('swipeout-deleting swipeout-transitioning').css({ + height: '0px' + }).find('.swipeout-content').transform('translate3d(-100%,0,0)'); + }); + } +}; +var _default = { + name: 'swipeout', + params: { + swipeout: { + actionsNoFold: false, + noFollow: false, + removeElements: true, + removeElementsWithTimeout: false, + removeElementsTimeout: 0, + overswipeRatio: 1.2 + } + }, + create: function create() { + var app = this; + (0, _utils.bindMethods)(app, { + swipeout: Swipeout + }); + }, + clicks: { + '.swipeout-open': function openSwipeout($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + app.swipeout.open(data.swipeout, data.side); + }, + '.swipeout-close': function closeSwipeout($clickedEl) { + var app = this; + var $swipeoutEl = $clickedEl.closest('.swipeout'); + if ($swipeoutEl.length === 0) return; + app.swipeout.close($swipeoutEl); + }, + '.swipeout-delete': function deleteSwipeout($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + var app = this; + var $swipeoutEl = $clickedEl.closest('.swipeout'); + if ($swipeoutEl.length === 0) return; + var _data = data, + confirm = _data.confirm, + confirmTitle = _data.confirmTitle; + + if (data.confirm) { + app.dialog.confirm(confirm, confirmTitle, function () { + app.swipeout.delete($swipeoutEl); + }); + } else { + app.swipeout.delete($swipeoutEl); + } + } + }, + on: { + init: function init() { + var app = this; + if (!app.params.swipeout) return; + app.swipeout.init(); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/swiper/swiper.js b/www/assets/framework7/cjs/components/swiper/swiper.js new file mode 100644 index 000000000..b6f44a6ff --- /dev/null +++ b/www/assets/framework7/cjs/components/swiper/swiper.js @@ -0,0 +1,189 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _bundle = _interopRequireDefault(require("swiper/bundle")); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + + + +function initSwiper(swiperEl) { + var app = this; + var $swiperEl = (0, _dom.default)(swiperEl); + if ($swiperEl.length === 0) return; + if ($swiperEl[0].swiper) return; + var initialSlide; + var params = {}; + var isTabs; + var isRoutableTabs; + + if ($swiperEl.hasClass('tabs-swipeable-wrap')) { + $swiperEl.addClass('swiper-container').children('.tabs').addClass('swiper-wrapper').children('.tab').addClass('swiper-slide'); + initialSlide = $swiperEl.children('.tabs').children('.tab-active').index(); + isTabs = true; + isRoutableTabs = $swiperEl.find('.tabs-routable').length > 0; + } + + if ($swiperEl.attr('data-swiper')) { + params = JSON.parse($swiperEl.attr('data-swiper')); + } else if ($swiperEl[0].f7SwiperParams) { + params = $swiperEl[0].f7SwiperParams; + } else { + params = $swiperEl.dataset(); + Object.keys(params).forEach(function (key) { + var value = params[key]; + + if (typeof value === 'string' && value.indexOf('{') === 0 && value.indexOf('}') > 0) { + try { + params[key] = JSON.parse(value); + } catch (e) {// not JSON + } + } + }); + } + + if (typeof params.initialSlide === 'undefined' && typeof initialSlide !== 'undefined') { + params.initialSlide = initialSlide; + } + + var swiper = app.swiper.create($swiperEl[0], params); + + function updateSwiper() { + swiper.update(); + } + + var $tabEl = $swiperEl.parents('.tab').filter(function (tabEl) { + return (0, _dom.default)(tabEl).parent('.tabs').parent('.tabs-animated-wrap, .tabs-swipeable-wrap').length === 0; + }).eq(0); + $swiperEl.parents('.popup, .login-screen, .sheet-modal, .popover').on('modal:open', updateSwiper); + $swiperEl.parents('.panel').on('panel:open', updateSwiper); + + if ($tabEl && $tabEl.length) { + $tabEl.on('tab:show', updateSwiper); + } + + swiper.on('beforeDestroy', function () { + $swiperEl.parents('.popup, .login-screen, .sheet-modal, .popover').off('modal:open', updateSwiper); + $swiperEl.parents('.panel').off('panel:open', updateSwiper); + + if ($tabEl && $tabEl.length) { + $tabEl.off('tab:show', updateSwiper); + } + }); + + if (isTabs) { + swiper.on('slideChange', function () { + if (isRoutableTabs) { + var view = app.views.get($swiperEl.parents('.view')); + if (!view) view = app.views.main; + var router = view.router; + var tabRouteUrl = router.findTabRouteUrl(swiper.slides.eq(swiper.activeIndex)[0]); + + if (tabRouteUrl) { + setTimeout(function () { + router.navigate(tabRouteUrl); + }, 0); + } + } else { + app.tab.show({ + tabEl: swiper.slides.eq(swiper.activeIndex) + }); + } + }); + } +} + +var _default = { + name: 'swiper', + static: { + Swiper: _bundle.default + }, + create: function create() { + var app = this; + app.swiper = (0, _constructorMethods.default)({ + defaultSelector: '.swiper-container', + constructor: _bundle.default, + domProp: 'swiper' + }); + }, + on: { + pageBeforeRemove: function pageBeforeRemove(page) { + var app = this; + page.$el.find('.swiper-init, .tabs-swipeable-wrap').each(function (swiperEl) { + app.swiper.destroy(swiperEl); + }); + }, + pageMounted: function pageMounted(page) { + var app = this; + page.$el.find('.tabs-swipeable-wrap').each(function (swiperEl) { + initSwiper.call(app, swiperEl); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.swiper-init, .tabs-swipeable-wrap').each(function (swiperEl) { + initSwiper.call(app, swiperEl); + }); + }, + pageReinit: function pageReinit(page) { + var app = this; + page.$el.find('.swiper-init, .tabs-swipeable-wrap').each(function (swiperEl) { + var swiper = app.swiper.get(swiperEl); + if (swiper && swiper.update) swiper.update(); + }); + }, + tabMounted: function tabMounted(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.swiper-init, .tabs-swipeable-wrap').each(function (swiperEl) { + initSwiper.call(app, swiperEl); + }); + }, + tabShow: function tabShow(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.swiper-init, .tabs-swipeable-wrap').each(function (swiperEl) { + var swiper = app.swiper.get(swiperEl); + if (swiper && swiper.update) swiper.update(); + }); + }, + tabBeforeRemove: function tabBeforeRemove(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.swiper-init, .tabs-swipeable-wrap').each(function (swiperEl) { + app.swiper.destroy(swiperEl); + }); + } + }, + vnode: { + 'swiper-init': { + insert: function insert(vnode) { + var app = this; + var swiperEl = vnode.elm; + initSwiper.call(app, swiperEl); + }, + destroy: function destroy(vnode) { + var app = this; + var swiperEl = vnode.elm; + app.swiper.destroy(swiperEl); + } + }, + 'tabs-swipeable-wrap': { + insert: function insert(vnode) { + var app = this; + var swiperEl = vnode.elm; + initSwiper.call(app, swiperEl); + }, + destroy: function destroy(vnode) { + var app = this; + var swiperEl = vnode.elm; + app.swiper.destroy(swiperEl); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/tabs/tabs.js b/www/assets/framework7/cjs/components/tabs/tabs.js new file mode 100644 index 000000000..bde47cc12 --- /dev/null +++ b/www/assets/framework7/cjs/components/tabs/tabs.js @@ -0,0 +1,295 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Tab = { + show: function show() { + var app = this; + var tabEl; + var tabLinkEl; + var animate; + var tabRoute; + var animatedInit; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + if (args.length === 1 && args[0] && args[0].constructor === Object) { + tabEl = args[0].tabEl; + tabLinkEl = args[0].tabLinkEl; + animate = args[0].animate; + tabRoute = args[0].tabRoute; + animatedInit = args[0].animatedInit; + } else { + tabEl = args[0]; + tabLinkEl = args[1]; + animate = args[2]; + tabRoute = args[3]; + + if (typeof args[1] === 'boolean') { + tabEl = args[0]; + animate = args[1]; + tabLinkEl = args[2]; + tabRoute = args[3]; + + if (args.length > 2 && tabLinkEl.constructor === Object) { + tabEl = args[0]; + animate = args[1]; + tabRoute = args[2]; + tabLinkEl = args[3]; + } + } + } + + if (typeof animate === 'undefined') animate = true; + var $newTabEl = (0, _dom.default)(tabEl); + + if (tabRoute && $newTabEl[0]) { + $newTabEl[0].f7TabRoute = tabRoute; + } + + if (!animatedInit && ($newTabEl.length === 0 || $newTabEl.hasClass('tab-active'))) { + return { + $newTabEl: $newTabEl, + newTabEl: $newTabEl[0] + }; + } + + var $tabLinkEl; + if (tabLinkEl) $tabLinkEl = (0, _dom.default)(tabLinkEl); + var $tabsEl = $newTabEl.parent('.tabs'); + + if ($tabsEl.length === 0) { + return { + $newTabEl: $newTabEl, + newTabEl: $newTabEl[0] + }; + } // Release swipeouts in hidden tabs + + + if (app.swipeout) app.swipeout.allowOpen = true; // Animated tabs + + var tabsChangedCallbacks = []; + + function onTabsChanged(callback) { + tabsChangedCallbacks.push(callback); + } + + function tabsChanged() { + tabsChangedCallbacks.forEach(function (callback) { + callback(); + }); + } + + var animated = false; + + if ($tabsEl.parent().hasClass('tabs-animated-wrap')) { + $tabsEl.parent()[animate ? 'removeClass' : 'addClass']('not-animated'); + var transitionDuration = parseFloat($tabsEl.css('transition-duration').replace(',', '.')); + + if (animate && transitionDuration) { + $tabsEl.transitionEnd(tabsChanged); + animated = true; + } + + var tabsTranslate = (app.rtl ? $newTabEl.index() : -$newTabEl.index()) * 100; + $tabsEl.transform("translate3d(" + tabsTranslate + "%,0,0)"); + } // Swipeable tabs + + + var swiper; + + if ($tabsEl.parent().hasClass('tabs-swipeable-wrap') && app.swiper) { + swiper = $tabsEl.parent()[0].swiper; + + if (swiper && swiper.activeIndex !== $newTabEl.index()) { + animated = true; + swiper.once('slideChangeTransitionEnd', function () { + tabsChanged(); + }).slideTo($newTabEl.index(), animate ? undefined : 0); + } else if (swiper && swiper.animating) { + animated = true; + swiper.once('slideChangeTransitionEnd', function () { + tabsChanged(); + }); + } + } // Remove active class from old tabs + + + var $oldTabEl = $tabsEl.children('.tab-active'); + $oldTabEl.removeClass('tab-active'); + + if (!animatedInit && (!swiper || swiper && !swiper.animating || swiper && tabRoute)) { + if ($oldTabEl.hasClass('view') && $oldTabEl.children('.page').length) { + $oldTabEl.children('.page').each(function (pageEl) { + (0, _dom.default)(pageEl).trigger('page:tabhide'); + app.emit('pageTabHide', pageEl); + }); + } + + $oldTabEl.trigger('tab:hide'); + app.emit('tabHide', $oldTabEl[0]); + } // Trigger 'show' event on new tab + + + $newTabEl.addClass('tab-active'); + + if (!animatedInit && (!swiper || swiper && !swiper.animating || swiper && tabRoute)) { + if ($newTabEl.hasClass('view') && $newTabEl.children('.page').length) { + $newTabEl.children('.page').each(function (pageEl) { + (0, _dom.default)(pageEl).trigger('page:tabshow'); + app.emit('pageTabShow', pageEl); + }); + } + + $newTabEl.trigger('tab:show'); + app.emit('tabShow', $newTabEl[0]); + } // Find related link for new tab + + + if (!$tabLinkEl) { + // Search by id + if (typeof tabEl === 'string') $tabLinkEl = (0, _dom.default)(".tab-link[href=\"" + tabEl + "\"]");else $tabLinkEl = (0, _dom.default)(".tab-link[href=\"#" + $newTabEl.attr('id') + "\"]"); // Search by data-tab + + if (!$tabLinkEl || $tabLinkEl && $tabLinkEl.length === 0) { + (0, _dom.default)('[data-tab]').each(function (el) { + if ($newTabEl.is((0, _dom.default)(el).attr('data-tab'))) $tabLinkEl = (0, _dom.default)(el); + }); + } + + if (tabRoute && (!$tabLinkEl || $tabLinkEl && $tabLinkEl.length === 0)) { + $tabLinkEl = (0, _dom.default)("[data-route-tab-id=\"" + tabRoute.route.tab.id + "\"]"); + + if ($tabLinkEl.length === 0) { + $tabLinkEl = (0, _dom.default)(".tab-link[href=\"" + tabRoute.url + "\"]"); + } + } + + if ($tabLinkEl.length > 1 && $newTabEl.parents('.page').length) { + // eslint-disable-next-line + $tabLinkEl = $tabLinkEl.filter(function (tabLinkElement) { + return (0, _dom.default)(tabLinkElement).parents('.page')[0] === $newTabEl.parents('.page')[0]; + }); + + if (app.theme === 'ios' && $tabLinkEl.length === 0 && tabRoute) { + var $pageEl = $newTabEl.parents('.page'); + var $navbarEl = (0, _dom.default)(app.navbar.getElByPage($pageEl)); + $tabLinkEl = $navbarEl.find("[data-route-tab-id=\"" + tabRoute.route.tab.id + "\"]"); + + if ($tabLinkEl.length === 0) { + $tabLinkEl = $navbarEl.find(".tab-link[href=\"" + tabRoute.url + "\"]"); + } + } + } + } + + if ($tabLinkEl.length > 0) { + // Find related link for old tab + var $oldTabLinkEl; + + if ($oldTabEl && $oldTabEl.length > 0) { + // Search by id + var oldTabId = $oldTabEl.attr('id'); + + if (oldTabId) { + $oldTabLinkEl = (0, _dom.default)(".tab-link[href=\"#" + oldTabId + "\"]"); // Search by data-route-tab-id + + if (!$oldTabLinkEl || $oldTabLinkEl && $oldTabLinkEl.length === 0) { + $oldTabLinkEl = (0, _dom.default)(".tab-link[data-route-tab-id=\"" + oldTabId + "\"]"); + } + } // Search by data-tab + + + if (!$oldTabLinkEl || $oldTabLinkEl && $oldTabLinkEl.length === 0) { + (0, _dom.default)('[data-tab]').each(function (tabLinkElement) { + if ($oldTabEl.is((0, _dom.default)(tabLinkElement).attr('data-tab'))) $oldTabLinkEl = (0, _dom.default)(tabLinkElement); + }); + } + + if (!$oldTabLinkEl || $oldTabLinkEl && $oldTabLinkEl.length === 0) { + $oldTabLinkEl = $tabLinkEl.siblings('.tab-link-active'); + } + } else if (tabRoute) { + $oldTabLinkEl = $tabLinkEl.siblings('.tab-link-active'); + } + + if ($oldTabLinkEl && $oldTabLinkEl.length > 1 && $oldTabEl && $oldTabEl.parents('.page').length) { + // eslint-disable-next-line + $oldTabLinkEl = $oldTabLinkEl.filter(function (tabLinkElement) { + return (0, _dom.default)(tabLinkElement).parents('.page')[0] === $oldTabEl.parents('.page')[0]; + }); + } + + if ($oldTabLinkEl && $oldTabLinkEl.length > 0) $oldTabLinkEl.removeClass('tab-link-active'); // Update links' classes + + if ($tabLinkEl && $tabLinkEl.length > 0) { + $tabLinkEl.addClass('tab-link-active'); // Material Highlight + + var $tabbarEl = $tabLinkEl.parents('.tabbar, .tabbar-labels'); + var hasHighlight = app.toolbar && $tabbarEl.length > 0 && ($tabbarEl.hasClass('tabbar-highlight') || app.theme !== 'ios'); + + if (hasHighlight) { + app.toolbar.setHighlight($tabbarEl); + } + } + } + + return { + $newTabEl: $newTabEl, + newTabEl: $newTabEl[0], + $oldTabEl: $oldTabEl, + oldTabEl: $oldTabEl[0], + onTabsChanged: onTabsChanged, + animated: animated + }; + } +}; +var _default = { + name: 'tabs', + create: function create() { + var app = this; + (0, _utils.extend)(app, { + tab: { + show: Tab.show.bind(app) + } + }); + }, + on: { + 'pageInit tabMounted': function onInit(pageOrTabEl) { + var $el = (0, _dom.default)(pageOrTabEl.el || pageOrTabEl); + var animatedTabEl = $el.find('.tabs-animated-wrap > .tabs > .tab-active')[0]; + if (!animatedTabEl) return; + var app = this; + app.tab.show({ + tabEl: animatedTabEl, + animatedInit: true, + animate: false + }); + } + }, + clicks: { + '.tab-link': function tabLinkClick($clickedEl, data) { + if (data === void 0) { + data = {}; + } + + if ($clickedEl.attr('href') && $clickedEl.attr('href').indexOf('#') === 0 || $clickedEl.attr('data-tab')) { + var app = this; + app.tab.show({ + tabEl: data.tab || $clickedEl.attr('href'), + tabLinkEl: $clickedEl, + animate: data.animate + }); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/text-editor/text-editor-class.js b/www/assets/framework7/cjs/components/text-editor/text-editor-class.js new file mode 100644 index 000000000..8223648df --- /dev/null +++ b/www/assets/framework7/cjs/components/text-editor/text-editor-class.js @@ -0,0 +1,627 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _getDevice = require("../../shared/get-device"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var textEditorButtonsMap = { + // f7-icon, material-icon, command + bold: ['bold', 'format_bold', 'bold'], + italic: ['italic', 'format_italic', 'italic'], + underline: ['underline', 'format_underlined', 'underline'], + strikeThrough: ['strikethrough', 'strikethrough_s', 'strikeThrough'], + orderedList: ['list_number', 'format_list_numbered', 'insertOrderedList'], + unorderedList: ['list_bullet', 'format_list_bulleted', 'insertUnorderedList'], + link: ['link', 'link', 'createLink'], + image: ['photo', 'image', 'insertImage'], + paragraph: ['paragraph', '', 'formatBlock.P'], + h1: ['H1', 'H1', 'formatBlock.H1'], + h2: ['H2', 'H2', 'formatBlock.H2'], + h3: ['H3', 'H3', 'formatBlock.H3'], + alignLeft: ['text_alignleft', 'format_align_left', 'justifyLeft'], + alignCenter: ['text_aligncenter', 'format_align_center', 'justifyCenter'], + alignRight: ['text_alignright', 'format_align_right', 'justifyRight'], + alignJustify: ['text_justify', 'format_align_justify', 'justifyFull'], + subscript: ['textformat_subscript', 'A1', 'subscript'], + superscript: ['textformat_superscript', 'A1', 'superscript'], + indent: ['increase_indent', 'format_indent_increase', 'indent'], + outdent: ['decrease_indent', 'format_indent_decrease', 'outdent'] +}; + +var TextEditor = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(TextEditor, _Framework7Class); + + function TextEditor(app, params) { + var _this; + + _this = _Framework7Class.call(this, params, [app]) || this; + + var self = _assertThisInitialized(_this); + + var document = (0, _ssrWindow.getDocument)(); + var device = (0, _getDevice.getDevice)(); + var defaults = (0, _utils.extend)({}, app.params.textEditor); // Extend defaults with modules params + + self.useModulesParams(defaults); + self.params = (0, _utils.extend)(defaults, params); + var el = self.params.el; + if (!el) return self || _assertThisInitialized(_this); + var $el = (0, _dom.default)(el); + if ($el.length === 0) return self || _assertThisInitialized(_this); + if ($el[0].f7TextEditor) return $el[0].f7TextEditor || _assertThisInitialized(_this); + var $contentEl = $el.children('.text-editor-content'); + + if (!$contentEl.length) { + $el.append('
    '); + $contentEl = $el.children('.text-editor-content'); + } + + (0, _utils.extend)(self, { + app: app, + $el: $el, + el: $el[0], + $contentEl: $contentEl, + contentEl: $contentEl[0] + }); + + if ('value' in params) { + self.value = self.params.value; + } + + if (self.params.mode === 'keyboard-toolbar') { + if (!(device.cordova || device.capacitor) && !device.android) { + self.params.mode = 'popover'; + } + } + + if (typeof self.params.buttons === 'string') { + try { + self.params.buttons = JSON.parse(self.params.buttons); + } catch (err) { + throw new Error('Framework7: TextEditor: wrong "buttons" parameter format'); + } + } + + $el[0].f7TextEditor = self; // Bind + + self.onButtonClick = self.onButtonClick.bind(self); + self.onFocus = self.onFocus.bind(self); + self.onBlur = self.onBlur.bind(self); + self.onInput = self.onInput.bind(self); + self.onPaste = self.onPaste.bind(self); + self.onSelectionChange = self.onSelectionChange.bind(self); + self.closeKeyboardToolbar = self.closeKeyboardToolbar.bind(self); // Handle Events + + self.attachEvents = function attachEvents() { + if (self.params.mode === 'toolbar') { + self.$el.find('.text-editor-toolbar').on('click', 'button', self.onButtonClick); + } + + if (self.params.mode === 'keyboard-toolbar') { + self.$keyboardToolbarEl.on('click', 'button', self.onButtonClick); + self.$el.parents('.page').on('page:beforeout', self.closeKeyboardToolbar); + } + + if (self.params.mode === 'popover' && self.popover) { + self.popover.$el.on('click', 'button', self.onButtonClick); + } + + self.$contentEl.on('paste', self.onPaste); + self.$contentEl.on('focus', self.onFocus); + self.$contentEl.on('blur', self.onBlur); + self.$contentEl.on('input', self.onInput, true); + (0, _dom.default)(document).on('selectionchange', self.onSelectionChange); + }; + + self.detachEvents = function detachEvents() { + if (self.params.mode === 'toolbar') { + self.$el.find('.text-editor-toolbar').off('click', 'button', self.onButtonClick); + } + + if (self.params.mode === 'keyboard-toolbar') { + self.$keyboardToolbarEl.off('click', 'button', self.onButtonClick); + self.$el.parents('.page').off('page:beforeout', self.closeKeyboardToolbar); + } + + if (self.params.mode === 'popover' && self.popover) { + self.popover.$el.off('click', 'button', self.onButtonClick); + } + + self.$contentEl.off('paste', self.onPaste); + self.$contentEl.off('focus', self.onFocus); + self.$contentEl.off('blur', self.onBlur); + self.$contentEl.off('input', self.onInput, true); + (0, _dom.default)(document).off('selectionchange', self.onSelectionChange); + }; // Install Modules + + + self.useModules(); // Init + + self.init(); + return self || _assertThisInitialized(_this); + } + + var _proto = TextEditor.prototype; + + _proto.setValue = function setValue(newValue) { + var self = this; + var currentValue = self.value; + if (currentValue === newValue) return self; + self.value = newValue; + self.$contentEl.html(newValue); + self.$el.trigger('texteditor:change', self.value); + self.emit('local::change textEditorChange', self, self.value); + return self; + }; + + _proto.getValue = function getValue() { + var self = this; + return self.value; + }; + + _proto.clearValue = function clearValue() { + var self = this; + self.setValue(''); + + if (self.params.placeholder && !self.$contentEl.html()) { + self.insertPlaceholder(); + } + + return self; + }; + + _proto.createLink = function createLink() { + var self = this; + var window = (0, _ssrWindow.getWindow)(); + var document = (0, _ssrWindow.getDocument)(); + var currentSelection = window.getSelection(); + var selectedNodes = []; + var $selectedLinks; + + if (currentSelection && currentSelection.anchorNode && (0, _dom.default)(currentSelection.anchorNode).parents(self.$el).length) { + var anchorNode = currentSelection.anchorNode; + + while (anchorNode) { + selectedNodes.push(anchorNode); + + if (!anchorNode.nextSibling || anchorNode === currentSelection.focusNode) { + anchorNode = null; + } + + if (anchorNode) { + anchorNode = anchorNode.nextSibling; + } + } + + var selectedNodesLinks = []; + var $selectedNodes = (0, _dom.default)(selectedNodes); + + for (var i = 0; i < $selectedNodes.length; i += 1) { + var childNodes = $selectedNodes[i].children; + + if (childNodes) { + for (var j = 0; j < childNodes.length; j += 1) { + if ((0, _dom.default)(childNodes[j]).is('a')) { + selectedNodesLinks.push(childNodes[j]); + } + } + } + } + + $selectedLinks = $selectedNodes.closest('a').add((0, _dom.default)(selectedNodesLinks)); + } + + if ($selectedLinks && $selectedLinks.length) { + $selectedLinks.each(function (linkNode) { + var selection = window.getSelection(); + var range = document.createRange(); + range.selectNodeContents(linkNode); + selection.removeAllRanges(); + selection.addRange(range); + document.execCommand('unlink', false); + selection.removeAllRanges(); + }); + return self; + } + + var currentRange = self.getSelectionRange(); + if (!currentRange) return self; + var dialog = self.app.dialog.prompt(self.params.linkUrlText, '', function (link) { + if (link && link.trim().length) { + self.setSelectionRange(currentRange); + document.execCommand('createLink', false, link.trim()); + self.$el.trigger('texteditor:insertlink', { + url: link.trim() + }); + self.emit('local:insertLink textEditorInsertLink', self, link.trim()); + } + }); + dialog.$el.find('input').focus(); + return self; + }; + + _proto.insertImage = function insertImage() { + var self = this; + var document = (0, _ssrWindow.getDocument)(); + var currentRange = self.getSelectionRange(); + if (!currentRange) return self; + var dialog = self.app.dialog.prompt(self.params.imageUrlText, '', function (imageUrl) { + if (imageUrl && imageUrl.trim().length) { + self.setSelectionRange(currentRange); + document.execCommand('insertImage', false, imageUrl.trim()); + self.$el.trigger('texteditor:insertimage', { + url: imageUrl.trim() + }); + self.emit('local:insertImage textEditorInsertImage', self, imageUrl.trim()); + } + }); + dialog.$el.find('input').focus(); + return self; + }; + + _proto.removePlaceholder = function removePlaceholder() { + var self = this; + self.$contentEl.find('.text-editor-placeholder').remove(); + }; + + _proto.insertPlaceholder = function insertPlaceholder() { + var self = this; + self.$contentEl.append("
    " + self.params.placeholder + "
    "); + }; + + _proto.onSelectionChange = function onSelectionChange() { + var self = this; + var window = (0, _ssrWindow.getWindow)(); + var document = (0, _ssrWindow.getDocument)(); + if (self.params.mode === 'toolbar') return; + var selection = window.getSelection(); + var selectionIsInContent = (0, _dom.default)(selection.anchorNode).parents(self.contentEl).length || selection.anchorNode === self.contentEl; + + if (self.params.mode === 'keyboard-toolbar') { + if (!selectionIsInContent) { + self.closeKeyboardToolbar(); + } else { + self.openKeyboardToolbar(); + } + + return; + } + + if (self.params.mode === 'popover') { + var selectionIsInPopover = (0, _dom.default)(selection.anchorNode).parents(self.popover.el).length || selection.anchorNode === self.popover.el; + + if (!selectionIsInContent && !selectionIsInPopover) { + self.closePopover(); + return; + } + + if (!selection.isCollapsed && selection.rangeCount) { + var range = selection.getRangeAt(0); + var rect = range.getBoundingClientRect(); + var rootEl = self.app.$el[0] || document.body; + self.openPopover(rect.x + (window.scrollX || 0) - rootEl.offsetLeft, rect.y + (window.scrollY || 0) - rootEl.offsetTop, rect.width, rect.height); + } else if (selection.isCollapsed) { + self.closePopover(); + } + } + }; + + _proto.onPaste = function onPaste(e) { + var self = this; + var document = (0, _ssrWindow.getDocument)(); + + if (self.params.clearFormattingOnPaste && e.clipboardData && e.clipboardData.getData) { + var text = e.clipboardData.getData('text/plain'); + e.preventDefault(); + document.execCommand('insertText', false, text); + } + }; + + _proto.onInput = function onInput() { + var self = this; + var value = self.$contentEl.html(); + self.value = value; + self.$el.trigger('texteditor:input'); + self.emit('local:input textEditorInput', self, self.value); + self.$el.trigger('texteditor:change', self.value); + self.emit('local::change textEditorChange', self, self.value); + }; + + _proto.onFocus = function onFocus() { + var self = this; + self.removePlaceholder(); + self.$contentEl.focus(); + self.$el.trigger('texteditor:focus'); + self.emit('local::focus textEditorFocus', self); + }; + + _proto.onBlur = function onBlur() { + var self = this; + var window = (0, _ssrWindow.getWindow)(); + var document = (0, _ssrWindow.getDocument)(); + + if (self.params.placeholder && self.$contentEl.html() === '') { + self.insertPlaceholder(); + } + + if (self.params.mode === 'popover') { + var selection = window.getSelection(); + var selectionIsInContent = (0, _dom.default)(selection.anchorNode).parents(self.contentEl).length || selection.anchorNode === self.contentEl; + var inPopover = document.activeElement && self.popover && (0, _dom.default)(document.activeElement).closest(self.popover.$el).length; + + if (!inPopover && !selectionIsInContent) { + self.closePopover(); + } + } + + if (self.params.mode === 'keyboard-toolbar') { + var _selection = window.getSelection(); + + var _selectionIsInContent = (0, _dom.default)(_selection.anchorNode).parents(self.contentEl).length || _selection.anchorNode === self.contentEl; + + if (!_selectionIsInContent) { + self.closeKeyboardToolbar(); + } + } + + self.$el.trigger('texteditor:blur'); + self.emit('local::blur textEditorBlur', self); + }; + + _proto.onButtonClick = function onButtonClick(e) { + var self = this; + var window = (0, _ssrWindow.getWindow)(); + var document = (0, _ssrWindow.getDocument)(); + var selection = window.getSelection(); + var selectionIsInContent = (0, _dom.default)(selection.anchorNode).parents(self.contentEl).length || selection.anchorNode === self.contentEl; + if (!selectionIsInContent) return; + var $buttonEl = (0, _dom.default)(e.target).closest('button'); + + if ($buttonEl.parents('form').length) { + e.preventDefault(); + } + + var button = $buttonEl.attr('data-button'); + var buttonData = self.params.customButtons && self.params.customButtons[button]; + if (!button || !(textEditorButtonsMap[button] || buttonData)) return; + $buttonEl.trigger('texteditor:buttonclick', button); + self.emit('local::buttonClick textEditorButtonClick', self, button); + + if (buttonData) { + if (buttonData.onClick) buttonData.onClick(self, $buttonEl[0]); + return; + } + + var command = textEditorButtonsMap[button][2]; + + if (command === 'createLink') { + self.createLink(); + return; + } + + if (command === 'insertImage') { + self.insertImage(); + return; + } + + if (command.indexOf('formatBlock') === 0) { + var tagName = command.split('.')[1]; + var $anchorNode = (0, _dom.default)(selection.anchorNode); + + if ($anchorNode.parents(tagName.toLowerCase()).length || $anchorNode.is(tagName)) { + document.execCommand('formatBlock', false, 'div'); + } else { + document.execCommand('formatBlock', false, tagName); + } + + return; + } + + document.execCommand(command, false); + } // eslint-disable-next-line + ; + + _proto.getSelectionRange = function getSelectionRange() { + var window = (0, _ssrWindow.getWindow)(); + var document = (0, _ssrWindow.getDocument)(); + + if (window.getSelection) { + var sel = window.getSelection(); + + if (sel.getRangeAt && sel.rangeCount) { + return sel.getRangeAt(0); + } + } else if (document.selection && document.selection.createRange) { + return document.selection.createRange(); + } + + return null; + } // eslint-disable-next-line + ; + + _proto.setSelectionRange = function setSelectionRange(range) { + var window = (0, _ssrWindow.getWindow)(); + var document = (0, _ssrWindow.getDocument)(); + + if (range) { + if (window.getSelection) { + var sel = window.getSelection(); + sel.removeAllRanges(); + sel.addRange(range); + } else if (document.selection && range.select) { + range.select(); + } + } + }; + + _proto.renderButtons = function renderButtons() { + var self = this; + var html = ''; + + function renderButton(button) { + var iconClass = self.app.theme === 'md' ? 'material-icons' : 'f7-icons'; + + if (self.params.customButtons && self.params.customButtons[button]) { + var buttonData = self.params.customButtons[button]; + return ""; + } + + if (!textEditorButtonsMap[button]) return ''; + var iconContent = textEditorButtonsMap[button][self.app.theme === 'md' ? 1 : 0]; + return ("").trim(); + } + + self.params.buttons.forEach(function (button, buttonIndex) { + if (Array.isArray(button)) { + button.forEach(function (b) { + html += renderButton(b); + }); + + if (buttonIndex < self.params.buttons.length - 1 && self.params.dividers) { + html += '
    '; + } + } else { + html += renderButton(button); + } + }); + return html; + }; + + _proto.createToolbar = function createToolbar() { + var self = this; + self.$el.prepend("
    " + self.renderButtons() + "
    "); + }; + + _proto.createKeyboardToolbar = function createKeyboardToolbar() { + var self = this; + self.$keyboardToolbarEl = (0, _dom.default)("
    " + self.renderButtons() + "
    "); + }; + + _proto.createPopover = function createPopover() { + var self = this; + self.popover = self.app.popover.create({ + content: "\n
    \n
    " + self.renderButtons() + "
    \n
    \n ", + closeByOutsideClick: false, + backdrop: false + }); + }; + + _proto.openKeyboardToolbar = function openKeyboardToolbar() { + var self = this; + if (self.$keyboardToolbarEl.parent(self.app.$el).length) return; + self.$el.trigger('texteditor:keyboardopen'); + self.emit('local::keyboardOpen textEditorKeyboardOpen', self); + self.app.$el.append(self.$keyboardToolbarEl); + }; + + _proto.closeKeyboardToolbar = function closeKeyboardToolbar() { + var self = this; + self.$keyboardToolbarEl.remove(); + self.$el.trigger('texteditor:keyboardclose'); + self.emit('local::keyboardClose textEditorKeyboardClose', self); + }; + + _proto.openPopover = function openPopover(targetX, targetY, targetWidth, targetHeight) { + var self = this; + if (!self.popover) return; + Object.assign(self.popover.params, { + targetX: targetX, + targetY: targetY, + targetWidth: targetWidth, + targetHeight: targetHeight + }); + clearTimeout(self.popoverTimeout); + self.popoverTimeout = setTimeout(function () { + if (!self.popover) return; + + if (self.popover.opened) { + self.popover.resize(); + } else { + self.$el.trigger('texteditor:popoveropen'); + self.emit('local::popoverOpen textEditorPopoverOpen', self); + self.popover.open(); + } + }, 400); + }; + + _proto.closePopover = function closePopover() { + var self = this; + clearTimeout(self.popoverTimeout); + if (!self.popover || !self.popover.opened) return; + self.popoverTimeout = setTimeout(function () { + if (!self.popover) return; + self.$el.trigger('texteditor:popoverclose'); + self.emit('local::popoverClose textEditorPopoverClose', self); + self.popover.close(); + }, 400); + }; + + _proto.init = function init() { + var self = this; + + if (self.value) { + self.$contentEl.html(self.value); + } else { + self.value = self.$contentEl.html(); + } + + if (self.params.placeholder && self.value === '') { + self.insertPlaceholder(); + } + + if (self.params.mode === 'toolbar') { + self.createToolbar(); + } else if (self.params.mode === 'popover') { + self.createPopover(); + } else if (self.params.mode === 'keyboard-toolbar') { + self.createKeyboardToolbar(); + } + + self.attachEvents(); + self.$el.trigger('texteditor:init'); + self.emit('local::init textEditorInit', self); + return self; + }; + + _proto.destroy = function destroy() { + var self = this; + self.$el.trigger('texteditor:beforedestroy'); + self.emit('local::beforeDestroy textEditorBeforeDestroy', self); + self.detachEvents(); + + if (self.params.mode === 'keyboard-toolbar' && self.$keyboardToolbarEl) { + self.$keyboardToolbarEl.remove(); + } + + if (self.popover) { + self.popover.close(false); + self.popover.destroy(); + } + + delete self.$el[0].f7TextEditor; + (0, _utils.deleteProps)(self); + self = null; + }; + + return TextEditor; +}(_class.default); + +var _default = TextEditor; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/text-editor/text-editor.js b/www/assets/framework7/cjs/components/text-editor/text-editor.js new file mode 100644 index 000000000..a765e3961 --- /dev/null +++ b/www/assets/framework7/cjs/components/text-editor/text-editor.js @@ -0,0 +1,93 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _textEditorClass = _interopRequireDefault(require("./text-editor-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'textEditor', + params: { + textEditor: { + el: null, + mode: 'toolbar', + // or 'popover' + value: undefined, + // will use html content + customButtons: null, + buttons: [['bold', 'italic', 'underline', 'strikeThrough'], ['orderedList', 'unorderedList'], ['link', 'image'], ['paragraph', 'h1', 'h2', 'h3'], ['alignLeft', 'alignCenter', 'alignRight', 'alignJustify'], ['subscript', 'superscript'], ['indent', 'outdent']], + dividers: true, + imageUrlText: 'Insert image URL', + linkUrlText: 'Insert link URL', + placeholder: null, + clearFormattingOnPaste: true + } + }, + create: function create() { + var app = this; + app.textEditor = (0, _utils.extend)((0, _constructorMethods.default)({ + defaultSelector: '.text-editor', + constructor: _textEditorClass.default, + app: app, + domProp: 'f7TextEditor' + })); + }, + static: { + TextEditor: _textEditorClass.default + }, + on: { + tabMounted: function tabMounted(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.text-editor-init').each(function (editorEl) { + var dataset = (0, _dom.default)(editorEl).dataset(); + app.textEditor.create((0, _utils.extend)({ + el: editorEl + }, dataset || {})); + }); + }, + tabBeforeRemove: function tabBeforeRemove(tabEl) { + (0, _dom.default)(tabEl).find('.text-editor-init').each(function (editorEl) { + if (editorEl.f7TextEditor) editorEl.f7TextEditor.destroy(); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.text-editor-init').each(function (editorEl) { + var dataset = (0, _dom.default)(editorEl).dataset(); + app.textEditor.create((0, _utils.extend)({ + el: editorEl + }, dataset || {})); + }); + }, + pageBeforeRemove: function pageBeforeRemove(page) { + page.$el.find('.text-editor-init').each(function (editorEl) { + if (editorEl.f7TextEditor) editorEl.f7TextEditor.destroy(); + }); + } + }, + vnode: { + 'text-editor-init': { + insert: function insert(vnode) { + var app = this; + var editorEl = vnode.elm; + var dataset = (0, _dom.default)(editorEl).dataset(); + app.textEditor.create((0, _utils.extend)({ + el: editorEl + }, dataset || {})); + }, + destroy: function destroy(vnode) { + var editorEl = vnode.elm; + if (editorEl.f7TextEditor) editorEl.f7TextEditor.destroy(); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/timeline/timeline.js b/www/assets/framework7/cjs/components/timeline/timeline.js new file mode 100644 index 000000000..fd80d91e2 --- /dev/null +++ b/www/assets/framework7/cjs/components/timeline/timeline.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _default = { + name: 'timeline' +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/toast/toast-class.js b/www/assets/framework7/cjs/components/toast/toast-class.js new file mode 100644 index 000000000..aed8bcf99 --- /dev/null +++ b/www/assets/framework7/cjs/components/toast/toast-class.js @@ -0,0 +1,142 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _modalClass = _interopRequireDefault(require("../modal/modal-class")); + +var _$jsx = _interopRequireDefault(require("../../shared/$jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Toast = /*#__PURE__*/function (_Modal) { + _inheritsLoose(Toast, _Modal); + + function Toast(app, params) { + var _this; + + var extendedParams = (0, _utils.extend)({ + on: {} + }, app.params.toast, params); // Extends with open/close Modal methods; + + _this = _Modal.call(this, app, extendedParams) || this; + + var toast = _assertThisInitialized(_this); + + var window = (0, _ssrWindow.getWindow)(); + toast.app = app; + toast.params = extendedParams; + var _toast$params = toast.params, + closeButton = _toast$params.closeButton, + closeTimeout = _toast$params.closeTimeout; + var $el; + + if (!toast.params.el) { + // Find Element + var toastHtml = toast.render(); + $el = (0, _dom.default)(toastHtml); + } else { + $el = (0, _dom.default)(toast.params.el); + } + + if ($el && $el.length > 0 && $el[0].f7Modal) { + return $el[0].f7Modal || _assertThisInitialized(_this); + } + + if ($el.length === 0) { + return toast.destroy() || _assertThisInitialized(_this); + } + + (0, _utils.extend)(toast, { + $el: $el, + el: $el[0], + type: 'toast' + }); + $el[0].f7Modal = toast; + + if (closeButton) { + $el.find('.toast-button').on('click', function () { + toast.emit('local::closeButtonClick toastCloseButtonClick', toast); + toast.close(); + }); + toast.on('beforeDestroy', function () { + $el.find('.toast-button').off('click'); + }); + } + + var timeoutId; + toast.on('open', function () { + (0, _dom.default)('.toast.modal-in').each(function (openedEl) { + var toastInstance = app.toast.get(openedEl); + + if (openedEl !== toast.el && toastInstance) { + toastInstance.close(); + } + }); + + if (closeTimeout) { + timeoutId = (0, _utils.nextTick)(function () { + toast.close(); + }, closeTimeout); + } + }); + toast.on('close', function () { + window.clearTimeout(timeoutId); + }); + + if (toast.params.destroyOnClose) { + toast.once('closed', function () { + setTimeout(function () { + toast.destroy(); + }, 0); + }); + } + + return toast || _assertThisInitialized(_this); + } + + var _proto = Toast.prototype; + + _proto.render = function render() { + var toast = this; + if (toast.params.render) return toast.params.render.call(toast, toast); + var _toast$params2 = toast.params, + position = _toast$params2.position, + horizontalPosition = _toast$params2.horizontalPosition, + cssClass = _toast$params2.cssClass, + icon = _toast$params2.icon, + text = _toast$params2.text, + closeButton = _toast$params2.closeButton, + closeButtonColor = _toast$params2.closeButtonColor, + closeButtonText = _toast$params2.closeButtonText; + var horizontalClass = position === 'top' || position === 'bottom' ? "toast-horizontal-" + horizontalPosition : ''; + return (0, _$jsx.default)("div", { + class: "toast toast-" + position + " " + horizontalClass + " " + (cssClass || '') + " " + (icon ? 'toast-with-icon' : '') + }, (0, _$jsx.default)("div", { + class: "toast-content" + }, icon && (0, _$jsx.default)("div", { + class: "toast-icon" + }, icon), (0, _$jsx.default)("div", { + class: "toast-text" + }, text), closeButton && !icon && (0, _$jsx.default)("a", { + class: "toast-button button " + (closeButtonColor ? "color-" + closeButtonColor : '') + }, closeButtonText))); + }; + + return Toast; +}(_modalClass.default); + +var _default = Toast; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/toast/toast.js b/www/assets/framework7/cjs/components/toast/toast.js new file mode 100644 index 000000000..4a65bd525 --- /dev/null +++ b/www/assets/framework7/cjs/components/toast/toast.js @@ -0,0 +1,51 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _utils = require("../../shared/utils"); + +var _toastClass = _interopRequireDefault(require("./toast-class")); + +var _modalMethods = _interopRequireDefault(require("../../shared/modal-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'toast', + static: { + Toast: _toastClass.default + }, + create: function create() { + var app = this; + app.toast = (0, _utils.extend)({}, (0, _modalMethods.default)({ + app: app, + constructor: _toastClass.default, + defaultSelector: '.toast.modal-in' + }), { + // Shortcuts + show: function show(params) { + (0, _utils.extend)(params, { + destroyOnClose: true + }); + return new _toastClass.default(app, params).open(); + } + }); + }, + params: { + toast: { + icon: null, + text: null, + position: 'bottom', + horizontalPosition: 'left', + closeButton: false, + closeButtonColor: null, + closeButtonText: 'Ok', + closeTimeout: null, + cssClass: null, + render: null, + containerEl: null + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/toggle/toggle-class.js b/www/assets/framework7/cjs/components/toggle/toggle-class.js new file mode 100644 index 000000000..482e3a432 --- /dev/null +++ b/www/assets/framework7/cjs/components/toggle/toggle-class.js @@ -0,0 +1,213 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _getSupport = require("../../shared/get-support"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Toggle = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(Toggle, _Framework7Class); + + function Toggle(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params, [app]) || this; + + var toggle = _assertThisInitialized(_this); + + var support = (0, _getSupport.getSupport)(); + var defaults = {}; // Extend defaults with modules params + + toggle.useModulesParams(defaults); + toggle.params = (0, _utils.extend)(defaults, params); + var el = toggle.params.el; + if (!el) return toggle || _assertThisInitialized(_this); + var $el = (0, _dom.default)(el); + if ($el.length === 0) return toggle || _assertThisInitialized(_this); + if ($el[0].f7Toggle) return $el[0].f7Toggle || _assertThisInitialized(_this); + var $inputEl = $el.children('input[type="checkbox"]'); + (0, _utils.extend)(toggle, { + app: app, + $el: $el, + el: $el[0], + $inputEl: $inputEl, + inputEl: $inputEl[0], + disabled: $el.hasClass('disabled') || $inputEl.hasClass('disabled') || $inputEl.attr('disabled') || $inputEl[0].disabled + }); + Object.defineProperty(toggle, 'checked', { + enumerable: true, + configurable: true, + set: function set(checked) { + if (!toggle || typeof toggle.$inputEl === 'undefined') return; + if (toggle.checked === checked) return; + $inputEl[0].checked = checked; + toggle.$inputEl.trigger('change'); + }, + get: function get() { + return $inputEl[0].checked; + } + }); + $el[0].f7Toggle = toggle; + var isTouched; + var touchesStart = {}; + var isScrolling; + var touchesDiff; + var toggleWidth; + var touchStartTime; + var touchStartChecked; + + function handleTouchStart(e) { + if (isTouched || toggle.disabled) return; + touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; + touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + touchesDiff = 0; + isTouched = true; + isScrolling = undefined; + touchStartTime = (0, _utils.now)(); + touchStartChecked = toggle.checked; + toggleWidth = $el[0].offsetWidth; + (0, _utils.nextTick)(function () { + if (isTouched) { + $el.addClass('toggle-active-state'); + } + }); + } + + function handleTouchMove(e) { + if (!isTouched || toggle.disabled) return; + var pageX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; + var pageY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; + var inverter = app.rtl ? -1 : 1; + + if (typeof isScrolling === 'undefined') { + isScrolling = !!(isScrolling || Math.abs(pageY - touchesStart.y) > Math.abs(pageX - touchesStart.x)); + } + + if (isScrolling) { + isTouched = false; + return; + } + + e.preventDefault(); + touchesDiff = pageX - touchesStart.x; + var changed; + + if (touchesDiff * inverter < 0 && Math.abs(touchesDiff) > toggleWidth / 3 && touchStartChecked) { + changed = true; + } + + if (touchesDiff * inverter > 0 && Math.abs(touchesDiff) > toggleWidth / 3 && !touchStartChecked) { + changed = true; + } + + if (changed) { + touchesStart.x = pageX; + toggle.checked = !touchStartChecked; + touchStartChecked = !touchStartChecked; + } + } + + function handleTouchEnd() { + if (!isTouched || toggle.disabled) { + if (isScrolling) $el.removeClass('toggle-active-state'); + isTouched = false; + return; + } + + var inverter = app.rtl ? -1 : 1; + isTouched = false; + $el.removeClass('toggle-active-state'); + var changed; + + if ((0, _utils.now)() - touchStartTime < 300) { + if (touchesDiff * inverter < 0 && touchStartChecked) { + changed = true; + } + + if (touchesDiff * inverter > 0 && !touchStartChecked) { + changed = true; + } + + if (changed) { + toggle.checked = !touchStartChecked; + } + } + } + + function handleInputChange() { + toggle.$el.trigger('toggle:change'); + toggle.emit('local::change toggleChange', toggle); + } + + toggle.attachEvents = function attachEvents() { + var passive = support.passiveListener ? { + passive: true + } : false; + $el.on(app.touchEvents.start, handleTouchStart, passive); + app.on('touchmove', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + toggle.$inputEl.on('change', handleInputChange); + }; + + toggle.detachEvents = function detachEvents() { + var passive = support.passiveListener ? { + passive: true + } : false; + $el.off(app.touchEvents.start, handleTouchStart, passive); + app.off('touchmove', handleTouchMove); + app.off('touchend:passive', handleTouchEnd); + toggle.$inputEl.off('change', handleInputChange); + }; // Install Modules + + + toggle.useModules(); // Init + + toggle.init(); + return _this; + } + + var _proto = Toggle.prototype; + + _proto.toggle = function toggle() { + var toggle = this; + toggle.checked = !toggle.checked; + }; + + _proto.init = function init() { + var toggle = this; + toggle.attachEvents(); + }; + + _proto.destroy = function destroy() { + var toggle = this; + toggle.$el.trigger('toggle:beforedestroy'); + toggle.emit('local::beforeDestroy toggleBeforeDestroy', toggle); + delete toggle.$el[0].f7Toggle; + toggle.detachEvents(); + (0, _utils.deleteProps)(toggle); + toggle = null; + }; + + return Toggle; +}(_class.default); + +var _default = Toggle; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/toggle/toggle.js b/www/assets/framework7/cjs/components/toggle/toggle.js new file mode 100644 index 000000000..2beaff1a9 --- /dev/null +++ b/www/assets/framework7/cjs/components/toggle/toggle.js @@ -0,0 +1,72 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +var _toggleClass = _interopRequireDefault(require("./toggle-class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'toggle', + create: function create() { + var app = this; + app.toggle = (0, _constructorMethods.default)({ + defaultSelector: '.toggle', + constructor: _toggleClass.default, + app: app, + domProp: 'f7Toggle' + }); + }, + static: { + Toggle: _toggleClass.default + }, + on: { + tabMounted: function tabMounted(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.toggle-init').each(function (toggleEl) { + return app.toggle.create({ + el: toggleEl + }); + }); + }, + tabBeforeRemove: function tabBeforeRemove(tabEl) { + (0, _dom.default)(tabEl).find('.toggle-init').each(function (toggleEl) { + if (toggleEl.f7Toggle) toggleEl.f7Toggle.destroy(); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.toggle-init').each(function (toggleEl) { + return app.toggle.create({ + el: toggleEl + }); + }); + }, + pageBeforeRemove: function pageBeforeRemove(page) { + page.$el.find('.toggle-init').each(function (toggleEl) { + if (toggleEl.f7Toggle) toggleEl.f7Toggle.destroy(); + }); + } + }, + vnode: { + 'toggle-init': { + insert: function insert(vnode) { + var app = this; + var toggleEl = vnode.elm; + app.toggle.create({ + el: toggleEl + }); + }, + destroy: function destroy(vnode) { + var toggleEl = vnode.elm; + if (toggleEl.f7Toggle) toggleEl.f7Toggle.destroy(); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/toolbar/toolbar.js b/www/assets/framework7/cjs/components/toolbar/toolbar.js new file mode 100644 index 000000000..885b0699a --- /dev/null +++ b/www/assets/framework7/cjs/components/toolbar/toolbar.js @@ -0,0 +1,234 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Toolbar = { + setHighlight: function setHighlight(tabbarEl) { + var app = this; + var $tabbarEl = (0, _dom.default)(tabbarEl); + if (app.theme === 'ios' && !$tabbarEl.hasClass('tabbar-highlight')) return; + if ($tabbarEl.length === 0 || !($tabbarEl.hasClass('tabbar') || $tabbarEl.hasClass('tabbar-labels'))) return; + var $highlightEl = $tabbarEl.find('.tab-link-highlight'); + var tabLinksCount = $tabbarEl.find('.tab-link').length; + + if (tabLinksCount === 0) { + $highlightEl.remove(); + return; + } + + if ($highlightEl.length === 0) { + $tabbarEl.children('.toolbar-inner').append(''); + $highlightEl = $tabbarEl.find('.tab-link-highlight'); + } else if ($highlightEl.next().length) { + $tabbarEl.children('.toolbar-inner').append($highlightEl); + } + + var $activeLink = $tabbarEl.find('.tab-link-active'); + var highlightWidth; + var highlightTranslate; + + if ($tabbarEl.hasClass('tabbar-scrollable') && $activeLink && $activeLink[0]) { + highlightWidth = $activeLink[0].offsetWidth + "px"; + highlightTranslate = $activeLink[0].offsetLeft + "px"; + } else { + var activeIndex = $activeLink.index(); + highlightWidth = 100 / tabLinksCount + "%"; + highlightTranslate = (app.rtl ? -activeIndex : activeIndex) * 100 + "%"; + } + + (0, _utils.nextFrame)(function () { + $highlightEl.css('width', highlightWidth).transform("translate3d(" + highlightTranslate + ",0,0)"); + }); + }, + init: function init(tabbarEl) { + var app = this; + app.toolbar.setHighlight(tabbarEl); + }, + hide: function hide(el, animate) { + if (animate === void 0) { + animate = true; + } + + var app = this; + var $el = (0, _dom.default)(el); + if ($el.hasClass('toolbar-hidden')) return; + var className = "toolbar-hidden" + (animate ? ' toolbar-transitioning' : ''); + $el.transitionEnd(function () { + $el.removeClass('toolbar-transitioning'); + }); + $el.addClass(className); + $el.trigger('toolbar:hide'); + app.emit('toolbarHide', $el[0]); + }, + show: function show(el, animate) { + if (animate === void 0) { + animate = true; + } + + var app = this; + var $el = (0, _dom.default)(el); + if (!$el.hasClass('toolbar-hidden')) return; + + if (animate) { + $el.addClass('toolbar-transitioning'); + $el.transitionEnd(function () { + $el.removeClass('toolbar-transitioning'); + }); + } + + $el.removeClass('toolbar-hidden'); + $el.trigger('toolbar:show'); + app.emit('toolbarShow', $el[0]); + }, + initToolbarOnScroll: function initToolbarOnScroll(pageEl) { + var app = this; + var $pageEl = (0, _dom.default)(pageEl); + var $toolbarEl = $pageEl.parents('.view').children('.toolbar'); + + if ($toolbarEl.length === 0) { + $toolbarEl = $pageEl.find('.toolbar'); + } + + if ($toolbarEl.length === 0) { + $toolbarEl = $pageEl.parents('.views').children('.tabbar, .tabbar-labels'); + } + + if ($toolbarEl.length === 0) { + return; + } + + var previousScrollTop; + var currentScrollTop; + var scrollHeight; + var offsetHeight; + var reachEnd; + var action; + var toolbarHidden; + + function handleScroll(e) { + if ($pageEl.hasClass('page-with-card-opened')) return; + if ($pageEl.hasClass('page-previous')) return; + var scrollContent = this; + + if (e && e.target && e.target !== scrollContent) { + return; + } + + currentScrollTop = scrollContent.scrollTop; + scrollHeight = scrollContent.scrollHeight; + offsetHeight = scrollContent.offsetHeight; + reachEnd = currentScrollTop + offsetHeight >= scrollHeight; + toolbarHidden = $toolbarEl.hasClass('toolbar-hidden'); + + if (reachEnd) { + if (app.params.toolbar.showOnPageScrollEnd) { + action = 'show'; + } + } else if (previousScrollTop > currentScrollTop) { + if (app.params.toolbar.showOnPageScrollTop || currentScrollTop <= 44) { + action = 'show'; + } else { + action = 'hide'; + } + } else if (currentScrollTop > 44) { + action = 'hide'; + } else { + action = 'show'; + } + + if (action === 'show' && toolbarHidden) { + app.toolbar.show($toolbarEl); + toolbarHidden = false; + } else if (action === 'hide' && !toolbarHidden) { + app.toolbar.hide($toolbarEl); + toolbarHidden = true; + } + + previousScrollTop = currentScrollTop; + } + + $pageEl.on('scroll', '.page-content', handleScroll, true); + $pageEl[0].f7ScrollToolbarHandler = handleScroll; + } +}; +var _default = { + name: 'toolbar', + create: function create() { + var app = this; + (0, _utils.bindMethods)(app, { + toolbar: Toolbar + }); + }, + params: { + toolbar: { + hideOnPageScroll: false, + showOnPageScrollEnd: true, + showOnPageScrollTop: true + } + }, + on: { + pageBeforeRemove: function pageBeforeRemove(page) { + if (page.$el[0].f7ScrollToolbarHandler) { + page.$el.off('scroll', '.page-content', page.$el[0].f7ScrollToolbarHandler, true); + } + }, + pageBeforeIn: function pageBeforeIn(page) { + var app = this; + var $toolbarEl = page.$el.parents('.view').children('.toolbar'); + + if ($toolbarEl.length === 0) { + $toolbarEl = page.$el.parents('.views').children('.tabbar, .tabbar-labels'); + } + + if ($toolbarEl.length === 0) { + $toolbarEl = page.$el.find('.toolbar'); + } + + if ($toolbarEl.length === 0) { + return; + } + + if (page.$el.hasClass('no-toolbar')) { + app.toolbar.hide($toolbarEl); + } else { + app.toolbar.show($toolbarEl); + } + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.tabbar, .tabbar-labels').each(function (tabbarEl) { + app.toolbar.init(tabbarEl); + }); + + if (app.params.toolbar.hideOnPageScroll || page.$el.find('.hide-toolbar-on-scroll').length || page.$el.hasClass('hide-toolbar-on-scroll') || page.$el.find('.hide-bars-on-scroll').length || page.$el.hasClass('hide-bars-on-scroll')) { + if (page.$el.find('.keep-toolbar-on-scroll').length || page.$el.hasClass('keep-toolbar-on-scroll') || page.$el.find('.keep-bars-on-scroll').length || page.$el.hasClass('keep-bars-on-scroll')) { + return; + } + + app.toolbar.initToolbarOnScroll(page.el); + } + }, + init: function init() { + var app = this; + app.$el.find('.tabbar, .tabbar-labels').each(function (tabbarEl) { + app.toolbar.init(tabbarEl); + }); + } + }, + vnode: { + tabbar: { + insert: function insert(vnode) { + var app = this; + app.toolbar.init(vnode.elm); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/tooltip/tooltip-class.js b/www/assets/framework7/cjs/components/tooltip/tooltip-class.js new file mode 100644 index 000000000..dc9648c0b --- /dev/null +++ b/www/assets/framework7/cjs/components/tooltip/tooltip-class.js @@ -0,0 +1,409 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _getSupport = require("../../shared/get-support"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Tooltip = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(Tooltip, _Framework7Class); + + function Tooltip(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params, [app]) || this; + + var tooltip = _assertThisInitialized(_this); + + var support = (0, _getSupport.getSupport)(); + var defaults = (0, _utils.extend)({}, app.params.tooltip); + var document = (0, _ssrWindow.getDocument)(); // Extend defaults with modules params + + tooltip.useModulesParams(defaults); + tooltip.params = (0, _utils.extend)(defaults, params); + + if (typeof params.offset === 'undefined' && support.touch && tooltip.params.trigger === 'hover') { + tooltip.params.offset = 10; + } + + var _tooltip$params = tooltip.params, + targetEl = _tooltip$params.targetEl, + containerEl = _tooltip$params.containerEl; + if (!targetEl && !tooltip.params.delegated) return tooltip || _assertThisInitialized(_this); + var $targetEl = (0, _dom.default)(targetEl); + if ($targetEl.length === 0 && !tooltip.params.delegated) return tooltip || _assertThisInitialized(_this); + if ($targetEl[0] && $targetEl[0].f7Tooltip && !tooltip.params.delegated) return $targetEl[0].f7Tooltip || _assertThisInitialized(_this); + var $containerEl = (0, _dom.default)(containerEl || app.$el).eq(0); + + if ($containerEl.length === 0) { + $containerEl = app.$el; + } + + var $el = (0, _dom.default)(tooltip.render()).eq(0); + (0, _utils.extend)(tooltip, { + app: app, + $targetEl: $targetEl, + targetEl: $targetEl && $targetEl[0], + $containerEl: $containerEl, + containerEl: $containerEl && $containerEl[0], + $el: $el, + el: $el && $el[0], + text: tooltip.params.text || '', + visible: false, + opened: false + }); + if ($targetEl[0]) $targetEl[0].f7Tooltip = tooltip; + var touchesStart = {}; + var isTouched; + + function handleClick() { + if (tooltip.opened) tooltip.hide();else tooltip.show(this); + } + + function handleClickOut(e) { + if (tooltip.opened && ((0, _dom.default)(e.target).closest($targetEl).length || (0, _dom.default)(e.target).closest(tooltip.$el).length)) return; + tooltip.hide(); + } + + function handleTouchStart(e) { + if (isTouched) return; + isTouched = true; + touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; + touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + tooltip.show(this); + } + + function handleTouchMove(e) { + if (!isTouched) return; + var x = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; + var y = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; + var distance = Math.pow(Math.pow(x - touchesStart.x, 2) + Math.pow(y - touchesStart.y, 2), 0.5); + + if (distance > 50) { + isTouched = false; + tooltip.hide(); + } + } + + function handleTouchEnd() { + if (!isTouched) return; + isTouched = false; + tooltip.hide(); + } + + function handleMouseEnter() { + tooltip.show(this); + } + + function handleMouseLeave() { + tooltip.hide(); + } + + function handleTransitionEnd() { + if (!$el.hasClass('tooltip-in')) { + $el.removeClass('tooltip-out').remove(); + } + } + + tooltip.attachEvents = function attachEvents() { + $el.on('transitionend', handleTransitionEnd); + + if (tooltip.params.trigger === 'click') { + if (tooltip.params.delegated) { + (0, _dom.default)(document).on('click', tooltip.params.targetEl, handleClick); + } else { + tooltip.$targetEl.on('click', handleClick); + } + + (0, _dom.default)('html').on('click', handleClickOut); + return; + } + + if (tooltip.params.trigger === 'manual') return; + + if (support.touch) { + var passive = support.passiveListener ? { + passive: true + } : false; + + if (tooltip.params.delegated) { + (0, _dom.default)(document).on(app.touchEvents.start, tooltip.params.targetEl, handleTouchStart, passive); + } else { + tooltip.$targetEl.on(app.touchEvents.start, handleTouchStart, passive); + } + + app.on('touchmove', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + } else { + // eslint-disable-next-line + if (tooltip.params.delegated) { + (0, _dom.default)(document).on(support.pointerEvents ? 'pointerenter' : 'mouseenter', tooltip.params.targetEl, handleMouseEnter, true); + (0, _dom.default)(document).on(support.pointerEvents ? 'pointerleave' : 'mouseleave', tooltip.params.targetEl, handleMouseLeave, true); + } else { + tooltip.$targetEl.on(support.pointerEvents ? 'pointerenter' : 'mouseenter', handleMouseEnter); + tooltip.$targetEl.on(support.pointerEvents ? 'pointerleave' : 'mouseleave', handleMouseLeave); + } + } + }; + + tooltip.detachEvents = function detachEvents() { + $el.off('transitionend', handleTransitionEnd); + + if (tooltip.params.trigger === 'click') { + if (tooltip.params.delegated) { + (0, _dom.default)(document).on('click', tooltip.params.targetEl, handleClick); + } else { + tooltip.$targetEl.off('click', handleClick); + } + + (0, _dom.default)('html').off('click', handleClickOut); + return; + } + + if (tooltip.params.trigger === 'manual') return; + + if (support.touch) { + var passive = support.passiveListener ? { + passive: true + } : false; + + if (tooltip.params.delegated) { + (0, _dom.default)(document).off(app.touchEvents.start, tooltip.params.targetEl, handleTouchStart, passive); + } else { + tooltip.$targetEl.off(app.touchEvents.start, handleTouchStart, passive); + } + + app.off('touchmove', handleTouchMove); + app.off('touchend:passive', handleTouchEnd); + } else { + // eslint-disable-next-line + if (tooltip.params.delegated) { + (0, _dom.default)(document).off(support.pointerEvents ? 'pointerenter' : 'mouseenter', tooltip.params.targetEl, handleMouseEnter, true); + (0, _dom.default)(document).off(support.pointerEvents ? 'pointerleave' : 'mouseleave', tooltip.params.targetEl, handleMouseLeave, true); + } else { + tooltip.$targetEl.off(support.pointerEvents ? 'pointerenter' : 'mouseenter', handleMouseEnter); + tooltip.$targetEl.off(support.pointerEvents ? 'pointerleave' : 'mouseleave', handleMouseLeave); + } + } + }; // Install Modules + + + tooltip.useModules(); + tooltip.init(); + return tooltip || _assertThisInitialized(_this); + } + + var _proto = Tooltip.prototype; + + _proto.setTargetEl = function setTargetEl(targetEl) { + var tooltip = this; + tooltip.detachEvents(); + tooltip.$targetEl = (0, _dom.default)(targetEl); + tooltip.targetEl = tooltip.$targetEl[0]; + tooltip.attachEvents(); + return tooltip; + }; + + _proto.position = function position(targetEl) { + var tooltip = this; + var $el = tooltip.$el, + app = tooltip.app, + $containerEl = tooltip.$containerEl; + var hasContainerEl = !!tooltip.params.containerEl; + var tooltipOffset = tooltip.params.offset || 0; + $el.css({ + left: '', + top: '' + }); + var $targetEl = (0, _dom.default)(targetEl || tooltip.targetEl); + var _ref = [$el.width(), $el.height()], + width = _ref[0], + height = _ref[1]; + $el.css({ + left: '', + top: '' + }); + var targetWidth; + var targetHeight; + var targetOffsetLeft; + var targetOffsetTop; + var boundaries = hasContainerEl && $containerEl.length ? $containerEl[0].getBoundingClientRect() : app; + + if ($targetEl && $targetEl.length > 0) { + targetWidth = $targetEl.outerWidth(); + targetHeight = $targetEl.outerHeight(); + + if (typeof targetWidth === 'undefined' && typeof targetHeight === 'undefined') { + var clientRect = $targetEl[0].getBoundingClientRect(); + targetWidth = clientRect.width; + targetHeight = clientRect.height; + } + + var targetOffset = $targetEl.offset(); + targetOffsetLeft = targetOffset.left - boundaries.left; + targetOffsetTop = targetOffset.top - boundaries.top; + var targetParentPage = $targetEl.parents('.page'); + + if (targetParentPage.length > 0) { + targetOffsetTop -= targetParentPage[0].scrollTop; + } + } + + var _ref2 = [0, 0, 0], + left = _ref2[0], + top = _ref2[1]; // Top Position + + var position = 'top'; + + if (height + tooltipOffset < targetOffsetTop) { + // On top + top = targetOffsetTop - height - tooltipOffset; + } else if (height < boundaries.height - targetOffsetTop - targetHeight) { + // On bottom + position = 'bottom'; + top = targetOffsetTop + targetHeight + tooltipOffset; + } else { + // On middle + position = 'middle'; + top = targetHeight / 2 + targetOffsetTop - height / 2; + + if (top <= 0) { + top = 8; + } else if (top + height >= boundaries.height) { + top = boundaries.height - height - 8; + } + } // Horizontal Position + + + if (position === 'top' || position === 'bottom') { + left = targetWidth / 2 + targetOffsetLeft - width / 2; + if (left < 8) left = 8; + if (left + width > boundaries.width) left = boundaries.width - width - 8; + if (left < 0) left = 0; + } else if (position === 'middle') { + left = targetOffsetLeft - width; + + if (left < 8 || left + width > boundaries.width) { + if (left < 8) left = targetOffsetLeft + targetWidth; + if (left + width > boundaries.width) left = boundaries.width - width - 8; + } + } // Apply Styles + + + $el.css({ + top: top + "px", + left: left + "px" + }); + }; + + _proto.show = function show(aroundEl) { + var tooltip = this; + var $el = tooltip.$el, + $targetEl = tooltip.$targetEl, + $containerEl = tooltip.$containerEl; + + if ($containerEl[0] && $el[0] && !$containerEl[0].contains($el[0])) { + $containerEl.append($el); + } + + tooltip.position(aroundEl); + var $aroundEl = (0, _dom.default)(aroundEl); + tooltip.visible = true; + tooltip.opened = true; + $targetEl.trigger('tooltip:show'); + $el.trigger('tooltip:show'); + + if ($aroundEl.length && $aroundEl[0] !== $targetEl[0]) { + $aroundEl.trigger('tooltip:show'); + } + + tooltip.emit('local::show tooltipShow', tooltip); + $el.removeClass('tooltip-out').addClass('tooltip-in'); + return tooltip; + }; + + _proto.hide = function hide() { + var tooltip = this; + var $el = tooltip.$el, + $targetEl = tooltip.$targetEl; + tooltip.visible = false; + tooltip.opened = false; + $targetEl.trigger('tooltip:hide'); + $el.trigger('tooltip:hide'); + tooltip.emit('local::hide tooltipHide', tooltip); + $el.addClass('tooltip-out').removeClass('tooltip-in'); + return tooltip; + }; + + _proto.render = function render() { + var tooltip = this; + if (tooltip.params.render) return tooltip.params.render.call(tooltip, tooltip); + var _tooltip$params2 = tooltip.params, + cssClass = _tooltip$params2.cssClass, + text = _tooltip$params2.text; + return ("\n
    \n
    " + (text || '') + "
    \n
    \n ").trim(); + }; + + _proto.setText = function setText(newText) { + var tooltip = this; + + if (typeof newText === 'undefined') { + return tooltip; + } + + tooltip.params.text = newText; + tooltip.text = newText; + + if (tooltip.$el) { + tooltip.$el.children('.tooltip-content').html(newText); + } + + if (tooltip.opened) { + tooltip.position(); + } + + return tooltip; + }; + + _proto.init = function init() { + var tooltip = this; + tooltip.attachEvents(); + }; + + _proto.destroy = function destroy() { + var tooltip = this; + if (!tooltip.$targetEl || tooltip.destroyed) return; + tooltip.$targetEl.trigger('tooltip:beforedestroy'); + tooltip.emit('local::beforeDestroy tooltipBeforeDestroy', tooltip); + tooltip.$el.remove(); + if (tooltip.$targetEl[0]) delete tooltip.$targetEl[0].f7Tooltip; + tooltip.detachEvents(); + (0, _utils.deleteProps)(tooltip); + tooltip.destroyed = true; + }; + + return Tooltip; +}(_class.default); + +var _default = Tooltip; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/tooltip/tooltip.js b/www/assets/framework7/cjs/components/tooltip/tooltip.js new file mode 100644 index 000000000..038fdd558 --- /dev/null +++ b/www/assets/framework7/cjs/components/tooltip/tooltip.js @@ -0,0 +1,146 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _tooltipClass = _interopRequireDefault(require("./tooltip-class")); + +var _constructorMethods = _interopRequireDefault(require("../../shared/constructor-methods")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = { + name: 'tooltip', + static: { + Tooltip: _tooltipClass.default + }, + create: function create() { + var app = this; + app.tooltip = (0, _constructorMethods.default)({ + defaultSelector: '.tooltip', + constructor: _tooltipClass.default, + app: app, + domProp: 'f7Tooltip' + }); + + app.tooltip.show = function show(el) { + var $el = (0, _dom.default)(el); + if ($el.length === 0) return undefined; + var tooltip = $el[0].f7Tooltip; + if (!tooltip) return undefined; + tooltip.show($el[0]); + return tooltip; + }; + + app.tooltip.hide = function hide(el) { + var $el = (0, _dom.default)(el); + if ($el.length === 0) return undefined; + var tooltip = $el[0].f7Tooltip; + if (!tooltip) return undefined; + tooltip.hide(); + return tooltip; + }; + + app.tooltip.setText = function text(el, newText) { + var $el = (0, _dom.default)(el); + if ($el.length === 0) return undefined; + var tooltip = $el[0].f7Tooltip; + if (!tooltip) return undefined; + tooltip.setText(newText); + return tooltip; + }; + }, + params: { + tooltip: { + targetEl: null, + delegated: false, + text: null, + cssClass: null, + render: null, + offset: 0, + trigger: 'hover', + containerEl: undefined + } + }, + on: { + tabMounted: function tabMounted(tabEl) { + var app = this; + (0, _dom.default)(tabEl).find('.tooltip-init').each(function (el) { + var text = (0, _dom.default)(el).attr('data-tooltip'); + if (!text) return; + app.tooltip.create({ + targetEl: el, + text: text + }); + }); + }, + tabBeforeRemove: function tabBeforeRemove(tabEl) { + (0, _dom.default)(tabEl).find('.tooltip-init').each(function (el) { + if (el.f7Tooltip) el.f7Tooltip.destroy(); + }); + }, + pageInit: function pageInit(page) { + var app = this; + page.$el.find('.tooltip-init').each(function (el) { + var text = (0, _dom.default)(el).attr('data-tooltip'); + if (!text) return; + app.tooltip.create({ + targetEl: el, + text: text + }); + }); + + if (app.theme === 'ios' && page.view && page.view.router.dynamicNavbar && page.$navbarEl && page.$navbarEl.length > 0) { + page.$navbarEl.find('.tooltip-init').each(function (el) { + var text = (0, _dom.default)(el).attr('data-tooltip'); + if (!text) return; + app.tooltip.create({ + targetEl: el, + text: text + }); + }); + } + }, + pageBeforeRemove: function pageBeforeRemove(page) { + var app = this; + page.$el.find('.tooltip-init').each(function (el) { + if (el.f7Tooltip) el.f7Tooltip.destroy(); + }); + + if (app.theme === 'ios' && page.view && page.view.router.dynamicNavbar && page.$navbarEl && page.$navbarEl.length > 0) { + page.$navbarEl.find('.tooltip-init').each(function (el) { + if (el.f7Tooltip) el.f7Tooltip.destroy(); + }); + } + } + }, + vnode: { + 'tooltip-init': { + insert: function insert(vnode) { + var app = this; + var el = vnode.elm; + var text = (0, _dom.default)(el).attr('data-tooltip'); + if (!text) return; + app.tooltip.create({ + targetEl: el, + text: text + }); + }, + update: function update(vnode) { + var el = vnode.elm; + if (!el.f7Tooltip) return; + + if (vnode && vnode.data && vnode.data.attrs && vnode.data.attrs['data-tooltip']) { + el.f7Tooltip.setText(vnode.data.attrs['data-tooltip']); + } + }, + destroy: function destroy(vnode) { + var el = vnode.elm; + if (el.f7Tooltip) el.f7Tooltip.destroy(); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/touch-ripple/touch-ripple-class.js b/www/assets/framework7/cjs/components/touch-ripple/touch-ripple-class.js new file mode 100644 index 000000000..57a253400 --- /dev/null +++ b/www/assets/framework7/cjs/components/touch-ripple/touch-ripple-class.js @@ -0,0 +1,110 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var TouchRipple = /*#__PURE__*/function () { + function TouchRipple(app, $el, x, y) { + var ripple = this; + if (!$el) return undefined; + + var _$el$0$getBoundingCli = $el[0].getBoundingClientRect(), + left = _$el$0$getBoundingCli.left, + top = _$el$0$getBoundingCli.top, + width = _$el$0$getBoundingCli.width, + height = _$el$0$getBoundingCli.height; + + var center = { + x: x - left, + y: y - top + }; + var diameter = Math.max(Math.pow(Math.pow(height, 2) + Math.pow(width, 2), 0.5), 48); + var isInset = false; + var insetElements = app.params.touch.touchRippleInsetElements || ''; + + if (insetElements && $el.is(insetElements)) { + isInset = true; + } + + if (isInset) { + diameter = Math.max(Math.min(width, height), 48); + } + + if (!isInset && $el.css('overflow') === 'hidden') { + var distanceFromCenter = Math.pow(Math.pow(center.x - width / 2, 2) + Math.pow(center.y - height / 2, 2), 0.5); + var scale = (diameter / 2 + distanceFromCenter) / (diameter / 2); + ripple.rippleTransform = "translate3d(0px, 0px, 0) scale(" + scale + ")"; + } else { + // prettier-ignore + ripple.rippleTransform = "translate3d(" + (-center.x + width / 2) + "px, " + (-center.y + height / 2) + "px, 0) scale(1)"; + } + + if (isInset) { + $el.addClass('ripple-inset'); + } + + ripple.$rippleWaveEl = (0, _dom.default)("
    "); + $el.prepend(ripple.$rippleWaveEl); + ripple.$rippleWaveEl.animationEnd(function () { + if (!ripple.$rippleWaveEl) return; + if (ripple.$rippleWaveEl.hasClass('ripple-wave-out')) return; + ripple.$rippleWaveEl.addClass('ripple-wave-in'); + + if (ripple.shouldBeRemoved) { + ripple.out(); + } + }); + return ripple; + } + + var _proto = TouchRipple.prototype; + + _proto.destroy = function destroy() { + var ripple = this; + + if (ripple.$rippleWaveEl) { + ripple.$rippleWaveEl.remove(); + } + + Object.keys(ripple).forEach(function (key) { + ripple[key] = null; + delete ripple[key]; + }); + ripple = null; + }; + + _proto.out = function out() { + var ripple = this; + var $rippleWaveEl = this.$rippleWaveEl; + clearTimeout(ripple.removeTimeout); + $rippleWaveEl.addClass('ripple-wave-out'); + ripple.removeTimeout = setTimeout(function () { + ripple.destroy(); + }, 300); + $rippleWaveEl.animationEnd(function () { + clearTimeout(ripple.removeTimeout); + ripple.destroy(); + }); + }; + + _proto.remove = function remove() { + var ripple = this; + if (ripple.shouldBeRemoved) return; + ripple.removeTimeout = setTimeout(function () { + ripple.destroy(); + }, 400); + ripple.shouldBeRemoved = true; + + if (ripple.$rippleWaveEl.hasClass('ripple-wave-in')) { + ripple.out(); + } + }; + + return TouchRipple; +}(); + +exports.default = TouchRipple; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/touch-ripple/touch-ripple.js b/www/assets/framework7/cjs/components/touch-ripple/touch-ripple.js new file mode 100644 index 000000000..34ce327b8 --- /dev/null +++ b/www/assets/framework7/cjs/components/touch-ripple/touch-ripple.js @@ -0,0 +1,34 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _touchRippleClass = _interopRequireDefault(require("./touch-ripple-class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var _default = { + name: 'touch-ripple', + static: { + TouchRipple: _touchRippleClass.default + }, + create: function create() { + var app = this; + app.touchRipple = { + create: function create() { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _construct(_touchRippleClass.default, args); + } + }; + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/treeview/treeview.js b/www/assets/framework7/cjs/components/treeview/treeview.js new file mode 100644 index 000000000..c5d02a235 --- /dev/null +++ b/www/assets/framework7/cjs/components/treeview/treeview.js @@ -0,0 +1,88 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Treeview = { + open: function open(itemEl) { + var app = this; + var $itemEl = (0, _dom.default)(itemEl).eq(0); + if (!$itemEl.length) return; + $itemEl.addClass('treeview-item-opened'); + $itemEl.trigger('treeview:open'); + app.emit('treeviewOpen', $itemEl[0]); + + function done(cancel) { + if (cancel) { + $itemEl.removeClass('treeview-item-opened'); + $itemEl.trigger('treeview:close'); + app.emit('treeviewClose', $itemEl[0]); + } else { + $itemEl[0].f7TreeviewChildrenLoaded = true; + } + + $itemEl.find('.treeview-toggle').removeClass('treeview-toggle-hidden'); + $itemEl.find('.treeview-preloader').remove(); + } + + if ($itemEl.hasClass('treeview-load-children') && !$itemEl[0].f7TreeviewChildrenLoaded) { + var preloaders = { + iosPreloaderContent: _utils.iosPreloaderContent, + mdPreloaderContent: _utils.mdPreloaderContent, + auroraPreloaderContent: _utils.auroraPreloaderContent + }; + $itemEl.trigger('treeview:loadchildren', done); + app.emit('treeviewLoadChildren', $itemEl[0], done); + $itemEl.find('.treeview-toggle').addClass('treeview-toggle-hidden'); + $itemEl.find('.treeview-item-root').prepend("
    " + preloaders[app.theme + "PreloaderContent"] + "
    "); + } + }, + close: function close(itemEl) { + var app = this; + var $itemEl = (0, _dom.default)(itemEl).eq(0); + if (!$itemEl.length) return; + $itemEl.removeClass('treeview-item-opened'); + $itemEl.trigger('treeview:close'); + app.emit('treeviewClose', $itemEl[0]); + }, + toggle: function toggle(itemEl) { + var app = this; + var $itemEl = (0, _dom.default)(itemEl).eq(0); + if (!$itemEl.length) return; + var wasOpened = $itemEl.hasClass('treeview-item-opened'); + app.treeview[wasOpened ? 'close' : 'open']($itemEl); + } +}; +var _default = { + name: 'treeview', + create: function create() { + var app = this; + (0, _utils.bindMethods)(app, { + treeview: Treeview + }); + }, + clicks: { + '.treeview-toggle': function toggle($clickedEl, clickedData, e) { + var app = this; + if ($clickedEl.parents('.treeview-item-toggle').length) return; + var $treeviewItemEl = $clickedEl.parents('.treeview-item').eq(0); + if (!$treeviewItemEl.length) return; + e.preventF7Router = true; + app.treeview.toggle($treeviewItemEl[0]); + }, + '.treeview-item-toggle': function toggle($clickedEl, clickedData, e) { + var app = this; + var $treeviewItemEl = $clickedEl.closest('.treeview-item').eq(0); + if (!$treeviewItemEl.length) return; + e.preventF7Router = true; + app.treeview.toggle($treeviewItemEl[0]); + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/typography/typography.js b/www/assets/framework7/cjs/components/typography/typography.js new file mode 100644 index 000000000..bec68a934 --- /dev/null +++ b/www/assets/framework7/cjs/components/typography/typography.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _default = { + name: 'typography' +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/view/resizable-view.js b/www/assets/framework7/cjs/components/view/resizable-view.js new file mode 100644 index 000000000..69402e5a1 --- /dev/null +++ b/www/assets/framework7/cjs/components/view/resizable-view.js @@ -0,0 +1,155 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _getSupport = require("../../shared/get-support"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function resizableView(view) { + var app = view.app; + var support = (0, _getSupport.getSupport)(); + if (view.resizableInitialized) return; + (0, _utils.extend)(view, { + resizable: true, + resizableWidth: null, + resizableInitialized: true + }); + var $htmlEl = (0, _dom.default)('html'); + var $el = view.$el; + if (!$el) return; + var $resizeHandlerEl; + var isTouched; + var isMoved; + var touchesStart = {}; + var touchesDiff; + var width; + var minWidth; + var maxWidth; + + function transformCSSWidth(v) { + if (!v) return null; + + if (v.indexOf('%') >= 0 || v.indexOf('vw') >= 0) { + return parseInt(v, 10) / 100 * app.width; + } + + var newV = parseInt(v, 10); + if (Number.isNaN(newV)) return null; + return newV; + } + + function isResizable() { + return view.resizable && $el.hasClass('view-resizable') && $el.hasClass('view-master-detail'); + } + + function handleTouchStart(e) { + if (!isResizable()) return; + touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; + touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; + isMoved = false; + isTouched = true; + var $pageMasterEl = $el.children('.page-master'); + minWidth = transformCSSWidth($pageMasterEl.css('min-width')); + maxWidth = transformCSSWidth($pageMasterEl.css('max-width')); + } + + function handleTouchMove(e) { + if (!isTouched) return; + e.f7PreventSwipePanel = true; + var pageX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; + + if (!isMoved) { + width = $resizeHandlerEl[0].offsetLeft + $resizeHandlerEl[0].offsetWidth; + $el.addClass('view-resizing'); + $htmlEl.css('cursor', 'col-resize'); + } + + isMoved = true; + e.preventDefault(); + touchesDiff = pageX - touchesStart.x; + var newWidth = width + touchesDiff; + + if (minWidth && !Number.isNaN(minWidth)) { + newWidth = Math.max(newWidth, minWidth); + } + + if (maxWidth && !Number.isNaN(maxWidth)) { + newWidth = Math.min(newWidth, maxWidth); + } + + newWidth = Math.min(Math.max(newWidth, 0), app.width); + view.resizableWidth = newWidth; + $htmlEl[0].style.setProperty('--f7-page-master-width', newWidth + "px"); + $el.trigger('view:resize', newWidth); + view.emit('local::resize viewResize', view, newWidth); + } + + function handleTouchEnd() { + (0, _dom.default)('html').css('cursor', ''); + + if (!isTouched || !isMoved) { + isTouched = false; + isMoved = false; + return; + } + + isTouched = false; + isMoved = false; + $htmlEl[0].style.setProperty('--f7-page-master-width', view.resizableWidth + "px"); + $el.removeClass('view-resizing'); + } + + function handleResize() { + if (!view.resizableWidth) return; + minWidth = transformCSSWidth($resizeHandlerEl.css('min-width')); + maxWidth = transformCSSWidth($resizeHandlerEl.css('max-width')); + + if (minWidth && !Number.isNaN(minWidth) && view.resizableWidth < minWidth) { + view.resizableWidth = Math.max(view.resizableWidth, minWidth); + } + + if (maxWidth && !Number.isNaN(maxWidth) && view.resizableWidth > maxWidth) { + view.resizableWidth = Math.min(view.resizableWidth, maxWidth); + } + + view.resizableWidth = Math.min(Math.max(view.resizableWidth, 0), app.width); + $htmlEl[0].style.setProperty('--f7-page-master-width', view.resizableWidth + "px"); + } + + $resizeHandlerEl = view.$el.children('.view-resize-handler'); + + if (!$resizeHandlerEl.length) { + view.$el.append('
    '); + $resizeHandlerEl = view.$el.children('.view-resize-handler'); + } + + view.$resizeHandlerEl = $resizeHandlerEl; + $el.addClass('view-resizable'); // Add Events + + var passive = support.passiveListener ? { + passive: true + } : false; + view.$el.on(app.touchEvents.start, '.view-resize-handler', handleTouchStart, passive); + app.on('touchmove:active', handleTouchMove); + app.on('touchend:passive', handleTouchEnd); + app.on('resize', handleResize); + view.on('beforeOpen', handleResize); + view.once('viewDestroy', function () { + $el.removeClass('view-resizable'); + view.$resizeHandlerEl.remove(); + view.$el.off(app.touchEvents.start, '.view-resize-handler', handleTouchStart, passive); + app.off('touchmove:active', handleTouchMove); + app.off('touchend:passive', handleTouchEnd); + app.off('resize', handleResize); + view.off('beforeOpen', handleResize); + }); +} + +var _default = resizableView; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/view/view-class.js b/www/assets/framework7/cjs/components/view/view-class.js new file mode 100644 index 000000000..684008661 --- /dev/null +++ b/www/assets/framework7/cjs/components/view/view-class.js @@ -0,0 +1,251 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _router = _interopRequireDefault(require("../../modules/router/router")); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _resizableView = _interopRequireDefault(require("./resizable-view")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var View = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(View, _Framework7Class); + + function View(app, el, viewParams) { + var _this; + + if (viewParams === void 0) { + viewParams = {}; + } + + _this = _Framework7Class.call(this, viewParams, [app]) || this; + + var view = _assertThisInitialized(_this); + + var ssr = view.params.routerId; + var defaults = { + routes: [], + routesAdd: [] + }; + + if (!ssr) { + var $el = (0, _dom.default)(el); + + if (!$el.length) { + var message = "Framework7: can't create a View instance because "; + message += typeof el === 'string' ? "the selector \"" + el + "\" didn't match any element" : 'el must be an HTMLElement or Dom7 object'; + throw new Error(message); + } + } // Default View params + + + view.params = (0, _utils.extend)({ + el: el + }, defaults, app.params.view, viewParams); // Routes + + if (view.params.routes.length > 0) { + view.routes = view.params.routes; + } else { + view.routes = [].concat(app.routes, view.params.routesAdd); + } // View Props + + + (0, _utils.extend)(false, view, { + app: app, + name: view.params.name, + main: view.params.main, + history: [], + scrollHistory: {} + }); // Install Modules + + view.useModules(); // Add to app + + app.views.push(view); + + if (view.main) { + app.views.main = view; + } + + if (view.name) { + app.views[view.name] = view; + } // Index + + + view.index = app.views.indexOf(view); // View ID + + var viewId; + + if (view.name) { + viewId = "view_" + view.name; + } else if (view.main) { + viewId = 'view_main'; + } else { + viewId = "view_" + view.index; + } + + view.id = viewId; + + if (!view.params.init) { + return view || _assertThisInitialized(_this); + } // Init View + + + if (app.initialized) { + view.init(); + } else { + app.on('init', function () { + view.init(); + }); + } + + return view || _assertThisInitialized(_this); + } + + var _proto = View.prototype; + + _proto.destroy = function destroy() { + var view = this; + var app = view.app; + view.$el.trigger('view:beforedestroy'); + view.emit('local::beforeDestroy viewBeforeDestroy', view); + app.off('resize', view.checkMasterDetailBreakpoint); + + if (view.main) { + app.views.main = null; + delete app.views.main; + } else if (view.name) { + app.views[view.name] = null; + delete app.views[view.name]; + } + + view.$el[0].f7View = null; + delete view.$el[0].f7View; + app.views.splice(app.views.indexOf(view), 1); // Destroy Router + + if (view.params.router && view.router) { + view.router.destroy(); + } + + view.emit('local::destroy viewDestroy', view); // Delete props & methods + + Object.keys(view).forEach(function (viewProp) { + view[viewProp] = null; + delete view[viewProp]; + }); + view = null; + }; + + _proto.checkMasterDetailBreakpoint = function checkMasterDetailBreakpoint(force) { + var view = this; + var app = view.app; + var wasMasterDetail = view.$el.hasClass('view-master-detail'); + var isMasterDetail = app.width >= view.params.masterDetailBreakpoint && view.$el.children('.page-master').length; + + if (typeof force === 'undefined' && isMasterDetail || force === true) { + view.$el.addClass('view-master-detail'); + + if (!wasMasterDetail) { + view.emit('local::masterDetailBreakpoint viewMasterDetailBreakpoint', view); + view.$el.trigger('view:masterDetailBreakpoint'); + } + } else { + view.$el.removeClass('view-master-detail'); + + if (wasMasterDetail) { + view.emit('local::masterDetailBreakpoint viewMasterDetailBreakpoint', view); + view.$el.trigger('view:masterDetailBreakpoint'); + } + } + }; + + _proto.initMasterDetail = function initMasterDetail() { + var view = this; + var app = view.app; + view.checkMasterDetailBreakpoint = view.checkMasterDetailBreakpoint.bind(view); + view.checkMasterDetailBreakpoint(); + + if (view.params.masterDetailResizable) { + (0, _resizableView.default)(view); + } + + app.on('resize', view.checkMasterDetailBreakpoint); + }; + + _proto.mount = function mount(viewEl) { + var view = this; + var app = view.app; + var el = view.params.el || viewEl; + var $el = (0, _dom.default)(el); // Selector + + var selector; + if (typeof el === 'string') selector = el;else { + // Supposed to be HTMLElement or Dom7 + selector = ($el.attr('id') ? "#" + $el.attr('id') : '') + ($el.attr('class') ? "." + $el.attr('class').replace(/ /g, '.').replace('.active', '') : ''); + } // DynamicNavbar + + var $navbarsEl; + + if (app.theme === 'ios' && view.params.iosDynamicNavbar) { + $navbarsEl = $el.children('.navbars').eq(0); + + if ($navbarsEl.length === 0) { + $navbarsEl = (0, _dom.default)(''); + } + } + + (0, _utils.extend)(view, { + $el: $el, + el: $el[0], + main: view.main || $el.hasClass('view-main'), + $navbarsEl: $navbarsEl, + navbarsEl: $navbarsEl ? $navbarsEl[0] : undefined, + selector: selector + }); + + if (view.main) { + app.views.main = view; + } // Save in DOM + + + if ($el && $el[0]) { + $el[0].f7View = view; + } + + view.emit('local::mount viewMount', view); + }; + + _proto.init = function init(viewEl) { + var view = this; + view.mount(viewEl); + + if (view.params.router) { + if (view.params.masterDetailBreakpoint > 0) { + view.initMasterDetail(); + } + + view.router.init(); + view.$el.trigger('view:init'); + view.emit('local::init viewInit', view); + } + }; + + return View; +}(_class.default); // Use Router + + +View.use(_router.default); +var _default = View; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/view/view.js b/www/assets/framework7/cjs/components/view/view.js new file mode 100644 index 000000000..97597c39e --- /dev/null +++ b/www/assets/framework7/cjs/components/view/view.js @@ -0,0 +1,196 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _viewClass = _interopRequireDefault(require("./view-class")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function getCurrentView(app) { + var $popoverView = (0, _dom.default)('.popover.modal-in .view'); + var $popupView = (0, _dom.default)('.popup.modal-in .view'); + var $panelView = (0, _dom.default)('.panel.panel-in .view'); + var $viewsEl = (0, _dom.default)('.views'); + if ($viewsEl.length === 0) $viewsEl = app.$el; // Find active view as tab + + var $viewEl = $viewsEl.children('.view'); + + if ($viewEl.length === 0) { + $viewEl = $viewsEl.children('.tabs').children('.view'); + } // Propably in tabs or split view + + + if ($viewEl.length > 1) { + if ($viewEl.hasClass('tab')) { + // Tabs + $viewEl = $viewsEl.children('.view.tab-active'); + + if ($viewEl.length === 0) { + $viewEl = $viewsEl.children('.tabs').children('.view.tab-active'); + } + } else {// Split View, leave appView intact + } + } + + if ($popoverView.length > 0 && $popoverView[0].f7View) return $popoverView[0].f7View; + if ($popupView.length > 0 && $popupView[0].f7View) return $popupView[0].f7View; + if ($panelView.length > 0 && $panelView[0].f7View) return $panelView[0].f7View; + + if ($viewEl.length > 0) { + if ($viewEl.length === 1 && $viewEl[0].f7View) return $viewEl[0].f7View; + + if ($viewEl.length > 1) { + return app.views.main; + } + } + + return undefined; +} + +var _default = { + name: 'view', + params: { + view: { + init: true, + name: undefined, + main: false, + router: true, + linksView: null, + stackPages: false, + xhrCache: true, + xhrCacheIgnore: [], + xhrCacheIgnoreGetParameters: false, + xhrCacheDuration: 1000 * 60 * 10, + // Ten minutes + componentCache: true, + preloadPreviousPage: true, + allowDuplicateUrls: false, + reloadPages: false, + reloadDetail: false, + masterDetailBreakpoint: 0, + masterDetailResizable: false, + removeElements: true, + removeElementsWithTimeout: false, + removeElementsTimeout: 0, + restoreScrollTopOnBack: true, + unloadTabContent: true, + passRouteQueryToRequest: true, + passRouteParamsToRequest: false, + loadInitialPage: true, + // Swipe Back + iosSwipeBack: true, + iosSwipeBackAnimateShadow: true, + iosSwipeBackAnimateOpacity: true, + iosSwipeBackActiveArea: 30, + iosSwipeBackThreshold: 0, + mdSwipeBack: false, + mdSwipeBackAnimateShadow: true, + mdSwipeBackAnimateOpacity: false, + mdSwipeBackActiveArea: 30, + mdSwipeBackThreshold: 0, + auroraSwipeBack: false, + auroraSwipeBackAnimateShadow: false, + auroraSwipeBackAnimateOpacity: true, + auroraSwipeBackActiveArea: 30, + auroraSwipeBackThreshold: 0, + // Push State + browserHistory: false, + browserHistoryRoot: undefined, + browserHistoryAnimate: true, + browserHistoryAnimateOnLoad: false, + browserHistorySeparator: '#!', + browserHistoryOnLoad: true, + browserHistoryInitialMatch: false, + browserHistoryStoreHistory: true, + // Animate Pages + animate: true, + // iOS Dynamic Navbar + iosDynamicNavbar: true, + // Animate iOS Navbar Back Icon + iosAnimateNavbarBackIcon: true, + // Delays + iosPageLoadDelay: 0, + mdPageLoadDelay: 0, + auroraPageLoadDelay: 0, + // Routes hooks + routesBeforeEnter: null, + routesBeforeLeave: null + } + }, + static: { + View: _viewClass.default + }, + create: function create() { + var app = this; + (0, _utils.extend)(app, { + views: (0, _utils.extend)([], { + create: function create(el, params) { + return new _viewClass.default(app, el, params); + }, + get: function get(viewEl) { + var $viewEl = (0, _dom.default)(viewEl); + if ($viewEl.length && $viewEl[0].f7View) return $viewEl[0].f7View; + return undefined; + } + }) + }); + Object.defineProperty(app.views, 'current', { + enumerable: true, + configurable: true, + get: function get() { + return getCurrentView(app); + } + }); // Alias + + app.view = app.views; + }, + on: { + init: function init() { + var app = this; + (0, _dom.default)('.view-init').each(function (viewEl) { + if (viewEl.f7View) return; + var viewParams = (0, _dom.default)(viewEl).dataset(); + app.views.create(viewEl, viewParams); + }); + }, + 'modalOpen panelOpen': function onOpen(instance) { + var app = this; + instance.$el.find('.view-init').each(function (viewEl) { + if (viewEl.f7View) return; + var viewParams = (0, _dom.default)(viewEl).dataset(); + app.views.create(viewEl, viewParams); + }); + }, + 'modalBeforeDestroy panelBeforeDestroy': function onClose(instance) { + if (!instance || !instance.$el) return; + instance.$el.find('.view-init').each(function (viewEl) { + var view = viewEl.f7View; + if (!view) return; + view.destroy(); + }); + } + }, + vnode: { + 'view-init': { + insert: function insert(vnode) { + var app = this; + var viewEl = vnode.elm; + if (viewEl.f7View) return; + var viewParams = (0, _dom.default)(viewEl).dataset(); + app.views.create(viewEl, viewParams); + }, + destroy: function destroy(vnode) { + var viewEl = vnode.elm; + var view = viewEl.f7View; + if (!view) return; + view.destroy(); + } + } + } +}; +exports.default = _default; \ No newline at end of file diff --git a/www/assets/framework7/cjs/components/virtual-list/virtual-list-class.js b/www/assets/framework7/cjs/components/virtual-list/virtual-list-class.js new file mode 100644 index 000000000..3a362b1d9 --- /dev/null +++ b/www/assets/framework7/cjs/components/virtual-list/virtual-list-class.js @@ -0,0 +1,654 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; + +var _ssrWindow = require("ssr-window"); + +var _dom = _interopRequireDefault(require("../../shared/dom7")); + +var _utils = require("../../shared/utils"); + +var _class = _interopRequireDefault(require("../../shared/class")); + +var _getDevice = require("../../shared/get-device"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var VirtualList = /*#__PURE__*/function (_Framework7Class) { + _inheritsLoose(VirtualList, _Framework7Class); + + function VirtualList(app, params) { + var _this; + + if (params === void 0) { + params = {}; + } + + _this = _Framework7Class.call(this, params, [app]) || this; + + var vl = _assertThisInitialized(_this); + + var device = (0, _getDevice.getDevice)(); + var document = (0, _ssrWindow.getDocument)(); + var defaultHeight; + + if (app.theme === 'md') { + defaultHeight = 48; + } else if (app.theme === 'ios') { + defaultHeight = 44; + } else if (app.theme === 'aurora') { + defaultHeight = 38; + } + + var defaults = { + cols: 1, + height: defaultHeight, + cache: true, + dynamicHeightBufferSize: 1, + showFilteredItemsOnly: false, + renderExternal: undefined, + setListHeight: true, + searchByItem: undefined, + searchAll: undefined, + ul: null, + createUl: true, + scrollableParentEl: undefined, + renderItem: function renderItem(item) { + return ("\n
  • \n
    \n
    \n
    " + item + "
    \n
    \n
    \n
  • \n ").trim(); + }, + on: {} + }; // Extend defaults with modules params + + vl.useModulesParams(defaults); + vl.params = (0, _utils.extend)(defaults, params); + + if (vl.params.height === undefined || !vl.params.height) { + vl.params.height = defaultHeight; + } + + vl.$el = (0, _dom.default)(params.el); + vl.el = vl.$el[0]; + if (vl.$el.length === 0) return undefined || _assertThisInitialized(_this); + vl.$el[0].f7VirtualList = vl; + vl.items = vl.params.items; + + if (vl.params.showFilteredItemsOnly) { + vl.filteredItems = []; + } + + if (vl.params.renderItem) { + vl.renderItem = vl.params.renderItem; + } + + vl.$pageContentEl = vl.$el.parents('.page-content'); + vl.pageContentEl = vl.$pageContentEl[0]; + vl.$scrollableParentEl = vl.params.scrollableParentEl ? (0, _dom.default)(vl.params.scrollableParentEl).eq(0) : vl.$pageContentEl; + + if (!vl.$scrollableParentEl.length && vl.$pageContentEl.length) { + vl.$scrollableParentEl = vl.$pageContentEl; + } + + vl.scrollableParentEl = vl.$scrollableParentEl[0]; // Bad scroll + + if (typeof vl.params.updatableScroll !== 'undefined') { + vl.updatableScroll = vl.params.updatableScroll; + } else { + vl.updatableScroll = true; + + if (device.ios && device.osVersion.split('.')[0] < 8) { + vl.updatableScroll = false; + } + } // Append