Merge branch 'master' of https://github.com/savetheinternet/Tinyboard into vichan-devel-4.5
Conflicts: js/quick-reply.js
This commit is contained in:
commit
99a2e1cf3d
|
@ -253,7 +253,7 @@ class Bans {
|
||||||
modLog('Created a new ' .
|
modLog('Created a new ' .
|
||||||
($length > 0 ? preg_replace('/^(\d+) (\w+?)s?$/', '$1-$2', until($length)) : 'permanent') .
|
($length > 0 ? preg_replace('/^(\d+) (\w+?)s?$/', '$1-$2', until($length)) : 'permanent') .
|
||||||
' ban on ' .
|
' ban on ' .
|
||||||
($board ? '/' . $board . '/' : 'all boards') .
|
($ban_board ? '/' . $ban_board . '/' : 'all boards') .
|
||||||
' for ' .
|
' for ' .
|
||||||
(filter_var($mask, FILTER_VALIDATE_IP) !== false ? "<a href=\"?/IP/$mask\">$mask</a>" : $mask) .
|
(filter_var($mask, FILTER_VALIDATE_IP) !== false ? "<a href=\"?/IP/$mask\">$mask</a>" : $mask) .
|
||||||
' (<small>#' . $pdo->lastInsertId() . '</small>)' .
|
' (<small>#' . $pdo->lastInsertId() . '</small>)' .
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$(window).ready(function() {
|
$(window).ready(function() {
|
||||||
|
var settings = new script_settings('ajax');
|
||||||
var do_not_ajax = false;
|
var do_not_ajax = false;
|
||||||
|
|
||||||
var setup_form = function($form) {
|
var setup_form = function($form) {
|
||||||
|
@ -68,7 +69,8 @@ $(window).ready(function() {
|
||||||
$(form).find('input[type="submit"]').removeAttr('disabled');
|
$(form).find('input[type="submit"]').removeAttr('disabled');
|
||||||
}
|
}
|
||||||
} else if (post_response.redirect && post_response.id) {
|
} else if (post_response.redirect && post_response.id) {
|
||||||
if (!$(form).find('input[name="thread"]').length) {
|
if (!$(form).find('input[name="thread"]').length
|
||||||
|
|| (!settings.get('always_noko_replies', true) && !post_response.noko)) {
|
||||||
document.location = post_response.redirect;
|
document.location = post_response.redirect;
|
||||||
} else {
|
} else {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
|
@ -12,7 +12,10 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var do_css = function() {
|
(function() {
|
||||||
|
var settings = new script_settings('quick-reply');
|
||||||
|
|
||||||
|
var do_css = function() {
|
||||||
$('#quick-reply-css').remove();
|
$('#quick-reply-css').remove();
|
||||||
|
|
||||||
// Find background of reply posts
|
// Find background of reply posts
|
||||||
|
@ -116,9 +119,9 @@ var do_css = function() {
|
||||||
}\
|
}\
|
||||||
}\
|
}\
|
||||||
</style>').appendTo($('head'));
|
</style>').appendTo($('head'));
|
||||||
};
|
};
|
||||||
|
|
||||||
var show_quick_reply = function(){
|
var show_quick_reply = function(){
|
||||||
if($('div.banner').length == 0)
|
if($('div.banner').length == 0)
|
||||||
return;
|
return;
|
||||||
if($('#quick-reply').length != 0)
|
if($('#quick-reply').length != 0)
|
||||||
|
@ -302,7 +305,7 @@ var show_quick_reply = function(){
|
||||||
if (localStorage.quickReplyPosition) {
|
if (localStorage.quickReplyPosition) {
|
||||||
var offset = JSON.parse(localStorage.quickReplyPosition);
|
var offset = JSON.parse(localStorage.quickReplyPosition);
|
||||||
if (offset.top < 0)
|
if (offset.top < 0)
|
||||||
offset.top = 10;
|
offset.top = 0;
|
||||||
if (offset.right > $(window).width() - $postForm.width())
|
if (offset.right > $(window).width() - $postForm.width())
|
||||||
offset.right = $(window).width() - $postForm.width();
|
offset.right = $(window).width() - $postForm.width();
|
||||||
if (offset.top > $(window).height() - $postForm.height())
|
if (offset.top > $(window).height() - $postForm.height())
|
||||||
|
@ -330,6 +333,7 @@ var show_quick_reply = function(){
|
||||||
$postForm.find('th .close-btn').click(function() {
|
$postForm.find('th .close-btn').click(function() {
|
||||||
$origPostForm.find('textarea[name="body"]').attr('id', 'body');
|
$origPostForm.find('textarea[name="body"]').attr('id', 'body');
|
||||||
$postForm.remove();
|
$postForm.remove();
|
||||||
|
floating_link();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fix bug when table gets too big for form. Shouldn't exist, but crappy CSS etc.
|
// Fix bug when table gets too big for form. Shouldn't exist, but crappy CSS etc.
|
||||||
|
@ -340,6 +344,7 @@ var show_quick_reply = function(){
|
||||||
$(window).trigger('quick-reply');
|
$(window).trigger('quick-reply');
|
||||||
|
|
||||||
$(window).ready(function() {
|
$(window).ready(function() {
|
||||||
|
if (settings.get('hide_at_top', true)) {
|
||||||
$(window).scroll(function() {
|
$(window).scroll(function() {
|
||||||
if ($(this).width() <= 800)
|
if ($(this).width() <= 800)
|
||||||
return;
|
return;
|
||||||
|
@ -347,16 +352,21 @@ var show_quick_reply = function(){
|
||||||
$postForm.fadeOut(100);
|
$postForm.fadeOut(100);
|
||||||
else
|
else
|
||||||
$postForm.fadeIn(100);
|
$postForm.fadeIn(100);
|
||||||
}).on('stylesheet', function() {
|
}).scroll();
|
||||||
|
} else {
|
||||||
|
$postForm.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
$(window).on('stylesheet', function() {
|
||||||
do_css();
|
do_css();
|
||||||
if ($('link#stylesheet').attr('href')) {
|
if ($('link#stylesheet').attr('href')) {
|
||||||
$('link#stylesheet')[0].onload = do_css;
|
$('link#stylesheet')[0].onload = do_css;
|
||||||
}
|
}
|
||||||
}).scroll();
|
|
||||||
});
|
});
|
||||||
};
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$(window).on('cite', function(e, id, with_link) {
|
$(window).on('cite', function(e, id, with_link) {
|
||||||
if ($(this).width() <= 800)
|
if ($(this).width() <= 800)
|
||||||
return;
|
return;
|
||||||
show_quick_reply();
|
show_quick_reply();
|
||||||
|
@ -369,4 +379,51 @@ $(window).on('cite', function(e, id, with_link) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var floating_link = function() {
|
||||||
|
if (!settings.get('floating_link', false))
|
||||||
|
return;
|
||||||
|
$('<a href="javascript:void(0)" class="quick-reply-btn">Quick Reply</a>')
|
||||||
|
.click(function() {
|
||||||
|
show_quick_reply();
|
||||||
|
$(this).remove();
|
||||||
|
}).prependTo($('body'));
|
||||||
|
|
||||||
|
$(window).on('quick-reply', function() {
|
||||||
|
$('.quick-reply-btn').remove();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (settings.get('floating_link', false)) {
|
||||||
|
$(window).ready(function() {
|
||||||
|
if($('div.banner').length == 0)
|
||||||
|
return;
|
||||||
|
$('<style type="text/css">\
|
||||||
|
a.quick-reply-btn {\
|
||||||
|
position: fixed;\
|
||||||
|
right: 0;\
|
||||||
|
top: 0;\
|
||||||
|
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() {
|
||||||
|
if ($(this).width() <= 800)
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* settings.js
|
||||||
|
* https://github.com/savetheinternet/Tinyboard/blob/master/js/settings.js
|
||||||
|
*
|
||||||
|
* Optional settings. Used to customize some scripts without needing to tweak their code.
|
||||||
|
* Notes:
|
||||||
|
* - You must include this script first.
|
||||||
|
* - This file is just an example.
|
||||||
|
* - You should copy settings.js to something like instance.settings.js to prevent conflicts when upgrading.
|
||||||
|
* - This file should always be optional.
|
||||||
|
*
|
||||||
|
* Released under the MIT license
|
||||||
|
* Copyright (c) 2013 Michael Save <savetheinternet@tinyboard.org>
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* $config['additional_javascript'][] = 'js/jquery.min.js';
|
||||||
|
* $config['additional_javascript'][] = 'js/instance.settings.js';
|
||||||
|
* // $config['additional_javascript'][] = 'js/quick-reply.js';
|
||||||
|
*
|
||||||
|
* Usage in scripts:
|
||||||
|
* var settings = new script_settings('my-script');
|
||||||
|
* var some_value = settings.get('option', 'default value');
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
var tb_settings = {};
|
||||||
|
|
||||||
|
// quick-reply.js
|
||||||
|
tb_settings['quick-reply'] = {
|
||||||
|
// Hide form when scrolled to top of page (where original form is visible)
|
||||||
|
hide_at_top: true,
|
||||||
|
// "Quick reply" button floating at the top right hand corner of the page at all times
|
||||||
|
floating_link: true
|
||||||
|
};
|
||||||
|
|
||||||
|
// ajax.js
|
||||||
|
tb_settings['ajax'] = {
|
||||||
|
// Always act as if "noko" was typed when posting replies with the ajax script
|
||||||
|
always_noko_replies: false
|
||||||
|
};
|
1
post.php
1
post.php
|
@ -775,6 +775,7 @@ if (isset($_POST['delete'])) {
|
||||||
header('Content-Type: text/json; charset=utf-8');
|
header('Content-Type: text/json; charset=utf-8');
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'redirect' => $redirect,
|
'redirect' => $redirect,
|
||||||
|
'noko' => $config['always_noko'] || $noko,
|
||||||
'id' => $id
|
'id' => $id
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,6 +249,17 @@ function rememberStuff() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var script_settings = function(script_name) {
|
||||||
|
this.script_name = script_name;
|
||||||
|
this.get = function(var_name, default_val) {
|
||||||
|
if (typeof tb_settings == 'undefined' ||
|
||||||
|
typeof tb_settings[this.script_name] == 'undefined' ||
|
||||||
|
typeof tb_settings[this.script_name][var_name] == 'undefined')
|
||||||
|
return default_val;
|
||||||
|
return tb_settings[this.script_name][var_name];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
init_stylechooser();
|
init_stylechooser();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue