From 22a530bf21da894893f2d86b16d2c264d2a0fbe0 Mon Sep 17 00:00:00 2001 From: Jico Baligod Date: Wed, 16 Jul 2014 18:13:04 -0400 Subject: [PATCH 1/2] Wrap module in a closure --- package.json | 8 ++-- src/ngClip.js | 109 ++++++++++++++++++++++++++------------------------ 2 files changed, 60 insertions(+), 57 deletions(-) diff --git a/package.json b/package.json index 799e002..799650b 100644 --- a/package.json +++ b/package.json @@ -26,11 +26,11 @@ "connect-livereload": "~0.2.0", "grunt-google-cdn": "~0.2.0", "grunt-ngmin": "~0.0.2", - "karma": "~0.9", - "karma-jasmine": "~0.0.3", - "karma-chrome-launcher": "~0.0.2" + "karma": "~0.12.0", + "karma-jasmine": "~0.1.5", + "karma-chrome-launcher": "~0.1.4" }, "engines": { "node": ">=0.8.0" } -} \ No newline at end of file +} diff --git a/src/ngClip.js b/src/ngClip.js index d90be2b..6cda4b5 100644 --- a/src/ngClip.js +++ b/src/ngClip.js @@ -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); From 1f6dfbf13af01a771d31056aff4af1a6b8d226aa Mon Sep 17 00:00:00 2001 From: Jico Baligod Date: Wed, 16 Jul 2014 18:24:53 -0400 Subject: [PATCH 2/2] bump version --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 054bd91..c274e0c 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "ng-clip", - "version": "0.2.1", + "version": "0.2.2", "main": "dest/ng-clip.min.js", "dependencies": { "angular": ">=1.0.4", diff --git a/package.json b/package.json index 799650b..419ddb9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngClip", - "version": "0.1.4", + "version": "0.2.2", "dependencies": {}, "devDependencies": { "grunt": "~0.4.1",