Version 0.3.4

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

No files matched your search

@@ -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 -->
+23 -14
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);
-12
View File
@@ -1,12 +0,0 @@
/**
*
* @package mChat JavaScript Code mini
* @version 1.5.1 of 2016-01-17
* @copyright (c) 2009 By Shapoval Andrey Vladimirovich (AllCity) ~ http://allcity.net.ru/
* @copyright (c) 2013 By Rich McGirr (RMcGirr83) http://rmcgirr83.org
* @copyright (c) 2015 By dmzx - http://www.dmzx-web.net
* @copyright (c) 2015 By kasimi
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
"undefined"==typeof document.hasFocus&&(document.hasFocus=function(){return"visible"==document.visibilityState}),jQuery(function(e){var t=function(t,a,s){var o=e.Deferred(),n=o.promise();return a&&e.extend(s,mChat.hiddenFields),e.ajax({url:mChat.file.replace("mchat","mchat-"+t),timeout:5e3,type:"POST",dataType:"json",data:s}).success(function(e,a,s){e.hasOwnProperty(t)?o.resolve(e,a,s):o.reject(s,a,s.responseJSON?"session":"format")}).error(function(e,t,a){o.reject(e,t,a)}),n.fail(function(e,t,a){mChat.sound("error"),mChat.$$("refresh-load","refresh-ok","refresh-paused").hide(),mChat.$$("refresh-error").show(),"format"==a||("session"==a?(mChat.endSession(),alert(mChat.sessOut)):400==e.status?alert(mChat.flood):403==e.status?alert(mChat.noAccess):413==e.status?alert(mChat.mssgLngthLong):501==e.status?alert(mChat.noMessageInput):"undefined"!=typeof console&&console.log&&console.log("AJAX error. status: "+t+", message: "+a))})};e.extend(mChat,{clear:function(){""!==mChat.$$("input").val()&&(confirm(mChat.clearConfirm)&&(mChat.resetSession(!0),mChat.$$("input").val("")),mChat.$$("input").focus())},sound:function(e){if(!Cookies.get("mchat_no_sound")){var t=mChat.$$("sound-"+e).get(0);t.pause(),t.currentTime=0,t.play()}},notice:function(){document.hasFocus()||e.titleAlert(mChat.newMessageAlert,{interval:1e3})},toggle:function(e){var t=mChat.$$(e);t.stop().slideToggle(function(){var a="mchat_show_"+e;t.is(":visible")?Cookies.set(a,"yes"):Cookies.remove(a)})},add:function(){if(!mChat.$$("add").prop("disabled")&&""!==e.trim(mChat.$$("input").val())){var a=mChat.$$("input").val().replace(/\s/g,"");if(a.length>mChat.mssgLngth)return void alert(mChat.mssgLngthLong);mChat.pauseSession(),mChat.$$("add").prop("disabled",!0),t("add",!0,{message:mChat.$$("input").val()}).done(function(e){mChat.$$("input").val(""),mChat.refresh()}).always(function(){mChat.$$("input").focus(),mChat.$$("add").prop("disabled",!1),mChat.resetSession(!1)})}},edit:function(){var a=e(this).closest(".mchat-message"),s=mChat.$$("confirm").find("textarea").show().val(a.data("message"));mChat.$$("confirm").find("p").text(mChat.editInfo),phpbb.confirm(mChat.$$("confirm"),function(){t("edit",!0,{message_id:a.data("id"),message:s.val()}).done(function(t){mChat.sound("edit"),a.fadeOut("slow",function(){a.replaceWith(e(t.edit).hide().fadeIn("slow"))}),mChat.resetSession(!0)})})},del:function(){var a=e(this).closest(".mchat-message");mChat.$$("confirm").find("textarea").hide(),mChat.$$("confirm").find("p").text(mChat.delConfirm),phpbb.confirm(mChat.$$("confirm"),function(){t("del",!0,{message_id:a.data("id")}).done(function(e){mChat.sound("del"),a.fadeOut("slow",function(){a.remove()}),mChat.resetSession(!0)})})},refresh:function(){var a=mChat.$$("messages").children(),s={message_last_id:a.filter(mChat.messageTop?":first":":last").data("id")};if(mChat.liveUpdates){s.message_first_id=a.filter(mChat.messageTop?":last":":first").data("id"),s.message_edits={};var o=Math.floor(Date.now()/1e3);e.each(a,function(){var t=e(this),a=t.data("edit-time");a&&(!mChat.editDeleteLimit||t.data("message-time")>=o-mChat.editDeleteLimit/1e3)&&(s.message_edits[t.data("id")]=a)})}mChat.$$("refresh-ok","refresh-error","refresh-paused").hide(),mChat.$$("refresh-load").show(),t("refresh",!1,s).done(function(t){var a=e(t.refresh);if(a.length&&(mChat.sound("add"),mChat.notice(),mChat.$$("no-messages").remove(),a.hide().each(function(t){var a=e(this);if(setTimeout(function(){mChat.messageTop?mChat.$$("messages").prepend(a):mChat.$$("messages").append(a),a.css("opacity",0).slideDown("slow").animate({opacity:1},{queue:!1,duration:"slow"}),mChat.$$("main").animate({scrollTop:mChat.messageTop?0:mChat.$$("main")[0].scrollHeight},"slow")},600*t),mChat.editDeleteLimit&&a.data("edit-delete-limit")&&a.find('[data-mchat-action="edit"], [data-mchat-action="del"]').length>0){var s=a.attr("id");setTimeout(function(){e("#"+s).find('[data-mchat-action="edit"], [data-mchat-action="del"]').fadeOut("slow",function(){e(this).remove()})},mChat.editDeleteLimit)}})),t.hasOwnProperty("edit")){var s=!0;e.each(t.edit,function(t,a){var o=e("#mchat-message-"+t);o.length&&(s&&(s=!1,mChat.sound("edit")),o.fadeOut("slow",function(){o.replaceWith(e(a).hide().fadeIn("slow"))}))})}if(t.hasOwnProperty("del")){var o=!0;e.each(t.del,function(t,a){var s=e("#mchat-message-"+a);s.length&&(o&&(o=!1,mChat.sound("del")),s.fadeOut("slow",function(){s.remove()}))})}setTimeout(function(){mChat.refreshInterval&&(mChat.$$("refresh-load","refresh-error","refresh-paused").hide(),mChat.$$("refresh-ok").show())},250)})},whois:function(){mChat.customPage&&(mChat.$$("refresh-pending").show(),mChat.$$("refresh").hide()),t("whois",!1,{}).done(function(t){var a=e(t.whois),s=a.find("#mchat-userlist");Cookies.get("mchat_show_userlist")&&s.show(),mChat.$$("whois").replaceWith(a),mChat.cache.whois=a,mChat.cache.userlist=s,mChat.customPage&&setTimeout(function(){mChat.$$("refresh-pending").hide(),mChat.$$("refresh").show()},250)})},clean:functiLine truncated
@@ -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 -->
+2 -2
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">
+3 -3
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 -->