Browse Source

Ugly fix for a nasty change in jQuery UI behavior: UI tabs were considered as "Ajax" tabs when the page has a "base" tag, which was not the case in previous versions. Cf http://bugs.jqueryui.com/ticket/8637

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2813 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 12 năm trước cách đây
mục cha
commit
4686df9d4b
2 tập tin đã thay đổi với 23 bổ sung1 xóa
  1. 12 1
      application/ajaxwebpage.class.inc.php
  2. 11 0
      application/itopwebpage.class.inc.php

+ 12 - 1
application/ajaxwebpage.class.inc.php

@@ -124,7 +124,18 @@ class ajax_page extends WebPage
 <<<EOF
 			// The "tab widgets" to handle.
 			var tabs = $('div[id^=tabbedContent]');
-
+			  
+			// Ugly patch for a change in the behavior of jQuery UI:
+			// Before jQuery UI 1.9, tabs were always considered as "local" (opposed to Ajax)
+			// when their href was beginning by #. Starting with 1.9, a <base> tag in the page
+			// is taken into account and causes "local" tabs to be considered as Ajax
+			// unless their URL is equal to the URL of the page...
+			$('div[id^=tabbedContent] ul li a').each(function() {
+				var sHash = location.hash;
+				var sCleanLocation = location.href.toString().replace(sHash, '').replace(/#$/, '');
+	    		$(this).attr("href", sCleanLocation+$(this).attr("href"));
+			});
+			
 			if ($.bbq)
 			{
 				// This selector will be reused when selecting actual tab widget A elements.

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

@@ -162,6 +162,17 @@ class iTopWebPage extends NiceWebPage
 		// This selector will be reused when selecting actual tab widget A elements.
 		var tab_a_selector = 'ul.ui-tabs-nav a';
 		  
+		// Ugly patch for a change in the behavior of jQuery UI:
+		// Before jQuery UI 1.9, tabs were always considered as "local" (opposed to Ajax)
+		// when their href was beginning by #. Starting with 1.9, a <base> tag in the page
+		// is taken into account and causes "local" tabs to be considered as Ajax
+		// unless their URL is equal to the URL of the page...
+		$('div[id^=tabbedContent] ul li a').each(function() {
+			var sHash = location.hash;
+			var sCleanLocation = location.href.toString().replace(sHash, '').replace(/#$/, '');
+	    	$(this).attr("href", sCleanLocation+$(this).attr("href"));
+		});
+
 		// 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