- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
/**
* Create table sorting
**/
var sotr=function(el,by){
var trs=dialog.find('#file_list').find('tr')
,reverse=false;
if(el.attr('reverse')=='true'){
el.removeAttr('reverse');
reverse=true;
}else{
el.attr('reverse','true')
}
trs=trs.sort(function(a,b){
a=$(a);
b=$(b);
var i=0;
switch(by){
case 'by-name':
var txt1=$(a.find('td')[0]).text();
var txt2=$(b.find('td')[0]).text();
if ((txt1 < txt2)){
return reverse?1:-1;
}else if ((txt1 > txt2)&&!reverse){
return reverse?-1:1;
}else{
return 0;
}
break;
case 'by-link':
if(reverse)
return $(a.find('td')[1]).text().length-$(b.find('td')[1]).text().length
else
return $(b.find('td')[1]).text().length-$(a.find('td')[1]).text().length
break;
case 'by-date':
var aDate=new Date(parseInt($(a.find('td')[2]).attr('data-date'))*1000)
,bDate=new Date(parseInt($(b.find('td')[2]).attr('data-date'))*1000);
return (aDate>bDate)&&(reverse)?-1:1;
break;
}
});
dialog.find('#file_list').find('tr').remove();
trs.bind('click',function(e){
trClickListener.call(this,e);
});
trs.bind('dblclick',function(e){
trDBClickListener.call(this,e);
});
trs.appendTo(dialog.find('#file_list')).show(100);
}