diff options
| author | Michael Foster <savetheinternet@tinyboard.org> | 2013-09-18 15:00:47 +1000 |
|---|---|---|
| committer | Michael Foster <savetheinternet@tinyboard.org> | 2013-09-18 15:00:47 +1000 |
| commit | 79874afbd0a2e5e5edaf8ab0094efadd2e4e4a2e (patch) | |
| tree | 13e8cb0f9219d4bb6e2b9054df1b336215af5b93 /js | |
| parent | d13f30b39f93f694241239c86c08c306c7b94fd4 (diff) | |
forgot to commit js/settings.js. and new quick reply setting
Diffstat (limited to 'js')
| -rw-r--r-- | js/quick-reply.js | 45 | ||||
| -rw-r--r-- | js/settings.js | 40 |
2 files changed, 85 insertions, 0 deletions
diff --git a/js/quick-reply.js b/js/quick-reply.js index a3cf1404..1934c4c7 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -326,6 +326,7 @@ $postForm.find('th .close-btn').click(function() { $origPostForm.find('textarea[name="body"]').attr('id', 'body'); $postForm.remove(); + floating_link(); }); // Fix bug when table gets too big for form. Shouldn't exist, but crappy CSS etc. @@ -372,4 +373,48 @@ }); } }); + + 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() { + $('<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(); + } + }); + } })(); diff --git a/js/settings.js b/js/settings.js new file mode 100644 index 00000000..e98b35ae --- /dev/null +++ b/js/settings.js @@ -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 +}; |
