diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-02-07 11:02:45 +0100 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-04-06 17:19:57 +0200 |
commit | 8119e0b18ef4438e7da1279332a960ce8f749835 (patch) | |
tree | 0ef2e67d2c7adc8a90af9226f279608f3a61ab7e /core/src | |
parent | 01a70e5d0f6f369fefd510379994e7f465289421 (diff) | |
download | nextcloud-server-8119e0b18ef4438e7da1279332a960ce8f749835.tar.gz nextcloud-server-8119e0b18ef4438e7da1279332a960ce8f749835.zip |
Inline usages of OCP.Toast in bundled files
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/OC/notification.js | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/core/src/OC/notification.js b/core/src/OC/notification.js index 4e95476b69b..725aa9d2a15 100644 --- a/core/src/OC/notification.js +++ b/core/src/OC/notification.js @@ -21,10 +21,11 @@ import _ from 'underscore' import $ from 'jquery' +import { showMessage } from '@nextcloud/dialogs' /** * @todo Write documentation - * @deprecated 17.0.0 use OCP.Toast + * @deprecated 17.0.0 use the `@nextcloud/dialogs` package instead * @namespace OC.Notification */ export default { @@ -35,7 +36,7 @@ export default { /** * @param {Function} callback callback function - * @deprecated 17.0.0 use OCP.Toast + * @deprecated 17.0.0 use the `@nextcloud/dialogs` package */ setDefault: function(callback) { this.getDefaultNotificationFunction = callback @@ -49,7 +50,7 @@ export default { * * @param {jQuery} [$row] notification row * @param {Function} [callback] callback - * @deprecated 17.0.0 use OCP.Toast + * @deprecated 17.0.0 use the `@nextcloud/dialogs` package */ hide: function($row, callback) { if (_.isFunction($row)) { @@ -65,7 +66,11 @@ export default { // remove the row directly $row.each(function() { - $(this)[0].toastify.hideToast() + if ($(this)[0].toastify) { + $(this)[0].toastify.hideToast() + } else { + console.error('cannot hide toast because object is not set') + } if (this === this.updatableNotification) { this.updatableNotification = null } @@ -88,13 +93,14 @@ export default { * @param {string} [options.type] notification type * @param {int} [options.timeout=0] timeout value, defaults to 0 (permanent) * @returns {jQuery} jQuery element for notification row - * @deprecated 17.0.0 use OCP.Toast + * @deprecated 17.0.0 use the `@nextcloud/dialogs` package */ showHtml: function(html, options) { options = options || {} options.isHTML = true options.timeout = (!options.timeout) ? -1 : options.timeout - const toast = window.OCP.Toast.message(html, options) + const toast = showMessage(html, options) + toast.toastElement.toastify = toast return $(toast.toastElement) }, @@ -106,12 +112,13 @@ export default { * @param {string} [options.type] notification type * @param {int} [options.timeout=0] timeout value, defaults to 0 (permanent) * @returns {jQuery} jQuery element for notification row - * @deprecated 17.0.0 use OCP.Toast + * @deprecated 17.0.0 use the `@nextcloud/dialogs` package */ show: function(text, options) { options = options || {} options.timeout = (!options.timeout) ? -1 : options.timeout - const toast = window.OCP.Toast.message(text, options) + const toast = showMessage(text, options) + toast.toastElement.toastify = toast return $(toast.toastElement) }, @@ -120,13 +127,14 @@ export default { * * @param {string} text Message to display * @returns {jQuery} JQuery element for notificaiton row - * @deprecated 17.0.0 use OCP.Toast + * @deprecated 17.0.0 use the `@nextcloud/dialogs` package */ showUpdate: function(text) { if (this.updatableNotification) { this.updatableNotification.hideToast() } - this.updatableNotification = OCP.Toast.message(text, { timeout: -1 }) + this.updatableNotification = showMessage(text, { timeout: -1 }) + this.updatableNotification.toastElement.toastify = this.updatableNotification return $(this.updatableNotification.toastElement) }, @@ -140,19 +148,20 @@ export default { * @param {boolean} [options.isHTML=false] an indicator for HTML notifications (true) or text (false) * @param {string} [options.type] notification type * @returns {JQuery<any>} the toast element - * @deprecated 17.0.0 use OCP.Toast + * @deprecated 17.0.0 use the `@nextcloud/dialogs` package */ showTemporary: function(text, options) { options = options || {} options.timeout = options.timeout || 7 - const toast = window.OCP.Toast.message(text, options) + const toast = showMessage(text, options) + toast.toastElement.toastify = toast return $(toast.toastElement) }, /** * Returns whether a notification is hidden. * @returns {boolean} - * @deprecated 17.0.0 use OCP.Toast + * @deprecated 17.0.0 use the `@nextcloud/dialogs` package */ isHidden: function() { return !$('#content').find('.toastify').length |