diff --git a/README.md b/README.md index f5dde1b..56d9ce1 100644 --- a/README.md +++ b/README.md @@ -10,14 +10,12 @@ Notifications are short messages that notify users of something that occurred in Requirements ------------ -- PHP 7.1+ +- PHP 8.1+ - gmp - mbstring - curl - openssl -- PHP 7.2+ is recommended for better performance. - Installation ------------ @@ -316,4 +314,4 @@ If you customize the HTML template remember to include a button with id 'js-web- ``` -Remember to place the service-worker.js file in the web root in order to serve the service worker when the WebNotifications widget is initialized. \ No newline at end of file +Remember to place the service-worker.js file in the web root in order to serve the service worker when the WebNotifications widget is initialized. diff --git a/assets/js/notifications.js b/assets/js/notifications.js index 0621a44..1f7403c 100644 --- a/assets/js/notifications.js +++ b/assets/js/notifications.js @@ -1,36 +1,37 @@ +'use strict'; + /** * notifications plugin */ - -var Notifications = (function(opts) { - if(!opts.id){ +const Notifications = (function (opts) { + if (!opts.id) { throw new Error('Notifications: the param id is required.'); } - var elem = $('#'+opts.id); - if(!elem.length){ + const elem = $('#' + opts.id); + if (!elem.length) { throw Error('Notifications: the element was not found.'); } - var options = $.extend({ + const options = $.extend({ pollInterval: 60000, xhrTimeout: 2000, - readLabel: 'read', + readLabel: 'mark as unread', markAsReadLabel: 'mark as read' }, opts); /** - * Renders a notification row + * Renders a notification row. * * @param object The notification instance * @returns {jQuery|HTMLElement|*} */ - var renderRow = function (object) { - var html = ' -
+
$pagination]); ?> diff --git a/widgets/Notifications.php b/widgets/Notifications.php index 7ddd265..aced79a 100644 --- a/widgets/Notifications.php +++ b/widgets/Notifications.php @@ -120,9 +120,12 @@ public function registerAssets() 'url' => Url::to(['/notifications/default/list']), 'countUrl' => Url::to(['/notifications/default/count']), 'readUrl' => Url::to(['/notifications/default/read']), + 'unreadUrl' => Url::to(['/notifications/default/unread']), 'readAllUrl' => Url::to(['/notifications/default/read-all']), 'xhrTimeout' => Html::encode($this->xhrTimeout), 'pollInterval' => Html::encode($this->pollInterval), + 'readLabel' => Yii::t('modules/notifications', 'Mark as unread'), + 'markAsReadLabel' => Yii::t('modules/notifications', 'Mark as read'), ], $this->clientOptions); $js = 'Notifications(' . Json::encode($this->clientOptions) . ');';