-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jico Baligod
committed
Jul 16, 2014
1 parent
3a284a9
commit 22a530b
Showing
2 changed files
with
60 additions
and
57 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,65 @@ | ||
/*jslint node: true */ | ||
/*global ZeroClipboard */ | ||
'use strict'; | ||
|
||
angular.module('ngClipboard', []). | ||
provider('ngClip', function() { | ||
var self = this; | ||
this.path = '//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.1.1/ZeroClipboard.swf'; | ||
return { | ||
setPath: function(newPath) { | ||
self.path = newPath; | ||
}, | ||
$get: function() { | ||
return { | ||
path: self.path | ||
}; | ||
} | ||
}; | ||
}). | ||
run(['ngClip', function(ngClip) { | ||
ZeroClipboard.config({ | ||
swfPath: ngClip.path, | ||
trustedDomains: ["*"], | ||
allowScriptAccess: "always", | ||
forceHandCursor: true | ||
}); | ||
}]). | ||
directive('clipCopy', ['ngClip', function (ngClip) { | ||
return { | ||
scope: { | ||
clipCopy: '&', | ||
clipClick: '&' | ||
}, | ||
restrict: 'A', | ||
link: function (scope, element, attrs) { | ||
// Create the client object | ||
var client = new ZeroClipboard(element); | ||
if (attrs.clipCopy === "") { | ||
scope.clipCopy = function(scope) { | ||
return element[0].previousElementSibling.innerText; | ||
(function(window, angular, undefined) { | ||
'use strict'; | ||
|
||
angular.module('ngClipboard', []). | ||
provider('ngClip', function() { | ||
var self = this; | ||
this.path = '//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.1.1/ZeroClipboard.swf'; | ||
return { | ||
setPath: function(newPath) { | ||
self.path = newPath; | ||
}, | ||
$get: function() { | ||
return { | ||
path: self.path | ||
}; | ||
} | ||
client.on( 'ready', function(readyEvent) { | ||
}; | ||
}). | ||
run(['ngClip', function(ngClip) { | ||
ZeroClipboard.config({ | ||
swfPath: ngClip.path, | ||
trustedDomains: ["*"], | ||
allowScriptAccess: "always", | ||
forceHandCursor: true | ||
}); | ||
}]). | ||
directive('clipCopy', ['ngClip', function (ngClip) { | ||
return { | ||
scope: { | ||
clipCopy: '&', | ||
clipClick: '&' | ||
}, | ||
restrict: 'A', | ||
link: function (scope, element, attrs) { | ||
// Create the client object | ||
var client = new ZeroClipboard(element); | ||
if (attrs.clipCopy === "") { | ||
scope.clipCopy = function(scope) { | ||
return element[0].previousElementSibling.innerText; | ||
}; | ||
} | ||
client.on( 'ready', function(readyEvent) { | ||
|
||
client.on('copy', function (event) { | ||
var clipboard = event.clipboardData; | ||
clipboard.setData('text/plain', scope.$eval(scope.clipCopy)); | ||
}); | ||
client.on('copy', function (event) { | ||
var clipboard = event.clipboardData; | ||
clipboard.setData('text/plain', scope.$eval(scope.clipCopy)); | ||
}); | ||
|
||
client.on( 'aftercopy', function(event) { | ||
if (angular.isDefined(attrs.clipClick)) { | ||
scope.$apply(scope.clipClick); | ||
} | ||
}); | ||
client.on( 'aftercopy', function(event) { | ||
if (angular.isDefined(attrs.clipClick)) { | ||
scope.$apply(scope.clipClick); | ||
} | ||
}); | ||
|
||
scope.$on('$destroy', function() { | ||
client.destroy(); | ||
scope.$on('$destroy', function() { | ||
client.destroy(); | ||
}); | ||
}); | ||
}); | ||
} | ||
}; | ||
}]); | ||
} | ||
}; | ||
}]); | ||
})(window, window.angular); |