From 14e8888116893f8f004ef6bdae3f26f9f63a21a7 Mon Sep 17 00:00:00 2001 From: Juan Gaya Date: Fri, 22 May 2015 14:48:25 -0300 Subject: [PATCH 1/4] Firefox fix Firefox uses textContext instead of innerText --- src/ngClip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ngClip.js b/src/ngClip.js index e92a426..a4a1a94 100644 --- a/src/ngClip.js +++ b/src/ngClip.js @@ -58,7 +58,7 @@ var client = new ZeroClipboard(element); if (attrs.clipCopy === "") { scope.clipCopy = function(scope) { - return element[0].previousElementSibling.innerText; + return element[0].previousElementSibling.innerText || element[0].previousElementSibling.textContent; }; } client.on( 'ready', function(readyEvent) { From 36da9236b811d4febacc9d2d602ddd9901992977 Mon Sep 17 00:00:00 2001 From: jgaya Date: Wed, 27 May 2015 13:25:25 -0300 Subject: [PATCH 2/4] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 65b16b0..56a7fe9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ng-clip", - "version": "0.2.6", + "version": "0.2.7", "main": "dest/ng-clip.min.js", "filename": "ng-clip.min.js", "description": "Copy to clipboard using AngularJS", From d2b065ddf2885531258d415b7ed2dab855b62fdf Mon Sep 17 00:00:00 2001 From: Juan Gaya Date: Fri, 29 May 2015 11:41:31 -0300 Subject: [PATCH 3/4] unminified version in ./dest --- dest/ng-clip.js | 85 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/dest/ng-clip.js b/dest/ng-clip.js index aac918d..bbd789f 120000 --- a/dest/ng-clip.js +++ b/dest/ng-clip.js @@ -1 +1,84 @@ -../src/ngClip.js \ No newline at end of file +/*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 || element[0].previousElementSibling.textContent; + }; + } + 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); From a9355c9dcbd85c2c1b0ed9ca74ef2541852a0afb Mon Sep 17 00:00:00 2001 From: jgaya Date: Wed, 12 Aug 2015 19:26:01 -0300 Subject: [PATCH 4/4] Update ng-clip.js --- dest/ng-clip.js | 85 +------------------------------------------------ 1 file changed, 1 insertion(+), 84 deletions(-) diff --git a/dest/ng-clip.js b/dest/ng-clip.js index bbd789f..c40a6b3 120000 --- a/dest/ng-clip.js +++ b/dest/ng-clip.js @@ -1,84 +1 @@ -/*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 || element[0].previousElementSibling.textContent; - }; - } - 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); +../src/ngClip.js