Skip to content

The Unified and Autonomous Development Platform

Auto hide top headers when scrolling page.

robin shine0b8d3ff9ec2b
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobview/blob-view.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobview/blob-view.js
index aba1220286..50279ee7f8 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobview/blob-view.js
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobview/blob-view.js
@@ -1,11 +1,16 @@
gitplex.blobView = function(containerId) {
var $blobView = $("#" + containerId + ">.blob-view");
+ var $head = $blobView.find(">.head");
+ var $body = $blobView.find(">.body");
+
+ gitplex.spaceGreedy.getScrollTop = function() {
+ return $body.scrollTop();
+ };
+
$blobView.on("autofit", function(event, width, height) {
event.stopPropagation();
$blobView.outerWidth(width);
$blobView.outerHeight(height);
- var $head = $blobView.find(">.head");
- var $body = $blobView.find(">.body");
height = $blobView.height()-$head.outerHeight();
$body.outerWidth(width).outerHeight(height);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobview/source/source-view.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobview/source/source-view.js
index 61a84a9310..1222dd1dd7 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobview/source/source-view.js
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobview/source/source-view.js
@@ -25,6 +25,13 @@ gitplex.sourceview = {
});
}
+ gitplex.spaceGreedy.getScrollTop = function() {
+ if (cm)
+ return cm.getScrollInfo().top;
+ else
+ return 0;
+ };
+
$sourceView.on("autofit", function(event, width, height) {
event.stopPropagation();
$sourceView.outerWidth(width);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/file-list.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/file-list.js
index d31a88e1d7..38b655381f 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/file-list.js
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/file-list.js
@@ -1,12 +1,18 @@
gitplex.filelist = {
init: function(containerId) {
var $container = $("#" + containerId);
- var $fileList = $container.children();
+ var $fileList = $container.find(">.file-list");
+ var $body = $fileList.find(">.body");
+
+ gitplex.spaceGreedy.getScrollTop = function() {
+ return $body.scrollTop();
+ };
+
$fileList.on("autofit", function(event, width, height) {
event.stopPropagation();
- var $head = $fileList.find(">.head");
- var $body = $fileList.find(">.body");
- $body.outerWidth(width).outerHeight(height-$head.outerHeight());
+ $fileList.outerWidth(width);
+ $fileList.outerHeight(height);
+ $body.outerWidth($fileList.width()).outerHeight($fileList.height()-$fileList.find(">.head").outerHeight());
});
},
renderLastCommits: function(containerId, lastCommits) {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/base/base.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/base/base.js
index 44ebd36dda..e9ace3efa3 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/base/base.js
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/base/base.js
@@ -131,15 +131,56 @@ var gitplex = {
$("#comment-diffline-" + index).closest("tr").remove();
$("#diffline-" + index).find("a.add-comment").show();
}
- }
+ },
+ spaceGreedy: {
+ mouseDown: false,
+ check: function() {
+ var $topHideable = $(".top.hideable");
+ if (gitplex.spaceGreedy.getScrollTop && !gitplex.spaceGreedy.mouseDown && !$topHideable.is(":animated")) {
+ if ($topHideable.is(":visible")) {
+ var height = 0;
+ $(".hideable").each(function() {
+ height += $(this).outerHeight();
+ });
+ if (gitplex.spaceGreedy.getScrollTop()>height+10) {
+ var completed = 0;
+ $topHideable.slideUp(200, function() {
+ completed++;
+ if (completed == $topHideable.length) {
+ $(".bottom.hideable").hide();
+ $(window).resize();
+ }
+ });
+ }
+ } else if (gitplex.spaceGreedy.getScrollTop() < 5) {
+ var completed = 0;
+ $topHideable.slideDown(200, function() {
+ completed++;
+ if (completed == $topHideable.length) {
+ $(".bottom.hideable").show();
+ $(window).resize();
+ }
+ });
+ }
+ }
+ setTimeout(gitplex.spaceGreedy.check, 100);
+ }
+ }
};
$(document).ready(function() {
- $('#globalheader a').tooltip({placement: 'bottom'});
- $('#main .has-tip').tooltip();
-
$(window).on("beforeunload", function() {
$(":focus").trigger("blur");
});
+
+ $(window).load(function() {
+ document.onmousedown = function() {
+ gitplex.spaceGreedy.mouseDown = true;
+ };
+ document.onmouseup = function() {
+ gitplex.spaceGreedy.mouseDown = false;
+ };
+ gitplex.spaceGreedy.check();
+ });
});
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/LayoutPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/LayoutPage.html
index e424c07afd..a5c457a671 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/LayoutPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/LayoutPage.html
@@ -1,6 +1,6 @@
<wicket:extend>
<div id="main" class="container-fluid">
- <div wicket:id="mainHead" class="head row">
+ <div wicket:id="mainHead" class="head row top hideable">
<div class="logo col-xs-1">
<a wicket:id="home"><i class="fa fa-ext fa-gitplex-logo"></i></a>
</div>
@@ -32,7 +32,7 @@
<div class="body">
<wicket:child></wicket:child>
</div>
- <div class="foot clearfix">
+ <div class="foot clearfix bottom hideable">
<div class="pull-left">
<a href="http://www.pmease.com">PMEase GitPlex</a>, 1.0.0, 2013-03-05, Commercial License for Site 'PMEase Inc.'
</div>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/RepositoryPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/RepositoryPage.html
index 84b3111591..74ececd534 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/RepositoryPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/RepositoryPage.html
@@ -1,6 +1,6 @@
<wicket:extend>
<div id="repository">
- <div class="head clearfix">
+ <div class="head clearfix top hideable">
<div class="pull-left nav">
<i class="fa fa-ext fa-repo"></i>
<span wicket:id="accountAndRepo">
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/repo-file.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/repo-file.js
index 70ce0bac51..e1a06a99da 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/repo-file.js
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/repo-file.js
@@ -24,7 +24,9 @@ $(window).load(function() {
e.stopPropagation();
var $fileViewer = $("#repo-file>.file-viewer");
var width = $(window).width()-$("#repo-file").parent().prev().outerWidth();
- var height = $(window).height()-$fileViewer.offset().top-$("#main>.foot").outerHeight();
+ var height = $(window).height()-$fileViewer.offset().top;
+ if ($("#main>.foot").is(":visible"))
+ height -= $("#main>.foot").outerHeight();
if ($searchResult.is(":visible")) {
height -= $searchResult.outerHeight();
$searchResult.find(">div>.body").outerHeight($searchResult.height()