Version 2.1.2
This commit is contained in:
@@ -335,6 +335,9 @@ jQuery(function($) {
|
||||
mChat.resetSession();
|
||||
},
|
||||
refresh: function(message) {
|
||||
if (mChat.pageIsUnloading) {
|
||||
return $.when();
|
||||
}
|
||||
var isAdd = typeof message !== 'undefined';
|
||||
if (!isAdd) {
|
||||
mChat.sessionLength += mChat.refreshTime;
|
||||
@@ -348,7 +351,7 @@ jQuery(function($) {
|
||||
}
|
||||
var data = {
|
||||
last: mChat.messageIds.length ? mChat.messageIds.max() : 0,
|
||||
log: mChat.liveUpdates ? mChat.logId : undefined,
|
||||
log: mChat.logId,
|
||||
message: isAdd ? message : undefined
|
||||
};
|
||||
mChat.status('load');
|
||||
@@ -597,7 +600,6 @@ jQuery(function($) {
|
||||
},
|
||||
updateCharCount: function() {
|
||||
var count = mChat.cleanMessage(mChat.cached('input').val()).length;
|
||||
var exceedCount = Math.max(mChat.mssgLngth - count, -999);
|
||||
if (mChat.showCharCount) {
|
||||
var charCount = mChat.lang.charCount.format({current: count, max: mChat.mssgLngth});
|
||||
var $elem = mChat.cached('character-count').html(charCount).toggleClass('invisible', count === 0);
|
||||
@@ -605,9 +607,12 @@ jQuery(function($) {
|
||||
$elem.toggleClass('error', count > mChat.mssgLngth);
|
||||
}
|
||||
}
|
||||
mChat.cached('exceed-character-count').text(exceedCount).toggleClass('hidden', exceedCount >= 0);
|
||||
mChat.cached('input').parent().toggleClass('mchat-input-error', exceedCount < 0);
|
||||
mChat.cached('add').toggleClass('hidden', exceedCount < 0);
|
||||
if (mChat.mssgLngth) {
|
||||
var exceedCount = mChat.mssgLngth - count;
|
||||
mChat.cached('exceed-character-count').text(exceedCount).toggleClass('hidden', exceedCount >= 0);
|
||||
mChat.cached('input').parent().toggleClass('mchat-input-error', exceedCount < 0);
|
||||
mChat.cached('add').toggleClass('hidden', exceedCount < 0);
|
||||
}
|
||||
},
|
||||
cleanMessage: function(message) {
|
||||
if (!mChat.maxInputHeight) {
|
||||
@@ -773,20 +778,38 @@ jQuery(function($) {
|
||||
}
|
||||
});
|
||||
|
||||
var toggleRememberColor = function() {
|
||||
var $this = $(this);
|
||||
var newColor = $this.data('color');
|
||||
if (mChat.storage.get('color') === newColor) {
|
||||
mChat.storage.remove('color');
|
||||
} else {
|
||||
mChat.storage.set('color', newColor);
|
||||
mChat.cached('colour').find('.colour-palette a').removeClass('remember-color');
|
||||
}
|
||||
$this.toggleClass('remember-color');
|
||||
};
|
||||
|
||||
var toggleRememberColorTimer = 0;
|
||||
var isToggledRememberColor = false;
|
||||
mChat.cached('colour').find('.colour-palette').on('click', 'a', function(e) {
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
if (isToggledRememberColor) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
var $this = $(this);
|
||||
var newColor = $this.data('color');
|
||||
if (mChat.storage.get('color') === newColor) {
|
||||
mChat.storage.remove('color');
|
||||
} else {
|
||||
mChat.storage.set('color', newColor);
|
||||
mChat.cached('colour').find('.colour-palette a').removeClass('remember-color');
|
||||
}
|
||||
$this.toggleClass('remember-color');
|
||||
isToggledRememberColor = false;
|
||||
} else if (e.ctrlKey || e.metaKey) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
toggleRememberColor.call(this);
|
||||
}
|
||||
}).on('mousedown touchstart', 'a', function() {
|
||||
var that = this;
|
||||
toggleRememberColorTimer = setTimeout(function() {
|
||||
toggleRememberColor.call(that);
|
||||
isToggledRememberColor = true;
|
||||
}, 500);
|
||||
}).on('mouseup touchend', 'a', function() {
|
||||
clearTimeout(toggleRememberColorTimer);
|
||||
});
|
||||
|
||||
var color = mChat.storage.get('color');
|
||||
@@ -794,6 +817,10 @@ jQuery(function($) {
|
||||
mChat.cached('colour').find('.colour-palette a[data-color="' + color + '"]').addClass('remember-color');
|
||||
}
|
||||
|
||||
mChat.cached('colour').find('.colour-palette a').each(function() {
|
||||
$(this).removeAttr('href');
|
||||
});
|
||||
|
||||
if (mChat.maxInputHeight) {
|
||||
mChat.cached('input').one('focus', function() {
|
||||
autosize(this);
|
||||
@@ -803,7 +830,8 @@ jQuery(function($) {
|
||||
mChat.cached('form').submit(function(e) {
|
||||
e.preventDefault();
|
||||
}).keypress(function(e) {
|
||||
if ((e.which === 10 || e.which === 13) && mChat.cached('input').is(e.target)) {
|
||||
var isEnter = e.which === 10 || e.which === 13;
|
||||
if (isEnter && mChat.cached('input').is(e.target)) {
|
||||
var isCtrl = e.ctrlKey || e.metaKey;
|
||||
if (!mChat.maxInputHeight || !isCtrl === !mChat.storage.get('no_enter')) {
|
||||
e.preventDefault();
|
||||
@@ -829,6 +857,9 @@ jQuery(function($) {
|
||||
|
||||
$(window).on('beforeunload', function() {
|
||||
mChat.pageIsUnloading = true;
|
||||
if (mChat.page !== 'archive') {
|
||||
mChat.pauseSession();
|
||||
}
|
||||
});
|
||||
|
||||
$('#phpbb').on('click', '[data-mchat-action]', function(e) {
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
playSound : {{ MCHAT_SOUND ? 'true' : 'false' }},
|
||||
messageTop : {{ MCHAT_MESSAGE_TOP ? 'true' : 'false' }},
|
||||
allowBBCodes : {{ S_BBCODE_ALLOWED ? 'true' : 'false' }},
|
||||
liveUpdates : {{ MCHAT_LIVE_UPDATES ? 'true' : 'false' }},
|
||||
relativeTime : {{ MCHAT_RELATIVE_TIME ? 'true' : 'false' }},
|
||||
showCharCount : {{ MCHAT_CHARACTER_COUNT ? 'true' : 'false' }},
|
||||
jumpTo : {{ MCHAT_JUMP_TO }},
|
||||
|
||||
Reference in New Issue
Block a user