Skip to content

Commit ee120cd

Browse files
committed
init
0 parents  commit ee120cd

File tree

6 files changed

+166
-0
lines changed

6 files changed

+166
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
bower_components/*

LICENSE.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright (C) 2014 lisposter(Leigh Zhu)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Angular ZeroClipboard
2+
3+
An angular wrapper for ZeroClipboard
4+
5+
## Install
6+
7+
```
8+
bower install angular-zeroclipboard
9+
```
10+
11+
or, you can download 'angular-zeroclipboard.js' form 'src' manualy
12+
13+
14+
15+
## LICENSE
16+
17+
Copyright (C) 2014 lisposter(Leigh Zhu)
18+
19+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
20+
21+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

bower.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "angular-zeroclipboard",
3+
"version": "0.0.1",
4+
"description": "Angular Wrapper for ZeroClipboard",
5+
"main": "src/angular-zeroclipboard.js",
6+
"keywords": [
7+
"angular",
8+
"zeroclipboard"
9+
],
10+
"authors": [
11+
"Leigh Zhu"
12+
],
13+
"ignore": [
14+
"**/.*",
15+
"node_modules",
16+
"components",
17+
"bower_components",
18+
"test*",
19+
"demo*",
20+
"GruntFile.js",
21+
"package.json"
22+
],
23+
"license": "MIT",
24+
"homepage": "http://github.com/lisposter/angular-zeroclipboard",
25+
"dependencies": {
26+
"angular": "~1.2.16",
27+
"zeroclipboard": "~1.3.5"
28+
}
29+
}

demo/demo.html

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!doctype html>
2+
<html lang="en" ng-app="demo">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Angular ZeroClipBoard</title>
6+
<script src="../bower_components/angular/angular.js"></script>
7+
<script src="../bower_components/zeroclipboard/ZeroClipboard.js"></script>
8+
<script src="../src/angular-zeroclipboard.js"></script>
9+
<script>
10+
angular.module('demo', ['angular.zeroclipboard']).
11+
config(['uiZeroclipConfigProvider', function(uiZeroclip) {
12+
13+
}])
14+
</script>
15+
</head>
16+
<body>
17+
18+
<h1>Angular ZeroClipboard Demo</h1>
19+
20+
<form action="">
21+
<label for="">input: <input type="text" ui-zeroclip ng-model="input"></label>
22+
23+
<label for="">textarea: <textarea name="" id="" cols="30" rows="10" ui-zeroclip ng-model="textarea"></textarea></label>
24+
</form>
25+
26+
</body>
27+
</html>

src/angular-zeroclipboard.js

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
angular.module('angular.zeroclipboard', []).provider('uiZeroclipConfig', function() {
2+
this.zeroclipConfig = {
3+
buttonClass: '',
4+
moviePath: "../bower_components/zeroclipboard/ZeroClipboard.swf",
5+
trustedDomains: [window.location.host],
6+
cacheBust: true,
7+
forceHandCursor: false,
8+
zIndex: 999999999,
9+
debug: true,
10+
title: null,
11+
autoActivate: true,
12+
flashLoadTimeout: 30000,
13+
hoverClass: "zeroclipboard-is-hover",
14+
activeClass: "zeroclipboard-is-active"
15+
};
16+
this.options = {
17+
buttonClass: '',
18+
buttonText: 'Copy',
19+
load: null,
20+
mouseover: null,
21+
mouseout: null,
22+
mousedown: null,
23+
mouseup: null,
24+
complete: null,
25+
noflash: null,
26+
wrongflash: null,
27+
dataRequested: null
28+
};
29+
this.$get = ['$rootScope',
30+
function($rootScope) {
31+
return {
32+
zeroclipConfig: this.zeroclipConfig,
33+
options: this.options
34+
}
35+
}
36+
];
37+
}).
38+
directive('uiZeroclip', ['$document', '$window', 'uiZeroclipConfig',
39+
function($document, $window, uiZeroclipConfig) {
40+
var zeroclipConfig = uiZeroclipConfig.zeroclipConfig || {};
41+
var options = uiZeroclipConfig.options;
42+
var copyBtns = [];
43+
var _id = 0;
44+
45+
function insertAfter(newNode, referenceNode) {
46+
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
47+
}
48+
return {
49+
priority: 10,
50+
require: 'ngModel',
51+
link: function(scope, elm, attrs, ngModel) {
52+
// config
53+
ZeroClipboard.config(zeroclipConfig);
54+
if (!attrs.id) {
55+
attrs.$set('id', 'uiZeroclip' + _id);
56+
var btn = document.createElement('button');
57+
btn.appendChild(document.createTextNode(options.buttonText));
58+
btn.setAttribute('data-clipboard-target', 'uiZeroclip' + _id);
59+
_id++;
60+
insertAfter(btn, elm[0]);
61+
copyBtns.push(btn);
62+
}
63+
if (angular.isFunction(ZeroClipboard)) {
64+
scope.client = new ZeroClipboard(copyBtns);
65+
}
66+
scope.client.on('load', options.load);
67+
scope.client.on('mouseover', options.mouseover);
68+
scope.client.on('mouseout', options.mouseout);
69+
scope.client.on('mouseup', options.mouseup);
70+
scope.client.on('mousedown', options.mousedown);
71+
scope.client.on('complete', options.complete);
72+
scope.client.on('dataRequested', options.dataRequested);
73+
scope.client.on('noflash', options.noflash);
74+
scope.client.on('wrongflash', options.wrongflash);
75+
}
76+
}
77+
}
78+
]);

0 commit comments

Comments
 (0)