Explorar o código

Support pages that do not track tabs selection in their history

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1770 a333f486-631f-4898-b8df-5754b55c2be0
dflaven %!s(int64=13) %!d(string=hai) anos
pai
achega
51bcb69d45
Modificáronse 1 ficheiros con 30 adicións e 23 borrados
  1. 30 23
      application/ajaxwebpage.class.inc.php

+ 30 - 23
application/ajaxwebpage.class.inc.php

@@ -117,31 +117,38 @@ class ajax_page extends WebPage
 <<<EOF
 			// The "tab widgets" to handle.
 			var tabs = $('div[id^=tabbedContent]');
-			    
-			// This selector will be reused when selecting actual tab widget A elements.
-			var tab_a_selector = 'ul.ui-tabs-nav a';
-			  
-			// Enable tabs on all tab widgets. The `event` property must be overridden so
-			// that the tabs aren't changed on click, and any custom event name can be
-			// specified. Note that if you define a callback for the 'select' event, it
-			// will be executed for the selected tab whenever the hash changes.
-			tabs.tabs({ event: 'change' });
-			  
-			// Define our own click handler for the tabs, overriding the default.
-			tabs.find( tab_a_selector ).click(function()
+
+			if ($.bbq)
 			{
-				var state = {};
-						  
-				// Get the id of this tab widget.
-				var id = $(this).closest( 'div[id^=tabbedContent]' ).attr( 'id' );
+				// This selector will be reused when selecting actual tab widget A elements.
+				var tab_a_selector = 'ul.ui-tabs-nav a';
+				  
+				// Enable tabs on all tab widgets. The `event` property must be overridden so
+				// that the tabs aren't changed on click, and any custom event name can be
+				// specified. Note that if you define a callback for the 'select' event, it
+				// will be executed for the selected tab whenever the hash changes.
+				tabs.tabs({ event: 'change' });
 				  
-				// Get the index of this tab.
-				var idx = $(this).parent().prevAll().length;
-				
-				// Set the state!
-				state[ id ] = idx;
-				$.bbq.pushState( state );
-			});
+				// Define our own click handler for the tabs, overriding the default.
+				tabs.find( tab_a_selector ).click(function()
+				{
+					var state = {};
+							  
+					// Get the id of this tab widget.
+					var id = $(this).closest( 'div[id^=tabbedContent]' ).attr( 'id' );
+					  
+					// Get the index of this tab.
+					var idx = $(this).parent().prevAll().length;
+					
+					// Set the state!
+					state[ id ] = idx;
+					$.bbq.pushState( state );
+				});
+			}
+			else
+			{
+				tabs.tabs();
+			}
 EOF
 );
 		}