diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-10-10 21:40:51 -0400 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-10-10 21:40:51 -0400 |
commit | b2632dec099cb2727933149d2d59cc5e46baa15f (patch) | |
tree | 0339b98dcd6a38bf9a02e3681d4e22a024ceaa9f /public/ng/js/gogs.js | |
parent | 54930c001df8316d8dfda450b5c39379df2cc1b1 (diff) |
Page: Compare 2 commits
Diffstat (limited to 'public/ng/js/gogs.js')
-rw-r--r-- | public/ng/js/gogs.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/public/ng/js/gogs.js b/public/ng/js/gogs.js index 4bcdc5c8..538e6c67 100644 --- a/public/ng/js/gogs.js +++ b/public/ng/js/gogs.js @@ -299,6 +299,9 @@ function initCore() { e.preventDefault(); $.magnificPopup.close(); }); + + // Collapse. + $('.collapse').hide(); } function initUserSetting() { @@ -698,6 +701,37 @@ function initProfile() { }); } +function initTimeSwitch() { + // Time switch. + $(".time-since[title]").on("click", function () { + var $this = $(this); + + var title = $this.attr("title"); + var text = $this.text(); + + $this.text(title); + $this.attr("title", text); + }); +} + +function initDiff() { + $('.diff-detail-box>a').click(function () { + $($(this).data('target')).slideToggle(100); + }) + + var $counter = $('.diff-counter'); + if ($counter.length < 1) { + return; + } + $counter.each(function (i, item) { + var $item = $(item); + var addLine = $item.find('span[data-line].add').data("line"); + var delLine = $item.find('span[data-line].del').data("line"); + var addPercent = parseFloat(addLine) / (parseFloat(addLine) + parseFloat(delLine)) * 100; + $item.find(".bar .add").css("width", addPercent + "%"); + }); +} + $(document).ready(function () { Gogs.AppSubUrl = $('head').data('suburl') || ''; initCore(); @@ -737,6 +771,10 @@ $(document).ready(function () { if ($('#user-profile-page').length) { initProfile(); } + if ($('#diff-page').length) { + initTimeSwitch(); + initDiff(); + } $('#dashboard-sidebar-menu').tabs(); $('#pull-issue-preview').markdown_preview(".issue-add-comment"); |