2012-03-14 09:41:56 +01:00
|
|
|
|
/*
|
|
|
|
|
* quick-reply.js
|
2012-03-31 02:13:11 +02:00
|
|
|
|
* https://github.com/savetheinternet/Tinyboard/blob/master/js/quick-reply.js
|
2012-03-14 09:41:56 +01:00
|
|
|
|
*
|
|
|
|
|
* Released under the MIT license
|
2013-09-14 23:17:02 +02:00
|
|
|
|
* Copyright (c) 2013 Michael Save <savetheinternet@tinyboard.org>
|
2014-01-19 14:27:24 +01:00
|
|
|
|
* Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net>
|
2012-03-14 09:41:56 +01:00
|
|
|
|
*
|
|
|
|
|
* Usage:
|
2012-03-15 06:19:26 +01:00
|
|
|
|
* $config['additional_javascript'][] = 'js/jquery.min.js';
|
2013-09-15 03:18:46 +02:00
|
|
|
|
* $config['additional_javascript'][] = 'js/jquery-ui.custom.min.js'; // Optional; if you want the form to be draggable.
|
2012-03-15 06:19:26 +01:00
|
|
|
|
* $config['additional_javascript'][] = 'js/quick-reply.js';
|
2012-03-14 09:41:56 +01:00
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2013-09-18 06:40:39 +02:00
|
|
|
|
(function() {
|
|
|
|
|
var settings = new script_settings('quick-reply');
|
2013-09-15 02:29:35 +02:00
|
|
|
|
|
2013-09-18 06:40:39 +02:00
|
|
|
|
var do_css = function() {
|
|
|
|
|
$('#quick-reply-css').remove();
|
|
|
|
|
|
|
|
|
|
// Find background of reply posts
|
|
|
|
|
var dummy_reply = $('<div class="post reply"></div>').appendTo($('body'));
|
|
|
|
|
var reply_background = dummy_reply.css('backgroundColor');
|
|
|
|
|
var reply_border_style = dummy_reply.css('borderStyle');
|
|
|
|
|
var reply_border_color = dummy_reply.css('borderColor');
|
|
|
|
|
var reply_border_width = dummy_reply.css('borderWidth');
|
|
|
|
|
dummy_reply.remove();
|
|
|
|
|
|
|
|
|
|
$('<style type="text/css" id="quick-reply-css">\
|
2013-09-15 00:08:44 +02:00
|
|
|
|
#quick-reply {\
|
2013-09-18 06:40:39 +02:00
|
|
|
|
position: fixed;\
|
2013-12-23 00:12:04 +01:00
|
|
|
|
right: 5%;\
|
2013-09-18 06:40:39 +02:00
|
|
|
|
top: 5%;\
|
|
|
|
|
float: right;\
|
|
|
|
|
display: block;\
|
|
|
|
|
padding: 0 0 0 0;\
|
|
|
|
|
width: 300px;\
|
2014-04-15 13:49:38 +02:00
|
|
|
|
z-index: 100;\
|
2013-09-15 00:08:44 +02:00
|
|
|
|
}\
|
2013-09-18 06:40:39 +02:00
|
|
|
|
#quick-reply table {\
|
|
|
|
|
border-collapse: collapse;\
|
|
|
|
|
background: ' + reply_background + ';\
|
|
|
|
|
border-style: ' + reply_border_style + ';\
|
|
|
|
|
border-width: ' + reply_border_width + ';\
|
|
|
|
|
border-color: ' + reply_border_color + ';\
|
|
|
|
|
margin: 0;\
|
|
|
|
|
width: 100%;\
|
|
|
|
|
}\
|
|
|
|
|
#quick-reply tr td:nth-child(2) {\
|
|
|
|
|
white-space: nowrap;\
|
|
|
|
|
text-align: right;\
|
|
|
|
|
padding-right: 4px;\
|
|
|
|
|
}\
|
|
|
|
|
#quick-reply tr td:nth-child(2) input[type="submit"] {\
|
|
|
|
|
width: 100%;\
|
|
|
|
|
}\
|
|
|
|
|
#quick-reply th, #quick-reply td {\
|
|
|
|
|
margin: 0;\
|
|
|
|
|
padding: 0;\
|
|
|
|
|
}\
|
|
|
|
|
#quick-reply th {\
|
|
|
|
|
text-align: center;\
|
|
|
|
|
padding: 2px 0;\
|
|
|
|
|
border: 1px solid #222;\
|
|
|
|
|
}\
|
|
|
|
|
#quick-reply th .handle {\
|
|
|
|
|
float: left;\
|
|
|
|
|
width: 100%;\
|
|
|
|
|
display: inline-block;\
|
|
|
|
|
}\
|
|
|
|
|
#quick-reply th .close-btn {\
|
|
|
|
|
float: right;\
|
|
|
|
|
padding: 0 5px;\
|
|
|
|
|
}\
|
|
|
|
|
#quick-reply input[type="text"], #quick-reply select {\
|
|
|
|
|
width: 100%;\
|
|
|
|
|
padding: 2px;\
|
|
|
|
|
font-size: 10pt;\
|
|
|
|
|
box-sizing: border-box;\
|
|
|
|
|
-webkit-box-sizing:border-box;\
|
|
|
|
|
-moz-box-sizing: border-box;\
|
|
|
|
|
}\
|
|
|
|
|
#quick-reply textarea {\
|
|
|
|
|
width: 100%;\
|
2015-03-30 04:31:38 +02:00
|
|
|
|
min-width: 100%;\
|
2013-09-18 06:40:39 +02:00
|
|
|
|
box-sizing: border-box;\
|
|
|
|
|
-webkit-box-sizing:border-box;\
|
|
|
|
|
-moz-box-sizing: border-box;\
|
|
|
|
|
font-size: 10pt;\
|
2015-03-30 04:31:38 +02:00
|
|
|
|
resize: vertical horizontal;\
|
2013-09-18 06:40:39 +02:00
|
|
|
|
}\
|
|
|
|
|
#quick-reply input, #quick-reply select, #quick-reply textarea {\
|
|
|
|
|
margin: 0 0 1px 0;\
|
|
|
|
|
}\
|
|
|
|
|
#quick-reply input[type="file"] {\
|
|
|
|
|
padding: 5px 2px;\
|
|
|
|
|
}\
|
|
|
|
|
#quick-reply .nonsense {\
|
|
|
|
|
display: none;\
|
|
|
|
|
}\
|
|
|
|
|
#quick-reply td.submit {\
|
|
|
|
|
width: 1%;\
|
|
|
|
|
}\
|
|
|
|
|
#quick-reply td.recaptcha {\
|
|
|
|
|
text-align: center;\
|
|
|
|
|
padding: 0 0 1px 0;\
|
|
|
|
|
}\
|
|
|
|
|
#quick-reply td.recaptcha span {\
|
|
|
|
|
display: inline-block;\
|
|
|
|
|
width: 100%;\
|
|
|
|
|
background: white;\
|
|
|
|
|
border: 1px solid #ccc;\
|
|
|
|
|
cursor: pointer;\
|
|
|
|
|
}\
|
|
|
|
|
#quick-reply td.recaptcha-response {\
|
|
|
|
|
padding: 0 0 1px 0;\
|
|
|
|
|
}\
|
2015-02-07 03:42:13 +01:00
|
|
|
|
@media screen and (max-width: 400px) {\
|
2013-09-18 06:40:39 +02:00
|
|
|
|
#quick-reply {\
|
|
|
|
|
display: none !important;\
|
|
|
|
|
}\
|
|
|
|
|
}\
|
|
|
|
|
</style>').appendTo($('head'));
|
|
|
|
|
};
|
2013-09-15 02:29:35 +02:00
|
|
|
|
|
2013-09-18 06:40:39 +02:00
|
|
|
|
var show_quick_reply = function(){
|
|
|
|
|
if($('div.banner').length == 0)
|
|
|
|
|
return;
|
|
|
|
|
if($('#quick-reply').length != 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
do_css();
|
|
|
|
|
|
|
|
|
|
var $postForm = $('form[name="post"]').clone();
|
|
|
|
|
|
|
|
|
|
$postForm.clone();
|
|
|
|
|
|
|
|
|
|
$dummyStuff = $('<div class="nonsense"></div>').appendTo($postForm);
|
|
|
|
|
|
|
|
|
|
$postForm.find('table tr').each(function() {
|
|
|
|
|
var $th = $(this).children('th:first');
|
|
|
|
|
var $td = $(this).children('td:first');
|
|
|
|
|
if ($th.length && $td.length) {
|
|
|
|
|
$td.attr('colspan', 2);
|
2013-09-15 02:29:35 +02:00
|
|
|
|
|
2013-09-18 06:40:39 +02:00
|
|
|
|
if ($td.find('input[type="text"]').length) {
|
|
|
|
|
// Replace <th> with input placeholders
|
|
|
|
|
$td.find('input[type="text"]')
|
|
|
|
|
.removeAttr('size')
|
|
|
|
|
.attr('placeholder', $th.clone().children().remove().end().text());
|
|
|
|
|
}
|
2013-09-14 23:17:02 +02:00
|
|
|
|
|
2013-09-18 06:40:39 +02:00
|
|
|
|
// Move anti-spam nonsense and remove <th>
|
|
|
|
|
$th.contents().filter(function() {
|
|
|
|
|
return this.nodeType == 3; // Node.TEXT_NODE
|
|
|
|
|
}).remove();
|
|
|
|
|
$th.contents().appendTo($dummyStuff);
|
|
|
|
|
$th.remove();
|
2012-03-14 09:41:56 +01:00
|
|
|
|
|
2013-09-18 06:40:39 +02:00
|
|
|
|
if ($td.find('input[name="password"]').length) {
|
|
|
|
|
// Hide password field
|
|
|
|
|
$(this).hide();
|
|
|
|
|
}
|
2013-09-14 23:17:02 +02:00
|
|
|
|
|
2013-09-18 06:40:39 +02:00
|
|
|
|
// Fix submit button
|
|
|
|
|
if ($td.find('input[type="submit"]').length) {
|
|
|
|
|
$td.removeAttr('colspan');
|
|
|
|
|
$('<td class="submit"></td>').append($td.find('input[type="submit"]')).insertAfter($td);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// reCAPTCHA
|
|
|
|
|
if ($td.find('#recaptcha_widget_div').length) {
|
|
|
|
|
// Just show the image, and have it interact with the real form.
|
|
|
|
|
var $captchaimg = $td.find('#recaptcha_image img');
|
|
|
|
|
|
|
|
|
|
$captchaimg
|
|
|
|
|
.removeAttr('id')
|
|
|
|
|
.removeAttr('style')
|
|
|
|
|
.addClass('recaptcha_image')
|
|
|
|
|
.click(function() {
|
|
|
|
|
$('#recaptcha_reload').click();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// When we get a new captcha...
|
|
|
|
|
$('#recaptcha_response_field').focus(function() {
|
|
|
|
|
if ($captchaimg.attr('src') != $('#recaptcha_image img').attr('src')) {
|
|
|
|
|
$captchaimg.attr('src', $('#recaptcha_image img').attr('src'));
|
|
|
|
|
$postForm.find('input[name="recaptcha_challenge_field"]').val($('#recaptcha_challenge_field').val());
|
|
|
|
|
$postForm.find('input[name="recaptcha_response_field"]').val('').focus();
|
|
|
|
|
}
|
2013-09-16 00:11:54 +02:00
|
|
|
|
});
|
2013-09-14 23:17:02 +02:00
|
|
|
|
|
2013-09-18 06:40:39 +02:00
|
|
|
|
$postForm.submit(function() {
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
$('#recaptcha_reload').click();
|
|
|
|
|
}, 200);
|
|
|
|
|
});
|
2013-09-14 23:17:02 +02:00
|
|
|
|
|
2013-09-18 06:40:39 +02:00
|
|
|
|
// Make a new row for the response text
|
|
|
|
|
var $newRow = $('<tr><td class="recaptcha-response" colspan="2"></td></tr>');
|
|
|
|
|
$newRow.children().first().append(
|
|
|
|
|
$td.find('input').removeAttr('style')
|
|
|
|
|
);
|
|
|
|
|
$newRow.find('#recaptcha_response_field')
|
|
|
|
|
.removeAttr('id')
|
|
|
|
|
.addClass('recaptcha_response_field')
|
|
|
|
|
.attr('placeholder', $('#recaptcha_response_field').attr('placeholder'));
|
2013-09-14 23:17:02 +02:00
|
|
|
|
|
2013-09-18 06:40:39 +02:00
|
|
|
|
$('#recaptcha_response_field').addClass('recaptcha_response_field')
|
2013-09-14 23:17:02 +02:00
|
|
|
|
|
2013-09-18 06:40:39 +02:00
|
|
|
|
$td.replaceWith($('<td class="recaptcha" colspan="2"></td>').append($('<span></span>').append($captchaimg)));
|
|
|
|
|
|
|
|
|
|
$newRow.insertAfter(this);
|
2013-09-15 02:16:33 +02:00
|
|
|
|
}
|
2013-09-18 06:40:39 +02:00
|
|
|
|
|
|
|
|
|
// Upload section
|
|
|
|
|
if ($td.find('input[type="file"]').length) {
|
|
|
|
|
if ($td.find('input[name="file_url"]').length) {
|
|
|
|
|
$file_url = $td.find('input[name="file_url"]');
|
|
|
|
|
|
2013-12-24 00:28:30 +01:00
|
|
|
|
if (settings.get('show_remote', false)) {
|
|
|
|
|
// Make a new row for it
|
|
|
|
|
var $newRow = $('<tr><td colspan="2"></td></tr>');
|
2013-09-18 06:40:39 +02:00
|
|
|
|
|
2013-12-24 00:28:30 +01:00
|
|
|
|
$file_url.clone().attr('placeholder', _('Upload URL')).appendTo($newRow.find('td'));
|
2013-09-18 06:40:39 +02:00
|
|
|
|
|
2013-12-24 00:28:30 +01:00
|
|
|
|
$newRow.insertBefore(this);
|
|
|
|
|
}
|
|
|
|
|
$file_url.parent().remove();
|
|
|
|
|
|
2013-09-18 06:40:39 +02:00
|
|
|
|
|
2013-09-15 02:16:33 +02:00
|
|
|
|
$td.find('label').remove();
|
2013-09-18 06:40:39 +02:00
|
|
|
|
$td.contents().filter(function() {
|
|
|
|
|
return this.nodeType == 3; // Node.TEXT_NODE
|
|
|
|
|
}).remove();
|
|
|
|
|
$td.find('input[name="file_url"]').removeAttr('id');
|
2013-09-15 02:16:33 +02:00
|
|
|
|
}
|
2013-09-18 06:40:39 +02:00
|
|
|
|
|
|
|
|
|
if ($(this).find('input[name="spoiler"]').length) {
|
|
|
|
|
$td.removeAttr('colspan');
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-09-15 06:03:27 +02:00
|
|
|
|
|
2013-12-24 00:28:30 +01:00
|
|
|
|
// Disable embedding if configured so
|
|
|
|
|
if (!settings.get('show_embed', false) && $td.find('input[name="embed"]').length) {
|
|
|
|
|
$(this).remove();
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-18 15:00:22 +02:00
|
|
|
|
// Remove oekaki if existent
|
|
|
|
|
if ($(this).is('#oekaki')) {
|
|
|
|
|
$(this).remove();
|
|
|
|
|
}
|
2013-12-24 00:14:29 +01:00
|
|
|
|
|
|
|
|
|
// Remove upload selection
|
2013-12-25 14:40:57 +01:00
|
|
|
|
if ($td.is('#upload_selection')) {
|
2013-12-24 00:14:29 +01:00
|
|
|
|
$(this).remove();
|
|
|
|
|
}
|
2013-09-15 03:18:46 +02:00
|
|
|
|
|
2013-09-18 06:40:39 +02:00
|
|
|
|
// Remove mod controls, because it looks shit.
|
|
|
|
|
if ($td.find('input[type="checkbox"]').length) {
|
|
|
|
|
var tr = this;
|
|
|
|
|
$td.find('input[type="checkbox"]').each(function() {
|
|
|
|
|
if ($(this).attr('name') == 'spoiler') {
|
|
|
|
|
$td.find('label').remove();
|
|
|
|
|
$(this).attr('id', 'q-spoiler-image');
|
|
|
|
|
$postForm.find('input[type="file"]').parent()
|
|
|
|
|
.removeAttr('colspan')
|
|
|
|
|
.after($('<td class="spoiler"></td>').append(this, ' ', $('<label for="q-spoiler-image">').text(_('Spoiler Image'))));
|
2014-09-20 17:21:50 +02:00
|
|
|
|
} else if ($(this).attr('name') == 'no_country') {
|
|
|
|
|
$td.find('label,input[type="checkbox"]').remove();
|
2013-09-18 06:40:39 +02:00
|
|
|
|
} else {
|
|
|
|
|
$(tr).remove();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$td.find('small').hide();
|
2013-09-15 03:18:46 +02:00
|
|
|
|
}
|
|
|
|
|
});
|
2013-09-18 06:40:39 +02:00
|
|
|
|
|
|
|
|
|
$postForm.find('textarea[name="body"]').removeAttr('id').removeAttr('cols').attr('placeholder', _('Comment'));
|
2013-09-14 23:17:02 +02:00
|
|
|
|
|
2017-04-24 11:46:00 +02:00
|
|
|
|
$postForm.find('textarea:not([name="body"]),input[type="hidden"]:not(.captcha_cookie)').removeAttr('id').appendTo($dummyStuff);
|
2013-09-14 23:17:02 +02:00
|
|
|
|
|
2013-09-18 06:40:39 +02:00
|
|
|
|
$postForm.find('br').remove();
|
|
|
|
|
$postForm.find('table').prepend('<tr><th colspan="2">\
|
|
|
|
|
<span class="handle">\
|
2015-03-17 10:22:35 +01:00
|
|
|
|
<a class="close-btn" href="javascript:void(0)">×</a>\
|
2013-09-18 06:40:39 +02:00
|
|
|
|
' + _('Quick Reply') + '\
|
|
|
|
|
</span>\
|
|
|
|
|
</th></tr>');
|
|
|
|
|
|
|
|
|
|
$postForm.attr('id', 'quick-reply');
|
|
|
|
|
|
|
|
|
|
$postForm.appendTo($('body')).hide();
|
|
|
|
|
$origPostForm = $('form[name="post"]:first');
|
|
|
|
|
|
|
|
|
|
// Synchronise body text with original post form
|
2014-01-21 19:25:11 +01:00
|
|
|
|
$origPostForm.find('textarea[name="body"]').on('change input propertychange', function() {
|
2013-09-18 06:40:39 +02:00
|
|
|
|
$postForm.find('textarea[name="body"]').val($(this).val());
|
|
|
|
|
});
|
2014-01-21 19:25:11 +01:00
|
|
|
|
$postForm.find('textarea[name="body"]').on('change input propertychange', function() {
|
2013-09-18 06:40:39 +02:00
|
|
|
|
$origPostForm.find('textarea[name="body"]').val($(this).val());
|
|
|
|
|
});
|
|
|
|
|
$postForm.find('textarea[name="body"]').focus(function() {
|
|
|
|
|
$origPostForm.find('textarea[name="body"]').removeAttr('id');
|
|
|
|
|
$(this).attr('id', 'body');
|
|
|
|
|
});
|
|
|
|
|
$origPostForm.find('textarea[name="body"]').focus(function() {
|
|
|
|
|
$postForm.find('textarea[name="body"]').removeAttr('id');
|
|
|
|
|
$(this).attr('id', 'body');
|
|
|
|
|
});
|
|
|
|
|
// Synchronise other inputs
|
2014-01-21 19:25:11 +01:00
|
|
|
|
$origPostForm.find('input[type="text"],select').on('change input propertychange', function() {
|
2013-09-18 06:40:39 +02:00
|
|
|
|
$postForm.find('[name="' + $(this).attr('name') + '"]').val($(this).val());
|
|
|
|
|
});
|
2014-01-21 19:25:11 +01:00
|
|
|
|
$postForm.find('input[type="text"],select').on('change input propertychange', function() {
|
2013-09-18 06:40:39 +02:00
|
|
|
|
$origPostForm.find('[name="' + $(this).attr('name') + '"]').val($(this).val());
|
|
|
|
|
});
|
2013-09-15 03:18:46 +02:00
|
|
|
|
|
2013-09-18 15:00:22 +02:00
|
|
|
|
if (typeof $postForm.draggable != 'undefined') {
|
2013-09-18 06:40:39 +02:00
|
|
|
|
if (localStorage.quickReplyPosition) {
|
|
|
|
|
var offset = JSON.parse(localStorage.quickReplyPosition);
|
2013-09-18 13:37:31 +02:00
|
|
|
|
if (offset.top < 0)
|
|
|
|
|
offset.top = 0;
|
2013-09-18 06:40:39 +02:00
|
|
|
|
if (offset.right > $(window).width() - $postForm.width())
|
|
|
|
|
offset.right = $(window).width() - $postForm.width();
|
|
|
|
|
if (offset.top > $(window).height() - $postForm.height())
|
|
|
|
|
offset.top = $(window).height() - $postForm.height();
|
|
|
|
|
$postForm.css('right', offset.right).css('top', offset.top);
|
2013-09-15 03:28:32 +02:00
|
|
|
|
}
|
2013-09-18 06:40:39 +02:00
|
|
|
|
$postForm.draggable({
|
|
|
|
|
handle: 'th .handle',
|
|
|
|
|
containment: 'window',
|
|
|
|
|
distance: 10,
|
|
|
|
|
scroll: false,
|
|
|
|
|
stop: function() {
|
|
|
|
|
var offset = {
|
|
|
|
|
top: $(this).offset().top - $(window).scrollTop(),
|
|
|
|
|
right: $(window).width() - $(this).offset().left - $(this).width(),
|
|
|
|
|
};
|
|
|
|
|
localStorage.quickReplyPosition = JSON.stringify(offset);
|
|
|
|
|
|
|
|
|
|
$postForm.css('right', offset.right).css('top', offset.top).css('left', 'auto');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
$postForm.find('th .handle').css('cursor', 'move');
|
2013-09-15 03:18:46 +02:00
|
|
|
|
}
|
2013-09-18 06:40:39 +02:00
|
|
|
|
|
|
|
|
|
$postForm.find('th .close-btn').click(function() {
|
|
|
|
|
$origPostForm.find('textarea[name="body"]').attr('id', 'body');
|
|
|
|
|
$postForm.remove();
|
2013-09-18 07:00:47 +02:00
|
|
|
|
floating_link();
|
2013-09-18 06:40:39 +02:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Fix bug when table gets too big for form. Shouldn't exist, but crappy CSS etc.
|
|
|
|
|
$postForm.show();
|
|
|
|
|
$postForm.width($postForm.find('table').width());
|
|
|
|
|
$postForm.hide();
|
|
|
|
|
|
|
|
|
|
$(window).trigger('quick-reply');
|
|
|
|
|
|
2013-09-15 03:18:46 +02:00
|
|
|
|
$(window).ready(function() {
|
2013-09-18 06:40:39 +02:00
|
|
|
|
if (settings.get('hide_at_top', true)) {
|
|
|
|
|
$(window).scroll(function() {
|
2015-02-07 03:42:13 +01:00
|
|
|
|
if ($(this).width() <= 400)
|
2013-09-18 06:40:39 +02:00
|
|
|
|
return;
|
|
|
|
|
if ($(this).scrollTop() < $origPostForm.offset().top + $origPostForm.height() - 100)
|
|
|
|
|
$postForm.fadeOut(100);
|
|
|
|
|
else
|
|
|
|
|
$postForm.fadeIn(100);
|
|
|
|
|
}).scroll();
|
|
|
|
|
} else {
|
|
|
|
|
$postForm.show();
|
2013-09-15 03:18:46 +02:00
|
|
|
|
}
|
2013-09-18 06:40:39 +02:00
|
|
|
|
|
|
|
|
|
$(window).on('stylesheet', function() {
|
|
|
|
|
do_css();
|
|
|
|
|
if ($('link#stylesheet').attr('href')) {
|
|
|
|
|
$('link#stylesheet')[0].onload = do_css;
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-09-15 03:18:46 +02:00
|
|
|
|
});
|
2013-09-18 06:40:39 +02:00
|
|
|
|
};
|
2013-09-15 19:20:11 +02:00
|
|
|
|
|
2013-09-18 06:40:39 +02:00
|
|
|
|
$(window).on('cite', function(e, id, with_link) {
|
2015-02-07 03:42:13 +01:00
|
|
|
|
if ($(this).width() <= 400)
|
2013-09-18 06:40:39 +02:00
|
|
|
|
return;
|
|
|
|
|
show_quick_reply();
|
|
|
|
|
if (with_link) {
|
2013-09-19 06:42:54 +02:00
|
|
|
|
$(document).ready(function() {
|
2013-09-18 06:40:39 +02:00
|
|
|
|
if ($('#' + id).length) {
|
|
|
|
|
highlightReply(id);
|
2013-09-19 06:42:54 +02:00
|
|
|
|
$(document).scrollTop($('#' + id).offset().top);
|
2013-09-18 06:40:39 +02:00
|
|
|
|
}
|
2013-09-19 06:42:54 +02:00
|
|
|
|
|
|
|
|
|
// Honestly, I'm not sure why we need setTimeout() here, but it seems to work.
|
|
|
|
|
// Same for the "tmp" variable stuff you see inside here:
|
|
|
|
|
setTimeout(function() {
|
2013-09-21 13:47:44 +02:00
|
|
|
|
var tmp = $('#quick-reply textarea[name="body"]').val();
|
|
|
|
|
$('#quick-reply textarea[name="body"]').val('').focus().val(tmp);
|
2013-09-19 06:42:54 +02:00
|
|
|
|
}, 1);
|
2013-09-18 06:40:39 +02:00
|
|
|
|
});
|
|
|
|
|
}
|
2013-09-15 19:20:11 +02:00
|
|
|
|
});
|
2013-09-16 00:11:54 +02:00
|
|
|
|
|
2013-09-18 07:00:47 +02:00
|
|
|
|
var floating_link = function() {
|
2013-12-27 15:46:59 +01:00
|
|
|
|
if (!settings.get('floating_link', false))
|
2013-09-18 07:00:47 +02:00
|
|
|
|
return;
|
2013-12-25 16:22:13 +01:00
|
|
|
|
$('<a href="javascript:void(0)" class="quick-reply-btn">'+_('Quick Reply')+'</a>')
|
2013-09-18 07:00:47 +02:00
|
|
|
|
.click(function() {
|
|
|
|
|
show_quick_reply();
|
|
|
|
|
$(this).remove();
|
2013-12-23 00:12:04 +01:00
|
|
|
|
}).appendTo($('body'));
|
2013-09-18 07:00:47 +02:00
|
|
|
|
|
|
|
|
|
$(window).on('quick-reply', function() {
|
|
|
|
|
$('.quick-reply-btn').remove();
|
|
|
|
|
});
|
|
|
|
|
};
|
2013-09-16 00:11:54 +02:00
|
|
|
|
|
2013-12-27 15:46:59 +01:00
|
|
|
|
if (settings.get('floating_link', false)) {
|
2013-09-15 03:18:46 +02:00
|
|
|
|
$(window).ready(function() {
|
2013-09-18 07:05:45 +02:00
|
|
|
|
if($('div.banner').length == 0)
|
|
|
|
|
return;
|
2013-09-18 07:00:47 +02:00
|
|
|
|
$('<style type="text/css">\
|
|
|
|
|
a.quick-reply-btn {\
|
|
|
|
|
position: fixed;\
|
|
|
|
|
right: 0;\
|
2013-12-23 00:12:04 +01:00
|
|
|
|
bottom: 0;\
|
2013-09-18 07:00:47 +02:00
|
|
|
|
display: block;\
|
|
|
|
|
padding: 5px 13px;\
|
|
|
|
|
text-decoration: none;\
|
|
|
|
|
}\
|
|
|
|
|
</style>').appendTo($('head'));
|
|
|
|
|
|
|
|
|
|
floating_link();
|
|
|
|
|
|
|
|
|
|
if (settings.get('hide_at_top', true)) {
|
|
|
|
|
$('.quick-reply-btn').hide();
|
|
|
|
|
|
|
|
|
|
$(window).scroll(function() {
|
2015-02-07 03:42:13 +01:00
|
|
|
|
if ($(this).width() <= 400)
|
2013-09-18 07:00:47 +02:00
|
|
|
|
return;
|
|
|
|
|
if ($(this).scrollTop() < $('form[name="post"]:first').offset().top + $('form[name="post"]:first').height() - 100)
|
|
|
|
|
$('.quick-reply-btn').fadeOut(100);
|
|
|
|
|
else
|
|
|
|
|
$('.quick-reply-btn').fadeIn(100);
|
|
|
|
|
}).scroll();
|
2013-09-15 03:18:46 +02:00
|
|
|
|
}
|
|
|
|
|
});
|
2013-09-14 23:31:05 +02:00
|
|
|
|
}
|
2013-09-18 06:40:39 +02:00
|
|
|
|
})();
|