UI: SSH/HTTPS address switch and copy
This commit is contained in:
parent
7e36bf448d
commit
676bd764fa
6 changed files with 87 additions and 14 deletions
|
@ -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
Loading…
Add table
Add a link
Reference in a new issue