فهرست منبع

- Make sure that resulsts tables are always sortable.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1359 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 14 سال پیش
والد
کامیت
f8a7be667a
3فایلهای تغییر یافته به همراه22 افزوده شده و 17 حذف شده
  1. 0 17
      application/displayblock.class.inc.php
  2. 3 0
      application/itopwebpage.class.inc.php
  3. 19 0
      js/utils.js

+ 0 - 17
application/displayblock.class.inc.php

@@ -270,23 +270,6 @@ class DisplayBlock
 				 $("#'.$sId.'").empty();
 				 $("#'.$sId.'").append(data);
 				 $("#'.$sId.'").removeClass("loading");
-				 // Check each "listResults" table for a checkbox in the first column and make the first column sortable only if it does not contain a checkbox in the header
-				 $("#'.$sId.'.listResults").each( function()
-					{
-						var table = $(this);
-						var id = $(this).parent();
-						var checkbox = (table.find(\'th:first :checkbox\').length > 0);
-						if (checkbox)
-						{
-							// There is a checkbox in the first column, do not make it sortable
-							table.tablesorter( { headers: { 0: {sorter: false}}, widgets: [\'myZebra\', \'truncatedList\']} ); // sortable and zebra tables
-						}
-						else
-						{
-							// There is NO checkbox in the first column, all columns are considered sortable
-							table.tablesorter( { widgets: [\'myZebra\', \'truncatedList\']} ); // sortable and zebra tables
-						}
-					});	
 				}
 			 );
 			 </script>';

+ 3 - 0
application/itopwebpage.class.inc.php

@@ -504,6 +504,9 @@ EOF
 	// Since the event is only triggered when the hash changes, we need to trigger
 	// the event now, to handle the hash the page may have loaded with.
 	$(window).trigger( 'hashchange' );
+	
+	// Some table are sort-able, some are not, let's fix this
+	$('table.listResults').each( function() { FixTableSorter($(this)); } );
 
 EOF
 );

+ 19 - 0
js/utils.js

@@ -271,4 +271,23 @@ function PropagateCheckBox(bCurrValue, aFieldsList, bCheck)
 			ToogleField(bCheck, aFieldsList[i]);
 		}
 	}
+}
+
+function FixTableSorter(table)
+{
+	if ($('th.header', table).length == 0)
+	{
+		// Table is not sort-able, let's fix it
+		var checkbox = (table.find('th:first :checkbox').length > 0);
+		if (checkbox)
+		{
+			// There is a checkbox in the first column, don't make it sort-able
+			table.tablesorter( { headers: { 0: {sorter: false}}, widgets: ['myZebra', 'truncatedList']} ); // sort-able and zebra tables
+		}
+		else
+		{
+			// There is NO checkbox in the first column, all columns are considered sort-able
+			table.tablesorter( { widgets: ['myZebra', 'truncatedList']} ); // sort-able and zebra tables
+		}
+	}
 }