Skip to content

Commit

Permalink
Replace ng-clip.js symlink with actual file.
Browse files Browse the repository at this point in the history
The symlink doesn't come down with the bower download. It also
appears to be more trouble than its worth in terms of versioning
since dest/ng-clip.js would always point to the latest code.
If a build/version-bump isn't performed for every single ng-clip.js commit,
it would come out sync with ng-clip.min.js.
  • Loading branch information
pmowrer committed Dec 17, 2014
1 parent 9ed4e61 commit 74e7eef
Showing 1 changed file with 84 additions and 1 deletion.
1 change: 0 additions & 1 deletion dest/ng-clip.js

This file was deleted.

84 changes: 84 additions & 0 deletions dest/ng-clip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*jslint node: true */
/*global ZeroClipboard */

(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.6/ZeroClipboard.swf';
return {
setPath: function(newPath) {
self.path = newPath;
},
setConfig: function(config) {
self.config = config;
},
$get: function() {
return {
path: self.path,
config: self.config
};
}
};
}).
run(['ngClip', function(ngClip) {
var config = {
swfPath: ngClip.path,
trustedDomains: ["*"],
allowScriptAccess: "always",
forceHandCursor: true,
};
ZeroClipboard.config(angular.extend(config,ngClip.config || {}));
}]).
directive('clipCopy', ['ngClip', function (ngClip) {
return {
scope: {
clipCopy: '&',
clipClick: '&',
clipClickFallback: '&'
},
restrict: 'A',
link: function (scope, element, attrs) {
// Bind a fallback function if flash is unavailable
if (ZeroClipboard.isFlashUnusable()) {
element.bind('click', function($event) {
// Execute the expression with local variables `$event` and `copy`
scope.$apply(scope.clipClickFallback({
$event: $event,
copy: scope.$eval(scope.clipCopy)
}));
});

return;
}

// 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(attrs.clipCopyMimeType || 'text/plain', scope.$eval(scope.clipCopy));
});

client.on( 'aftercopy', function(event) {
if (angular.isDefined(attrs.clipClick)) {
scope.$apply(scope.clipClick);
}
});

scope.$on('$destroy', function() {
client.destroy();
});
});
}
};
}]);
})(window, window.angular);

0 comments on commit 74e7eef

Please sign in to comment.