Commit 02faa555 authored by JC Brand's avatar JC Brand

Recreate dist files. fixes #443

parent 550f7827
......@@ -3274,6 +3274,9 @@ define("polyfill", function(){});
}, attributes));
this.on('destroy', function () { this.removeFromRoster(); }.bind(this));
this.on('change:chat_status', function (item) {
converse.emit('contactStatusChanged', item.attributes);
});
},
subscribe: function (message) {
......@@ -3947,7 +3950,7 @@ define("polyfill", function(){});
}.bind(this),
function () {
this.clearSpinner();
converse.log("Error while trying to fetch archived messages", "error");
converse.log("Error or timeout while trying to fetch archived messages", "error");
}.bind(this)
);
},
......@@ -4505,7 +4508,6 @@ define("polyfill", function(){});
this.$el.find('div.chat-event').remove();
}
}
converse.emit('contactStatusChanged', item.attributes);
},
onStatusChanged: function (item) {
......@@ -9128,17 +9130,14 @@ return parser;
onChatRoomMessage: function (message) {
var $message = $(message),
archive_id = $message.find('result[xmlns="'+Strophe.NS.MAM+'"]').attr('id'),
delayed = $message.find('delay').length > 0,
$forwarded = $message.find('forwarded'),
$delay;
if ($forwarded.length) {
$message = $forwarded.children('message');
$delay = $forwarded.children('delay');
delayed = $delay.length > 0;
}
var body = $message.children('body').text(),
jid = $message.attr('from'),
var jid = $message.attr('from'),
msgid = $message.attr('id'),
resource = Strophe.getResourceFromJid(jid),
sender = resource && Strophe.unescapeNode(resource) || '',
......@@ -9160,9 +9159,6 @@ return parser;
return true;
}
this.model.createMessage($message, $delay, archive_id);
if (!delayed && sender !== this.model.get('nick') && (new RegExp("\\b"+this.model.get('nick')+"\\b")).test(body)) {
converse.notifyOfNewMessage();
}
if (sender !== this.model.get('nick')) {
// We only emit an event if it's not our own message
converse.emit('message', message);
......@@ -10861,11 +10857,33 @@ return parser;
);
};
converse.shouldNotifyOfNewMessage = function ($message) {
converse.shouldNotifyOfGroupMessage = function ($message) {
/* Is this a group message worthy of notification?
*/
var jid = $message.attr('from'),
resource = Strophe.getResourceFromJid(jid),
sender = resource && Strophe.unescapeNode(resource) || '';
if (sender === '' || $message.find('delay').length > 0) {
return false;
}
var room = converse.chatboxes.get(Strophe.getBareJidFromJid(jid));
var body = $message.children('body').text();
if (sender === room.get('nick') || !(new RegExp("\\b"+room.get('nick')+"\\b")).test(body)) {
return false;
}
return true;
};
converse.shouldNotifyOfMessage = function ($message) {
/* Is this a message worthy of notification?
*/
var $forwarded = $message.find('forwarded');
if ($forwarded.length) {
return false;
}
if ($message.attr('type') === 'groupchat') {
return converse.shouldNotifyOfGroupMessage($message);
}
var is_me = Strophe.getBareJidFromJid($message.attr('from')) === converse.bare_jid;
return !converse.isOnlyChatStateNotification($message) && !is_me;
};
......@@ -10888,9 +10906,34 @@ return parser;
}
};
converse.showChatStateNotification = function (evt, contact) {
/* Show an HTML5 notification indicating that a contact changed
* their chat state.
converse.areDesktopNotificationsEnabled = function (ignore_blur) {
var enabled = supports_html5_notification &&
converse.show_desktop_notifications &&
Notification.permission === "granted";
if (ignore_blur) {
return enabled;
} else {
return enabled && converse.windowState === 'blur';
}
};
converse.showMessageNotification = function ($message) {
/* Shows an HTML5 Notification to indicate that a new chat
* message was received.
*/
var contact_jid = Strophe.getBareJidFromJid($message.attr('from'));
var roster_item = converse.roster.get(contact_jid);
var n = new Notification(__(___("%1$s says"), roster_item.get('fullname')), {
body: $message.children('body').text(),
lang: converse.i18n.locale_data.converse[""].lang,
icon: converse.notification_icon
});
setTimeout(n.close.bind(n), 5000);
};
converse.showChatStateNotification = function (contact) {
/* Creates an HTML5 Notification to inform of a change in a
* contact's chat state.
*/
var chat_state = contact.chat_status,
message = null;
......@@ -10914,40 +10957,48 @@ return parser;
setTimeout(n.close.bind(n), 5000);
};
converse.showMessageNotification = function (evt, $message) {
/* Shows an HTML5 Notification to indicate that a new chat
* message was received.
*/
if (!supports_html5_notification ||
!converse.show_desktop_notifications ||
converse.windowState !== 'blur' ||
Notification.permission !== "granted") {
return;
}
var contact_jid = Strophe.getBareJidFromJid($message.attr('from'));
var roster_item = converse.roster.get(contact_jid);
var n = new Notification(__(___("%1$s says"), roster_item.get('fullname')), {
body: $message.children('body').text(),
converse.showContactRequestNotification = function (contact) {
var n = new Notification(contact.fullname, {
body: __('wants to be your contact'),
lang: converse.i18n.locale_data.converse[""].lang,
icon: converse.notification_icon
icon: 'logo/conversejs.png'
});
setTimeout(n.close.bind(n), 5000);
};
converse.notifyOfNewMessage = function (message) {
converse.handleChatStateNotification = function (evt, contact) {
/* Event handler for on('contactStatusChanged').
* Will show an HTML5 notification to indicate that the chat
* status has changed.
*/
if (converse.areDesktopNotificationsEnabled()) {
converse.showChatStateNotification(contact);
}
};
converse.handleMessageNotification = function (evt, message) {
/* Event handler for the on('message') event. Will call methods
* to play sounds and show HTML5 notifications.
*/
var $message = $(message);
if (!converse.shouldNotifyOfNewMessage($message)) {
if (!converse.shouldNotifyOfMessage($message)) {
return false;
}
converse.playSoundNotification($message);
if (converse.areDesktopNotificationsEnabled()) {
converse.showMessageNotification($message);
}
};
converse.handleContactRequestNotification = function (evt, contact) {
if (converse.areDesktopNotificationsEnabled(true)) {
converse.showContactRequestNotification(contact);
}
};
converse.on('contactStatusChanged', converse.showChatStateNotification);
converse.on('message', converse.notifyOfNewMessage);
converse.on('contactRequest', converse.handleContactRequestNotification);
converse.on('contactStatusChanged', converse.handleChatStateNotification);
converse.on('message', converse.handleMessageNotification);
}
});
}));
......
......@@ -29121,6 +29121,9 @@ return Backbone.BrowserStorage;
}, attributes));
this.on('destroy', function () { this.removeFromRoster(); }.bind(this));
this.on('change:chat_status', function (item) {
converse.emit('contactStatusChanged', item.attributes);
});
},
subscribe: function (message) {
......@@ -29794,7 +29797,7 @@ return Backbone.BrowserStorage;
}.bind(this),
function () {
this.clearSpinner();
converse.log("Error while trying to fetch archived messages", "error");
converse.log("Error or timeout while trying to fetch archived messages", "error");
}.bind(this)
);
},
......@@ -30352,7 +30355,6 @@ return Backbone.BrowserStorage;
this.$el.find('div.chat-event').remove();
}
}
converse.emit('contactStatusChanged', item.attributes);
},
onStatusChanged: function (item) {
......@@ -35077,17 +35079,14 @@ define('text!zh',[],function () { return '{\n "domain": "converse",\n "local
onChatRoomMessage: function (message) {
var $message = $(message),
archive_id = $message.find('result[xmlns="'+Strophe.NS.MAM+'"]').attr('id'),
delayed = $message.find('delay').length > 0,
$forwarded = $message.find('forwarded'),
$delay;
if ($forwarded.length) {
$message = $forwarded.children('message');
$delay = $forwarded.children('delay');
delayed = $delay.length > 0;
}
var body = $message.children('body').text(),
jid = $message.attr('from'),
var jid = $message.attr('from'),
msgid = $message.attr('id'),
resource = Strophe.getResourceFromJid(jid),
sender = resource && Strophe.unescapeNode(resource) || '',
......@@ -35109,9 +35108,6 @@ define('text!zh',[],function () { return '{\n "domain": "converse",\n "local
return true;
}
this.model.createMessage($message, $delay, archive_id);
if (!delayed && sender !== this.model.get('nick') && (new RegExp("\\b"+this.model.get('nick')+"\\b")).test(body)) {
converse.notifyOfNewMessage();
}
if (sender !== this.model.get('nick')) {
// We only emit an event if it's not our own message
converse.emit('message', message);
......@@ -44507,11 +44503,33 @@ Strophe.addConnectionPlugin('ping', {
);
};
converse.shouldNotifyOfNewMessage = function ($message) {
converse.shouldNotifyOfGroupMessage = function ($message) {
/* Is this a group message worthy of notification?
*/
var jid = $message.attr('from'),
resource = Strophe.getResourceFromJid(jid),
sender = resource && Strophe.unescapeNode(resource) || '';
if (sender === '' || $message.find('delay').length > 0) {
return false;
}
var room = converse.chatboxes.get(Strophe.getBareJidFromJid(jid));
var body = $message.children('body').text();
if (sender === room.get('nick') || !(new RegExp("\\b"+room.get('nick')+"\\b")).test(body)) {
return false;
}
return true;
};
converse.shouldNotifyOfMessage = function ($message) {
/* Is this a message worthy of notification?
*/
var $forwarded = $message.find('forwarded');
if ($forwarded.length) {
return false;
}
if ($message.attr('type') === 'groupchat') {
return converse.shouldNotifyOfGroupMessage($message);
}
var is_me = Strophe.getBareJidFromJid($message.attr('from')) === converse.bare_jid;
return !converse.isOnlyChatStateNotification($message) && !is_me;
};
......@@ -44534,9 +44552,34 @@ Strophe.addConnectionPlugin('ping', {
}
};
converse.showChatStateNotification = function (evt, contact) {
/* Show an HTML5 notification indicating that a contact changed
* their chat state.
converse.areDesktopNotificationsEnabled = function (ignore_blur) {
var enabled = supports_html5_notification &&
converse.show_desktop_notifications &&
Notification.permission === "granted";
if (ignore_blur) {
return enabled;
} else {
return enabled && converse.windowState === 'blur';
}
};
converse.showMessageNotification = function ($message) {
/* Shows an HTML5 Notification to indicate that a new chat
* message was received.
*/
var contact_jid = Strophe.getBareJidFromJid($message.attr('from'));
var roster_item = converse.roster.get(contact_jid);
var n = new Notification(__(___("%1$s says"), roster_item.get('fullname')), {
body: $message.children('body').text(),
lang: converse.i18n.locale_data.converse[""].lang,
icon: converse.notification_icon
});
setTimeout(n.close.bind(n), 5000);
};
converse.showChatStateNotification = function (contact) {
/* Creates an HTML5 Notification to inform of a change in a
* contact's chat state.
*/
var chat_state = contact.chat_status,
message = null;
......@@ -44560,40 +44603,48 @@ Strophe.addConnectionPlugin('ping', {
setTimeout(n.close.bind(n), 5000);
};
converse.showMessageNotification = function (evt, $message) {
/* Shows an HTML5 Notification to indicate that a new chat
* message was received.
*/
if (!supports_html5_notification ||
!converse.show_desktop_notifications ||
converse.windowState !== 'blur' ||
Notification.permission !== "granted") {
return;
}
var contact_jid = Strophe.getBareJidFromJid($message.attr('from'));
var roster_item = converse.roster.get(contact_jid);
var n = new Notification(__(___("%1$s says"), roster_item.get('fullname')), {
body: $message.children('body').text(),
converse.showContactRequestNotification = function (contact) {
var n = new Notification(contact.fullname, {
body: __('wants to be your contact'),
lang: converse.i18n.locale_data.converse[""].lang,
icon: converse.notification_icon
icon: 'logo/conversejs.png'
});
setTimeout(n.close.bind(n), 5000);
};
converse.notifyOfNewMessage = function (message) {
converse.handleChatStateNotification = function (evt, contact) {
/* Event handler for on('contactStatusChanged').
* Will show an HTML5 notification to indicate that the chat
* status has changed.
*/
if (converse.areDesktopNotificationsEnabled()) {
converse.showChatStateNotification(contact);
}
};
converse.handleMessageNotification = function (evt, message) {
/* Event handler for the on('message') event. Will call methods
* to play sounds and show HTML5 notifications.
*/
var $message = $(message);
if (!converse.shouldNotifyOfNewMessage($message)) {
if (!converse.shouldNotifyOfMessage($message)) {
return false;
}
converse.playSoundNotification($message);
if (converse.areDesktopNotificationsEnabled()) {
converse.showMessageNotification($message);
}
};
converse.handleContactRequestNotification = function (evt, contact) {
if (converse.areDesktopNotificationsEnabled(true)) {
converse.showContactRequestNotification(contact);
}
};
converse.on('contactStatusChanged', converse.showChatStateNotification);
converse.on('message', converse.notifyOfNewMessage);
converse.on('contactRequest', converse.handleContactRequestNotification);
converse.on('contactStatusChanged', converse.handleChatStateNotification);
converse.on('message', converse.handleMessageNotification);
}
});
}));
......@@ -158,7 +158,7 @@
converse.showContactRequestNotification = function (contact) {
var n = new Notification(contact.fullname, {
body: __('is requesting to be your contact'),
body: __('wants to be your contact'),
lang: converse.i18n.locale_data.converse[""].lang,
icon: 'logo/conversejs.png'
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment