Revision 36dacb92 snf-astakos-app/astakos/im/static/im/js/common.js

b/snf-astakos-app/astakos/im/static/im/js/common.js
84 84
}
85 85
//end of fix
86 86

  
87
 
87
function tableSort(tableEl, iDisplayLength, bFilter) {
88

  
89
  // bFilter is an optional parameter
90
  // if bFilter is provided, search input will be visible
91
  bFilter = typeof bFilter !== 'undefined' ? bFilter : true;
92

  
93
  // iDisplayLength is an optional parameter
94
  // iDisplayLength controls the max number of rows visible to each page
95
  iDisplayLength = typeof iDisplayLength !== 'undefined' ? iDisplayLength : 10;
96

  
97
  // return if table holds no data
98
  if (tableEl.find('tbody').find('tr').length <2 ){
99
    return;
100
  }
101

  
102
  var dateArr = [];
103
  var numHTMLArr = [];
104

  
105
  _.each(tableEl.find('th'),function(value, key, list){
106
    if ( $(value).attr('class').indexOf("date")> -1 ) {
107
      dateArr.push(key);
108
    }
109
    if ( $(value).attr('class').indexOf("members_count")> -1) {
110
      numHTMLArr.push(key);
111
    };
112

  
113
  });
114

  
115
  // control pagination & table sorting for projects intro page
116
  tableEl.dataTable({
117
    "bFilter": bFilter,
118
    "iDisplayLength": iDisplayLength,
119
    "bLengthChange": false,
120
    "aoColumnDefs": [
121
         { "sType": "num-html", "aTargets": numHTMLArr },
122
         { "sType": "date-uk", "aTargets": dateArr },
123
    ]
124
  });
125
  $('.dataTables_wrapper').addClass('clearfix');
126

  
127
}
128

  
88 129
$(document).ready(function() {
89 130
	
90 131
    var is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
......
444 485
    $('.renew-token a.do').show();
445 486
  })
446 487

  
447
  // control pagination for projects intro page
448
  $('.search-projects').parents('.projects').find('table#projects-list').dataTable({
449
    "iDisplayLength": 20,
450
  });
451

  
452
  $('.search-projects').parents('.projects').find('#projects-list_filter').hide();
453
  // control pagination for projects intro page
454
  $('.projects-intro').parents('.projects').siblings('table#projects-list').dataTable({
455
    "iDisplayLength": 10,
456
  });
488
  tableSort($('.projects-intro').siblings('table#projects-list'), 10, true );
489
  tableSort($('.search-projects').siblings('table#projects-list'), 20, false);
490
  tableSort($('#members-table'), 10, true);
457 491

  
458 492
});
459 493

  
......
461 495
$(window).resize(function() {
462 496
    
463 497
   setContainerMinHeight('.container .wrapper');
464
    
465 498

  
466 499
});

Also available in: Unified diff