add clipboard API support
This commit is contained in:
		
							parent
							
								
									6a89eeedf3
								
							
						
					
					
						commit
						eebcbf9d34
					
				|  | @ -269,8 +269,35 @@ var Gogits = {}; | |||
|         if ($(selector).hasClass('js-copy-bind')) { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         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"); | ||||
|                 }, 200); | ||||
|                 setTimeout(function () { | ||||
|                     $this.tipsy('hide').attr('original-title', $this.data('original-title')); | ||||
|                 }, 2000); | ||||
|                  | ||||
|                 this.blur(); | ||||
|                 return; | ||||
|             }); | ||||
| 
 | ||||
|             $(selector).addClass("js-copy-bind"); | ||||
| 
 | ||||
|         } else { | ||||
| 
 | ||||
|             $(selector).zclip({ | ||||
|             path: "/js/ZeroClipboard.swf", | ||||
|                 path: Gogs.AppSubUrl + "/js/ZeroClipboard.swf", | ||||
|                 copy: function () { | ||||
|                     var t = $(this).data("copy-val"); | ||||
|                     var to = $($(this).data("copy-from")); | ||||
|  | @ -288,18 +315,17 @@ var Gogits = {}; | |||
|                 }, | ||||
|                 afterCopy: function () { | ||||
|                     var $this = $(this); | ||||
|                 $this.tooltip('hide') | ||||
|                     .attr('data-original-title', 'Copied OK'); | ||||
|                     $this.tipsy("hide").attr('original-title', $this.data('after-title')); | ||||
|                     setTimeout(function () { | ||||
|                     $this.tooltip("show"); | ||||
|                         $this.tipsy("show"); | ||||
|                     }, 200); | ||||
|                     setTimeout(function () { | ||||
|                     $this.tooltip('hide') | ||||
|                         .attr('data-original-title', 'Copy to Clipboard'); | ||||
|                 }, 3000); | ||||
|                         $this.tipsy('hide').attr('original-title', $this.data('original-title')); | ||||
|                     }, 2000); | ||||
|                 } | ||||
|             }).addClass("js-copy-bind"); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     // api working
 | ||||
|     Gogits.getUsers = function (val, $target) { | ||||
|  |  | |||
|  | @ -333,6 +333,33 @@ var Gogs = {}; | |||
|         if ($(selector).hasClass('js-copy-bind')) { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         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"); | ||||
|                 }, 200); | ||||
|                 setTimeout(function () { | ||||
|                     $this.tipsy('hide').attr('original-title', $this.data('original-title')); | ||||
|                 }, 2000); | ||||
|                  | ||||
|                 this.blur(); | ||||
|                 return; | ||||
|             }); | ||||
| 
 | ||||
|             $(selector).addClass("js-copy-bind"); | ||||
| 
 | ||||
|         } else { | ||||
| 
 | ||||
|             $(selector).zclip({ | ||||
|                 path: Gogs.AppSubUrl + "/js/ZeroClipboard.swf", | ||||
|                 copy: function () { | ||||
|  | @ -362,6 +389,7 @@ var Gogs = {}; | |||
|                 } | ||||
|             }).addClass("js-copy-bind"); | ||||
|         } | ||||
|     } | ||||
| })(jQuery); | ||||
| 
 | ||||
| function initCore() { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue