summaryrefslogtreecommitdiffstats
path: root/public/ng/js/gogs.js
diff options
context:
space:
mode:
authorFernando San Julián <fjsanjulian@hotmail.com>2015-08-03 21:27:15 +0200
committerFernando San Julián <fjsanjulian@hotmail.com>2015-08-03 21:27:15 +0200
commiteebcbf9d3438a9910dee56fd76ab624726eb207c (patch)
treea90a35e9940a936adf224a9e5549a8c6f70f92d1 /public/ng/js/gogs.js
parent6a89eeedf3e2130031ac75b8329037424f936013 (diff)
downloadgitea-eebcbf9d3438a9910dee56fd76ab624726eb207c.tar.gz
gitea-eebcbf9d3438a9910dee56fd76ab624726eb207c.zip
add clipboard API support
Diffstat (limited to 'public/ng/js/gogs.js')
-rw-r--r--public/ng/js/gogs.js68
1 files changed, 48 insertions, 20 deletions
diff --git a/public/ng/js/gogs.js b/public/ng/js/gogs.js
index 7ffef8af8b..38b34c6152 100644
--- a/public/ng/js/gogs.js
+++ b/public/ng/js/gogs.js
@@ -333,25 +333,17 @@ var Gogs = {};
if ($(selector).hasClass('js-copy-bind')) {
return;
}
- $(selector).zclip({
- path: Gogs.AppSubUrl + "/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 () {
+
+ if ( document.documentElement.classList.contains("is-copy-enabled") ) {
+
+ $(selector).click(function(event) {
var $this = $(this);
+
+ var cfrom = $this.attr('data-copy-from');
+ $(cfrom).select();
+ document.execCommand('copy');
+ getSelection().removeAllRanges();
+
$this.tipsy("hide").attr('original-title', $this.data('after-title'));
setTimeout(function () {
$this.tipsy("show");
@@ -359,8 +351,44 @@ var Gogs = {};
setTimeout(function () {
$this.tipsy('hide').attr('original-title', $this.data('original-title'));
}, 2000);
- }
- }).addClass("js-copy-bind");
+
+ this.blur();
+ return;
+ });
+
+ $(selector).addClass("js-copy-bind");
+
+ } else {
+
+ $(selector).zclip({
+ path: Gogs.AppSubUrl + "/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.tipsy("hide").attr('original-title', $this.data('after-title'));
+ setTimeout(function () {
+ $this.tipsy("show");
+ }, 200);
+ setTimeout(function () {
+ $this.tipsy('hide').attr('original-title', $this.data('original-title'));
+ }, 2000);
+ }
+ }).addClass("js-copy-bind");
+ }
}
})(jQuery);