Version 2.1.4
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*!
|
||||
autosize 4.0.1
|
||||
autosize 4.0.2
|
||||
license: MIT
|
||||
http://www.jacklmoore.com/autosize
|
||||
*/
|
||||
!function(e,t){if("function"==typeof define&&define.amd)define(["module","exports"],t);else if("undefined"!=typeof exports)t(module,exports);else{var n={exports:{}};t(n,n.exports),e.autosize=n.exports}}(this,function(e,t){"use strict";var n,o,p="function"==typeof Map?new Map:(n=[],o=[],{has:function(e){return-1<n.indexOf(e)},get:function(e){return o[n.indexOf(e)]},set:function(e,t){-1===n.indexOf(e)&&(n.push(e),o.push(t))},delete:function(e){var t=n.indexOf(e);-1<t&&(n.splice(t,1),o.splice(t,1))}}),c=function(e){return new Event(e,{bubbles:!0})};try{new Event("test")}catch(e){c=function(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!1),t}}function r(r){if(r&&r.nodeName&&"TEXTAREA"===r.nodeName&&!p.has(r)){var e,n=null,o=null,i=null,d=function(){r.clientWidth!==o&&a()},l=function(t){window.removeEventListener("resize",d,!1),r.removeEventListener("input",a,!1),r.removeEventListener("keyup",a,!1),r.removeEventListener("autosize:destroy",l,!1),r.removeEventListener("autosize:update",a,!1),Object.keys(t).forEach(function(e){r.style[e]=t[e]}),p.delete(r)}.bind(r,{height:r.style.height,resize:r.style.resize,overflowY:r.style.overflowY,overflowX:r.style.overflowX,wordWrap:r.style.wordWrap});r.addEventListener("autosize:destroy",l,!1),"onpropertychange"in r&&"oninput"in r&&r.addEventListener("keyup",a,!1),window.addEventListener("resize",d,!1),r.addEventListener("input",a,!1),r.addEventListener("autosize:update",a,!1),r.style.overflowX="hidden",r.style.wordWrap="break-word",p.set(r,{destroy:l,update:a}),"vertical"===(e=window.getComputedStyle(r,null)).resize?r.style.resize="none":"both"===e.resize&&(r.style.resize="horizontal"),n="content-box"===e.boxSizing?-(parseFloat(e.paddingTop)+parseFloat(e.paddingBottom)):parseFloat(e.borderTopWidth)+parseFloat(e.borderBottomWidth),isNaN(n)&&(n=0),a()}function s(e){var t=r.style.width;r.style.width="0px",r.offsetWidth,r.style.width=t,r.style.overflowY=e}function u(){if(0!==r.scrollHeight){var e=function(e){for(var t=[];e&&e.parentNode&&e.parentNode instanceof Element;)e.parentNode.scrollTop&&t.push({node:e.parentNode,scrollTop:e.parentNode.scrollTop}),e=e.parentNode;return t}(r),t=document.documentElement&&document.documentElement.scrollTop;r.style.height="",r.style.height=r.scrollHeight+n+"px",o=r.clientWidth,e.forEach(function(e){e.node.scrollTop=e.scrollTop}),t&&(document.documentElement.scrollTop=t)}}function a(){u();var e=Math.round(parseFloat(r.style.height)),t=window.getComputedStyle(r,null),n="content-box"===t.boxSizing?Math.round(parseFloat(t.height)):r.offsetHeight;if(n!==e?"hidden"===t.overflowY&&(s("scroll"),u(),n="content-box"===t.boxSizing?Math.round(parseFloat(window.getComputedStyle(r,null).height)):r.offsetHeight):"hidden"!==t.overflowY&&(s("hidden"),u(),n="content-box"===t.boxSizing?Math.round(parseFloat(window.getComputedStyle(r,null).height)):r.offsetHeight),i!==n){i=n;var o=c("autosize:resized");try{r.dispatchEvent(o)}catch(e){}}}}function i(e){var t=p.get(e);t&&t.destroy()}function d(e){var t=p.get(e);t&&t.update()}var l=null;"undefined"==typeof window||"function"!=typeof window.getComputedStyle?((l=function(e){return e}).destroy=function(e){return e},l.update=function(e){return e}):((l=function(e,t){return e&&Array.prototype.forEach.call(e.length?e:[e],function(e){return r(e)}),e}).destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],i),e},l.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],d),e}),t.default=l,e.exports=t.default});
|
||||
!function(e,t){if("function"==typeof define&&define.amd)define(["module","exports"],t);else if("undefined"!=typeof exports)t(module,exports);else{var n={exports:{}};t(n,n.exports),e.autosize=n.exports}}(this,function(e,t){"use strict";var n,o,p="function"==typeof Map?new Map:(n=[],o=[],{has:function(e){return-1<n.indexOf(e)},get:function(e){return o[n.indexOf(e)]},set:function(e,t){-1===n.indexOf(e)&&(n.push(e),o.push(t))},delete:function(e){var t=n.indexOf(e);-1<t&&(n.splice(t,1),o.splice(t,1))}}),c=function(e){return new Event(e,{bubbles:!0})};try{new Event("test")}catch(e){c=function(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!1),t}}function r(r){if(r&&r.nodeName&&"TEXTAREA"===r.nodeName&&!p.has(r)){var e,n=null,o=null,i=null,d=function(){r.clientWidth!==o&&a()},l=function(t){window.removeEventListener("resize",d,!1),r.removeEventListener("input",a,!1),r.removeEventListener("keyup",a,!1),r.removeEventListener("autosize:destroy",l,!1),r.removeEventListener("autosize:update",a,!1),Object.keys(t).forEach(function(e){r.style[e]=t[e]}),p.delete(r)}.bind(r,{height:r.style.height,resize:r.style.resize,overflowY:r.style.overflowY,overflowX:r.style.overflowX,wordWrap:r.style.wordWrap});r.addEventListener("autosize:destroy",l,!1),"onpropertychange"in r&&"oninput"in r&&r.addEventListener("keyup",a,!1),window.addEventListener("resize",d,!1),r.addEventListener("input",a,!1),r.addEventListener("autosize:update",a,!1),r.style.overflowX="hidden",r.style.wordWrap="break-word",p.set(r,{destroy:l,update:a}),"vertical"===(e=window.getComputedStyle(r,null)).resize?r.style.resize="none":"both"===e.resize&&(r.style.resize="horizontal"),n="content-box"===e.boxSizing?-(parseFloat(e.paddingTop)+parseFloat(e.paddingBottom)):parseFloat(e.borderTopWidth)+parseFloat(e.borderBottomWidth),isNaN(n)&&(n=0),a()}function s(e){var t=r.style.width;r.style.width="0px",r.offsetWidth,r.style.width=t,r.style.overflowY=e}function u(){if(0!==r.scrollHeight){var e=function(e){for(var t=[];e&&e.parentNode&&e.parentNode instanceof Element;)e.parentNode.scrollTop&&t.push({node:e.parentNode,scrollTop:e.parentNode.scrollTop}),e=e.parentNode;return t}(r),t=document.documentElement&&document.documentElement.scrollTop;r.style.height="",r.style.height=r.scrollHeight+n+"px",o=r.clientWidth,e.forEach(function(e){e.node.scrollTop=e.scrollTop}),t&&(document.documentElement.scrollTop=t)}}function a(){u();var e=Math.round(parseFloat(r.style.height)),t=window.getComputedStyle(r,null),n="content-box"===t.boxSizing?Math.round(parseFloat(t.height)):r.offsetHeight;if(n<e?"hidden"===t.overflowY&&(s("scroll"),u(),n="content-box"===t.boxSizing?Math.round(parseFloat(window.getComputedStyle(r,null).height)):r.offsetHeight):"hidden"!==t.overflowY&&(s("hidden"),u(),n="content-box"===t.boxSizing?Math.round(parseFloat(window.getComputedStyle(r,null).height)):r.offsetHeight),i!==n){i=n;var o=c("autosize:resized");try{r.dispatchEvent(o)}catch(e){}}}}function i(e){var t=p.get(e);t&&t.destroy()}function d(e){var t=p.get(e);t&&t.update()}var l=null;"undefined"==typeof window||"function"!=typeof window.getComputedStyle?((l=function(e){return e}).destroy=function(e){return e},l.update=function(e){return e}):((l=function(e,t){return e&&Array.prototype.forEach.call(e.length?e:[e],function(e){return r(e)}),e}).destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],i),e},l.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],d),e}),t.default=l,e.exports=t.default});
|
||||
@@ -114,7 +114,7 @@ jQuery(function($) {
|
||||
$.ajax({
|
||||
url: mChat.actionUrls[mode],
|
||||
timeout: Math.min(mChat.refreshTime, 10000) - 100,
|
||||
type: 'POST',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
context: {
|
||||
@@ -207,7 +207,7 @@ jQuery(function($) {
|
||||
},
|
||||
sound: function(file) {
|
||||
var data = {
|
||||
audio: mChat.cached('sound-' + file).get(0),
|
||||
audio: mChat.cached('sound-' + file)[0],
|
||||
file: file,
|
||||
play: !mChat.pageIsUnloading && mChat.cached('sound').hasClass('mchat-nav-item-enabled')
|
||||
};
|
||||
@@ -250,7 +250,7 @@ jQuery(function($) {
|
||||
var $input = $confirmFields.find(':input:visible:enabled:first');
|
||||
if ($input.length) {
|
||||
var value = $input.val();
|
||||
$input.focus().val('').val(value);
|
||||
$input.trigger('focus').val('').val(value);
|
||||
}
|
||||
}, 1);
|
||||
phpbb.confirm(data.container.show(), function(success) {
|
||||
@@ -288,7 +288,7 @@ jQuery(function($) {
|
||||
mChat.setText(originalInputValue);
|
||||
}).always(function() {
|
||||
$add.prop('disabled', false);
|
||||
$input.delay(1).focus();
|
||||
$input.delay(1).trigger('focus');
|
||||
});
|
||||
},
|
||||
edit: function() {
|
||||
@@ -393,12 +393,12 @@ jQuery(function($) {
|
||||
whoisDone: function(json) {
|
||||
var $whois = $(json.container);
|
||||
var $userlist = $whois.find('#mchat-userlist');
|
||||
if (mChat.storage.get('show_userlist')) {
|
||||
$userlist.show();
|
||||
}
|
||||
mChat.cached('whois').replaceWith($whois);
|
||||
mChat.cache.whois = $whois;
|
||||
mChat.cache.userlist = $userlist;
|
||||
if (mChat.storage.get('show_userlist')) {
|
||||
$userlist.show();
|
||||
}
|
||||
if (mChat.page === 'custom') {
|
||||
mChat.cached('refresh-pending').hide();
|
||||
mChat.cached('refresh-explain').show();
|
||||
@@ -411,82 +411,70 @@ jQuery(function($) {
|
||||
}
|
||||
},
|
||||
addMessages: function($messages) {
|
||||
var playSound = true;
|
||||
mChat.cached('messages').find('.mchat-no-messages').remove();
|
||||
$messages.reverse(mChat.messageTop).hide().each(function(i) {
|
||||
var $message = $(this);
|
||||
var dataAddMessageBefore = {
|
||||
message: $message,
|
||||
delay: mChat.refreshInterval ? 400 : 0,
|
||||
abort: $.inArray($message.data('mchat-id'), mChat.messageIds) !== -1,
|
||||
playSound: playSound
|
||||
};
|
||||
$(mChat).trigger('mchat_add_message_before', [dataAddMessageBefore]);
|
||||
if (dataAddMessageBefore.abort) {
|
||||
return;
|
||||
}
|
||||
if (dataAddMessageBefore.playSound) {
|
||||
mChat.sound('add');
|
||||
mChat.titleAlert();
|
||||
playSound = false;
|
||||
}
|
||||
mChat.messageIds.push($message.data('mchat-id'));
|
||||
mChat.fixJumpToUrl.call($message);
|
||||
setTimeout(function() {
|
||||
var dataAddMessageAnimateBefore = {
|
||||
container: mChat.cached('messages'),
|
||||
message: $message,
|
||||
add: function() {
|
||||
if (mChat.messageTop) {
|
||||
this.container.prepend(this.message);
|
||||
} else {
|
||||
this.container.append(this.message);
|
||||
}
|
||||
},
|
||||
show: function() {
|
||||
var container = this.container;
|
||||
var scrollTop = container.scrollTop();
|
||||
var scrollLeeway = 20;
|
||||
if (mChat.messageTop && scrollTop <= scrollLeeway || !mChat.messageTop && scrollTop >= container.get(0).scrollHeight - container.height() - scrollLeeway) {
|
||||
var animateOptions = {
|
||||
duration: dataAddMessageBefore.delay - 10,
|
||||
easing: 'swing'
|
||||
};
|
||||
this.message.slideDown(animateOptions);
|
||||
if (mChat.messageTop) {
|
||||
container.animate({scrollTop: 0}, animateOptions);
|
||||
} else {
|
||||
animateOptions.complete = function() {
|
||||
var scrollHeight = container.get(0).scrollHeight;
|
||||
if (container.scrollTop() + container.innerHeight() < scrollHeight) {
|
||||
container.animate({scrollTop: scrollHeight}, animateOptions);
|
||||
}
|
||||
};
|
||||
animateOptions.complete();
|
||||
}
|
||||
} else {
|
||||
this.message.show();
|
||||
if (mChat.messageTop) {
|
||||
this.container.scrollTop(scrollTop + this.message.outerHeight());
|
||||
}
|
||||
}
|
||||
this.message.addClass('mchat-message-flash');
|
||||
$messages.reverse(mChat.messageTop).hide().each(this.addMessage);
|
||||
},
|
||||
addMessage: function(index) {
|
||||
var $message = $(this);
|
||||
var dataAddMessageBefore = {
|
||||
message: $message,
|
||||
delay: mChat.refreshInterval ? 400 : 0,
|
||||
abort: $.inArray($message.data('mchat-id'), mChat.messageIds) !== -1,
|
||||
playSound: index === 0,
|
||||
titleAlert: index === 0
|
||||
};
|
||||
$(mChat).trigger('mchat_add_message_before', [dataAddMessageBefore]);
|
||||
if (dataAddMessageBefore.abort) {
|
||||
return;
|
||||
}
|
||||
if (dataAddMessageBefore.playSound) {
|
||||
mChat.sound('add');
|
||||
}
|
||||
if (dataAddMessageBefore.titleAlert) {
|
||||
mChat.titleAlert();
|
||||
}
|
||||
mChat.messageIds.push($message.data('mchat-id'));
|
||||
mChat.fixJumpToUrl.call($message);
|
||||
var dataAddMessageAnimateBefore = {
|
||||
container: mChat.cached('messages'),
|
||||
message: $message,
|
||||
add: function() {
|
||||
if (mChat.messageTop) {
|
||||
this.container.prepend(this.message);
|
||||
} else {
|
||||
this.container.append(this.message);
|
||||
}
|
||||
},
|
||||
show: function() {
|
||||
var scrollLeeway = 20;
|
||||
var scrollTop = this.container.scrollTop();
|
||||
var scrollHeight = this.container[0].scrollHeight;
|
||||
this.message.show();
|
||||
this.message.addClass('mchat-message-flash');
|
||||
if (mChat.messageTop) {
|
||||
if (scrollTop <= scrollLeeway) {
|
||||
this.container.scrollTop(0);
|
||||
}
|
||||
};
|
||||
$(mChat).trigger('mchat_add_message_animate_before', [dataAddMessageAnimateBefore]);
|
||||
dataAddMessageAnimateBefore.add();
|
||||
dataAddMessageAnimateBefore.show();
|
||||
}, i * dataAddMessageBefore.delay);
|
||||
if (mChat.editDeleteLimit && $message.data('mchat-edit-delete-limit') && $message.find('[data-mchat-action="edit"], [data-mchat-action="del"]').length > 0) {
|
||||
var id = $message.prop('id');
|
||||
setTimeout(function() {
|
||||
$('#' + id).find('[data-mchat-action="edit"], [data-mchat-action="del"]').fadeOut(function() {
|
||||
$(this).closest('li').remove();
|
||||
});
|
||||
}, mChat.editDeleteLimit);
|
||||
} else {
|
||||
var height = this.container.height();
|
||||
if (scrollHeight - height - scrollTop <= scrollLeeway) {
|
||||
this.container.scrollTop(scrollHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
mChat.startRelativeTimeUpdate.call($message);
|
||||
});
|
||||
};
|
||||
$(mChat).trigger('mchat_add_message_animate_before', [dataAddMessageAnimateBefore]);
|
||||
dataAddMessageAnimateBefore.add();
|
||||
dataAddMessageAnimateBefore.show();
|
||||
if (mChat.editDeleteLimit && $message.data('mchat-edit-delete-limit') && $message.find('[data-mchat-action="edit"], [data-mchat-action="del"]').length > 0) {
|
||||
var id = $message.prop('id');
|
||||
setTimeout(function() {
|
||||
$('#' + id).find('[data-mchat-action="edit"], [data-mchat-action="del"]').fadeOut(function() {
|
||||
$(this).closest('li').remove();
|
||||
});
|
||||
}, mChat.editDeleteLimit);
|
||||
}
|
||||
mChat.startRelativeTimeUpdate.call($message);
|
||||
},
|
||||
updateMessages: function($messages) {
|
||||
var playSound = true;
|
||||
@@ -729,7 +717,22 @@ jQuery(function($) {
|
||||
mChat.cache[name] = $('#mchat-' + name);
|
||||
}
|
||||
return mChat.cache[name];
|
||||
}
|
||||
},
|
||||
onKeyPress: function(e, callbacks) {
|
||||
var isEnter = e.which === 10 || e.which === 13;
|
||||
if (isEnter && $(e.target).is('textarea')) {
|
||||
var callback;
|
||||
var isCtrl = e.ctrlKey || e.metaKey;
|
||||
if (!mChat.maxInputHeight || !isCtrl === !mChat.storage.get('no_enter')) {
|
||||
callback = 'submit';
|
||||
} else if (mChat.maxInputHeight && isCtrl) {
|
||||
callback = 'newline';
|
||||
}
|
||||
if (typeof callbacks[callback] === 'function') {
|
||||
callbacks[callback].call(this, e);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
mChat.messageIds = mChat.cached('messages').children()
|
||||
@@ -737,6 +740,10 @@ jQuery(function($) {
|
||||
.each(mChat.fixJumpToUrl)
|
||||
.map(function() { return $(this).data('mchat-id'); }).get();
|
||||
|
||||
if (!mChat.messageIds.length) {
|
||||
mChat.messageIds.push(mChat.latestMessageId);
|
||||
}
|
||||
|
||||
mChat.hiddenFields = {};
|
||||
mChat.cached('form').find('input[type=hidden]').each(function() {
|
||||
mChat.hiddenFields[this.name] = this.value;
|
||||
@@ -772,10 +779,9 @@ jQuery(function($) {
|
||||
});
|
||||
|
||||
$.each(['userlist', 'smilies', 'bbcodes', 'colour'], function(i, elem) {
|
||||
if (mChat.storage.get('show_' + elem)) {
|
||||
$('.mchat-button-' + elem).addClass('mchat-button-is-down');
|
||||
mChat.cached(elem).toggle();
|
||||
}
|
||||
var isVisible = mChat.storage.get('show_' + elem) === 'yes';
|
||||
$('.mchat-button-' + elem).toggleClass('mchat-button-is-down', isVisible);
|
||||
mChat.cached(elem).toggle(isVisible);
|
||||
});
|
||||
|
||||
var toggleRememberColor = function() {
|
||||
@@ -827,19 +833,18 @@ jQuery(function($) {
|
||||
});
|
||||
}
|
||||
|
||||
mChat.cached('form').submit(function(e) {
|
||||
mChat.cached('form').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
}).keypress(function(e) {
|
||||
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')) {
|
||||
}).on('keypress', function(e) {
|
||||
mChat.onKeyPress(e, {
|
||||
'submit': function(e) {
|
||||
e.preventDefault();
|
||||
mChat.add();
|
||||
} else if (mChat.maxInputHeight && isCtrl) {
|
||||
},
|
||||
'newline': function() {
|
||||
mChat.appendText('\n');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (mChat.showCharCount || mChat.mssgLngth) {
|
||||
@@ -870,9 +875,19 @@ jQuery(function($) {
|
||||
e.preventDefault();
|
||||
mChat.jumpToMessage.call(this);
|
||||
}).on('click', '.mchat-panel-buttons button', function() {
|
||||
var $this = $(this).blur();
|
||||
var $this = $(this).trigger('blur');
|
||||
if ($this.hasClass('mchat-button-down')) {
|
||||
$this.toggleClass('mchat-button-is-down');
|
||||
}
|
||||
}).on('keydown.phpbb.alert', mChat.cached('confirm'), function(e) {
|
||||
mChat.onKeyPress(e, {
|
||||
'newline': function(e) {
|
||||
e.stopImmediatePropagation();
|
||||
var $target = $(e.target);
|
||||
$target.val(function(i, text) {
|
||||
return text + '\n';
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
maxInputHeight : {{ MCHAT_MAX_INPUT_HEIGHT }},
|
||||
editDeleteLimit : {{ MCHAT_EDIT_DELETE_LIMIT }},
|
||||
logId : {{ MCHAT_LOG_ID }},
|
||||
latestMessageId : {{ MCHAT_LATEST_MESSAGE_ID | default(0) }},
|
||||
removeBBCodes : '{{ MCHAT_DISALLOWED_BBCODES | escape('js') }}',
|
||||
|
||||
// Language
|
||||
|
||||
Reference in New Issue
Block a user