diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index b96165695..e6d035128 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1619,7 +1619,7 @@ module ApplicationHelper
# Returns the javascript tags that are included in the html layout head
def javascript_heads
- tags = javascript_include_tag('jquery-2.2.4-ui-1.11.0-ujs-5.2.3', 'tribute-3.7.3.min', 'application', 'responsive')
+ tags = javascript_include_tag('jquery-2.2.4-ui-1.11.0-ujs-5.2.3', 'tribute-3.7.3.min', 'tablesort-5.1.0.min', 'application', 'responsive')
unless User.current.pref.warn_on_leaving_unsaved == '0'
tags << "\n".html_safe + javascript_tag("$(window).on('load', function(){ warnLeavingUnsaved('#{escape_javascript l(:text_warn_on_leaving_unsaved)}'); });")
end
diff --git a/app/views/journals/update.js.erb b/app/views/journals/update.js.erb
index 47dfdebec..3d6be8d94 100644
--- a/app/views/journals/update.js.erb
+++ b/app/views/journals/update.js.erb
@@ -7,6 +7,7 @@
$("#journal-<%= @journal.id %>-notes").replaceWith('<%= escape_javascript(render_notes(@journal.issue, @journal, :reply_links => authorize_for('issues', 'edit'))) %>');
$("#journal-<%= @journal.id %>-notes").show();
$("#journal-<%= @journal.id %>-form").remove();
+ setupWikiTableSortableHeader();
<% end %>
<%= call_hook(:view_journals_update_js_bottom, { :journal => @journal }) %>
diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb
index 42819c1fb..61d9eddae 100644
--- a/app/views/layouts/base.html.erb
+++ b/app/views/layouts/base.html.erb
@@ -9,7 +9,7 @@
<%= csrf_meta_tag %>
<%= favicon %>
-<%= stylesheet_link_tag 'jquery/jquery-ui-1.11.0', 'tribute-3.7.3', 'application', 'responsive', :media => 'all' %>
+<%= stylesheet_link_tag 'jquery/jquery-ui-1.11.0', 'tribute-3.7.3', 'tablesort-5.1.0', 'application', 'responsive', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= heads_for_theme %>
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index e4e902d9c..e91b4d92f 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -954,6 +954,7 @@ $(document).ready(function(){
data: "text=" + element + '&' + attachments,
success: function(data){
jstBlock.find('.wiki-preview').html(data);
+ setupWikiTableSortableHeader();
}
});
});
@@ -995,6 +996,17 @@ function setupAttachmentDetail() {
$(window).resize(setFilecontentContainerHeight);
}
+function setupWikiTableSortableHeader() {
+ $('div.wiki table').each(function(i, table){
+ if (table.rows.length < 3) return true;
+ var tr = $(table.rows).first();
+ if (tr.find("TH").length > 0) {
+ tr.attr('data-sort-method', 'none');
+ tr.find("TD").attr('data-sort-method', 'none');
+ new Tablesort(table);
+ }
+ });
+}
$(function () {
$('[title]').tooltip({
@@ -1062,6 +1074,7 @@ $(document).ready(defaultFocus);
$(document).ready(setupAttachmentDetail);
$(document).ready(setupTabs);
$(document).ready(setupFilePreviewNavigation);
+$(document).ready(setupWikiTableSortableHeader);
$(document).on('focus', '[data-auto-complete=true]', function(event) {
inlineAutoComplete(event.target);
});
diff --git a/public/javascripts/tablesort-5.1.0.min.js b/public/javascripts/tablesort-5.1.0.min.js
new file mode 100755
index 000000000..09de2aed5
--- /dev/null
+++ b/public/javascripts/tablesort-5.1.0.min.js
@@ -0,0 +1,6 @@
+/*!
+ * tablesort v5.1.0 (2018-09-14)
+ * http://tristen.ca/tablesort/demo/
+ * Copyright (c) 2018 ; Licensed MIT
+*/
+!function(){function a(b,c){if(!(this instanceof a))return new a(b,c);if(!b||"TABLE"!==b.tagName)throw new Error("Element must be a table");this.init(b,c||{})}var b=[],c=function(a){var b;return window.CustomEvent&&"function"==typeof window.CustomEvent?b=new CustomEvent(a):(b=document.createEvent("CustomEvent"),b.initCustomEvent(a,!1,!1,void 0)),b},d=function(a){return a.getAttribute("data-sort")||a.textContent||a.innerText||""},e=function(a,b){return a=a.trim().toLowerCase(),b=b.trim().toLowerCase(),a===b?0:a0)if(a.tHead&&a.tHead.rows.length>0){for(e=0;e0&&l.push(k),m++;if(!l)return}for(m=0;m