Przeglądaj źródła

HUE-212. Add ability to load a link without scrolling to the top after it loads.

Aaron Newton 15 lat temu
rodzic
commit
872cf40d00

+ 44 - 0
apps/jframegallery/src/jframegallery/templates/Load_without_scrolling.html

@@ -0,0 +1,44 @@
+{% comment %}
+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.
+{% endcomment %}
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<html>
+	<head>
+		<title>Load Without Scrolling</title>
+	</head>
+	<body>
+		<div class="jframe_padded">
+			<p>Scroll down to the link below. When you click it, you'll be taken back to the JFrame gallery, but the window will not scroll back to the top.</p>
+			<br/>
+			<br/>
+			<br/>
+			<br/>
+			<br/>
+			<br/>
+			<br/>
+			<br/>
+			<br/>
+			<br/>
+			<br/>
+			<br/>
+			<br/>
+			<br/>
+			<br/>
+			<a href="/jframegallery/">back to jframe gallery (without scrolling to the top)</a>
+		</div>
+	</body>
+</html>

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

@@ -279,6 +279,7 @@ CCS.JFrame = new Class({
 		this.fireEvent('refresh');
 		this.load(
 			$merge(options, {
+				noScroll: true,
 				requestPath: this.currentPath
 			})
 		);

+ 34 - 0
desktop/core/static/js/Source/JFrameLinkers/CCS.JFrame.NoScroll.js

@@ -0,0 +1,34 @@
+
+// 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: Provides functionality for links that prevent the window from scrolling to the top after they are loaded.
+provides: [CCS.JFrame.NoScroll]
+requires: [/CCS.JFrame]
+script: CCS.JFrame.NoScroll.js
+...
+*/
+CCS.JFrame.addGlobalLinkers({
+
+	'.noScroll': function(event, link){
+		link.removeClass('noScroll');
+		this.callClick(event, link, false, {
+			noScroll: true
+		});
+	}
+
+});

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

@@ -39,6 +39,7 @@ sources: [
   Source/JFrameLinkers/CCS.JFrame.ConfirmAndPost.js,
   Source/JFrameLinkers/CCS.JFrame.FakeRefresh.js,
   Source/JFrameLinkers/CCS.JFrame.Nav.js,
+  Source/JFrameLinkers/CCS.JFrame.NoScroll.js,
   Source/JFrameLinkers/CCS.JFrame.PromptAndPost.js,
   Source/JFrameLinkers/CCS.JFrame.Refresh.js,
   Source/JFrameLinkers/CCS.JFrame.SubmitLink.js,