angular-clipboard 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +2 -0
- data/angular-clipboard.gemspec +35 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/angular/clipboard.rb +8 -0
- data/lib/angular/clipboard/version.rb +5 -0
- data/vendor/assets/javascripts/angular-clipboard.js +82 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e1fe8da3eeb771b9f7d00ec3e3c8b1896cd9523d
|
4
|
+
data.tar.gz: cf2a46dd644751b41f5919d0c5356bd4e3072211
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e9f56350e12e4045c938733f244981ac99f40a0e1e5d4b58347d551949c490754f019455a3e1f0b527d417e275275e85101862a8645c40f409dc1b3d15ea7665
|
7
|
+
data.tar.gz: d743510fa7eb427cb600a55f46a7a5a272806f9e70b220fc25553152467cc4ec31acc8545470485b8d7dc0c0428e561f1a6dc275a8da04f96585fcca6a8d153b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 axl
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Angular Clipboard for your rails APP
|
2
|
+
|
3
|
+
This gem provides [angular-clipboard.js][https://github.com/omichelsen/angular-clipboard] module for your rails application.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'angular-clipboard'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install angular-clipboard
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
The js files in your `application.js`
|
24
|
+
|
25
|
+
//= require angular-clipboard
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/axl/angular-clipboard. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
1. Fork it
|
38
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
39
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
40
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
41
|
+
5. Create new Pull Request
|
42
|
+
|
43
|
+
## License
|
44
|
+
|
45
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'angular/clipboard/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "angular-clipboard"
|
8
|
+
spec.version = Angular::Clipboard::VERSION
|
9
|
+
spec.authors = ["axl"]
|
10
|
+
spec.email = ["axel.catusse@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{angular-clipboard.js for Rails asset pipeline}
|
13
|
+
spec.description = %q{angular-clipboard.js Copy text to clipboard by clicking a button, without using Flash}
|
14
|
+
spec.homepage = "https://github.com/catuss-a/angular-clipboard"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "angular/clipboard"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
(function (root, factory) {
|
2
|
+
/* istanbul ignore next */
|
3
|
+
if (typeof define === 'function' && define.amd) {
|
4
|
+
define(['angular'], factory);
|
5
|
+
} else if (typeof module === 'object' && module.exports) {
|
6
|
+
module.exports = factory(require('angular'));
|
7
|
+
} else {
|
8
|
+
root.angularClipboard = factory(root.angular);
|
9
|
+
}
|
10
|
+
}(this, function (angular) {
|
11
|
+
|
12
|
+
return angular.module('angular-clipboard', [])
|
13
|
+
.factory('clipboard', ['$document', '$window', function ($document, $window) {
|
14
|
+
function createNode(text, context) {
|
15
|
+
var node = $document[0].createElement('textarea');
|
16
|
+
node.style.position = 'absolute';
|
17
|
+
node.textContent = text;
|
18
|
+
node.style.left = '-10000px';
|
19
|
+
node.style.top = ($window.pageYOffset || $document[0].documentElement.scrollTop) + 'px';
|
20
|
+
return node;
|
21
|
+
}
|
22
|
+
|
23
|
+
function copyNode(node) {
|
24
|
+
try {
|
25
|
+
// Set inline style to override css styles
|
26
|
+
$document[0].body.style.webkitUserSelect = 'initial';
|
27
|
+
|
28
|
+
var selection = $document[0].getSelection();
|
29
|
+
selection.removeAllRanges();
|
30
|
+
node.select();
|
31
|
+
|
32
|
+
if(!$document[0].execCommand('copy')) {
|
33
|
+
throw('failure copy');
|
34
|
+
}
|
35
|
+
selection.removeAllRanges();
|
36
|
+
} finally {
|
37
|
+
// Reset inline style
|
38
|
+
$document[0].body.style.webkitUserSelect = '';
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
function copyText(text, context) {
|
43
|
+
var node = createNode(text, context);
|
44
|
+
$document[0].body.appendChild(node);
|
45
|
+
copyNode(node);
|
46
|
+
$document[0].body.removeChild(node);
|
47
|
+
}
|
48
|
+
|
49
|
+
return {
|
50
|
+
copyText: copyText,
|
51
|
+
supported: 'queryCommandSupported' in $document[0] && $document[0].queryCommandSupported('copy')
|
52
|
+
};
|
53
|
+
}])
|
54
|
+
.directive('clipboard', ['clipboard', function (clipboard) {
|
55
|
+
return {
|
56
|
+
restrict: 'A',
|
57
|
+
scope: {
|
58
|
+
onCopied: '&',
|
59
|
+
onError: '&',
|
60
|
+
text: '=',
|
61
|
+
supported: '=?'
|
62
|
+
},
|
63
|
+
link: function (scope, element) {
|
64
|
+
scope.supported = clipboard.supported;
|
65
|
+
|
66
|
+
element.on('click', function (event) {
|
67
|
+
try {
|
68
|
+
clipboard.copyText(scope.text, element[0]);
|
69
|
+
if (angular.isFunction(scope.onCopied)) {
|
70
|
+
scope.$evalAsync(scope.onCopied());
|
71
|
+
}
|
72
|
+
} catch (err) {
|
73
|
+
if (angular.isFunction(scope.onError)) {
|
74
|
+
scope.$evalAsync(scope.onError({err: err}));
|
75
|
+
}
|
76
|
+
}
|
77
|
+
});
|
78
|
+
}
|
79
|
+
};
|
80
|
+
}]);
|
81
|
+
|
82
|
+
}));
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: angular-clipboard
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- axl
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: angular-clipboard.js Copy text to clipboard by clicking a button, without
|
42
|
+
using Flash
|
43
|
+
email:
|
44
|
+
- axel.catusse@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- angular-clipboard.gemspec
|
55
|
+
- bin/console
|
56
|
+
- bin/setup
|
57
|
+
- lib/angular/clipboard.rb
|
58
|
+
- lib/angular/clipboard/version.rb
|
59
|
+
- vendor/assets/javascripts/angular-clipboard.js
|
60
|
+
homepage: https://github.com/catuss-a/angular-clipboard
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.5.1
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: angular-clipboard.js for Rails asset pipeline
|
84
|
+
test_files: []
|