summaryrefslogtreecommitdiffstats
path: root/modules-available/js_stupidtable
diff options
context:
space:
mode:
authorUdo Walter2016-11-29 16:24:47 +0100
committerUdo Walter2016-11-29 16:24:47 +0100
commita250d56e61eeddf34fb8542babe1889de3475400 (patch)
tree6ea8207007a151561566570a6eb94c2dcbaee62e /modules-available/js_stupidtable
parentnew ui (diff)
downloadslx-admin-a250d56e61eeddf34fb8542babe1889de3475400.tar.gz
slx-admin-a250d56e61eeddf34fb8542babe1889de3475400.tar.xz
slx-admin-a250d56e61eeddf34fb8542babe1889de3475400.zip
added javascript table sorting plugin (stupidtable)
Diffstat (limited to 'modules-available/js_stupidtable')
-rw-r--r--modules-available/js_stupidtable/clientscript.js30
-rw-r--r--modules-available/js_stupidtable/config.json1
2 files changed, 31 insertions, 0 deletions
diff --git a/modules-available/js_stupidtable/clientscript.js b/modules-available/js_stupidtable/clientscript.js
new file mode 100644
index 00000000..bfbc9112
--- /dev/null
+++ b/modules-available/js_stupidtable/clientscript.js
@@ -0,0 +1,30 @@
+/*
+ Stupid jQuery table plugin.
+
+ https://github.com/joequery/Stupid-Table-Plugin
+
+ Copyright (c) 2012 Joseph McCullough
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+ */
+
+(function(c){c.fn.stupidtable=function(b){return this.each(function(){var a=c(this);b=b||{};b=c.extend({},c.fn.stupidtable.default_sort_fns,b);a.data("sortFns",b);a.on("click.stupidtable","thead th",function(){c(this).stupidsort()})})};c.fn.stupidsort=function(b){var a=c(this),g=0,f=c.fn.stupidtable.dir,e=a.closest("table"),k=a.data("sort")||null;if(null!==k){a.parents("tr").find("th").slice(0,c(this).index()).each(function(){var a=c(this).attr("colspan")||1;g+=parseInt(a,10)});var d;1==arguments.length?
+ d=b:(d=b||a.data("sort-default")||f.ASC,a.data("sort-dir")&&(d=a.data("sort-dir")===f.ASC?f.DESC:f.ASC));if(a.data("sort-dir")!==d)return a.data("sort-dir",d),e.trigger("beforetablesort",{column:g,direction:d}),e.css("display"),setTimeout(function(){var b=[],l=e.data("sortFns")[k],h=e.children("tbody").children("tr");h.each(function(a,d){var e=c(d).children().eq(g),f=e.data("sort-value");"undefined"===typeof f&&(f=e.text(),e.data("sort-value",f));b.push([f,d])});b.sort(function(a,b){return l(a[0],
+ b[0])});d!=f.ASC&&b.reverse();h=c.map(b,function(a){return a[1]});e.children("tbody").append(h);e.find("th").data("sort-dir",null).removeClass("sorting-desc sorting-asc");a.data("sort-dir",d).addClass("sorting-"+d);e.trigger("aftertablesort",{column:g,direction:d});e.css("display")},10),a}};c.fn.updateSortVal=function(b){var a=c(this);a.is("[data-sort-value]")&&a.attr("data-sort-value",b);a.data("sort-value",b);return a};c.fn.stupidtable.dir={ASC:"asc",DESC:"desc"};c.fn.stupidtable.default_sort_fns=
+ {"int":function(b,a){return parseInt(b,10)-parseInt(a,10)},"float":function(b,a){return parseFloat(b)-parseFloat(a)},string:function(b,a){return b.toString().localeCompare(a.toString())},"string-ins":function(b,a){b=b.toString().toLocaleLowerCase();a=a.toString().toLocaleLowerCase();return b.localeCompare(a)}}})(jQuery);
diff --git a/modules-available/js_stupidtable/config.json b/modules-available/js_stupidtable/config.json
new file mode 100644
index 00000000..9e26dfee
--- /dev/null
+++ b/modules-available/js_stupidtable/config.json
@@ -0,0 +1 @@
+{} \ No newline at end of file