UI: SSH/HTTPS address switch and copy
This commit is contained in:
parent
7e36bf448d
commit
676bd764fa
|
@ -185,6 +185,7 @@ migrate_type = Migration Type
|
|||
migrate_type_helper = This repository will be a <span class="label label-blue label-radius">Mirror</span>
|
||||
migrate_repo = Migrate Repository
|
||||
|
||||
copy_link = Copy
|
||||
clone_helper = Need help cloning? Visit <a target="_blank" href="http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository">Help</a>!
|
||||
unwatch = Unwatch
|
||||
watch = Watch
|
||||
|
@ -192,6 +193,11 @@ unstar = Unstar
|
|||
star = Star
|
||||
fork = Fork
|
||||
|
||||
quick_guide = Quick Guide
|
||||
clone_this_repo = Clone this repository
|
||||
create_new_repo_command = Create a new repository on the command line
|
||||
push_exist_repo = Push an existing repository from the command line
|
||||
|
||||
settings = Settings
|
||||
settings.options = Options
|
||||
settings.collaboration = Collaboration
|
||||
|
|
|
@ -185,6 +185,7 @@ migrate_type = 迁移类型
|
|||
migrate_type_helper = 本仓库将是 <span class="label label-blue label-radius">镜像</span>
|
||||
migrate_repo = 迁移仓库
|
||||
|
||||
copy_link = 复制链接
|
||||
clone_helper = 不知道如何操作?访问 <a target="_blank" href="http://git-scm.com/book/zh/Git-基础-取得项目的-Git-仓库">此处</a> 查看帮助!
|
||||
unwatch = 取消关注
|
||||
watch = 关注
|
||||
|
@ -192,6 +193,11 @@ unstar = 取消点赞
|
|||
star = 点赞
|
||||
fork = 派生
|
||||
|
||||
quick_guide = 快速帮助
|
||||
clone_this_repo = 克隆当前仓库
|
||||
create_new_repo_command = 从命令行创建一个新的仓库
|
||||
push_exist_repo = 从命令行推送已经创建的仓库
|
||||
|
||||
settings = 仓库设置
|
||||
settings.options = 基本设置
|
||||
settings.collaboration = 管理协作者
|
||||
|
|
|
@ -238,6 +238,44 @@ var Gogs = {};
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Copy util.
|
||||
Gogs.bindCopy = function (selector) {
|
||||
if ($(selector).hasClass('js-copy-bind')) {
|
||||
return;
|
||||
}
|
||||
$(selector).zclip({
|
||||
path: "/js/ZeroClipboard.swf",
|
||||
copy: function () {
|
||||
var t = $(this).data("copy-val");
|
||||
var to = $($(this).data("copy-from"));
|
||||
var str = "";
|
||||
if (t == "txt") {
|
||||
str = to.text();
|
||||
}
|
||||
if (t == 'val') {
|
||||
str = to.val();
|
||||
}
|
||||
if (t == 'html') {
|
||||
str = to.html();
|
||||
}
|
||||
return str;
|
||||
},
|
||||
afterCopy: function () {
|
||||
alert("Clone URL has copied!");
|
||||
// var $this = $(this);
|
||||
// $this.tooltip('hide')
|
||||
// .attr('data-original-title', 'Copied OK');
|
||||
// setTimeout(function () {
|
||||
// $this.tooltip("show");
|
||||
// }, 200);
|
||||
// setTimeout(function () {
|
||||
// $this.tooltip('hide')
|
||||
// .attr('data-original-title', 'Copy to Clipboard');
|
||||
// }, 3000);
|
||||
}
|
||||
}).addClass("js-copy-bind");
|
||||
}
|
||||
})(jQuery);
|
||||
|
||||
function initCore() {
|
||||
|
@ -291,6 +329,26 @@ function initRepoCreate() {
|
|||
console.log('initRepoCreate');
|
||||
}
|
||||
|
||||
function initRepo() {
|
||||
// Clone link switch button.
|
||||
$('#repo-clone-ssh').click(function () {
|
||||
$(this).removeClass('btn-gray').addClass('btn-blue');
|
||||
$('#repo-clone-https').removeClass('btn-blue').addClass('btn-gray');
|
||||
$('#repo-clone-url').val($(this).data('link'));
|
||||
$('.clone-url').text($(this).data('link'))
|
||||
});
|
||||
$('#repo-clone-https').click(function () {
|
||||
$(this).removeClass('btn-gray').addClass('btn-blue');
|
||||
$('#repo-clone-ssh').removeClass('btn-blue').addClass('btn-gray');
|
||||
$('#repo-clone-url').val($(this).data('link'));
|
||||
$('.clone-url').text($(this).data('link'))
|
||||
});
|
||||
// Copy URL.
|
||||
$('#repo-clone-copy').hover(function () {
|
||||
Gogs.bindCopy($(this));
|
||||
})
|
||||
}
|
||||
|
||||
function initRepoSetting() {
|
||||
// Options.
|
||||
// Confirmation of changing repository name.
|
||||
|
@ -481,6 +539,9 @@ $(document).ready(function () {
|
|||
if ($('#repo-create-form').length || $('#repo-migrate-form').length) {
|
||||
initRepoCreate();
|
||||
}
|
||||
if ($('#repo-header').length) {
|
||||
initRepo();
|
||||
}
|
||||
if ($('#repo-setting').length) {
|
||||
initRepoSetting();
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -16,20 +16,20 @@
|
|||
<div id="repo-bare-start" class="panel panel-radius">
|
||||
<div class="panel-header">
|
||||
<a class="btn btn-small btn-black btn-header btn-radius right" href="{{.RepoLink}}/settings">{{.i18n.Tr "repo.settings"}}</a>
|
||||
<strong>Quick Start</strong>
|
||||
<strong>{{.i18n.Tr "repo.quick_guide"}}</strong>
|
||||
</div>
|
||||
<div class="panel-content">
|
||||
<div id="repo-clone" class="clear text-center">
|
||||
<h2>Clone this repository</h2>
|
||||
<button id="repo-clone-ssh" class="btn btn-blue current left btn-left-radius">SSH</button>
|
||||
<button id="repo-clone-https" class="btn btn-gray left">HTTPS</button>
|
||||
<input id="repo-clone-url" type="text" class="ipt ipt-disabled left" value="{{.CloneLink.SSH}}" />
|
||||
<button id="repo-clone-copy" class="btn btn-black left btn-right-radius">Copy</button>
|
||||
<p class="text-center" id="repo-clone-help">Need help cloning? Visit <a href="#">Help</a>!</p>
|
||||
<h2>{{.i18n.Tr "repo.clone_this_repo"}}</h2>
|
||||
<button class="btn btn-blue current left btn-left-radius" id="repo-clone-ssh" data-link="{{.CloneLink.SSH}}">SSH</button>
|
||||
<button class="btn btn-gray left" id="repo-clone-https" data-link="{{.CloneLink.HTTPS}}">HTTPS</button>
|
||||
<input id="repo-clone-url" type="text" class="ipt ipt-disabled left" value="{{.CloneLink.SSH}}" readonly />
|
||||
<button class="btn btn-black left btn-right-radius" id="repo-clone-copy" data-copy-val="val" data-copy-from="#repo-clone-url">{{.i18n.Tr "repo.copy_link"}}</button>
|
||||
<p class="text-center" id="repo-clone-help">{{.i18n.Tr "repo.clone_helper" | Str2html}}</p>
|
||||
<hr/>
|
||||
</div>
|
||||
<div id="repo-bare-cmd" class="text-center">
|
||||
<h2>Create a new repository on the command line</h2>
|
||||
<h2>{{.i18n.Tr "repo.create_new_repo_command"}}</h2>
|
||||
<pre class="text-left radius"><code>touch README.md
|
||||
git init
|
||||
git add README.md
|
||||
|
@ -40,7 +40,7 @@ git push -u origin master</code></pre>
|
|||
<hr/>
|
||||
</div>
|
||||
<div id="repo-bare-remote" class="text-center">
|
||||
<h2>Push an existing repository from the command line</h2>
|
||||
<h2>{{.i18n.Tr "repo.push_exist_repo"}}</h2>
|
||||
<pre class="text-left radius"><code>git remote add origin <span class="clone-url">{{.CloneLink.SSH}}</span>
|
||||
git push -u origin master</code></pre>
|
||||
<br/>
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
</a>
|
||||
<div id="repo-header-download-drop" class="drop-down">
|
||||
<div id="repo-clone" class="clear">
|
||||
<button id="repo-clone-ssh" class="btn btn-blue current left left btn-left-radius">SSH</button>
|
||||
<button id="repo-clone-https" class="btn btn-gray left">HTTPS</button>
|
||||
<input id="repo-clone-url" type="text" class="ipt ipt-disabled left" value="{{.CloneLink.SSH}}" />
|
||||
<button id="repo-clone-copy" class="btn btn-black left btn-right-radius">Copy</button>
|
||||
<button class="btn btn-blue left left btn-left-radius" id="repo-clone-ssh" data-link="{{.CloneLink.SSH}}">SSH</button>
|
||||
<button class="btn btn-gray left" id="repo-clone-https" data-link="{{.CloneLink.HTTPS}}">HTTPS</button>
|
||||
<input id="repo-clone-url" class="ipt ipt-disabled left" value="{{.CloneLink.SSH}}" readonly />
|
||||
<button id="repo-clone-copy" class="btn btn-black left btn-right-radius" data-copy-val="val" data-copy-from="#repo-clone-url">{{.i18n.Tr "repo.copy_link"}}</button>
|
||||
<p class="text-center" id="repo-clone-help">{{.i18n.Tr "repo.clone_helper" | Str2html}}</p>
|
||||
<hr/>
|
||||
<div class="text-center" id="repo-clone-zip">
|
||||
|
|
Loading…
Reference in New Issue