Merge pull request #2102 from wairbut-m2c/iagirre-admin-poll-stats

Iagirre admin poll stats
This commit is contained in:
María Checa
2017-11-29 20:07:53 +01:00
committed by GitHub
10 changed files with 245 additions and 1 deletions

View File

@@ -73,6 +73,7 @@
//= require map
//= require polls
//= require sortable
//= require table_sortable
var initialize_modules = function() {
App.Comments.initialize();
@@ -113,6 +114,7 @@ var initialize_modules = function() {
App.Map.initialize();
App.Polls.initialize();
App.Sortable.initialize();
App.TableSortable.initialize();
};
$(function(){

View File

@@ -0,0 +1,23 @@
App.TableSortable =
getCellValue: (row, index) ->
$(row).children('td').eq(index).text()
comparer: (index) ->
(a, b) ->
valA = App.TableSortable.getCellValue(a, index)
valB = App.TableSortable.getCellValue(b, index)
return if $.isNumeric(valA) and $.isNumeric(valB) then valA - valB else valA.localeCompare(valB)
initialize: ->
$('table.sortable th').click ->
table = $(this).parents('table').eq(0)
rows = table.find('tr:gt(0)').not('tfoot tr').toArray().sort(App.TableSortable.comparer($(this).index()))
@asc = !@asc
if !@asc
rows = rows.reverse()
i = 0
while i < rows.length
table.append rows[i]
i++
return