summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorfisharebest <fisharebest@gmail.com>2011-11-16 09:20:15 +0000
committerfisharebest <fisharebest@gmail.com>2011-11-16 09:20:15 +0000
commitba1eb054586a2911581cf1c70156e2e82fcac042 (patch)
treeecc9bf4c36f9760b1a466f6897e0f0349e55bf70 /includes
parenta60f545fac11fdfa6166430f1a22a12bd833995a (diff)
downloadwebtrees-ba1eb054586a2911581cf1c70156e2e82fcac042.tar.gz
webtrees-ba1eb054586a2911581cf1c70156e2e82fcac042.tar.bz2
webtrees-ba1eb054586a2911581cf1c70156e2e82fcac042.zip
Surname table: needs a more intelligent sort
Diffstat (limited to 'includes')
-rw-r--r--includes/functions/functions_print_lists.php27
1 files changed, 10 insertions, 17 deletions
diff --git a/includes/functions/functions_print_lists.php b/includes/functions/functions_print_lists.php
index fc2de68ed1..5bfd9364ab 100644
--- a/includes/functions/functions_print_lists.php
+++ b/includes/functions/functions_print_lists.php
@@ -1197,6 +1197,8 @@ function format_surname_table($surnames, $script) {
$controller
->addExternalJavaScript(WT_STATIC_URL.'js/jquery/jquery.dataTables.min.js')
->addInlineJavaScript('
+ jQuery.fn.dataTableExt.oSort["num-asc" ]=function(a,b) {a=parseFloat(a); b=parseFloat(b); return (a<b) ? -1 : (a>b ? 1 : 0);};
+ jQuery.fn.dataTableExt.oSort["num-desc"]=function(a,b) {a=parseFloat(a); b=parseFloat(b); return (a>b) ? -1 : (a<b ? 1 : 0);};
jQuery(".surname-list").dataTable( {
"sDom": \'t\',
"bJQueryUI": true,
@@ -1204,9 +1206,10 @@ function format_surname_table($surnames, $script) {
"bPaginate": false,
"aaSorting": [],
"aoColumns": [
- /* 0 name */ {},
- /* 1 count */ {"iDataSort": 2, "sClass": "center"},
- /* 2 SORT */ {"bVisible": false}
+ /* 0 name */ {iDataSort:1},
+ /* 1 NAME */ {bVisible:false, sType:"num"},
+ /* 2 count */ {iDataSort:3, sClass:"center"},
+ /* 3 COUNT */ {bVisible:false}
],
});
jQuery(".surname-list").css("visibility", "visible");
@@ -1222,6 +1225,7 @@ function format_surname_table($surnames, $script) {
$thead=
'<tr>'.
'<th>'.WT_Gedcom_Tag::getLabel('SURN').'</th>'.
+ '<th>&nbsp;</th>'.
'<th>'.$col_heading.'</th>'.
'<th>&nbsp;</th>'.
'</tr>';
@@ -1229,6 +1233,7 @@ function format_surname_table($surnames, $script) {
$tbody='';
$unique_surn=array();
$unique_indi=array();
+ $n=0; // We have already sorted the data - use this as a surrogate sort key
foreach ($surnames as $surn=>$surns) {
// Each surname links back to the indi/fam surname list
if ($surn) {
@@ -1260,6 +1265,8 @@ function format_surname_table($surnames, $script) {
}
}
$tbody.='</td>';
+ // Sort column for name
+ $tbody.='<td>'.$n++.'<?td>';
// Surname count
$tbody.='<td>';
if (count($surns)==1) {
@@ -1282,25 +1289,11 @@ function format_surname_table($surnames, $script) {
$tbody.='<td>'. $subtotal. '</td></tr>';
}
-
-
-
-// $tfoot=
-// '<tr>'.
-// '<td class="list_item">&nbsp;</td>'.
-// '<td class="list_label name2">'.
-// /* I18N: A count of individuals */ WT_I18N::translate('Total individuals: %s', WT_I18N::number(count($unique_indi))).
-// '<br/>'.
-// /* I18N: A count of surnames */ WT_I18N::translate('Total surnames: %s', WT_I18N::number(count($unique_surn))).
-// '</td>'.
-// '</tr>';
-
return
'<div class="loading-image">&nbsp;</div>'.
'<table class="surname-list">'.
'<thead>'.$thead.'</thead>'.
'<tbody>'.$tbody.'</tbody>'.
-// '<tfoot>'.$tfoot.'</tfoot>'.
'</table>';
}