From 067f56bd0ce72dbee4a81c0dcd7cdd05b81276de Mon Sep 17 00:00:00 2001 From: "James M. Greene" Date: Tue, 13 Aug 2013 00:48:17 -0500 Subject: [PATCH] Replacing `make` with `grunt` for builds. Make does not work on Windows, Grunt works cross-platform. Fixes #71. Closes #71. --- .travis.yml | 4 +- CONTRIBUTING.md | 17 +++- Gruntfile.js | 128 +++++++++++++++++++++++++ LICENSE | 3 +- Makefile | 62 ------------ ZeroClipboard.js | 23 +++-- ZeroClipboard.min.js | 15 +-- ZeroClipboard.swf | Bin 1961 -> 1961 bytes bower.json | 2 +- package.json | 32 +++++-- src/build.js | 13 --- src/javascript/ZeroClipboard/core.js | 2 +- src/javascript/start.js | 8 -- src/{license.js => meta/LICENSE.tmpl} | 2 +- src/{bower.js => meta/bower.json.tmpl} | 4 +- src/meta/source-banner.tmpl | 8 ++ test/.jshintrc | 14 +++ test/client.js | 12 +-- test/core.js | 4 +- test/dom.js | 4 +- test/event.js | 58 ++++++----- test/utils.js | 34 +++---- 22 files changed, 271 insertions(+), 178 deletions(-) create mode 100644 Gruntfile.js delete mode 100644 Makefile delete mode 100644 src/build.js rename src/{license.js => meta/LICENSE.tmpl} (91%) rename src/{bower.js => meta/bower.json.tmpl} (50%) create mode 100644 src/meta/source-banner.tmpl create mode 100644 test/.jshintrc diff --git a/.travis.yml b/.travis.yml index c2ba3f90..6ef04eb8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ language: node_js node_js: - - 0.8 \ No newline at end of file + - "0.10" +before_script: + - npm install -g grunt-cli diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ba8237b9..68ad0ab3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,7 @@ Contributing ============== -If you find an issue, a pull request is always better than a bug report. Please fork and submit your code fixes. +If you find an issue, submitting a pull request is always better than a bug report! Please fork and submit your code fixes. If you want to build some new features, we have a [roadmap.md](docs/roadmap.md) of features we want. You can add features you want there, or just code the feature and send a pull request. @@ -9,8 +9,17 @@ If you want to build some new features, we have a [roadmap.md](docs/roadmap.md) $ git clone https://github.com/zeroclipboard/ZeroClipboard.git $ cd ZeroClipboard/ - $ make + $ npm install -g grunt-cli + $ npm install + $ grunt -### Tests - $ make test +### Developing + + $ npm install + $ grunt + + +### Testing + + $ grunt test diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 00000000..8a6a9672 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,128 @@ +/*jshint -W106 */ +module.exports = function(grunt) { + + // Metadata + var pkg = grunt.file.readJSON('package.json'); + + // Project configuration. + grunt.initConfig({ + // Task configuration + jshint: { + options: { + jshintrc: '.jshintrc' + }, + Gruntfile: ['Gruntfile.js'], + js: ['src/javascript/ZeroClipboard/**/*.js'], + test: { + options: { + jshintrc: 'test/.jshintrc' + }, + src: ['test/*.js'] + } + }, + clean: { + dist: ['ZeroClipboard.*', 'bower.json', 'LICENSE'] + }, + concat: { + options: { + stripBanners: true, + process: { + data: pkg + } + }, + js: { + src: [ + 'src/meta/source-banner.tmpl', + 'src/javascript/start.js', + 'src/javascript/ZeroClipboard/utils.js', + 'src/javascript/ZeroClipboard/client.js', + 'src/javascript/ZeroClipboard/core.js', + 'src/javascript/ZeroClipboard/dom.js', + 'src/javascript/ZeroClipboard/event.js', + 'src/javascript/end.js' + ], + dest: 'ZeroClipboard.js' + } + }, + uglify: { + options: { + preserveComments: 'some', + report: 'min' + }, + js: { + options: { + beautify: { + beautify: true, + // `indent_level` requires jshint -W106 + indent_level: 2 + }, + mangle: false, + compress: false + }, + src: ['ZeroClipboard.js'], + dest: 'ZeroClipboard.js' + }, + minjs: { + src: ['ZeroClipboard.js'], + dest: 'ZeroClipboard.min.js' + } + }, + mxmlc: { + options: { + rawConfig: '-static-link-runtime-shared-libraries=true' + }, + swf: { + files: { + 'ZeroClipboard.swf': ['src/flash/ZeroClipboard.as'] + } + } + }, + template: { + options: { + data: pkg + }, + bower: { + files: { + 'bower.json': ['src/meta/bower.json.tmpl'] + } + }, + LICENSE: { + files: { + 'LICENSE': ['src/meta/LICENSE.tmpl'] + } + } + }, + chmod: { + options: { + mode: '444' + }, + dist: ['ZeroClipboard.*', 'bower.json', 'LICENSE'] + }, + nodeunit: { + all: ['test/*.js'] + } + }); + + // These plugins provide necessary tasks + grunt.loadNpmTasks('grunt-contrib-clean'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-nodeunit'); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-mxmlc'); + grunt.loadNpmTasks('grunt-chmod'); + grunt.loadNpmTasks('grunt-template'); + + + // + // Task aliases and chains + // + + // Default task + grunt.registerTask('default', ['jshint', 'clean', 'concat', 'uglify', 'mxmlc', 'template', 'chmod', 'nodeunit']); + + // Other tasks + grunt.registerTask('test', ['jshint', 'nodeunit']); + grunt.registerTask('travis', ['test']); + +}; diff --git a/LICENSE b/LICENSE index db9a8b27..0b66a65b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,9 +1,8 @@ The MIT License (MIT) -Copyright (c) 2013 Jon Rohan, James M. Greene, +Copyright (c) 2013 Jon Rohan, James M. Greene 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: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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. - diff --git a/Makefile b/Makefile deleted file mode 100644 index db415031..00000000 --- a/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -# set an environment variable to override this to your location. export SWF_COMPILER = /My/Location/bin/mxmlc -SWF_COMPILER ?= /Applications/Adobe\ Flash\ Builder\ 4.7/sdks/4.6.0/bin/mxmlc -static-link-runtime-shared-libraries=true - -NODE_PATH = ./node_modules -JS_COMPILER = $(NODE_PATH)/uglify-js/bin/uglifyjs -JS_BEAUTIFIER = $(NODE_PATH)/uglify-js/bin/uglifyjs -b -i 2 -nm -ns -JS_TEST = $(NODE_PATH)/nodeunit/bin/nodeunit -JS_HINT = $(NODE_PATH)/jshint/bin/hint - -all: \ - node_modules \ - ZeroClipboard.min.js \ - ZeroClipboard.swf \ - bower.json \ - LICENSE \ - test \ - -node_modules: Makefile - npm install - -.INTERMEDIATE ZeroClipboard.js: \ - src/javascript/start.js \ - src/javascript/ZeroClipboard/utils.js \ - src/javascript/ZeroClipboard/client.js \ - src/javascript/ZeroClipboard/core.js \ - src/javascript/ZeroClipboard/dom.js \ - src/javascript/ZeroClipboard/event.js \ - src/javascript/end.js - -ZeroClipboard.js: - @rm -f $@ - cat $^ | node src/build.js | $(JS_BEAUTIFIER) > $@ - @chmod a-w $@ - -ZeroClipboard.min.js: ZeroClipboard.js - @rm -f $@ - $(JS_COMPILER) ./ZeroClipboard.js > $@ - @chmod a-w $@ - -ZeroClipboard.swf: src/flash/ZeroClipboard.as - @rm -f $@ - $(SWF_COMPILER) -output $@ $^ -source-path src/flash - @chmod a-w $@ - -LICENSE: Makefile - @rm -f $@ - cat ./src/license.js | node src/build.js > $@ - @chmod a-w $@ - -bower.json: Makefile - @rm -f $@ - cat ./src/bower.js | node src/build.js > $@ - @chmod a-w $@ - -test: ZeroClipboard.min.js - $(JS_HINT) ./src/javascript/ZeroClipboard/*.js - $(JS_TEST) ./test - -clean: - rm -rf ./bower.json ./ZeroClipboard* ./LICENSE - -.PHONY: all test clean diff --git a/ZeroClipboard.js b/ZeroClipboard.js index 4e1e108d..b1fb7f88 100644 --- a/ZeroClipboard.js +++ b/ZeroClipboard.js @@ -1,11 +1,12 @@ /*! - * zeroclipboard - * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie, and a JavaScript interface. - * Copyright 2013 Jon Rohan, James M. Greene, . - * Released under the MIT license - * http://zeroclipboard.github.io/ZeroClipboard/ - * v1.2.0-beta.4 - */(function() { +* ZeroClipboard +* The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface. +* Copyright (c) 2013 Jon Rohan, James M. Greene +* Licensed MIT +* http://zeroclipboard.github.io/ZeroClipboard/ +* v1.2.0-beta.4 (2013-08-23) +*/ +(function() { "use strict"; var _camelizeCssPropName = function() { var matcherRegex = /\-([a-z])/g, replacerFn = function(match, group) { @@ -158,7 +159,7 @@ var _noCache = function(path) { var client = ZeroClipboard.prototype._singleton; if (client.options.useNoCache) { - return (path.indexOf("?") >= 0 ? "&nocache=" : "?nocache=") + (new Date).getTime(); + return (path.indexOf("?") >= 0 ? "&nocache=" : "?nocache=") + new Date().getTime(); } else { return ""; } @@ -373,19 +374,24 @@ } this.htmlBridge.setAttribute("data-clipboard-ready", true); break; + case "mouseover": _addClass(element, this.options.hoverClass); break; + case "mouseout": _removeClass(element, this.options.hoverClass); this.resetBridge(); break; + case "mousedown": _addClass(element, this.options.activeClass); break; + case "mouseup": _removeClass(element, this.options.activeClass); break; + case "datarequested": var targetId = element.getAttribute("data-clipboard-target"), targetEl = !targetId ? null : document.getElementById(targetId); if (targetEl) { @@ -397,6 +403,7 @@ } performCallbackAsync = false; break; + case "complete": this.options.text = null; break; diff --git a/ZeroClipboard.min.js b/ZeroClipboard.min.js index 90385200..56ed1708 100644 --- a/ZeroClipboard.min.js +++ b/ZeroClipboard.min.js @@ -1,8 +1,9 @@ /*! - * zeroclipboard - * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie, and a JavaScript interface. - * Copyright 2013 Jon Rohan, James M. Greene, . - * Released under the MIT license - * http://zeroclipboard.github.io/ZeroClipboard/ - * v1.2.0-beta.4 - */(function(){"use strict";var a=function(){var a=/\-([a-z])/g,b=function(a,b){return b.toUpperCase()};return function(c){return c.replace(a,b)}}(),b=function(b,c){var d,e,f,g,h,i;window.getComputedStyle?d=window.getComputedStyle(b,null).getPropertyValue(c):(e=a(c),b.currentStyle?d=b.currentStyle[e]:d=b.style[e]);if(c==="cursor")if(!d||d==="auto"){f=b.tagName.toLowerCase(),g=["a"];for(h=0,i=g.length;h=0?"&nocache=":"?nocache=")+(new Date).getTime():""},k=function(a){var b=[];if(a.trustedDomains){var c;typeof a.trustedDomains=="string"&&a.trustedDomains?c=[a.trustedDomains]:"length"in a.trustedDomains&&(c=a.trustedDomains),b.push("trustedDomain="+encodeURIComponent(c.join(",")))}return typeof a.amdModuleId=="string"&&a.amdModuleId&&b.push("amdModuleId="+encodeURIComponent(a.amdModuleId)),typeof a.cjsModuleId=="string"&&a.cjsModuleId&&b.push("cjsModuleId="+encodeURIComponent(a.cjsModuleId)),b.join("&")},l=function(a,b){if(b.indexOf)return b.indexOf(a);for(var c=0,d=b.length;c ';b=document.createElement("div"),b.id="global-zeroclipboard-html-bridge",b.setAttribute("class","global-zeroclipboard-container"),b.setAttribute("data-clipboard-ready",!1),b.style.position="absolute",b.style.left="-9999px",b.style.top="-9999px",b.style.width="15px",b.style.height="15px",b.style.zIndex="9999",b.innerHTML=f,document.body.appendChild(b)}a.htmlBridge=b,a.flashBridge=document["global-zeroclipboard-flash-bridge"]||b.children[0].lastElementChild};o.prototype.resetBridge=function(){this.htmlBridge.style.left="-9999px",this.htmlBridge.style.top="-9999px",this.htmlBridge.removeAttribute("title"),this.htmlBridge.removeAttribute("data-clipboard-text"),g(p,this.options.activeClass),p=null,this.options.text=null},o.prototype.ready=function(){var a=this.htmlBridge.getAttribute("data-clipboard-ready");return a==="true"||a===!0},o.prototype.reposition=function(){if(!p)return!1;var a=i(p);this.htmlBridge.style.top=a.top+"px",this.htmlBridge.style.left=a.left+"px",this.htmlBridge.style.width=a.width+"px",this.htmlBridge.style.height=a.height+"px",this.htmlBridge.style.zIndex=a.zIndex+1,this.setSize(a.width,a.height)},o.dispatch=function(a,b){o.prototype._singleton.receiveEvent(a,b)},o.prototype.on=function(a,b){var c=a.toString().split(/\s/g);for(var d=0;dh;h++)if(f===g[h])return"pointer";return d},d=function(a){if(p.prototype._singleton){a||(a=window.event);var b;this!==window?b=this:a.target?b=a.target:a.srcElement&&(b=a.srcElement),p.prototype._singleton.setCurrent(b)}},e=function(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c)},f=function(a,b,c){a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent&&a.detachEvent("on"+b,c)},g=function(a,b){if(a.addClass)return a.addClass(b),a;if(b&&"string"==typeof b){var c=(b||"").split(/\s+/);if(1===a.nodeType)if(a.className){for(var d=" "+a.className+" ",e=a.className,f=0,g=c.length;g>f;f++)d.indexOf(" "+c[f]+" ")<0&&(e+=" "+c[f]);a.className=e.replace(/^\s+|\s+$/g,"")}else a.className=b}return a},h=function(a,b){if(a.removeClass)return a.removeClass(b),a;if(b&&"string"==typeof b||void 0===b){var c=(b||"").split(/\s+/);if(1===a.nodeType&&a.className)if(b){for(var d=(" "+a.className+" ").replace(/[\n\t]/g," "),e=0,f=c.length;f>e;e++)d=d.replace(" "+c[e]+" "," ");a.className=d.replace(/^\s+|\s+$/g,"")}else a.className=""}return a},i=function(){var a,b,c,d=1;return"function"==typeof document.body.getBoundingClientRect&&(a=document.body.getBoundingClientRect(),b=a.right-a.left,c=document.body.offsetWidth,d=Math.round(100*(b/c))/100),d},j=function(a){var b={left:0,top:0,width:0,height:0,zIndex:999999999},d=c(a,"z-index");if(d&&"auto"!==d&&(b.zIndex=parseInt(d,10)),a.getBoundingClientRect){var e,f,g,h=a.getBoundingClientRect();"pageXOffset"in window&&"pageYOffset"in window?(e=window.pageXOffset,f=window.pageYOffset):(g=i(),e=Math.round(document.documentElement.scrollLeft/g),f=Math.round(document.documentElement.scrollTop/g));var j=document.documentElement.clientLeft||0,k=document.documentElement.clientTop||0;b.left=h.left+e-j,b.top=h.top+f-k,b.width="width"in h?h.width:h.right-h.left,b.height="height"in h?h.height:h.bottom-h.top}return b},k=function(a){var b=p.prototype._singleton;return b.options.useNoCache?(a.indexOf("?")>=0?"&nocache=":"?nocache=")+(new Date).getTime():""},l=function(a){var b=[];if(a.trustedDomains){var c;"string"==typeof a.trustedDomains&&a.trustedDomains?c=[a.trustedDomains]:"length"in a.trustedDomains&&(c=a.trustedDomains),b.push("trustedDomain="+encodeURIComponent(c.join(",")))}return"string"==typeof a.amdModuleId&&a.amdModuleId&&b.push("amdModuleId="+encodeURIComponent(a.amdModuleId)),"string"==typeof a.cjsModuleId&&a.cjsModuleId&&b.push("cjsModuleId="+encodeURIComponent(a.cjsModuleId)),b.join("&")},m=function(a,b){if(b.indexOf)return b.indexOf(a);for(var c=0,d=b.length;d>c;c++)if(b[c]===a)return c;return-1},n=function(a){if("string"==typeof a)throw new TypeError("ZeroClipboard doesn't accept query strings.");return a.length?a:[a]},o=function(a,b,c,d,e){e?window.setTimeout(function(){a.call(b,c,d)},0):a.call(b,c,d)},p=function(a,b){if(a&&(p.prototype._singleton||this).glue(a),p.prototype._singleton)return p.prototype._singleton;p.prototype._singleton=this,this.options={};for(var c in s)this.options[c]=s[c];for(var d in b)this.options[d]=b[d];this.handlers={},p.detectFlashSupport()&&v()},q=[];p.prototype.setCurrent=function(b){a=b,this.reposition();var d=b.getAttribute("title");d&&this.setTitle(d);var e=this.options.forceHandCursor===!0||"pointer"===c(b,"cursor");r.call(this,e)},p.prototype.setText=function(a){a&&""!==a&&(this.options.text=a,this.ready()&&this.flashBridge.setText(a))},p.prototype.setTitle=function(a){a&&""!==a&&this.htmlBridge.setAttribute("title",a)},p.prototype.setSize=function(a,b){this.ready()&&this.flashBridge.setSize(a,b)},p.prototype.setHandCursor=function(a){a="boolean"==typeof a?a:!!a,r.call(this,a),this.options.forceHandCursor=a};var r=function(a){this.ready()&&this.flashBridge.setHandCursor(a)};p.version="1.2.0-beta.4";var s={moviePath:"ZeroClipboard.swf",trustedDomains:null,text:null,hoverClass:"zeroclipboard-is-hover",activeClass:"zeroclipboard-is-active",allowScriptAccess:"sameDomain",useNoCache:!0,forceHandCursor:!1};p.setDefaults=function(a){for(var b in a)s[b]=a[b]},p.destroy=function(){p.prototype._singleton.unglue(q);var a=p.prototype._singleton.htmlBridge;a.parentNode.removeChild(a),delete p.prototype._singleton},p.detectFlashSupport=function(){var a=!1;if("function"==typeof ActiveXObject)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash")&&(a=!0)}catch(b){}return!a&&navigator.mimeTypes["application/x-shockwave-flash"]&&(a=!0),a};var t=null,u=null,v=function(){var a=p.prototype._singleton,b=document.getElementById("global-zeroclipboard-html-bridge");if(!b){var c={};for(var d in a.options)c[d]=a.options[d];c.amdModuleId=t,c.cjsModuleId=u;var e=l(c),f=' ';b=document.createElement("div"),b.id="global-zeroclipboard-html-bridge",b.setAttribute("class","global-zeroclipboard-container"),b.setAttribute("data-clipboard-ready",!1),b.style.position="absolute",b.style.left="-9999px",b.style.top="-9999px",b.style.width="15px",b.style.height="15px",b.style.zIndex="9999",b.innerHTML=f,document.body.appendChild(b)}a.htmlBridge=b,a.flashBridge=document["global-zeroclipboard-flash-bridge"]||b.children[0].lastElementChild};p.prototype.resetBridge=function(){this.htmlBridge.style.left="-9999px",this.htmlBridge.style.top="-9999px",this.htmlBridge.removeAttribute("title"),this.htmlBridge.removeAttribute("data-clipboard-text"),h(a,this.options.activeClass),a=null,this.options.text=null},p.prototype.ready=function(){var a=this.htmlBridge.getAttribute("data-clipboard-ready");return"true"===a||a===!0},p.prototype.reposition=function(){if(!a)return!1;var b=j(a);this.htmlBridge.style.top=b.top+"px",this.htmlBridge.style.left=b.left+"px",this.htmlBridge.style.width=b.width+"px",this.htmlBridge.style.height=b.height+"px",this.htmlBridge.style.zIndex=b.zIndex+1,this.setSize(b.width,b.height)},p.dispatch=function(a,b){p.prototype._singleton.receiveEvent(a,b)},p.prototype.on=function(a,b){for(var c=a.toString().split(/\s/g),d=0;dc-oCt-E-5}6~9-ObS2qNY$rG&do(@>@OIh70)o2A6GWi{g&dZWs}|Qut1PwR;F0;3}$Q{+(DsW$yj^_s^9C zoUjNtFaGv9imz|~%>Hm2PW-RRbLP2a+iKTc>KW)yvOY*D}QIz_XkNx#PMvqmKBf)2cHsJ+xiA z>%g#o{I*RG#O=0c1x&1Wg1~ho9kiaX{UAwO#zQy5~7ekkOH z4|?Me)-w;9lNkfuaft7GpwwaktQd0-^LqSDGvnpIa9O}uk4d_IfBj1{;?ow~qyLzi1 z6Mz?#OGS7$od#&Uj_yKFB%Ct@EmTd(V^T}>kL!@@_fE`@y4eDS>*S42` z3Z-K4dZFI2?7(u8U00pJviA-?YpqBVo<+=z-t|F!J1!ErHrr!y%5lty7!Heng?V zOxbd&!Msh!ba~Hp1I6ykN}EQ*3K9B$>A>qi35|-|f;2=woFgJrqks8q0O-uLXI%`5 zy~nIZGms3A?mdP=KrZbjm8fBqo0e?|<*m)~gA9mqO|~qE6iTf;tnO^De_efly8c-1 zu{%$CV5R!(kBf=OF#tA+}aGu}^B1{tDG!f1a;Vco(5%DU)vjoq{bC}?g zTmrfzFX1!ryhiXR1b<5K4U$+U_$I+C1mBWZvAl-mGA80W!5c)rE017Nc@*^T5xhz8 zeS#klyhZRsf*%nK!G1yTPY8ZY@HW9u2;L$1Dan3G@K1^O6~Qlvyhh|Q!8L*@!F9sv zBw>&QBMCDdeN{NjVI=iGGC0Bg7?Vf^B7X!UeiS1igOQlUh~!|;F^uGKjFeLtB@v%T zn4iKEh~v>Dg1t^>6Bws3fnCxlfhBn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r5h^Bl*7XeT>=#SwpumSX#ZUUT)+NK=A z$sF`q?G89K$BvFcuHNG_S0F*H)+G3SfzHKOgMeyoB%0E}KbyA!`7d!Wj;`wi&Nl!6 diff --git a/bower.json b/bower.json index 393f13b3..779981c0 100644 --- a/bower.json +++ b/bower.json @@ -2,4 +2,4 @@ "name": "zeroclipboard", "version": "1.2.0-beta.4", "main": ["./ZeroClipboard.js", "./ZeroClipboard.swf"] -} +} \ No newline at end of file diff --git a/package.json b/package.json index a90ffb5a..0609f7e3 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "zeroclipboard", + "title": "ZeroClipboard", "version": "1.2.0-beta.4", - "main": "./ZeroClipboard.js", - "description": "The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie, and a JavaScript interface.", + "description": "The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.", "keywords": [ "flash", "clipboard", @@ -10,7 +10,12 @@ "paste" ], "homepage": "http://zeroclipboard.github.io/ZeroClipboard/", - "license": "MIT", + "licenses": [ + { + "type": "MIT", + "url": "https://github.com/zeroclipboard/ZeroClipboard/blob/master/LICENSE" + } + ], "contributors": [ { "name": "Jon Rohan", @@ -30,19 +35,26 @@ "send": "0" }, "devDependencies": { - "uglify-js": "1.2.3", - "nodeunit": "0.7.4", - "jshint": "0.9.1", - "handlebars": "1.0.7", - "jsdom": "0.3.4", - "jquery": "1.8.3" + "nodeunit": "~0.8.1", + "jsdom": "~0.8.3", + "jquery": "1.8.3", + "grunt": "~0.4.1", + "grunt-contrib-clean": "~0.5.0", + "grunt-contrib-jshint": "~0.6.3", + "grunt-contrib-nodeunit": "~0.2.0", + "grunt-contrib-concat": "~0.3.0", + "grunt-contrib-uglify": "~0.2.2", + "grunt-chmod": "~1.0.3", + "grunt-mxmlc": "~0.2.0", + "grunt-template": "~0.2.0" }, + "main": "./ZeroClipboard.js", "component": { "scripts": { "zeroclipboard": "ZeroClipboard.js" } }, "scripts": { - "test": "make test" + "test": "grunt travis --verbose" } } diff --git a/src/build.js b/src/build.js deleted file mode 100644 index 841caad1..00000000 --- a/src/build.js +++ /dev/null @@ -1,13 +0,0 @@ -var FILE_ENCODING = 'utf-8'; - -var _handlebars = require('handlebars'), - _fs = require('fs'); - -var distContent = _fs.readFileSync('/dev/stdin', FILE_ENCODING); -var template = _handlebars.compile(distContent); - -//reuse package.json data and add build date -var data = JSON.parse( _fs.readFileSync('package.json', FILE_ENCODING) ); -data.build_date = (new Date()).toUTCString(); - -console.log(template(data)); \ No newline at end of file diff --git a/src/javascript/ZeroClipboard/core.js b/src/javascript/ZeroClipboard/core.js index 594dd91c..52fd52ae 100755 --- a/src/javascript/ZeroClipboard/core.js +++ b/src/javascript/ZeroClipboard/core.js @@ -1,4 +1,4 @@ -ZeroClipboard.version = "{{version}}"; +ZeroClipboard.version = "<%= version %>"; // ZeroClipboard options defaults var _defaults = { moviePath: "ZeroClipboard.swf", // URL to movie diff --git a/src/javascript/start.js b/src/javascript/start.js index 8cd7afcd..a293a861 100644 --- a/src/javascript/start.js +++ b/src/javascript/start.js @@ -1,10 +1,2 @@ -/*! - * {{name}} - * {{description}} - * Copyright 2013 {{#each contributors}}{{name}}, {{/each}}. - * Released under the {{license}} license - * {{homepage}} - * v{{version}} - */ (function () { "use strict"; diff --git a/src/license.js b/src/meta/LICENSE.tmpl similarity index 91% rename from src/license.js rename to src/meta/LICENSE.tmpl index 8c0077f3..9e1dc1c3 100644 --- a/src/license.js +++ b/src/meta/LICENSE.tmpl @@ -1,5 +1,5 @@ The MIT License (MIT) -Copyright (c) 2013 {{#each contributors}}{{name}}, {{/each}} +Copyright (c) <%= grunt.template.today("yyyy") %> <%= _.pluck(contributors, "name").join(", ") %> 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: diff --git a/src/bower.js b/src/meta/bower.json.tmpl similarity index 50% rename from src/bower.js rename to src/meta/bower.json.tmpl index 441b3023..fd0ccbc9 100644 --- a/src/bower.js +++ b/src/meta/bower.json.tmpl @@ -1,5 +1,5 @@ { - "name": "{{name}}", - "version": "{{version}}", + "name": "<%= name %>", + "version": "<%= version %>", "main": ["./ZeroClipboard.js", "./ZeroClipboard.swf"] } \ No newline at end of file diff --git a/src/meta/source-banner.tmpl b/src/meta/source-banner.tmpl new file mode 100644 index 00000000..6e398832 --- /dev/null +++ b/src/meta/source-banner.tmpl @@ -0,0 +1,8 @@ +/*! +* <%= title || name %> +* <%= description %> +* Copyright (c) <%= grunt.template.today("yyyy") %> <%= _.pluck(contributors, "name").join(", ") %> +* Licensed <%= _.pluck(licenses, "type").join(", ") %> +* <%= homepage %> +* v<%= version %> (<%= grunt.template.today("yyyy-mm-dd") %>) +*/ diff --git a/test/.jshintrc b/test/.jshintrc new file mode 100644 index 00000000..459d5b27 --- /dev/null +++ b/test/.jshintrc @@ -0,0 +1,14 @@ +{ + "camelcase": true, + "indent": 2, + "strict": false, + "trailing": true, + "boss": true, + "browser": true, + "node": true, + "multistr": true, + "evil": true, + "globals": { + "$": false + } +} \ No newline at end of file diff --git a/test/client.js b/test/client.js index 1838afbb..2034b399 100644 --- a/test/client.js +++ b/test/client.js @@ -1,6 +1,6 @@ "use strict"; -require("./fixtures/env") +require("./fixtures/env"); var zeroClipboard, clip; exports.client = { @@ -64,7 +64,7 @@ exports.client = { clip.setCurrent(element); - test.equal(clip.htmlBridge.getAttribute("title"), "Click me to copy to clipboard.") + test.equal(clip.htmlBridge.getAttribute("title"), "Click me to copy to clipboard."); clip.resetBridge(); @@ -93,7 +93,7 @@ exports.client = { zeroClipboard.dispatch("datarequested", { flashVersion: "MAC 11,0,0" }); - test.equal(clip.options.text, "Copy me!") + test.equal(clip.options.text, "Copy me!"); clip.resetBridge(); @@ -114,7 +114,7 @@ exports.client = { "quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\n"+ "consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\n"+ "cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non\n"+ - "proident, sunt in culpa qui officia deserunt mollit anim id est laborum.") + "proident, sunt in culpa qui officia deserunt mollit anim id est laborum."); clip.resetBridge(); @@ -135,7 +135,7 @@ exports.client = { "quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\n"+ "consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\n"+ "cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non\n"+ - "proident, sunt in culpa qui officia deserunt mollit anim id est laborum.") + "proident, sunt in culpa qui officia deserunt mollit anim id est laborum."); clip.resetBridge(); @@ -151,7 +151,7 @@ exports.client = { zeroClipboard.dispatch("datarequested", { flashVersion: "MAC 11,0,0" }); - test.equal(clip.options.text, "Clipboard Text") + test.equal(clip.options.text, "Clipboard Text"); clip.resetBridge(); diff --git a/test/core.js b/test/core.js index 866900db..9e783c67 100644 --- a/test/core.js +++ b/test/core.js @@ -1,6 +1,6 @@ "use strict"; -require("./fixtures/env") +require("./fixtures/env"); var zeroClipboard, clip; exports.core = { @@ -96,4 +96,4 @@ exports.core = { zeroClipboard.destroy(); }, -} +}; diff --git a/test/dom.js b/test/dom.js index b115b113..508058d8 100644 --- a/test/dom.js +++ b/test/dom.js @@ -1,6 +1,6 @@ "use strict"; -require("./fixtures/env") +require("./fixtures/env"); var zeroClipboard, clip; exports.dom = { @@ -24,4 +24,4 @@ exports.dom = { test.done(); }, -} \ No newline at end of file +}; \ No newline at end of file diff --git a/test/event.js b/test/event.js index a12ffd62..d92c9b71 100644 --- a/test/event.js +++ b/test/event.js @@ -1,6 +1,6 @@ "use strict"; -require("./fixtures/env") +require("./fixtures/env"); var zeroClipboard, clip; exports.event = { @@ -18,7 +18,7 @@ exports.event = { "Glue element after new client": function (test) { test.expect(2); - clip.glue($("#d_clip_button")) + clip.glue($("#d_clip_button")); // Test the client was created properly test.ok(clip.htmlBridge); @@ -29,7 +29,7 @@ exports.event = { "unglue element removes items": function (test) { test.expect(0); - clip.glue($("#d_clip_button, #d_clip_button2, #d_clip_button3")) + clip.glue($("#d_clip_button, #d_clip_button2, #d_clip_button3")); clip.unglue($("#d_clip_button3, #d_clip_button2")); @@ -39,7 +39,7 @@ exports.event = { "Glue element with query string throws TypeError": function (test) { test.expect(1); test.throws(function(){ - clip.glue("#d_clip_button") + clip.glue("#d_clip_button"); }, TypeError); test.done(); @@ -115,7 +115,7 @@ exports.event = { test.done(); }, - + "Unregistering two events works": function (test) { test.expect(2); var func = function(){}; @@ -224,14 +224,14 @@ exports.event = { zeroClipboard.dispatch("complete", { flashVersion: "MAC 11,0,0" }); zeroClipboard.dispatch("mouseout", { flashVersion: "MAC 11,0,0" }); }, - + "Test onLoad Event with AMD": function (test) { test.expect(4); - + // This is a special private variable inside of ZeroClipboard, so we can // only simulate its functionality here var _amdModuleId = "zc"; - + var requireFn = (function() { var amdCache = {}; amdCache[_amdModuleId] = zeroClipboard; @@ -255,26 +255,24 @@ exports.event = { // fake load event eval( -'\ -(function(eventName, args, amdModuleId) {\ - requireFn([amdModuleId], function(ZeroClipboard) {\ - test.equal(ZeroClipboard, zeroClipboard);\ - test.equal(eventName, "load");\ - test.deepEqual(args, { flashVersion: "MAC 11,0,0" });\ - ZeroClipboard.dispatch(eventName, args);\ - });\ -})("load", { flashVersion: "MAC 11,0,0" }, ' + JSON.stringify(_amdModuleId) + ');\ -' +'(function(eventName, args, amdModuleId) {' + +' requireFn([amdModuleId], function(ZeroClipboard) {' + +' test.equal(ZeroClipboard, zeroClipboard);' + +' test.equal(eventName, "load");' + +' test.deepEqual(args, { flashVersion: "MAC 11,0,0" });' + +' ZeroClipboard.dispatch(eventName, args);' + +' });' + +'})("load", { flashVersion: "MAC 11,0,0" }, ' + JSON.stringify(_amdModuleId) + ');' ); }, - + "Test onLoad Event with CommonJS": function (test) { test.expect(4); - + // This is a special private variable inside of ZeroClipboard, so we can // only simulate its functionality here var _cjsModuleId = "zc"; - + var requireFn = (function() { var cjsCache = {}; cjsCache[_cjsModuleId] = zeroClipboard; @@ -295,16 +293,14 @@ exports.event = { // fake load event eval( -'\ -(function(eventName, args, cjsModuleId) {\ - var ZeroClipboard = requireFn(cjsModuleId);\ - test.equal(ZeroClipboard, zeroClipboard);\ - test.equal(eventName, "load");\ - test.deepEqual(args, { flashVersion: "MAC 11,0,0" });\ - ZeroClipboard.dispatch(eventName, args);\ -})("load", { flashVersion: "MAC 11,0,0" }, ' + JSON.stringify(_cjsModuleId) + ');\ -' +'(function(eventName, args, cjsModuleId) {' + +' var ZeroClipboard = requireFn(cjsModuleId);' + +' test.equal(ZeroClipboard, zeroClipboard);' + +' test.equal(eventName, "load");' + +' test.deepEqual(args, { flashVersion: "MAC 11,0,0" });' + +' ZeroClipboard.dispatch(eventName, args);' + +'})("load", { flashVersion: "MAC 11,0,0" }, ' + JSON.stringify(_cjsModuleId) + ');' ); } -} +}; diff --git a/test/utils.js b/test/utils.js index d80a7902..45f92457 100644 --- a/test/utils.js +++ b/test/utils.js @@ -1,6 +1,6 @@ "use strict"; -require("./fixtures/env") +require("./fixtures/env"); var sandbox = require('nodeunit').utils.sandbox; var ZeroClipboard, clip, _utils; @@ -22,7 +22,7 @@ exports.utils = { ZeroClipboard.destroy(); callback(); }, - + "_camelizeCssPropName converts CSS property names": function (test) { test.expect(3); test.strictEqual(_utils._camelizeCssPropName("z-index"), "zIndex"); @@ -33,10 +33,10 @@ exports.utils = { "_getStyle returns computed styles": function (test) { test.expect(10); - + test.equal(_utils._getStyle($("a.no_cursor_style")[0], "cursor"), "pointer"); test.notEqual(_utils._getStyle($("a.no_pointer_anchor")[0], "cursor"), "pointer"); - + var els = { zIndex: $(".zindex-auto")[0], clipButton: $("#d_clip_button")[0], @@ -44,14 +44,14 @@ exports.utils = { }; // evergreen browsers: `window.getComputedStyle(el, null)` - test.equal(_utils._getStyle(els.zIndex, "z-index"), "auto"); + test.equal(_utils._getStyle(els.zIndex, "z-index"), "auto"); test.equal(_utils._getStyle(els.clipButton, "border-left-width"), 0); test.equal(_utils._getStyle(els.bigBorder, "border-left-width"), 0); // oldIE (IE8-), doesn't exist in jsdom: `el.currentStyle` test.equal(typeof els.zIndex.currentStyle, "undefined"); test.equal(els.zIndex.currentStyle, null); - + // Plain ole `el.style` var tmp = window.getComputedStyle; try { @@ -61,12 +61,12 @@ exports.utils = { test.equal(_utils._getStyle(els.bigBorder, "border-left-width"), 0); } catch (e) { - test.ok(false, "An error occurred: " + e); + test.ok(false, "An error occurred: " + e); } finally { window.getComputedStyle = tmp; } - + test.done(); }, @@ -165,20 +165,20 @@ exports.utils = { "_vars builds flashvars": function (test) { test.expect(5); - + test.strictEqual(_utils._vars(clip.options), ""); clip.options.trustedDomains = ["*"]; test.strictEqual(_utils._vars(clip.options), "trustedDomain=*"); - + clip.options.trustedDomains = null; clip.options.amdModuleId = "zcAMD"; test.strictEqual(_utils._vars(clip.options), "amdModuleId=zcAMD"); - + clip.options.amdModuleId = null; clip.options.cjsModuleId = "zcCJS"; test.strictEqual(_utils._vars(clip.options), "cjsModuleId=zcCJS"); - + clip.options.trustedDomains = ["*"]; clip.options.amdModuleId = "zcAMD"; clip.options.cjsModuleId = "zcCJS"; @@ -220,26 +220,26 @@ exports.utils = { "_dispatchCallback = function (func, element, instance, args, async) {": function (test) { test.expect(6); - + var async = false; var proof = false; var proveIt = function() { proof = true; - + if (async) { test.strictEqual(proof, true); - + process.nextTick(function() { test.strictEqual(proof, true); test.done(); }); } }; - + test.strictEqual(proof, false); _utils._dispatchCallback(proveIt, null, null, null, async); test.strictEqual(proof, true); - + async = true; proof = false; test.strictEqual(proof, false);