Skip to content

Commit

Permalink
Merge pull request #2 from DiriectorDoc/v0.1.3
Browse files Browse the repository at this point in the history
v0.1.3
  • Loading branch information
DiriectorDoc committed Sep 10, 2020
2 parents ba402d0 + 290afd1 commit 8735b49
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
1 change: 0 additions & 1 deletion JQlipboard.min.js

This file was deleted.

22 changes: 11 additions & 11 deletions JQlipboard.js → jQlipboard.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* jQlipboard (v0.1.2)
* jQlipboard (v0.1.3)
* A jQuery plugin that makes handling clipboard processes easier
*
*
Expand Down Expand Up @@ -33,7 +33,7 @@
function warning(err){
console.error(err)
console.warn("Browser does not have permission to access clipboard. Some features may not work until permission is granted.")
console.info('To agrant permission, go into your browser setting and allow "Clipboard"')
console.info('To grant permission, go into your browser setting and allow "Clipboard"')
warning = nothing
}

Expand Down Expand Up @@ -79,10 +79,10 @@
$.fn.paste = function(){
let tag = this[0].tagName;
if("INPUT" == tag || "TEXTAREA" == tag){
if(this.is(":focus") || (this[0] === document.activeElement && (this[0].type || this[0].href))){
if(this.is(":focus") || this[0] === document.activeElement){
return $.paste() ? this:this.val(window.qlipboard.text)
}
let $focus = $(":focus").length ? $(":focus"):$(document.activeElement);
let $focus = $(document.activeElement);
this.focus()
if(!$.paste){
let text = this.val(),
Expand Down Expand Up @@ -154,7 +154,7 @@
console.info("Trying $.copy() instead")
}
if($.copy()){
let $focus = $(":focus").length ? $(":focus"):$(document.activeElement),
let $focus = $(document.activeElement),
e = $focus[0],
text = $focus.val();
text = text.slice(0, e.selectionStart) + text.slice(e.selectionEnd);
Expand Down Expand Up @@ -226,7 +226,7 @@
let success = true;
navigator.clipboard.readText()
.then(clipText => {
let $focus = $(":focus").length ? $(":focus"):$(document.activeElement),
let $focus = $(document.activeElement),
e = $focus[0],
text = $focus.val();
text = text.slice(0, e.selectionStart) + clipText + text.slice(e.selectionEnd);
Expand All @@ -251,20 +251,20 @@
.catch(warning)
}
if(config.copyListener){
if($().bind){
$(document).bind("copy", setQlipboard)
} else {
if($().on){
$(document).on("copy", setQlipboard)
} else {
$(document).bind("copy", setQlipboard)
}
}
};

$.jQlipboardVersion = "0.1.2"
$.jQlipboardVersion = "0.1.3"
}((function(){
try{
return jQuery
} catch(e){
console.warn("jQuery not detected. You must use a jQuery version of 1.0 or newer to run this plugin.")
return false
}
})()));
})()));
2 changes: 2 additions & 0 deletions jQlipboard.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions JQlipboard.tomin.js → jQlipboard.tomin.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
warning= err=>{
console.error(err)
console.warn("Browser does not have permission to access clipboard. Some features may not work until permission is granted.")
console.info('To agrant permission, go into your browser setting and allow "Clipboard"')
console.info('To grant permission, go into your browser setting and allow "Clipboard"')
warning = nothing
},
nothing=a=>0,
exec=a=>{return document.execCommand(a)||(b=>{throw 0})()},
focused=a=>$(":focus").length ? $(":focus"):$(document.activeElement);
focused=a=>$(document.activeElement),
$select = $.fn.select;

$.fn.copy = function() {
if (this.parent().length) {
Expand Down Expand Up @@ -62,7 +63,7 @@
$.fn.paste = function(){
let tag = this[0].tagName;
if("INPUT" == tag || "TEXTAREA" == tag){
if(this.is(":focus") || (this[0] === document.activeElement && (this[0].type || this[0].href))){
if(this.is(":focus") || this[0] === document.activeElement){
return $.paste() ? this:this.val(window.qlipboard.text)
}
let $focus = focused();
Expand All @@ -83,7 +84,6 @@
.remove()
};

let $select = $.fn.select;
$.fn.select = function(elem, name, value, pass) {
if ("INPUT" == this[0].tagName || "TEXTAREA" == this[0].tagName)
return $select(elem, name, value, pass);
Expand Down Expand Up @@ -191,11 +191,11 @@
}
};

$.jQlipboardVersion = "0.1.2"
$.jQlipboardVersion = "0.1.3"
}((function(){
try{
return jQuery
} catch(e){
return console.warn("jQuery not detected. You must use a jQuery version of 1.0 or newer to run this plugin.")
}
})()));
})()));

0 comments on commit 8735b49

Please sign in to comment.