Skip to content

The Unified and Autonomous Development Platform

midwork

robin shine17336f084d61
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobsearch/result/search-result.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobsearch/result/search-result.js
new file mode 100644
index 0000000000..ec02d45248
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobsearch/result/search-result.js
@@ -0,0 +1,31 @@
+gitplex.searchresult = {
+ confirmSwitchFileByLink: function(linkId) {
+ var linkURI = new URI(document.getElementById(linkId));
+ var currentURI = new URI(window.location.href);
+ if (linkURI.search(true).path != currentURI.search(true).path)
+ return pmease.commons.form.confirmLeave();
+ else
+ return true;
+ },
+ confirmSwitchFileByPath: function(path) {
+ var currentURI = new URI(window.location.href);
+ if (path != currentURI.search(true).path)
+ return pmease.commons.form.confirmLeave();
+ else
+ return true;
+ },
+ scrollIfNecessary: function(containerId) {
+ var margin = 25;
+ var $body = $("#" + containerId + ">.search-result>.body");
+
+ var $active = $body.find("a.selectable.active");
+ var contentTop = $body.offset().top;
+ var activeTop = $active.offset().top;
+ if (activeTop-margin<contentTop)
+ $body.scrollTop($body.scrollTop()-(contentTop-activeTop+margin));
+ var contentBottom = contentTop + $body.height();
+ var activeBottom = activeTop + $active.height();
+ if (activeBottom+margin>contentBottom)
+ $body.scrollTop($body.scrollTop()+(activeBottom+margin-contentBottom));
+ }
+}