All Projects → ryanpcmcquen → Cheval

ryanpcmcquen / Cheval

Licence: mpl-2.0
📋 Copy to the clipboard using JavaScript without writing JS. A full solution for all browsers and all devices. LibreJS compliant.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Cheval

Enhanced Github
🚀 Browser extension to display size of each file, download link and copy file contents directly to the clipboard
Stars: ✭ 1,146 (+396.1%)
Mutual labels:  hacktoberfest, clipboard
Markor
Text editor - Notes & ToDo (for Android) - Markdown, todo.txt, plaintext, math, ..
Stars: ✭ 1,394 (+503.46%)
Mutual labels:  hacktoberfest, clipboard
Clipboard
React Native Clipboard API for both iOS and Android.
Stars: ✭ 198 (-14.29%)
Mutual labels:  hacktoberfest, clipboard
Smallest Secured Golang Docker Image
Create the smallest and secured golang docker image based on scratch
Stars: ✭ 229 (-0.87%)
Mutual labels:  hacktoberfest
React Native Art Doc
📒 Unofficial documentation for react-native ART module.
Stars: ✭ 229 (-0.87%)
Mutual labels:  hacktoberfest
Lagom
Reactive Microservices for the JVM
Stars: ✭ 2,590 (+1021.21%)
Mutual labels:  hacktoberfest
Upcount
Invoicing for freelancers & small businesses
Stars: ✭ 230 (-0.43%)
Mutual labels:  hacktoberfest
Joshuto
ranger-like terminal file manager written in Rust
Stars: ✭ 224 (-3.03%)
Mutual labels:  hacktoberfest
Node Virtualbox
A JavaScript Library for Interacting with VirtualBox
Stars: ✭ 231 (+0%)
Mutual labels:  hacktoberfest
Pythonnet
Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers.
Stars: ✭ 2,873 (+1143.72%)
Mutual labels:  hacktoberfest
Terraform Provider Keycloak
Terraform provider for Keycloak
Stars: ✭ 230 (-0.43%)
Mutual labels:  hacktoberfest
Django Security
A collection of models, views, middlewares, and forms to help secure a Django project.
Stars: ✭ 228 (-1.3%)
Mutual labels:  hacktoberfest
Tageditor
A tag editor with Qt GUI and command-line interface supporting MP4/M4A/AAC (iTunes), ID3, Vorbis, Opus, FLAC and Matroska
Stars: ✭ 229 (-0.87%)
Mutual labels:  hacktoberfest
Fullstack Challenges
Open source's challenges of full-stack jobs to test your skills
Stars: ✭ 227 (-1.73%)
Mutual labels:  hacktoberfest
Laravel Query Monitor
Simple artisan command to monitoring triggered queries
Stars: ✭ 230 (-0.43%)
Mutual labels:  hacktoberfest
Vue Croppie
Vue wrapper for croppie
Stars: ✭ 228 (-1.3%)
Mutual labels:  hacktoberfest
Archivesspace
The ArchivesSpace archives management tool
Stars: ✭ 230 (-0.43%)
Mutual labels:  hacktoberfest
Ten Hands
⚡ Simplest way to organize and run command-line tasks
Stars: ✭ 228 (-1.3%)
Mutual labels:  hacktoberfest
Docker Build With Cache Action
Build and push docker images caching each stage to reduce build time
Stars: ✭ 228 (-1.3%)
Mutual labels:  hacktoberfest
Wwdc
You don't have the time to watch all the WWDC session videos yourself? No problem me and many contributors extracted the gist for you 🥳
Stars: ✭ 2,561 (+1008.66%)
Mutual labels:  hacktoberfest

Cheval 📋

Downloads GitHub license

Cheval glass

Just include the library (~2kB!):

<script src="https://cdn.jsdelivr.net/gh/ryanpcmcquen/[email protected]/cheval.min.js"></script>

https://cdn.jsdelivr.net/gh/ryanpcmcquen/[email protected]/cheval.min.js

Provided by:

jsDelivr

Then use the following elements:

  1. <textarea> with the class text-to-copy (can be readonly but not disabled)
  2. <button> with the class js-copy-btn

The library takes cares of the rest.

📰 You don't have to write any JavaScript to use it!

Alternatively, you can use the project with npm:

npm install cheval

Featured in MarkApp!

MarkApp


So what?! Where does it work?

Almost everywhere!

Desktop:

  • Chrome/Chromium 42+
  • Firefox 41+
  • Internet Explorer 9+
  • Opera 29+
  • Safari 10+

Android:

  • Chrome 42+
  • Firefox 41+

iOS:

  • 10+
What about other browsers?

Everywhere else (old versions of Safari), it will select the text. The library detects iDevices and will change the inital button text to Select text (to avoid confusing the user). After clicking it will say either Now tap 'Copy' (iPhone) or Now tap the text, then 'Copy' (iPad), to account for the strange behavioral differences of these devices.

On desktop Safari (< v10), the button will change to Press Command + C to copy.

On failure the button will say Please copy manually.


⚠️ If you want your textarea to be invisible for some reason, use this CSS:

.text-to-copy {
    opacity: 0;
    position: absolute;
}

Because it will not work with display: none; or visibility: hidden;. 👍

Note that you should also supplement that CSS with something like this helper library, otherwise people on iOS will not be able to copy at all since Safari doesn't support cool stuff:

https://gist.github.com/ryanpcmcquen/1229119ffcf5098543c0

What else is cool?

If you aren't concerned with maximum compatibility, you can use elements besides a textarea.

You may also add multiple copy elements and buttons to each page, using the following format:

<textarea class="text-to-copy-0"></textarea>
<button class="js-copy-btn-0"></button>

<textarea class="text-to-copy-1"></textarea>
<button class="js-copy-btn-1"></button>

<textarea class="text-to-copy-2"></textarea>
<button class="js-copy-btn-2"></button>

<textarea class="text-to-copy-3"></textarea>
<button class="js-copy-btn-3"></button>

The characters after the dash in text-to-copy- or js-copy-btn- can be anything, they just have to match between the button and element.

For example:

<textarea class="text-to-copy-email"></textarea>
<button class="js-copy-btn-email"></button>

Positioning of the elements and buttons does not matter, they do not need to be near each other on the page. This allows you to write declarative markup and not be concerned with the inner workings of this library. Enjoy!


But ...

I want to dynamically add elements to my page, cheval only runs on page load!

You're right! That's why in version 1.3.0, cheval also adds itself to global scope.

Now you can invoke at will on dynamic elements!

cheval('.dynamic-js-copy-btn', '.dynamic-text-to-copy');

What does cheval mean?

The name comes from Cheval glass, a type of mirror.


This project is LibreJS compliant!

LibreJS


If you prefer using specific tags instead of the latest version, you may specify a tag in the jsDelivr URL:

https://cdn.jsdelivr.net/gh/ryanpcmcquen/[email protected]/cheval.min.js


Contributing:

If you wish to contribute to this project, pull requests are always welcome! Please make sure that any changes pass through http://jslint.com/ with the following options before submitting them:

/*global module, window*/
/*jslint browser: true*/

Thanks to Lea Verou for lots of support and help with the name.

Thanks to Nikita Tcherednikov for the Cheval icon, provided under the Creative Commons license.

Thanks to Charles Raymond Macauley for the drawing available here. (Public domain)

Thanks to BrowserStack and Koding!

https://browserstack.com

Made with Koding

Full download stats available here:

https://data.jsdelivr.com/v1/package/gh/ryanpcmcquen/cheval/stats?from=2014-01-01

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].