From 06078cc8e77a3e9c7180f6ae8a59018820c79e7b Mon Sep 17 00:00:00 2001 From: "Fedor A. Fetisov" Date: Sat, 28 Aug 2021 03:09:23 +0300 Subject: [PATCH] Implement sound notification on invitation to chat --- src/mibew/js/source/widget.js | 30 +++++++++++++++---- .../Button/Generator/AbstractGenerator.php | 3 ++ .../Mibew/Controller/ButtonCodeController.php | 7 +++-- .../Mibew/Controller/WidgetController.php | 4 ++- .../server_side/button_code.handlebars | 6 ++++ .../server_side/button_code.handlebars | 6 ++++ 6 files changed, 47 insertions(+), 9 deletions(-) diff --git a/src/mibew/js/source/widget.js b/src/mibew/js/source/widget.js index a1de965f..2755a6f8 100644 --- a/src/mibew/js/source/widget.js +++ b/src/mibew/js/source/widget.js @@ -90,6 +90,12 @@ var Mibew = Mibew || {}; */ this.inviteStyle = options.inviteStyle; + /** + * Flag to disable sound notification on invitations + * @type Boolean + */ + this.silentInvitation = options.silentInvitation; + /** * Locale of the Widget * @type String @@ -134,7 +140,7 @@ var Mibew = Mibew || {}; delete this.dataToSend.user_id; } } - + this.dataToSend.silent = this.silentInvitation ? 1 : 0; Mibew.Utils.loadScript( this.requestURL + '?' + this.getQuery(), @@ -341,10 +347,12 @@ var Mibew = Mibew || {}; * - 'threadUrl': String, URL of the invitation thread which must be * dispaly in invitation iframe. * - 'acceptCaption': String, caption for accept button. + * - 'soundFile': String, pseudo URL (without extension) of the sound file to + * play on invitation event (in case when it's possible) */ Mibew.Invitation.create = function (options) { - // Cookies are blocked, invitation will behave badly + // Cookies are blocked, invitation will behave badly, won't even try if (Mibew.Objects.widget.cookiesBlocked) { return; } @@ -353,6 +361,7 @@ var Mibew = Mibew || {}; var avatarUrl = options.avatarUrl; var threadUrl = options.threadUrl; var acceptCaption = options.acceptCaption; + var soundFile = options.soundFile; var popuptext = ' +
+ +
+ +
+
{{/unless}}
{{/if}} diff --git a/src/mibew/styles/pages/default/templates_src/server_side/button_code.handlebars b/src/mibew/styles/pages/default/templates_src/server_side/button_code.handlebars index e0948a9c..2ee7cd73 100644 --- a/src/mibew/styles/pages/default/templates_src/server_side/button_code.handlebars +++ b/src/mibew/styles/pages/default/templates_src/server_side/button_code.handlebars @@ -92,6 +92,12 @@ +
+ +
+ +
+
{{/unless}}
{{/if}}