Browse Source

HUE-120. Anchor tags within frames don't work

Alex Newman 15 years ago
parent
commit
3c72745019

+ 4 - 1
apps/help/src/help/static/css/dv.css

@@ -58,4 +58,7 @@ div.ccs-help .left_col a:hover {
 	text-decoration: none;
 }
 
-
+div.ccs-help .right_col a[name] {
+  position: relative;
+  left: -10px;
+}

+ 54 - 0
desktop/core/static/js/Source/BehaviorFilters/Behavior.SplitViewScroller.js

@@ -0,0 +1,54 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+/*
+---
+description: Enables smooth scrolling for in-page anchors in SplitView.
+provides: [Behavior.SplitViewScroller]
+requires: [Widgets/Behavior.SplitView]
+script: Behavior.SplitViewScroller.js
+...
+*/
+
+Behavior.addGlobalPlugin('SplitView', 'SplitViewScroller', function(element, methods) {
+	var splitview = element.retrieve('SplitView');
+	var el = $(splitview);
+	var sides = splitview.getSides();
+	var tabAnchorScroller = function(e, link){
+		var name = link.get('href').split('#')[1];
+		var anchor = el.getElement('[name=' + name + ']');
+		if (!anchor) {
+			dbug.warn('warning, link name "%s" found no corresponding anchor', name);
+			return;
+		}
+		var scrollSide;
+		for (sideName in sides) {
+			if (sides[sideName].hasChild(anchor)) scrollSide = sides[sideName];
+		}
+		if (scrollSide){
+			var scroller = scrollSide.retrieve('_scroller');
+			if (!scroller) {
+				scroller = new Fx.Scroll(scrollSide);
+				scrollSide.store('_scroller', scroller);
+			}
+			scroller.toElement(anchor);
+			e.stop();
+		}
+	};
+	el.addEvent('click:relay([href*=#])', tabAnchorScroller);
+	this.markForCleanup(element, function(){
+		el.removeEvent('click:relay([href*=#]', tabEnchorScroller);
+	});
+});

+ 1 - 0
desktop/core/static/js/Source/CCS/CCS.JFrame.js

@@ -48,6 +48,7 @@ requires:
  - /Behavior.SideBySideSelect
  - /Behavior.SizeTo
  - /Behavior.SplitViewPostFold
+ - /Behavior.SplitViewScroller
  - /Behavior.SubmitOnChange
  - /Behavior.Tabs
  - /Behavior.Tips

+ 1 - 0
desktop/core/static/js/package.yml

@@ -62,6 +62,7 @@ sources: [
   Source/BehaviorFilters/Behavior.SideBySideSelect.js,
   Source/BehaviorFilters/Behavior.SizeTo.js,
   Source/BehaviorFilters/Behavior.SplitViewPostFold.js,
+  Source/BehaviorFilters/Behavior.SplitViewScroller.js,
   Source/BehaviorFilters/Behavior.SubmitOnChange.js,
   Source/BehaviorFilters/Behavior.Tabs.js,
   Source/BehaviorFilters/Behavior.Tips.js,