Explorar o código

New implementation for displaying long lists: pagination

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1309 a333f486-631f-4898-b8df-5754b55c2be0
dflaven %!s(int64=14) %!d(string=hai) anos
pai
achega
15e920d102
Modificáronse 4 ficheiros con 23 adicións e 21 borrados
  1. 11 2
      js/extkeywidget.js
  2. 11 1
      js/jquery.tablesorter.pager.js
  3. 1 0
      js/linkswidget.js
  4. 0 18
      js/utils.js

+ 11 - 2
js/extkeywidget.js

@@ -38,7 +38,7 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper
 	{
 		if (me.ajax_request)
 		{
-			me.ajax_request.Abort();
+			me.ajax_request.abort();
 			me.ajax_request = null;
 		}
 	}
@@ -183,7 +183,16 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper
 	
 	this.DoOk = function()
 	{
-		var iObjectId = $('#fr_'+me.id+' input[name=selectObject]:checked').val();
+		var s = $('#'+me.id+'_results').find(':input[name^=storedSelection]');
+		var iObjectId = 0;
+		if (s.length > 0)
+		{
+			iObjectId = s.val();
+		}
+		else
+		{
+			iObjectId = $('#fr_'+me.id+' input[name=selectObject]:checked').val();
+		}
 		$('#ac_dlg_'+this.id).dialog('close');
 		$('#label_'+this.id).addClass('ac_dlg_loading');
 

+ 11 - 1
js/jquery.tablesorter.pager.js

@@ -147,6 +147,12 @@ function sprintf(format, etc) {
 			
 			function getData(table, start, end)
 			{
+				if (table.ajax_request)
+				{
+					table.ajax_request.abort();
+					table.ajax_request = null;
+				}
+
 				var c = table.config;
 				var s = c.sortList[0];
 				var s_col = null;
@@ -157,7 +163,7 @@ function sprintf(format, etc) {
 					s_order = (s[1] == 0) ? 'asc' : 'desc';
 				}
 				$('#loading', table.config.container).html('<img src="../images/indicator.gif" />');
-				$.post("../pages/ajax.render.php",
+				table.ajax_request = $.post("../pages/ajax.render.php",
 						{ operation: 'pagination',
 						  filter: c.filter,
 						  extra_param: c.extra_params,
@@ -171,6 +177,7 @@ function sprintf(format, etc) {
 						},
 					    function(data)
 					    {
+							table.ajax_request = null; // Ajax request completed
 							oData = $(data);
 							var tableBody = $(table.tBodies[0]);
 							
@@ -251,6 +258,7 @@ function sprintf(format, etc) {
 							updatePageDisplay(c);
 							updateCounter(table, table.config.container);
 							renderPager(table, table.config.container);
+							$(table).tableHover();
 							$('#loading', table.config.container).empty();
 					   });
 			}
@@ -353,6 +361,8 @@ function sprintf(format, etc) {
 					
 					var table = this, pager = config.container;
 				
+					this.ajax_request = null;
+					
 					$(this).trigger("appendCache");
 					
 					config.size = parseInt($(".pagesize",pager).val());

+ 1 - 0
js/linkswidget.js

@@ -70,6 +70,7 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates)
 					   bDuplicates: me.bDuplicates
 					 }
 		
+		me.UpdateButtons(0);
 		// Gather the parameters from the search form
 		$('#SearchFormToAdd_'+me.id+' :input').each(
 			function(i)

+ 0 - 18
js/utils.js

@@ -82,24 +82,6 @@ function ReloadBlock(divId, sStyle, sSerializedFilter, sExtraParams)
 		 $('#'+divId).empty();
 		 $('#'+divId).append(data);
 		 $('#'+divId).removeClass('loading');
-		 $('#'+divId+' .listResults').tableHover(); // hover tables
-		 $('#'+divId+' .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, don't 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
-					}
-				});
-		 //$('#'+divId).unblockUI();
 		}
 	 );
 }