Browse Source

js clipboard

pull/61/head
FuXiaoHei 11 years ago
parent
commit
1757a59a99
  1. BIN
      public/js/ZeroClipboard.swf
  2. 45
      public/js/app.js
  3. 13
      public/js/lib.js
  4. 4
      templates/repo/nav.tmpl
  5. 2
      templates/repo/single_bare.tmpl

BIN
public/js/ZeroClipboard.swf

Binary file not shown.

45
public/js/app.js

@ -159,6 +159,7 @@ var Gogits = {
$tabs.tab("show"); $tabs.tab("show");
$tabs.find("li:eq(0) a").tab("show"); $tabs.find("li:eq(0) a").tab("show");
}; };
// fix dropdown inside click // fix dropdown inside click
Gogits.initDropDown = function () { Gogits.initDropDown = function () {
$('.dropdown-menu.no-propagation').on('click', function (e) { $('.dropdown-menu.no-propagation').on('click', function (e) {
@ -166,6 +167,7 @@ var Gogits = {
}); });
}; };
// render markdown // render markdown
Gogits.renderMarkdown = function () { Gogits.renderMarkdown = function () {
var $md = $('.markdown'); var $md = $('.markdown');
@ -192,6 +194,7 @@ var Gogits = {
}); });
}; };
// render code view
Gogits.renderCodeView = function () { Gogits.renderCodeView = function () {
function selectRange($list, $select, $from) { function selectRange($list, $select, $from) {
$list.removeClass('active'); $list.removeClass('active');
@ -255,6 +258,43 @@ var Gogits = {
}).trigger('hashchange'); }).trigger('hashchange');
}; };
// copy utils
Gogits.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 () {
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); })(jQuery);
// ajax utils // ajax utils
@ -343,7 +383,10 @@ function initRepository() {
$clone.find('span.clone-url').text($this.data('link')); $clone.find('span.clone-url').text($this.data('link'));
} }
}).eq(0).trigger("click"); }).eq(0).trigger("click");
// todo copy to clipboard $("#repo-clone").on("shown.bs.dropdown",function () {
Gogits.bindCopy("[data-init=copy]");
});
Gogits.bindCopy("[data-init=copy]:visible");
} }
})(); })();

13
public/js/lib.js

File diff suppressed because one or more lines are too long

4
templates/repo/nav.tmpl

@ -18,9 +18,9 @@
<button class="btn btn-default" data-link="{{.CloneLink.SSH}}" type="button">SSH</button> <button class="btn btn-default" data-link="{{.CloneLink.SSH}}" type="button">SSH</button>
<button class="btn btn-default" data-link="{{.CloneLink.HTTPS}}" type="button">HTTPS</button> <button class="btn btn-default" data-link="{{.CloneLink.HTTPS}}" type="button">HTTPS</button>
</span> </span>
<input type="text" class="form-control clone-group-url" value="" readonly/> <input type="text" class="form-control clone-group-url" value="" readonly id="repo-clone-ipt"/>
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default" type="button"><i class="fa fa-copy" data-toggle="tooltip" title="copy to clipboard" data-placement="top"></i></button> <button class="btn btn-default" type="button" data-toggle="tooltip" title="copy to clipboard" data-placement="top" data-init="copy" data-copy-val="val" data-copy-from="#repo-clone-ipt"><i class="fa fa-copy"></i></button>
</span> </span>
</div> </div>
<p class="help-block text-center">Need help cloning? Visit <a href="#">Help</a>!</p> <p class="help-block text-center">Need help cloning? Visit <a href="#">Help</a>!</p>

2
templates/repo/single_bare.tmpl

@ -17,7 +17,7 @@
</span> </span>
<input type="text" class="form-control clone-group-url" id="guide-clone-url" value="" readonly/> <input type="text" class="form-control clone-group-url" id="guide-clone-url" value="" readonly/>
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default" type="button"><i class="fa fa-copy" data-toggle="tooltip" title="copy to clipboard" data-placement="top"></i></button> <button class="btn btn-default" type="button" data-toggle="tooltip" title="copy to clipboard" data-placement="top" data-init="copy" data-copy-val="val" data-copy-from="#guide-clone-url"><i class="fa fa-copy"></i></button>
</span> </span>
</div> </div>
<p>We recommend every repository include a <strong>README</strong>, <strong>LICENSE</strong>, and <strong>.gitignore</strong>.</p> <p>We recommend every repository include a <strong>README</strong>, <strong>LICENSE</strong>, and <strong>.gitignore</strong>.</p>

Loading…
Cancel
Save