mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-03 15:07:12 +02:00
js clipboard
This commit is contained in:
1 parent
db66b8da72
commit
1757a59a99
5 files changed
+60
-4
No files matched your search
Binary file not shown.
+44
-1
@@ -159,6 +159,7 @@ var Gogits = {
|
||||
$tabs.tab("show");
|
||||
$tabs.find("li:eq(0) a").tab("show");
|
||||
};
|
||||
|
||||
// fix dropdown inside click
|
||||
Gogits.initDropDown = function () {
|
||||
$('.dropdown-menu.no-propagation').on('click', function (e) {
|
||||
@@ -166,6 +167,7 @@ var Gogits = {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// render markdown
|
||||
Gogits.renderMarkdown = function () {
|
||||
var $md = $('.markdown');
|
||||
@@ -192,6 +194,7 @@ var Gogits = {
|
||||
});
|
||||
};
|
||||
|
||||
// render code view
|
||||
Gogits.renderCodeView = function () {
|
||||
function selectRange($list, $select, $from) {
|
||||
$list.removeClass('active');
|
||||
@@ -255,6 +258,43 @@ var Gogits = {
|
||||
}).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);
|
||||
|
||||
// ajax utils
|
||||
@@ -343,7 +383,10 @@ function initRepository() {
|
||||
$clone.find('span.clone-url').text($this.data('link'));
|
||||
}
|
||||
}).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");
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
@@ -480,3 +480,16 @@ PR.registerLangHandler(PR.createSimpleLexer([["kwd",/^#[a-z]+/i,null,"#"]],[]),[
|
||||
var a=null;
|
||||
var a=null;
|
||||
PR.registerLangHandler(PR.createSimpleLexer([["pun",/^[:>?|]+/,a,":|>?"],["dec",/^%(?:YAML|TAG)[^\n\r#]+/,a,"%"],["typ",/^&\S+/,a,"&"],["typ",/^!\S*/,a,"!"],["str",/^"(?:[^"\\]|\\.)*(?:"|$)/,a,'"'],["str",/^'(?:[^']|'')*(?:'|$)/,a,"'"],["com",/^#[^\n\r]*/,a,"#"],["pln",/^\s+/,a," \t\r\n"]],[["dec",/^(?:---|\.\.\.)(?:[\n\r]|$)/],["pun",/^-/],["kwd",/^\w+:[\n\r ]/],["pln",/^\w+/]]),["yaml","yml"]);
|
||||
|
||||
/*
|
||||
* zClip :: jQuery ZeroClipboard v1.1.1
|
||||
* http://steamdev.com/zclip
|
||||
*
|
||||
* Copyright 2011, SteamDev
|
||||
* Released under the MIT license.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* Date: Wed Jun 01, 2011
|
||||
*/
|
||||
|
||||
(function(a){a.fn.zclip=function(c){if(typeof c=="object"&&!c.length){var b=a.extend({path:"ZeroClipboard.swf",copy:null,beforeCopy:null,afterCopy:null,clickAfter:true,setHandCursor:true,setCSSEffects:true},c);return this.each(function(){var e=a(this);if(e.is(":visible")&&(typeof b.copy=="string"||a.isFunction(b.copy))){ZeroClipboard.setMoviePath(b.path);var d=new ZeroClipboard.Client();if(a.isFunction(b.copy)){e.bind("zClip_copy",b.copy)}if(a.isFunction(b.beforeCopy)){e.bind("zClip_beforeCopy",b.beforeCopy)}if(a.isFunction(b.afterCopy)){e.bind("zClip_afterCopy",b.afterCopy)}d.setHandCursor(b.setHandCursor);d.setCSSEffects(b.setCSSEffects);d.addEventListener("mouseOver",function(f){e.trigger("mouseenter")});d.addEventListener("mouseOut",function(f){e.trigger("mouseleave")});d.addEventListener("mouseDown",function(f){e.trigger("mousedown");if(!a.isFunction(b.copy)){d.setText(b.copy)}else{d.setText(e.triggerHandler("zClip_copy"))}if(a.isFunction(b.beforeCopy)){e.trigger("zClip_beforeCopy")}});d.addEventListener("complete",function(f,g){if(a.isFunction(b.afterCopy)){e.trigger("zClip_afterCopy")}else{if(g.length>500){g=g.substr(0,500)+"...\n\n("+(g.length-500)+" characters not shown)"}e.removeClass("hover");alert("Copied text to clipboard:\n\n "+g)}if(b.clickAfter){e.trigger("click")}});d.glue(e[0],e.parent()[0]);a(window).bind("load resize",function(){d.reposition()})}})}else{if(typeof c=="string"){return this.each(function(){var f=a(this);c=c.toLowerCase();var e=f.data("zclipId");var d=a("#"+e+".zclip");if(c=="remove"){d.remove();f.removeClass("active hover")}else{if(c=="hide"){d.hide();f.removeClass("active hover")}else{if(c=="show"){d.show()}}}})}}}})(jQuery);var ZeroClipboard={version:"1.0.7",clients:{},moviePath:"ZeroClipboard.swf",nextId:1,$:function(a){if(typeof(a)=="string"){a=document.getElementById(a)}if(!a.addClass){a.hide=function(){/*this.style.display="none"*/};a.show=function(){this.style.display=""};a.addClass=function(b){this.removeClass(b);this.className+=" "+b};a.removeClass=function(d){var e=this.className.split(/\s+/);var b=-1;for(var c=0;c<e.length;c++){if(e[c]==d){b=c;c=e.length}}if(b>-1){e.splice(b,1);this.className=e.join(" ")}return this};a.hasClass=function(b){return !!this.className.match(new RegExp("\\s*"+b+"\\s*"))}}return a},setMoviePath:function(a){this.moviePath=a},dispatch:function(d,b,c){var a=this.clients[d];if(a){a.receiveEvent(b,c)}},register:function(b,a){this.clients[b]=a},getDOMObjectPosition:function(c,a){var b={left:0,top:0,width:c.width?c.width:c.offsetWidth,height:c.height?c.height:c.offsetHeight};if(c&&(c!=a)){b.left+=c.offsetLeft;b.top+=c.offsetTop}return b},Client:function(a){this.handlers={};this.id=ZeroClipboard.nextId++;this.movieId="ZeroClipboardMovie_"+this.id;ZeroClipboard.register(this.id,this);if(a){this.glue(a)}}};ZeroClipboard.Client.prototype={id:0,ready:false,movie:null,clipText:"",handCursorEnabled:true,cssEffects:true,handlers:null,glue:function(d,b,e){this.domElement=ZeroClipboard.$(d);var f=99;if(this.domElement.style.zIndex){f=parseInt(this.domElement.style.zIndex,10)+1}if(typeof(b)=="string"){b=ZeroClipboard.$(b)}else{if(typeof(b)=="undefined"){b=document.getElementsByTagName("body")[0]}}var c=ZeroClipboard.getDOMObjectPosition(this.domElement,b);this.div=document.createElement("div");this.div.className="zclip";this.div.id="zclip-"+this.movieId;$(this.domElement).data("zclipId","zclip-"+this.movieId);var a=this.div.style;a.position="absolute";a.left=""+c.left+"px";a.top=""+c.top+"px";a.width=""+c.width+"px";a.height=""+c.height+"px";a.zIndex=f;if(typeof(e)=="object"){for(addedStyle in e){a[addedStyle]=e[addedStyle]}}b.appendChild(this.div);this.div.innerHTML=this.getHTML(c.width,c.height)},getHTML:function(d,a){var c="";var b="id="+this.id+"&width="+d+"&height="+a;if(navigator.userAgent.match(/MSIE/)){var e=location.href.match(/^https/i)?"https://":"http://";c+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+e+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+d+'" height="'+a+'" id="'+this.movieId+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+ZeroClipboard.moviePath+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+b+'"/><param name="wmode" value="transparent"/></object>'}else{c+='<embed id="'+this.movieId+'" src="'+ZeroClipboard.moviePath+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+d+'" height="'+a+'" name="'+this.movieId+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+b+'" wmode="transparent" />'}return c},hide:function(){if(this.div){this.div.style.left="-2000px"}},show:function(){this.reposition()}Line truncated
|
||||
@@ -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.HTTPS}}" type="button">HTTPS</button>
|
||||
</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">
|
||||
<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>
|
||||
</div>
|
||||
<p class="help-block text-center">Need help cloning? Visit <a href="#">Help</a>!</p>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</span>
|
||||
<input type="text" class="form-control clone-group-url" id="guide-clone-url" value="" readonly/>
|
||||
<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>
|
||||
</div>
|
||||
<p>We recommend every repository include a <strong>README</strong>, <strong>LICENSE</strong>, and <strong>.gitignore</strong>.</p>
|
||||
|
||||
Reference in new issue
Block a user