From f5ff322c33e38291321fc486e78cbb371ea178b5 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 15 Nov 2017 21:27:45 -0500 Subject: [PATCH] Remove sweetalert, use a tooltip instead --- admin/service_messages.php | 12 +- css/sweetalert.css | 686 --------------- inc/headerAdmin.inc.php | 2 - internal-api/js/service-messages.js | 27 +- js/sweetalert.js | 1196 --------------------------- 5 files changed, 32 insertions(+), 1891 deletions(-) delete mode 100644 css/sweetalert.css delete mode 100644 js/sweetalert.js diff --git a/admin/service_messages.php b/admin/service_messages.php index b445e70f..c60d7b58 100644 --- a/admin/service_messages.php +++ b/admin/service_messages.php @@ -45,9 +45,10 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');

- + +

\n
\n " + - -// Loading animation -"
\n
\n
\n
\n
\n
\n
" + - -// End of modal -"
"; - -exports.default = injectedHTML; - -},{}],7:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; - -var _utils = require('./utils'); - -var _handleSwalDom = require('./handle-swal-dom'); - -var _handleDom = require('./handle-dom'); - -var alertTypes = ['error', 'warning', 'info', 'success', 'input', 'prompt']; - -/* - * Set type, text and actions on modal - */ -var setParameters = function setParameters(params) { - var modal = (0, _handleSwalDom.getModal)(); - - var $title = modal.querySelector('h2'); - var $text = modal.querySelector('p'); - var $cancelBtn = modal.querySelector('button.cancel'); - var $confirmBtn = modal.querySelector('button.confirm'); - - /* - * Title - */ - $title.innerHTML = params.html ? params.title : (0, _handleDom.escapeHtml)(params.title).split('\n').join('
'); - - /* - * Text - */ - $text.innerHTML = params.html ? params.text : (0, _handleDom.escapeHtml)(params.text || '').split('\n').join('
'); - if (params.text) (0, _handleDom.show)($text); - - /* - * Custom class - */ - if (params.customClass) { - (0, _handleDom.addClass)(modal, params.customClass); - modal.setAttribute('data-custom-class', params.customClass); - } else { - // Find previously set classes and remove them - var customClass = modal.getAttribute('data-custom-class'); - (0, _handleDom.removeClass)(modal, customClass); - modal.setAttribute('data-custom-class', ''); - } - - /* - * Icon - */ - (0, _handleDom.hide)(modal.querySelectorAll('.sa-icon')); - - if (params.type && !(0, _utils.isIE8)()) { - var _ret = function () { - - var validType = false; - - for (var i = 0; i < alertTypes.length; i++) { - if (params.type === alertTypes[i]) { - validType = true; - break; - } - } - - if (!validType) { - logStr('Unknown alert type: ' + params.type); - return { - v: false - }; - } - - var typesWithIcons = ['success', 'error', 'warning', 'info']; - var $icon = void 0; - - if (typesWithIcons.indexOf(params.type) !== -1) { - $icon = modal.querySelector('.sa-icon.' + 'sa-' + params.type); - (0, _handleDom.show)($icon); - } - - var $input = (0, _handleSwalDom.getInput)(); - - // Animate icon - switch (params.type) { - - case 'success': - (0, _handleDom.addClass)($icon, 'animate'); - (0, _handleDom.addClass)($icon.querySelector('.sa-tip'), 'animateSuccessTip'); - (0, _handleDom.addClass)($icon.querySelector('.sa-long'), 'animateSuccessLong'); - break; - - case 'error': - (0, _handleDom.addClass)($icon, 'animateErrorIcon'); - (0, _handleDom.addClass)($icon.querySelector('.sa-x-mark'), 'animateXMark'); - break; - - case 'warning': - (0, _handleDom.addClass)($icon, 'pulseWarning'); - (0, _handleDom.addClass)($icon.querySelector('.sa-body'), 'pulseWarningIns'); - (0, _handleDom.addClass)($icon.querySelector('.sa-dot'), 'pulseWarningIns'); - break; - - case 'input': - case 'prompt': - $input.setAttribute('type', params.inputType); - $input.value = params.inputValue; - $input.setAttribute('placeholder', params.inputPlaceholder); - (0, _handleDom.addClass)(modal, 'show-input'); - setTimeout(function () { - $input.focus(); - $input.addEventListener('keyup', swal.resetInputError); - }, 400); - break; - } - }(); - - if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; - } - - /* - * Custom image - */ - if (params.imageUrl) { - var $customIcon = modal.querySelector('.sa-icon.sa-custom'); - - $customIcon.style.backgroundImage = 'url(' + params.imageUrl + ')'; - (0, _handleDom.show)($customIcon); - - var _imgWidth = 80; - var _imgHeight = 80; - - if (params.imageSize) { - var dimensions = params.imageSize.toString().split('x'); - var imgWidth = dimensions[0]; - var imgHeight = dimensions[1]; - - if (!imgWidth || !imgHeight) { - logStr('Parameter imageSize expects value with format WIDTHxHEIGHT, got ' + params.imageSize); - } else { - _imgWidth = imgWidth; - _imgHeight = imgHeight; - } - } - - $customIcon.setAttribute('style', $customIcon.getAttribute('style') + 'width:' + _imgWidth + 'px; height:' + _imgHeight + 'px'); - } - - /* - * Show cancel button? - */ - modal.setAttribute('data-has-cancel-button', params.showCancelButton); - if (params.showCancelButton) { - $cancelBtn.style.display = 'inline-block'; - } else { - (0, _handleDom.hide)($cancelBtn); - } - - /* - * Show confirm button? - */ - modal.setAttribute('data-has-confirm-button', params.showConfirmButton); - if (params.showConfirmButton) { - $confirmBtn.style.display = 'inline-block'; - } else { - (0, _handleDom.hide)($confirmBtn); - } - - /* - * Custom text on cancel/confirm buttons - */ - if (params.cancelButtonText) { - $cancelBtn.innerHTML = (0, _handleDom.escapeHtml)(params.cancelButtonText); - } - if (params.confirmButtonText) { - $confirmBtn.innerHTML = (0, _handleDom.escapeHtml)(params.confirmButtonText); - } - - /* - * Reset confirm buttons to default class (Ugly fix) - */ - $confirmBtn.className = 'confirm btn btn-lg'; - - /* - * Attach selected class to the sweet alert modal - */ - (0, _handleDom.addClass)(modal, params.containerClass); - - /* - * Set confirm button to selected class - */ - (0, _handleDom.addClass)($confirmBtn, params.confirmButtonClass); - - /* - * Set cancel button to selected class - */ - (0, _handleDom.addClass)($cancelBtn, params.cancelButtonClass); - - /* - * Set title to selected class - */ - (0, _handleDom.addClass)($title, params.titleClass); - - /* - * Set text to selected class - */ - (0, _handleDom.addClass)($text, params.textClass); - - /* - * Allow outside click - */ - modal.setAttribute('data-allow-outside-click', params.allowOutsideClick); - - /* - * Callback function - */ - var hasDoneFunction = params.doneFunction ? true : false; - modal.setAttribute('data-has-done-function', hasDoneFunction); - - /* - * Animation - */ - if (!params.animation) { - modal.setAttribute('data-animation', 'none'); - } else if (typeof params.animation === 'string') { - modal.setAttribute('data-animation', params.animation); // Custom animation - } else { - modal.setAttribute('data-animation', 'pop'); - } - - /* - * Timer - */ - modal.setAttribute('data-timer', params.timer); -}; - -exports.default = setParameters; - -},{"./handle-dom":3,"./handle-swal-dom":5,"./utils":8}],8:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -/* - * Allow user to pass their own params - */ -var extend = function extend(a, b) { - for (var key in b) { - if (b.hasOwnProperty(key)) { - a[key] = b[key]; - } - } - return a; -}; - -/* - * Check if the user is using Internet Explorer 8 (for fallbacks) - */ -var isIE8 = function isIE8() { - return window.attachEvent && !window.addEventListener; -}; - -/* - * IE compatible logging for developers - */ -var logStr = function logStr(string) { - if (window.console) { - // IE... - window.console.log('SweetAlert: ' + string); - } -}; - -exports.extend = extend; -exports.isIE8 = isIE8; -exports.logStr = logStr; - -},{}],9:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; // SweetAlert -// 2014-2015 (c) - Tristan Edwards -// github.com/t4t5/sweetalert - -/* - * jQuery-like functions for manipulating the DOM - */ - - -/* - * Handy utilities - */ - - -/* - * Handle sweetAlert's DOM elements - */ - - -// Handle button events and keyboard events - - -// Default values - - -var _handleDom = require('./modules/handle-dom'); - -var _utils = require('./modules/utils'); - -var _handleSwalDom = require('./modules/handle-swal-dom'); - -var _handleClick = require('./modules/handle-click'); - -var _handleKey = require('./modules/handle-key'); - -var _handleKey2 = _interopRequireDefault(_handleKey); - -var _defaultParams = require('./modules/default-params'); - -var _defaultParams2 = _interopRequireDefault(_defaultParams); - -var _setParams = require('./modules/set-params'); - -var _setParams2 = _interopRequireDefault(_setParams); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/* - * Remember state in cases where opening and handling a modal will fiddle with it. - * (We also use window.previousActiveElement as a global variable) - */ -var previousWindowKeyDown; -var lastFocusedButton; - -/* - * Global sweetAlert function - * (this is what the user calls) - */ -var sweetAlert, _swal; - -exports.default = sweetAlert = _swal = function swal() { - var customizations = arguments[0]; - - (0, _handleDom.addClass)(document.body, 'stop-scrolling'); - (0, _handleSwalDom.resetInput)(); - - /* - * Use argument if defined or default value from params object otherwise. - * Supports the case where a default value is boolean true and should be - * overridden by a corresponding explicit argument which is boolean false. - */ - function argumentOrDefault(key) { - var args = customizations; - return args[key] === undefined ? _defaultParams2.default[key] : args[key]; - } - - if (customizations === undefined) { - (0, _utils.logStr)('SweetAlert expects at least 1 attribute!'); - return false; - } - - var params = (0, _utils.extend)({}, _defaultParams2.default); - - switch (typeof customizations === 'undefined' ? 'undefined' : _typeof(customizations)) { - - // Ex: swal("Hello", "Just testing", "info"); - case 'string': - params.title = customizations; - params.text = arguments[1] || ''; - params.type = arguments[2] || ''; - break; - - // Ex: swal({ title:"Hello", text: "Just testing", type: "info" }); - case 'object': - if (customizations.title === undefined) { - (0, _utils.logStr)('Missing "title" argument!'); - return false; - } - - params.title = customizations.title; - - for (var customName in _defaultParams2.default) { - params[customName] = argumentOrDefault(customName); - } - - // Show "Confirm" instead of "OK" if cancel button is visible - params.confirmButtonText = params.showCancelButton ? 'Confirm' : _defaultParams2.default.confirmButtonText; - params.confirmButtonText = argumentOrDefault('confirmButtonText'); - - // Callback function when clicking on "OK"/"Cancel" - params.doneFunction = arguments[1] || null; - - break; - - default: - (0, _utils.logStr)('Unexpected type of argument! Expected "string" or "object", got ' + (typeof customizations === 'undefined' ? 'undefined' : _typeof(customizations))); - return false; - - } - - (0, _setParams2.default)(params); - (0, _handleSwalDom.fixVerticalPosition)(); - (0, _handleSwalDom.openModal)(arguments[1]); - - // Modal interactions - var modal = (0, _handleSwalDom.getModal)(); - - /* - * Make sure all modal buttons respond to all events - */ - var $buttons = modal.querySelectorAll('button'); - var buttonEvents = ['onclick']; - var onButtonEvent = function onButtonEvent(e) { - return (0, _handleClick.handleButton)(e, params, modal); - }; - - for (var btnIndex = 0; btnIndex < $buttons.length; btnIndex++) { - for (var evtIndex = 0; evtIndex < buttonEvents.length; evtIndex++) { - var btnEvt = buttonEvents[evtIndex]; - $buttons[btnIndex][btnEvt] = onButtonEvent; - } - } - - // Clicking outside the modal dismisses it (if allowed by user) - (0, _handleSwalDom.getOverlay)().onclick = onButtonEvent; - - previousWindowKeyDown = window.onkeydown; - - var onKeyEvent = function onKeyEvent(e) { - return (0, _handleKey2.default)(e, params, modal); - }; - window.onkeydown = onKeyEvent; - - window.onfocus = function () { - // When the user has focused away and focused back from the whole window. - setTimeout(function () { - // Put in a timeout to jump out of the event sequence. - // Calling focus() in the event sequence confuses things. - if (lastFocusedButton !== undefined) { - lastFocusedButton.focus(); - lastFocusedButton = undefined; - } - }, 0); - }; - - // Show alert with enabled buttons always - _swal.enableButtons(); -}; - -/* - * Set default params for each popup - * @param {Object} userParams - */ - - -sweetAlert.setDefaults = _swal.setDefaults = function (userParams) { - if (!userParams) { - throw new Error('userParams is required'); - } - if ((typeof userParams === 'undefined' ? 'undefined' : _typeof(userParams)) !== 'object') { - throw new Error('userParams has to be a object'); - } - - (0, _utils.extend)(_defaultParams2.default, userParams); -}; - -/* - * Animation when closing modal - */ -sweetAlert.close = _swal.close = function () { - var modal = (0, _handleSwalDom.getModal)(); - - (0, _handleDom.fadeOut)((0, _handleSwalDom.getOverlay)(), 5); - (0, _handleDom.fadeOut)(modal, 5); - (0, _handleDom.removeClass)(modal, 'showSweetAlert'); - (0, _handleDom.addClass)(modal, 'hideSweetAlert'); - (0, _handleDom.removeClass)(modal, 'visible'); - - /* - * Reset icon animations - */ - var $successIcon = modal.querySelector('.sa-icon.sa-success'); - (0, _handleDom.removeClass)($successIcon, 'animate'); - (0, _handleDom.removeClass)($successIcon.querySelector('.sa-tip'), 'animateSuccessTip'); - (0, _handleDom.removeClass)($successIcon.querySelector('.sa-long'), 'animateSuccessLong'); - - var $errorIcon = modal.querySelector('.sa-icon.sa-error'); - (0, _handleDom.removeClass)($errorIcon, 'animateErrorIcon'); - (0, _handleDom.removeClass)($errorIcon.querySelector('.sa-x-mark'), 'animateXMark'); - - var $warningIcon = modal.querySelector('.sa-icon.sa-warning'); - (0, _handleDom.removeClass)($warningIcon, 'pulseWarning'); - (0, _handleDom.removeClass)($warningIcon.querySelector('.sa-body'), 'pulseWarningIns'); - (0, _handleDom.removeClass)($warningIcon.querySelector('.sa-dot'), 'pulseWarningIns'); - - // Reset custom class (delay so that UI changes aren't visible) - setTimeout(function () { - var customClass = modal.getAttribute('data-custom-class'); - (0, _handleDom.removeClass)(modal, customClass); - }, 300); - - // Make page scrollable again - (0, _handleDom.removeClass)(document.body, 'stop-scrolling'); - - // Reset the page to its previous state - window.onkeydown = previousWindowKeyDown; - if (window.previousActiveElement) { - window.previousActiveElement.focus(); - } - lastFocusedButton = undefined; - clearTimeout(modal.timeout); - - return true; -}; - -/* - * Validation of the input field is done by user - * If something is wrong => call showInputError with errorMessage - */ -sweetAlert.showInputError = _swal.showInputError = function (errorMessage) { - var modal = (0, _handleSwalDom.getModal)(); - - var $errorIcon = modal.querySelector('.sa-input-error'); - (0, _handleDom.addClass)($errorIcon, 'show'); - - var $errorContainer = modal.querySelector('.form-group'); - (0, _handleDom.addClass)($errorContainer, 'has-error'); - - $errorContainer.querySelector('.sa-help-text').innerHTML = errorMessage; - - setTimeout(function () { - sweetAlert.enableButtons(); - }, 1); - - modal.querySelector('input').focus(); -}; - -/* - * Reset input error DOM elements - */ -sweetAlert.resetInputError = _swal.resetInputError = function (event) { - // If press enter => ignore - if (event && event.keyCode === 13) { - return false; - } - - var $modal = (0, _handleSwalDom.getModal)(); - - var $errorIcon = $modal.querySelector('.sa-input-error'); - (0, _handleDom.removeClass)($errorIcon, 'show'); - - var $errorContainer = $modal.querySelector('.form-group'); - (0, _handleDom.removeClass)($errorContainer, 'has-error'); -}; - -/* - * Disable confirm and cancel buttons - */ -sweetAlert.disableButtons = _swal.disableButtons = function (event) { - var modal = (0, _handleSwalDom.getModal)(); - var $confirmButton = modal.querySelector('button.confirm'); - var $cancelButton = modal.querySelector('button.cancel'); - $confirmButton.disabled = true; - $cancelButton.disabled = true; -}; - -/* - * Enable confirm and cancel buttons - */ -sweetAlert.enableButtons = _swal.enableButtons = function (event) { - var modal = (0, _handleSwalDom.getModal)(); - var $confirmButton = modal.querySelector('button.confirm'); - var $cancelButton = modal.querySelector('button.cancel'); - $confirmButton.disabled = false; - $cancelButton.disabled = false; -}; - -if (typeof window !== 'undefined') { - // The 'handle-click' module requires - // that 'sweetAlert' was set as global. - window.sweetAlert = window.swal = sweetAlert; -} else { - (0, _utils.logStr)('SweetAlert is a frontend module!'); -} - -},{"./modules/default-params":1,"./modules/handle-click":2,"./modules/handle-dom":3,"./modules/handle-key":4,"./modules/handle-swal-dom":5,"./modules/set-params":7,"./modules/utils":8}]},{},[9]); - -/* - * Use SweetAlert with RequireJS - */ - -if (typeof define === 'function' && define.amd) { - define(function () { - return sweetAlert; - }); -} else if (typeof module !== 'undefined' && module.exports) { - module.exports = sweetAlert; -} - -})(window, document); \ No newline at end of file