Last active
February 9, 2018 15:26
-
-
Save anytizer/cc9247b09c5c8d3c3b50c169ea768a5b to your computer and use it in GitHub Desktop.
Color Picker using clipboard.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- https://raw.githubusercontent.com/zenorocha/clipboard.js/master/dist/clipboard.min.js --> | |
<script src="clipboard.min.js"></script> | |
<script> | |
function copyc(color, element) | |
{ | |
new Clipboard('.block', { | |
container: element | |
}); | |
} | |
</script> | |
<style> | |
.block | |
{ | |
display: inline-block; | |
border: 1px solid #000000; | |
margin: 3px; | |
height: 20px; | |
width: 20px; | |
cursor: pointer; | |
} | |
</style> | |
<div style="margin: auto;"> | |
<?php | |
$colors = array( | |
"00", | |
#"11", | |
#"22", | |
"33", | |
#"44", | |
#"55", | |
"66", | |
#"77", | |
#"88", | |
"99", | |
"AA", | |
#"BB", | |
"CC", | |
#"DD", | |
#"EE", | |
"FF" | |
); | |
foreach($colors as $red) | |
{ | |
foreach($colors as $green) | |
{ | |
foreach($colors as $blue) | |
{ | |
echo "<button onclick=\"copyc('#{$red}{$green}{$blue}, this')\" data-clipboard-text='#{$red}{$green}{$blue}' class='block' style='background-color: #{$red}{$green}{$blue};' title='#{$red}{$green}{$blue}'></button>"; | |
} | |
} | |
} | |
?> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://raw.githubusercontent.com/zenorocha/clipboard.js/master/dist/clipboard.min.js"></script> | |
<script> | |
function copyc(color) | |
{ | |
document.getElementById("cph").innerHTML=color; | |
document.getElementById("cph").setAttribute("data-clipboard-text", color); | |
new Clipboard('.block', { | |
container: document.getElementById('cph') | |
}); | |
} | |
</script> | |
<style> | |
.block | |
{ | |
display: inline-block; | |
border: 1px solid #000000; | |
margin: 3px; | |
height: 20px; | |
width: 20px; | |
cursor: pointer; | |
} | |
</style> | |
<button class="btn" data-clipboard-text="" id="cph" style="display: block;">#000000</button> | |
<div style="margin: auto;"> | |
<?php | |
$colors = array( | |
"00", | |
"11", | |
"22", | |
"33", | |
"44", | |
"55", | |
"66", | |
"77", | |
"88", | |
"99", | |
"AA", | |
"BB", | |
"CC", | |
"DD", | |
"EE", | |
"FF" | |
); | |
foreach($colors as $red) | |
{ | |
foreach($colors as $green) | |
{ | |
foreach($colors as $blue) | |
{ | |
echo "<button onclick=\"copyc('#{$red}{$green}{$blue}')\" data-clipboard-text='#{$red}{$green}{$blue}' class='block' style='background-color: #{$red}{$green}{$blue};' title='#{$red}{$green}{$blue}'></button>"; | |
} | |
} | |
} | |
?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment