From 42b08ff26158b9c815d13a427c596bd76468beb8 Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Thu, 20 Mar 2014 21:28:12 +0800 Subject: [PATCH 1/2] fix single bare page link --- modules/middleware/repo.go | 1 + public/js/app.js | 46 +++++++++++++++++---------------- templates/repo/nav.tmpl | 2 +- templates/repo/single_bare.tmpl | 4 +-- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index 62c67bcee19..a9a90e3ff57 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -79,5 +79,6 @@ func RepoAssignment(redirect bool) martini.Handler { ctx.Data["CloneLink"] = ctx.Repo.CloneLink ctx.Data["RepositoryLink"] = ctx.Data["Title"] ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner + ctx.Data["IsRepositoryWatching"] = ctx.Repo.IsWatching } } diff --git a/public/js/app.js b/public/js/app.js index 93cfbc1faaf..64cc980fd8e 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -72,18 +72,18 @@ var Gogits = { prettyPrint(); var $lineNums = $pre.parent().siblings('.lines-num'); - if($lineNums.length > 0){ + if ($lineNums.length > 0) { var nums = $pre.find('ol.linenums > li').length; - for(var i=0;i < nums;i++){ - $lineNums.append(''+(i+1)+''); + for (var i = 1; i <= nums; i++) { + $lineNums.append('' + i + ''); } var last; - $(document).on('click', '.lines-num span', function(){ + $(document).on('click', '.lines-num span', function () { var $e = $(this); console.log($e.parent().siblings('.lines-code').find('ol.linenums > ' + $e.attr('rel'))); console.log('ol.linenums > ' + $e.attr('rel')); - if(last){ + if (last) { last.removeClass('active'); } last = $e.parent().siblings('.lines-code').find('ol.linenums > ' + $e.attr('rel')); @@ -98,12 +98,12 @@ var Gogits = { var node = $(this); var val = encodeURIComponent(node.text().toLowerCase().replace(/[^\w\- ]/g, '').replace(/[ ]/g, '-')); var name = val; - if(headers[val] > 0){ + if (headers[val] > 0) { name = val + '-' + headers[val]; } - if(headers[val] == undefined){ + if (headers[val] == undefined) { headers[val] = 1; - }else{ + } else { headers[val] += 1; } node = node.wrap('
'); @@ -183,20 +183,22 @@ function initUserSetting() { } function initRepository() { - var $guide = $('.guide-box'); - if ($guide.length) { - var $url = $('#guide-clone-url'); - $guide.find('button[data-url]').on("click",function () { - var $this = $(this); - if (!$this.hasClass('btn-primary')) { - $guide.find('.btn-primary').removeClass('btn-primary').addClass("btn-default"); - $(this).addClass('btn-primary').removeClass('btn-default'); - $url.val($this.data("url")); - $guide.find('span.clone-url').text($this.data('url')); - } - }).eq(0).trigger("click"); - // todo copy to clipboard - } + (function () { + var $guide = $('.guide-box'); + if ($guide.length) { + var $url = $('#guide-clone-url'); + $guide.find('button[data-url]').on("click",function () { + var $this = $(this); + if (!$this.hasClass('btn-primary')) { + $guide.find('.btn-primary').removeClass('btn-primary').addClass("btn-default"); + $(this).addClass('btn-primary').removeClass('btn-default'); + $url.val($this.data("url")); + $guide.find('span.clone-url').text($this.data('url')); + } + }).eq(0).trigger("click"); + // todo copy to clipboard + } + })(); } (function ($) { diff --git a/templates/repo/nav.tmpl b/templates/repo/nav.tmpl index 92e529dbc7a..e8685b08bc7 100644 --- a/templates/repo/nav.tmpl +++ b/templates/repo/nav.tmpl @@ -13,7 +13,7 @@ -
+
- + + From 4efd73d37a7e76401ef93982db63b4538013ea23 Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Thu, 20 Mar 2014 21:32:08 +0800 Subject: [PATCH 2/2] fix single bare page link --- public/js/app.js | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index a39976006f9..2952083ed83 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -72,16 +72,16 @@ var Gogits = { prettyPrint(); var $lineNums = $pre.parent().siblings('.lines-num'); - if($lineNums.length > 0){ + if ($lineNums.length > 0) { var nums = $pre.find('ol.linenums > li').length; - for(var i=0;i < nums;i++){ - $lineNums.append(''+(i+1)+''); + for (var i = 0; i < nums; i++) { + $lineNums.append('' + (i + 1) + ''); } var last; - $(document).on('click', '.lines-num span', function(){ + $(document).on('click', '.lines-num span', function () { var $e = $(this); - if(last){ + if (last) { last.removeClass('active'); } last = $e.parent().siblings('.lines-code').find('ol.linenums > ' + $e.attr('rel')); @@ -96,12 +96,12 @@ var Gogits = { var node = $(this); var val = encodeURIComponent(node.text().toLowerCase().replace(/[^\w\- ]/g, '').replace(/[ ]/g, '-')); var name = val; - if(headers[val] > 0){ + if (headers[val] > 0) { name = val + '-' + headers[val]; } - if(headers[val] == undefined){ + if (headers[val] == undefined) { headers[val] = 1; - }else{ + } else { headers[val] += 1; } node = node.wrap('
'); @@ -181,20 +181,22 @@ function initUserSetting() { } function initRepository() { - var $guide = $('.guide-box'); - if ($guide.length) { - var $url = $('#guide-clone-url'); - $guide.find('button[data-url]').on("click",function () { - var $this = $(this); - if (!$this.hasClass('btn-primary')) { - $guide.find('.btn-primary').removeClass('btn-primary').addClass("btn-default"); - $(this).addClass('btn-primary').removeClass('btn-default'); - $url.val($this.data("url")); - $guide.find('span.clone-url').text($this.data('url')); - } - }).eq(0).trigger("click"); - // todo copy to clipboard - } + (function () { + var $guide = $('.guide-box'); + if ($guide.length) { + var $url = $('#guide-clone-url'); + $guide.find('button[data-link]').on("click",function () { + var $this = $(this); + if (!$this.hasClass('btn-primary')) { + $guide.find('.btn-primary').removeClass('btn-primary').addClass("btn-default"); + $(this).addClass('btn-primary').removeClass('btn-default'); + $url.val($this.data("link")); + $guide.find('span.clone-url').text($this.data('link')); + } + }).eq(0).trigger("click"); + // todo copy to clipboard + } + })(); } (function ($) {