Version 0.3.4

This commit is contained in:
dmzx
2016-02-07 14:57:51 +01:00
parent 3b003c669f
commit f4d19a5697
17 changed files with 234 additions and 168 deletions

View File

@@ -1,2 +1,2 @@
<!-- INCLUDECSS @dmzx_mchat/mchat.css -->
<!-- IF MCHAT_ALLOW_SMILES and not MCHAT_ALLOW_BBCODES --><!-- INCLUDEJS {T_ASSETS_PATH}/javascript/editor.js --><!-- ENDIF -->
<!-- IF MCHAT_ALLOW_SMILES or MCHAT_ALLOW_BBCODES --><!-- INCLUDEJS {T_ASSETS_PATH}/javascript/editor.js --><!-- ENDIF -->

View File

@@ -30,7 +30,7 @@ jQuery(function($) {
dataType: 'json',
data: data
}).success(function(json, status, xhr) {
if (json.hasOwnProperty(mode)) {
if (json[mode]) {
deferred.resolve(json, status, xhr);
} else {
deferred.reject(xhr, status, xhr.responseJSON ? 'session' : 'format');
@@ -72,7 +72,7 @@ jQuery(function($) {
}
},
sound: function(file) {
if (!Cookies.get('mchat_no_sound')) {
if (!mChat.pageIsUnloading && !Cookies.get('mchat_no_sound')) {
var audio = mChat.$$('sound-' + file).get(0);
audio.pause();
audio.currentTime = 0;
@@ -109,11 +109,8 @@ jQuery(function($) {
}
mChat.pauseSession();
mChat.$$('add').prop('disabled', true);
ajaxRequest('add', true, {
message: mChat.$$('input').val()
}).done(function(json) {
mChat.refresh(mChat.$$('input').val()).done(function() {
mChat.$$('input').val('');
mChat.refresh();
}).always(function() {
mChat.$$('input').focus();
mChat.$$('add').prop('disabled', false);
@@ -144,7 +141,7 @@ jQuery(function($) {
phpbb.confirm(mChat.$$('confirm'), function() {
ajaxRequest('del', true, {
message_id: $container.data('id')
}).done(function(json) {
}).done(function() {
mChat.sound('del');
$container.fadeOut('slow', function() {
$container.remove();
@@ -153,11 +150,14 @@ jQuery(function($) {
});
});
},
refresh: function() {
refresh: function(message) {
var $messages = mChat.$$('messages').children();
var data = {
message_last_id: $messages.filter(mChat.messageTop ? ':first' : ':last').data('id')
};
if (message) {
data.message = message;
}
if (mChat.liveUpdates) {
data.message_first_id = $messages.filter(mChat.messageTop ? ':last' : ':first').data('id');
data.message_edits = {};
@@ -172,8 +172,8 @@ jQuery(function($) {
}
mChat.$$('refresh-ok', 'refresh-error', 'refresh-paused').hide();
mChat.$$('refresh-load').show();
ajaxRequest('refresh', false, data).done(function(json) {
var $html = $(json.refresh);
return ajaxRequest(message ? 'add' : 'refresh', !!message, data).done(function(json) {
var $html = $(json.add);
if ($html.length) {
mChat.sound('add');
mChat.notice();
@@ -199,7 +199,7 @@ jQuery(function($) {
}
});
}
if (json.hasOwnProperty('edit')) {
if (json.edit) {
var isFirstEdit = true;
$.each(json.edit, function(id, content) {
var $container = $('#mchat-message-' + id);
@@ -214,7 +214,7 @@ jQuery(function($) {
}
});
}
if (json.hasOwnProperty('del')) {
if (json.del) {
var isFirstDelete = true;
$.each(json.del, function(i, id) {
var $container = $('#mchat-message-' + id);
@@ -263,6 +263,7 @@ jQuery(function($) {
mChat.$$('confirm').find('textarea').hide();
mChat.$$('confirm').find('p').text(mChat.cleanConfirm);
phpbb.confirm(mChat.$$('confirm'), function() {
mChat.pauseSession();
ajaxRequest('clean', true, {}).done(function() {
phpbb.alert('mChat', mChat.cleanDone);
setTimeout(function() {
@@ -376,7 +377,7 @@ jQuery(function($) {
mChat.$$('confirm').detach().show();
mChat.hiddenFields = {};
$('#' + form_name).find('input[type=hidden]').each(function() {
$('#mchat-form').find('input[type=hidden]').each(function() {
mChat.hiddenFields[this.name] = this.value;
});
@@ -444,6 +445,10 @@ jQuery(function($) {
e.preventDefault();
});
if (!mChat.$$('user-sound').prop('checked')) {
Cookies.set('mchat_no_sound', 'yes');
}
mChat.$$('user-sound').change(function() {
if (this.checked) {
Cookies.remove('mchat_no_sound');
@@ -452,7 +457,7 @@ jQuery(function($) {
}
});
$('#' + form_name).on('keypress', function(e) {
$('#mchat-form').on('keypress', function(e) {
if (e.which == 13) {
mChat.add();
e.preventDefault();
@@ -462,6 +467,10 @@ jQuery(function($) {
mChat.$$('input').autoGrowInput();
}
$(window).on('beforeunload', function() {
mChat.pageIsUnloading = true;
});
$('#phpbb').on('click', '[data-mchat-action]', function(e) {
var action = $(this).data('mchat-action');
mChat[action].call(this);

File diff suppressed because one or more lines are too long

View File

@@ -31,7 +31,6 @@
}
// ]]>
</script>
<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/editor.js -->
<!-- IF S_MCHAT_BBCODE_B -->
<input type="button" class="button2" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px" onclick="bbstyle(0)" title="{L_BBCODE_B_HELP}" />
<!-- ENDIF -->

View File

@@ -4,7 +4,7 @@
<!-- INCLUDEJS jquery.titlealert.min.js -->
<!-- INCLUDEJS js.cookie-2.0.4.min.js -->
<!-- INCLUDEJS mchat.min.js -->
<!-- INCLUDEJS mchat.js -->
<!-- IF MCHAT_ARCHIVE_PAGE and (.pagination or MCHAT_TOTAL_MESSAGES) -->
<div class="action-bar top">
@@ -104,7 +104,7 @@
<!-- INCLUDE mchat_whois.html -->
<!-- ENDIF -->
<form id="postform" action="{MCHAT_FILE_NAME}" method="POST">
<form name="postform" id="mchat-form" action="{MCHAT_FILE_NAME}" method="POST">
{S_FORM_TOKEN}
<!-- IF not MCHAT_ARCHIVE_PAGE -->
<div class="mchat-panel">

View File

@@ -13,7 +13,7 @@
<dt><label for="mchat_index">{L_DISPLAY_MCHAT}{L_COLON}</label></dt>
<dd>
<label><input type="radio" name="user_mchat_index" value="1"<!-- IF S_DISPLAY_MCHAT --> id="mchat_index" checked="checked"<!-- ENDIF --> /> {L_YES}</label>
<label><input type="radio" name="user_mchat_index" value="0"<!-- IF not S_DISPLAY_MCHAT --> id="mchat_index" checked="checked"<!-- ENDIF --> /> {L_NO}</label>
<label><input type="radio" name="user_mchat_index" value="0"<!-- IF not S_DISPLAY_MCHAT --> id="mchat_index" checked="checked"<!-- ENDIF --> /> {L_NO}</label>
</dd>
</dl>
<!-- ENDIF -->
@@ -24,7 +24,7 @@
<label><input type="radio" name="user_mchat_sound" value="0"<!-- IF not S_SOUND_MCHAT --> id="mchat_sound" checked="checked"<!-- ENDIF --> /> {L_NO}</label>
</dd>
</dl>
<!-- IF S_MCHAT_INDEX -->
<!-- IF S_MCHAT_INDEX_STATS -->
<dl>
<dt><label for="mchat_statsindex">{L_DISPLAY_STATS_INDEX}{L_COLON}</label></dt>
<dd>
@@ -68,4 +68,4 @@
</fieldset>
</form>
<!-- INCLUDE ucp_footer.html -->
<!-- INCLUDE ucp_footer.html -->