Version 1.0.0-RC2

This commit is contained in:
dmzx
2016-03-06 16:06:56 +01:00
parent fdde6ee2b2
commit 7fc464ff17
92 changed files with 2909 additions and 1845 deletions

View File

@@ -0,0 +1,47 @@
/*
jQuery autoGrowInput v1.0.3
Copyright (c) 2014 Simon Steinberger / Pixabay
Based on stackoverflow.com/questions/931207 (James Padolsey)
GitHub: https://github.com/Pixabay/jQuery-autoGrowInput
License: http://www.opensource.org/licenses/mit-license.php
*/
(function($){
var event = 'oninput' in document.createElement('input') ? 'input' : 'keydown';
$.fn.autoGrowInput = function(options){
var o = $.extend({ maxWidth: 500, minWidth: 20, comfortZone: 0 }, options);
this.each(function(){
var input = $(this),
val = ' ',
comfortZone = (options && 'comfortZone' in options) ? o.comfortZone : parseInt(input.css('fontSize')),
span = $('<span/>').css({
position: 'absolute',
top: -9999,
left: -9999,
width: 'auto',
fontSize: input.css('fontSize'),
fontFamily: input.css('fontFamily'),
fontWeight: input.css('fontWeight'),
letterSpacing: input.css('letterSpacing'),
textTransform: input.css('textTransform'),
whiteSpace: 'nowrap',
ariaHidden: true
}).appendTo('body'),
check = function(e){
if (val === (val = input.val()) && e.type !== 'autogrow') return;
if (!val) val = input.attr('placeholder') || '';
span.html(val.replace(/&/g, '&amp;').replace(/\s/g, '&nbsp;').replace(/</g, '&lt;').replace(/>/g, '&gt;'));
var newWidth = span.width() + comfortZone, mw = typeof(o.maxWidth) == "function" ? o.maxWidth() : o.maxWidth;
if (newWidth > mw) newWidth = mw;
else if (newWidth < o.minWidth) newWidth = o.minWidth;
if (newWidth != input.width()) input.width(newWidth);
};
input.on(event+'.autogrow autogrow', check);
// init on page load
check();
});
return this;
}
}(jQuery));

View File

@@ -0,0 +1,17 @@
/*!
* Title Alert 0.7
*
* Copyright (c) 2009 ESN | http://esn.me
* Jonatan Heyman | http://heyman.info
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
(function(a){a.titleAlert=function(e,c){if(a.titleAlert._running){a.titleAlert.stop()}a.titleAlert._settings=c=a.extend({},a.titleAlert.defaults,c);if(c.requireBlur&&a.titleAlert.hasFocus){return}c.originalTitleInterval=c.originalTitleInterval||c.interval;a.titleAlert._running=true;a.titleAlert._initialText=document.title;document.title=e;var b=true;var d=function(){if(!a.titleAlert._running){return}b=!b;document.title=(b?e:a.titleAlert._initialText);a.titleAlert._intervalToken=setTimeout(d,(b?c.interval:c.originalTitleInterval))};a.titleAlert._intervalToken=setTimeout(d,c.interval);if(c.stopOnMouseMove){a(document).mousemove(function(f){a(this).unbind(f);a.titleAlert.stop()})}if(c.duration>0){a.titleAlert._timeoutToken=setTimeout(function(){a.titleAlert.stop()},c.duration)}};a.titleAlert.defaults={interval:500,originalTitleInterval:null,duration:0,stopOnFocus:true,requireBlur:false,stopOnMouseMove:false};a.titleAlert.stop=function(){clearTimeout(a.titleAlert._intervalToken);clearTimeout(a.titleAlert._timeoutToken);document.title=a.titleAlert._initialText;a.titleAlert._timeoutToken=null;a.titleAlert._intervalToken=null;a.titleAlert._initialText=null;a.titleAlert._running=false;a.titleAlert._settings=null};a.titleAlert.hasFocus=true;a.titleAlert._running=false;a.titleAlert._intervalToken=null;a.titleAlert._timeoutToken=null;a.titleAlert._initialText=null;a.titleAlert._settings=null;a.titleAlert._focus=function(){a.titleAlert.hasFocus=true;if(a.titleAlert._running&&a.titleAlert._settings.stopOnFocus){var b=a.titleAlert._initialText;a.titleAlert.stop();setTimeout(function(){if(a.titleAlert._running){return}document.title=".";document.title=b},1000)}};a.titleAlert._blur=function(){a.titleAlert.hasFocus=false};a(window).bind("focus",a.titleAlert._focus);a(window).bind("blur",a.titleAlert._blur)})(jQuery);

View File

@@ -0,0 +1,2 @@
/*! js-cookie v2.0.4 | MIT */
!function(a){if("function"==typeof define&&define.amd)define(a);else if("object"==typeof exports)module.exports=a();else{var b=window.Cookies,c=window.Cookies=a();c.noConflict=function(){return window.Cookies=b,c}}}(function(){function a(){for(var a=0,b={};a<arguments.length;a++){var c=arguments[a];for(var d in c)b[d]=c[d]}return b}function b(c){function d(b,e,f){var g;if(arguments.length>1){if(f=a({path:"/"},d.defaults,f),"number"==typeof f.expires){var h=new Date;h.setMilliseconds(h.getMilliseconds()+864e5*f.expires),f.expires=h}try{g=JSON.stringify(e),/^[\{\[]/.test(g)&&(e=g)}catch(i){}return e=encodeURIComponent(String(e)),e=e.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),b=encodeURIComponent(String(b)),b=b.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),b=b.replace(/[\(\)]/g,escape),document.cookie=[b,"=",e,f.expires&&"; expires="+f.expires.toUTCString(),f.path&&"; path="+f.path,f.domain&&"; domain="+f.domain,f.secure?"; secure":""].join("")}b||(g={});for(var j=document.cookie?document.cookie.split("; "):[],k=/(%[0-9A-Z]{2})+/g,l=0;l<j.length;l++){var m=j[l].split("="),n=m[0].replace(k,decodeURIComponent),o=m.slice(1).join("=");'"'===o.charAt(0)&&(o=o.slice(1,-1));try{if(o=c&&c(o,n)||o.replace(k,decodeURIComponent),this.json)try{o=JSON.parse(o)}catch(i){}if(b===n){g=o;break}b||(g[n]=o)}catch(i){}}return g}return d.get=d.set=d,d.getJSON=function(){return d.apply({json:!0},[].slice.call(arguments))},d.defaults={},d.remove=function(b,c){d(b,"",a(c,{expires:-1}))},d.withConverter=b,d}return b()});

View File

@@ -0,0 +1,498 @@
/**
*
* @package phpBB Extension - mChat
* @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) 2016 By kasimi
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
// Support Opera
if (typeof document.hasFocus === 'undefined') {
document.hasFocus = function() {
return document.visibilityState == 'visible';
};
}
Array.prototype.max = function() {
return Math.max.apply(null, this);
};
Array.prototype.min = function() {
return Math.min.apply(null, this);
};
jQuery.fn.reverse = function(reverse) {
reverse = typeof reverse === 'undefined' ? true : reverse;
return reverse ? jQuery(this.toArray().reverse()) : this;
};
jQuery(function($) {
var ajaxRequest = function(mode, sendHiddenFields, data) {
var deferred = $.Deferred();
if (sendHiddenFields) {
$.extend(data, mChat.hiddenFields);
}
$.ajax({
url: mChat.actionUrls[mode],
timeout: 5000,
type: 'POST',
dataType: 'json',
data: data
}).done(function(json, status, xhr) {
if (json[mode]) {
deferred.resolve(json, status, xhr);
} else {
deferred.reject(xhr, status, xhr.responseJSON ? 'session' : 'format');
}
}).fail(function(xhr, status, error) {
deferred.reject(xhr, status, error);
});
return deferred.promise().fail(function(xhr, textStatus, errorThrown) {
mChat.sound('error');
mChat.cached('refresh-load', 'refresh-ok', 'refresh-paused').hide();
mChat.cached('refresh-error').show();
if (errorThrown == 'format') {
// Unexpected format
} else if (errorThrown == 'session') {
mChat.endSession(true);
alert(mChat.sessOut);
} else if (xhr.status == 400) {
alert(mChat.flood);
} else if (xhr.status == 403) {
alert(mChat.noAccess);
} else if (xhr.status == 413) {
alert(mChat.mssgLngthLong);
} else if (xhr.status == 501) {
alert(mChat.noMessageInput);
} else if (typeof console !== 'undefined' && console.log) {
console.log('AJAX error. status: ' + textStatus + ', message: ' + errorThrown);
}
});
};
$.extend(mChat, {
clear: function() {
if (mChat.cached('input').val() !== '') {
if (confirm(mChat.clearConfirm)) {
mChat.resetSession();
mChat.cached('input').val('');
}
setTimeout(function() {
mChat.cached('input').focus();
}, 1);
}
},
sound: function(file) {
if (!mChat.pageIsUnloading && !Cookies.get('mchat_no_sound')) {
var audio = mChat.cached('sound-' + file).get(0);
if (audio.duration) {
audio.pause();
audio.currentTime = 0;
audio.play();
}
}
},
notice: function() {
if (!document.hasFocus()) {
$.titleAlert(mChat.newMessageAlert, {interval: 1000});
}
},
toggle: function(name) {
var $elem = mChat.cached(name);
$elem.stop().slideToggle(function() {
var cookieName = 'mchat_show_' + name;
if ($elem.is(':visible')) {
Cookies.set(cookieName, 'yes');
} else {
Cookies.remove(cookieName);
}
});
},
add: function() {
if (mChat.cached('add').prop('disabled')) {
return;
}
var message = mChat.cached('input').val();
if ($.trim(message) === '') {
return;
}
var messChars = message.replace(/\s/g, '');
if (mChat.mssgLngth && messChars.length > mChat.mssgLngth) {
alert(mChat.mssgLngthLong);
return;
}
mChat.cached('add').prop('disabled', true);
mChat.pauseSession();
mChat.lastInputValue = message;
mChat.cached('input').val('');
mChat.refresh(message).done(function() {
mChat.resetSession();
}).fail(function() {
mChat.cached('input').val(mChat.lastInputValue);
}).always(function() {
mChat.cached('add').prop('disabled', false);
setTimeout(function() {
mChat.cached('input').focus();
}, 1);
});
},
edit: function() {
var $container = $(this).closest('.mchat-message');
var $message = mChat.cached('confirm').find('textarea').show().val($container.data('mchat-message'));
mChat.cached('confirm').find('p').text(mChat.editInfo);
phpbb.confirm(mChat.cached('confirm'), function() {
ajaxRequest('edit', true, {
message_id: $container.data('mchat-id'),
message: $message.val(),
archive: mChat.archiveMode ? 1 : 0
}).done(function(json) {
mChat.updateMessages($(json.edit));
mChat.resetSession();
});
});
},
del: function() {
var $container = $(this).closest('.mchat-message');
mChat.cached('confirm').find('textarea').hide();
mChat.cached('confirm').find('p').text(mChat.delConfirm);
phpbb.confirm(mChat.cached('confirm'), function() {
var delId = $container.data('mchat-id');
ajaxRequest('del', true, {
message_id: delId
}).done(function() {
mChat.removeMessages([delId]);
mChat.resetSession();
});
});
},
refresh: function(message) {
var $messages = mChat.cached('messages').children();
var data = {
message_last_id: mChat.messageIds.length ? mChat.messageIds.max() : 0
};
if (message) {
data.message = message;
}
if (mChat.liveUpdates) {
data.message_first_id = mChat.messageIds.length ? mChat.messageIds.min() : 0;
data.message_edits = {};
var now = Math.floor(Date.now() / 1000);
$.each($messages, function() {
var $message = $(this);
var editTime = $message.data('mchat-edit-time');
if (editTime && (!mChat.editDeleteLimit || $message.data('mchat-message-time') >= now - mChat.editDeleteLimit / 1000)) {
data.message_edits[$message.data('mchat-id')] = editTime;
}
});
}
mChat.cached('refresh-ok', 'refresh-error', 'refresh-paused').hide();
mChat.cached('refresh-load').show();
return ajaxRequest(message ? 'add' : 'refresh', !!message, data).done(function(json) {
if (json.add) {
var $html = $(json.add);
$('#mchat-no-messages').remove();
$html.reverse(mChat.messageTop).hide().each(function(i) {
var $message = $(this);
mChat.messageIds.push($message.data('mchat-id'));
setTimeout(function() {
if (mChat.messageTop) {
mChat.cached('messages').prepend($message);
} else {
mChat.cached('messages').append($message);
}
$message.css('opacity', 0).slideDown().animate({opacity: 1}, {queue: false});
mChat.cached('messages').animate({scrollTop: mChat.messageTop ? 0 : mChat.cached('messages')[0].scrollHeight});
}, i * 400);
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).remove();
});
}, mChat.editDeleteLimit);
}
mChat.startRelativeTimeUpdate($message);
});
mChat.sound('add');
mChat.notice();
}
if (json.edit) {
mChat.updateMessages($(json.edit));
}
if (json.del) {
mChat.removeMessages(json.del);
}
if (json.whois) {
mChat.whois();
}
if (mChat.refreshInterval) {
mChat.cached('refresh-load', 'refresh-error', 'refresh-paused').hide();
mChat.cached('refresh-ok').show();
}
});
},
whois: function() {
if (mChat.customPage) {
mChat.cached('refresh-pending').show();
mChat.cached('refresh-explain').hide();
}
ajaxRequest('whois', false, {}).done(function(json) {
var $whois = $(json.whois);
var $userlist = $whois.find('#mchat-userlist');
if (Cookies.get('mchat_show_userlist')) {
$userlist.show();
}
mChat.cached('whois').replaceWith($whois);
mChat.cache.whois = $whois;
mChat.cache.userlist = $userlist;
if (mChat.customPage) {
mChat.cached('refresh-pending').hide();
mChat.cached('refresh-explain').show();
}
});
},
updateMessages: function($messages) {
var soundPlayed = false;
$messages.each(function() {
var $newMessage = $(this);
var $oldMessage = $('#mchat-message-' + $newMessage.data('mchat-id'));
mChat.stopRelativeTimeUpdate($oldMessage);
mChat.startRelativeTimeUpdate($newMessage);
$oldMessage.fadeOut(function() {
$oldMessage.replaceWith($newMessage.hide().fadeIn());
});
if (!soundPlayed) {
soundPlayed = true;
mChat.sound('edit');
}
});
},
removeMessages: function(ids) {
var soundPlayed = false;
$.each(ids, function(i, id) {
var index = 0;
while ((index = $.inArray(id, mChat.messageIds, index)) !== -1) {
mChat.messageIds.splice(index, 1);
var $message = $('#mchat-message-' + id);
mChat.stopRelativeTimeUpdate($message);
$message.fadeOut(function() {
$message.remove();
});
if (!soundPlayed) {
soundPlayed = true;
mChat.sound('del');
}
}
});
},
startRelativeTimeUpdate: function($messages) {
if (mChat.relativeTime) {
$messages.find('.mchat-time[data-mchat-relative-update]').each(function() {
var $time = $(this);
setTimeout(function() {
mChat.relativeTimeUpdate($time);
$time.data('mchat-relative-interval', setInterval(function() {
mChat.relativeTimeUpdate($time);
}, 60 * 1000));
}, $time.data('mchat-relative-update') * 1000);
});
}
},
relativeTimeUpdate: function($time) {
var minutesAgo = $time.data('mchat-minutes-ago') + 1;
var langMinutesAgo = mChat.minutesAgo[minutesAgo];
if (langMinutesAgo) {
$time.text(langMinutesAgo).data('mchat-minutes-ago', minutesAgo);
} else {
mChat.stopRelativeTimeUpdate($time);
$time.text($time.attr('title')).removeAttr('data-mchat-relative-update data-mchat-minutes-ago data-mchat-relative-interval');
}
},
stopRelativeTimeUpdate: function($message) {
var selector = '.mchat-time[data-mchat-relative-update]';
clearInterval($message.find(selector).addBack(selector).data('mchat-relative-interval'));
},
timeLeft: function(sessionTime) {
return (new Date(sessionTime * 1000)).toUTCString().match(/(\d\d:\d\d:\d\d)/)[0];
},
countDown: function() {
mChat.sessionTime -= 1;
mChat.cached('session').html(mChat.sessEnds + ' ' + mChat.timeLeft(mChat.sessionTime));
if (mChat.sessionTime < 1) {
mChat.endSession();
}
},
pauseSession: function() {
clearInterval(mChat.refreshInterval);
if (mChat.userTimeout) {
clearInterval(mChat.sessionCountdown);
}
if (mChat.whoisRefresh) {
clearInterval(mChat.whoisInterval);
}
},
resetSession: function() {
if (!mChat.archiveMode) {
clearInterval(mChat.refreshInterval);
mChat.refreshInterval = setInterval(mChat.refresh, mChat.refreshTime);
if (mChat.userTimeout) {
mChat.sessionTime = mChat.userTimeout / 1000;
clearInterval(mChat.sessionCountdown);
mChat.cached('session').html(mChat.sessEnds + ' ' + mChat.timeLeft(mChat.sessionTime));
mChat.sessionCountdown = setInterval(mChat.countDown, 1000);
}
if (mChat.whoisRefresh) {
clearInterval(mChat.whoisInterval);
mChat.whoisInterval = setInterval(mChat.whois, mChat.whoisRefresh);
}
if (mChat.pause) {
mChat.cached('input').one('keypress', mChat.endSession);
}
mChat.cached('refresh-ok').show();
mChat.cached('refresh-load', 'refresh-error', 'refresh-paused').hide();
mChat.cached('refresh-text').html(mChat.refreshYes);
}
},
endSession: function(skipUpdateWhois) {
clearInterval(mChat.refreshInterval);
mChat.refreshInterval = false;
if (mChat.userTimeout) {
clearInterval(mChat.sessionCountdown);
mChat.cached('session').html(mChat.sessOut);
}
if (mChat.whoisRefresh) {
clearInterval(mChat.whoisInterval);
if (!skipUpdateWhois) {
mChat.whois();
}
}
mChat.cached('refresh-load', 'refresh-ok', 'refresh-error').hide();
mChat.cached('refresh-paused').show();
mChat.cached('refresh-text').html(mChat.refreshNo);
},
mention: function() {
var $container = $(this).closest('.mchat-message');
var username = mChat.entityDecode($container.data('mchat-username'));
var usercolor = $container.data('mchat-usercolor');
if (usercolor) {
username = '[b][color=' + usercolor + ']' + username + '[/color][/b]';
} else if (mChat.allowBBCodes) {
username = '[b]' + username + '[/b]';
}
insert_text('@ ' + username + ', ');
},
quote: function() {
var $container = $(this).closest('.mchat-message');
var username = mChat.entityDecode($container.data('mchat-username'));
var quote = mChat.entityDecode($container.data('mchat-message'));
insert_text('[quote="' + username + '"] ' + quote + '[/quote]');
},
like: function() {
var $container = $(this).closest('.mchat-message');
var username = mChat.entityDecode($container.data('mchat-username'));
var quote = mChat.entityDecode($container.data('mchat-message'));
insert_text(mChat.likes + '[quote="' + username + '"] ' + quote + '[/quote]');
},
entityDecode: function(text) {
var s = decodeURIComponent(text.toString().replace(/\+/g, ' '));
s = s.replace(/&lt;/g, '<');
s = s.replace(/&gt;/g, '>');
s = s.replace(/&#58;/g, ':');
s = s.replace(/&#46;/g, '.');
s = s.replace(/&amp;/g, '&');
s = s.replace(/&quot;/g, "'");
return s;
},
cached: function() {
return $($.map(arguments, function(name) {
if (!mChat.cache[name]) {
mChat.cache[name] = $('#mchat-' + name);
}
return mChat.cache[name];
})).map(function() {
return this.toArray();
});
}
});
mChat.cache = {};
mChat.cached('confirm').detach().show();
mChat.messageIds = mChat.cached('messages').children().map(function() {
return $(this).data('mchat-id');
}).get();
mChat.hiddenFields = {};
$('#mchat-form').find('input[type=hidden]').each(function() {
mChat.hiddenFields[this.name] = this.value;
});
if (!mChat.archiveMode) {
mChat.resetSession();
if (!mChat.messageTop) {
mChat.cached('messages').animate({scrollTop: mChat.cached('messages')[0].scrollHeight, easing: 'swing', duration: 'slow'});
}
if (!mChat.cached('user-sound').prop('checked')) {
Cookies.set('mchat_no_sound', 'yes');
}
mChat.cached('user-sound').prop('checked', mChat.playSound && !Cookies.get('mchat_no_sound'));
mChat.cached('user-sound').change(function() {
if (this.checked) {
Cookies.remove('mchat_no_sound');
} else {
Cookies.set('mchat_no_sound', 'yes');
}
});
$.each(mChat.removeBBCodes.split('|'), function(i, bbcode) {
$('#format-buttons .bbcode-' + bbcode).remove();
});
var $colourPalette = $('#colour_palette');
$colourPalette.appendTo($colourPalette.parent()).wrap('<div id="mchat-colour"></div>').show();
$('#bbpalette,#abbc3_bbpalette').prop('onclick', null).attr('data-mchat-toggle', 'colour');
$.each(['userlist', 'smilies', 'bbcodes', 'colour'], function(i, elem) {
if (Cookies.get('mchat_show_' + elem)) {
mChat.cached(elem).toggle();
}
});
mChat.startRelativeTimeUpdate(mChat.cached('messages'));
if (mChat.cached('input').is('input')) {
$('#mchat-form').on('keypress', function(e) {
if (e.which == 13) {
mChat.add();
e.preventDefault();
}
});
}
mChat.cached('input').autoGrowInput({
minWidth: mChat.cached('input').width(),
maxWidth: mChat.cached('form').width() - (mChat.cached('input').outerWidth(true) - mChat.cached('input').width())
});
}
$(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);
e.preventDefault();
}).on('click', '[data-mchat-toggle]', function(e) {
var elem = $(this).data('mchat-toggle');
mChat.toggle(elem);
e.preventDefault();
});
});