Browse Source

js/settings.js: Simple config stuff for javascript extensions

pull/40/head
Michael Foster 11 years ago
parent
commit
d13f30b39f
  1. 4
      js/ajax.js
  2. 26
      js/quick-reply.js
  3. 1
      post.php
  4. 11
      templates/main.js

4
js/ajax.js

@ -12,6 +12,7 @@
*/
$(window).ready(function() {
var settings = new script_settings('ajax');
var do_not_ajax = false;
var setup_form = function($form) {
@ -61,7 +62,8 @@ $(window).ready(function() {
$(form).find('input[type="submit"]').removeAttr('disabled');
}
} 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;
} else {
$.ajax({

26
js/quick-reply.js

@ -12,7 +12,10 @@
*
*/
var do_css = function() {
(function() {
var settings = new script_settings('quick-reply');
var do_css = function() {
$('#quick-reply-css').remove();
// Find background of reply posts
@ -116,9 +119,9 @@ var do_css = function() {
}\
}\
</style>').appendTo($('head'));
};
};
var show_quick_reply = function(){
var show_quick_reply = function(){
if($('div.banner').length == 0)
return;
if($('#quick-reply').length != 0)
@ -333,6 +336,7 @@ var show_quick_reply = function(){
$(window).trigger('quick-reply');
$(window).ready(function() {
if (settings.get('hide_at_top', true)) {
$(window).scroll(function() {
if ($(this).width() <= 800)
return;
@ -340,16 +344,21 @@ var show_quick_reply = function(){
$postForm.fadeOut(100);
else
$postForm.fadeIn(100);
}).on('stylesheet', function() {
}).scroll();
} else {
$postForm.show();
}
$(window).on('stylesheet', function() {
do_css();
if ($('link#stylesheet').attr('href')) {
$('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)
return;
show_quick_reply();
@ -362,4 +371,5 @@ $(window).on('cite', function(e, id, with_link) {
}
});
}
});
});
})();

1
post.php

@ -759,6 +759,7 @@ if (isset($_POST['delete'])) {
header('Content-Type: text/json; charset=utf-8');
echo json_encode(array(
'redirect' => $redirect,
'noko' => $config['always_noko'] || $noko,
'id' => $id
));
}

11
templates/main.js

@ -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() {
init_stylechooser();

Loading…
Cancel
Save