Added jQuery plugin tablesorter and data attrs

This commit is contained in:
Daniel Saunders 2019-03-14 23:37:36 -04:00
parent b2040b1bfc
commit 9cfd6daba0
6 changed files with 48 additions and 22 deletions

View File

@ -995,7 +995,8 @@
// Additional Javascript files to include on board index and thread pages. See js/ for available scripts. // Additional Javascript files to include on board index and thread pages. See js/ for available scripts.
$config['additional_javascript'][] = 'js/jquery.min.js'; $config['additional_javascript'][] = 'js/jquery.min.js';
$config['additional_javascript'][] = 'js/jquery-migrate-3.0.0.min.js'; $config['additional_javascript'][] = 'js/jquery-migrate-3.0.0.min.js';
$config['additional_javascript'][] = 'js/jquery.tablesorter.min.js';
$config['additional_javascript'][] = 'js/inline-expanding.js'; $config['additional_javascript'][] = 'js/inline-expanding.js';
// $config['additional_javascript'][] = 'js/local-time.js'; // $config['additional_javascript'][] = 'js/local-time.js';
@ -1011,7 +1012,7 @@
// $config['additional_javascript'][] = 'js/style-select.js'; // $config['additional_javascript'][] = 'js/style-select.js';
// Where these script files are located on the web. Defaults to $config['root']. // Where these script files are located on the web. Defaults to $config['root'].
// $config['additional_javascript_url'] = 'http://static.example.org/tinyboard-javascript-stuff/'; // $config['url_additional_javascript'] = 'http://static.example.org/tinyboard-javascript-stuff/';
// Compile all additional scripts into one file ($config['file_script']) instead of including them seperately. // Compile all additional scripts into one file ($config['file_script']) instead of including them seperately.
$config['additional_javascript_compile'] = false; $config['additional_javascript_compile'] = false;

View File

@ -233,8 +233,8 @@ function loadConfig() {
$config['url_stylesheet'] = $config['uri_stylesheets'] . 'style.css'; $config['url_stylesheet'] = $config['uri_stylesheets'] . 'style.css';
if (!isset($config['url_javascript'])) if (!isset($config['url_javascript']))
$config['url_javascript'] = $config['root'] . $config['file_script']; $config['url_javascript'] = $config['root'] . $config['file_script'];
if (!isset($config['additional_javascript_url'])) if (!isset($config['url_additional_javascript']))
$config['additional_javascript_url'] = $config['root']; $config['url_additional_javascript'] = $config['root'];
if (!isset($config['uri_flags'])) if (!isset($config['uri_flags']))
$config['uri_flags'] = $config['root'] . 'static/flags/%s.png'; $config['uri_flags'] = $config['root'] . 'static/flags/%s.png';
if (!isset($config['user_flag'])) if (!isset($config['user_flag']))

1
js/jquery.tablesorter.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -13,7 +13,7 @@
{% if not nojavascript %} {% if not nojavascript %}
<script src="{{ config.url_javascript }}"></script> <script src="{{ config.url_javascript }}"></script>
{% if not config.additional_javascript_compile %} {% if not config.additional_javascript_compile %}
{% for javascript in config.additional_javascript %}<script src="{{ config.additional_javascript_url }}{{ javascript }}"></script>{% endfor %} {% for javascript in config.additional_javascript %}<script src="{{ config.url_additional_javascript }}{{ javascript }}"></script>{% endfor %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if config.recaptcha %}<script src="//www.google.com/recaptcha/api.js"></script> {% if config.recaptcha %}<script src="//www.google.com/recaptcha/api.js"></script>

View File

@ -39,30 +39,29 @@
{{ config.board_abbreviation|sprintf(ban.board) }} {{ config.board_abbreviation|sprintf(ban.board) }}
{% else %} {% else %}
<em>{% trans 'all boards' %}</em> <em>{% trans 'all boards' %}</em>
{% endif %} {% endif %}
</td> </td>
<td style="white-space: nowrap"> <td style="white-space: nowrap" data-sort-value="{{ ban.created }}">
<span title="{{ ban.created|date(config.post_date) }}"> <span title="{{ ban.created|date(config.post_date) }}">
{{ ban.created|ago }} ago {{ ban.created|ago }} ago
</span> </span>
</td> </td>
<td style="white-space: nowrap"> {% if ban.expires == 0 %}
{% if ban.expires == 0 %} <td style="white-space: nowrap">-</td>
- <td style="white-space: nowrap">
{% else %}
{{ (ban.expires - ban.created + time()) | until }}
{% endif %}
</td>
<td style="white-space: nowrap">
{% if ban.expires == 0 %}
<em>{% trans 'never' %}</em> <em>{% trans 'never' %}</em>
{% else %} </td>
{% else %}
<td style="white-space: nowrap" data-sort-value="{{ ban.expires - ban.created + time() }}">
{{ (ban.expires - ban.created + time())|until }}
</td>
<td style="white-space: nowrap" data-sort-value="{{ ban.expires }}">
{{ ban.expires|date(config.post_date) }} {{ ban.expires|date(config.post_date) }}
{% if ban.expires > time() %} {% if ban.expires > time() %}
<small>(in {{ ban.expires|until }})</small> <small>(in {{ ban.expires|until }})</small>
{% endif %} {% endif %}
{% endif %} </td>
</td> {% endif %}
<td> <td>
{% if ban.seen %} {% if ban.seen %}
{% trans 'Yes' %} {% trans 'Yes' %}
@ -91,13 +90,25 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<script>
if (typeof $ !== 'undefined' && $.tablesorter)
$('table.mod').tablesorter({
textExtraction: (node) => {
let attr = $(node).data('sort-value');
if (typeof attr !== 'undefined' && attr !== false)
return attr;
return $(node).text();
}
});
</script>
<p style="text-align:center"> <p style="text-align:center">
<input type="submit" name="unban" value="{% trans 'Unban selected' %}"> <input type="submit" name="unban" value="{% trans 'Unban selected' %}">
</p> </p>
</form> </form>
{% endif %} {% endif %}
{% if count > bans|length %} {% if count > bans|length %}
<p class="unimportant" style="text-align:center;word-wrap:break-word"> <p class="unimportant" style="text-align:center;word-wrap:break-word">
{% for i in range(0, (count - 1) / config.mod.modlog_page) %} {% for i in range(0, (count - 1) / config.mod.modlog_page) %}

View File

@ -35,7 +35,7 @@
<em>hidden</em> <em>hidden</em>
{% endif %} {% endif %}
</td> </td>
<td class="minimal"> <td class="minimal" data-sort-value="{{ log.time }}">
<span title="{{ log.time|date(config.post_date) }}">{{ log.time|ago }}</span> <span title="{{ log.time|date(config.post_date) }}">{{ log.time|ago }}</span>
</td> </td>
<td class="minimal"> <td class="minimal">
@ -52,6 +52,19 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<script>
if (typeof $ !== 'undefined' && $.tablesorter)
$('table.mod').tablesorter({
textExtraction: (node) => {
let attr = $(node).data('sort-value');
if (typeof attr !== 'undefined' && attr !== false)
return attr;
return $(node).text();
}
});
</script>
{% if count > logs|length %} {% if count > logs|length %}
<p class="unimportant" style="text-align:center;word-wrap:break-word"> <p class="unimportant" style="text-align:center;word-wrap:break-word">