Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Commit

Permalink
Breaking the JS into modular sections
Browse files Browse the repository at this point in the history
Fixes #339.
Fixes #312.
  • Loading branch information
JamesMGreene committed May 19, 2014
1 parent 7702ca7 commit 75ff45d
Show file tree
Hide file tree
Showing 58 changed files with 8,335 additions and 14,354 deletions.
3 changes: 1 addition & 2 deletions .jshintrc
Expand Up @@ -58,6 +58,5 @@
"noyield": false,

/* Environments */
"browser": true,
"nonstandard": true
"browser": true
}
181 changes: 126 additions & 55 deletions Gruntfile.js
Expand Up @@ -18,23 +18,24 @@ module.exports = function(grunt) {
var localPort = 7320; // "ZERO"

// Project configuration.
grunt.initConfig({
var config = {
// Task configuration
jshint: {
options: {
jshintrc: true
},
Gruntfile: ["Gruntfile.js"],
js: ["src/javascript/ZeroClipboard/**/*.js"],
test: ["test/*.js"]
js: ["src/javascript/**/*.js", "!src/javascript/start.js", "!src/javascript/end.js"],
test: ["test/**/*.js"],
dist: ["dist/*.js", "!dist/*.min.js"]
},
flexpmd: {
flash: {
src: [flashTmpDir]
}
},
clean: {
dist: ["ZeroClipboard.*"],
dist: ["ZeroClipboard.*", "dist/ZeroClipboard.*"],
flash: {
options: {
// Force is required when trying to clean outside of the project dir
Expand All @@ -46,63 +47,84 @@ module.exports = function(grunt) {
},
concat: {
options: {
stripBanners: true,
stripBanners: false,
process: {
data: pkg
}
},
js: {
core: {
src: [
"src/meta/source-banner.tmpl",
"src/javascript/start.js",
"src/javascript/ZeroClipboard/state.js",
"src/javascript/ZeroClipboard/utils.js",
"src/javascript/ZeroClipboard/flash.js",
"src/javascript/ZeroClipboard/client.js",
"src/javascript/ZeroClipboard/core.js",
"src/javascript/ZeroClipboard/dom.js",
"src/javascript/ZeroClipboard/event.js",
"src/javascript/ZeroClipboard/deprecated.js",
"src/javascript/shared/state.js",
"src/javascript/shared/private.js",
"src/javascript/core/state.js",
"src/javascript/core/private.js",
"src/javascript/core/api.js",
"src/javascript/end.js"
],
dest: "ZeroClipboard.js"
},
flashMain: {
src: [
"src/meta/source-banner.tmpl",
"src/flash/ZeroClipboard.as"
],
dest: path.join(flashTmpDir, "ZeroClipboard.as")
},
flashClip: {
src: [
"src/meta/source-banner.tmpl",
"src/flash/ClipboardInjector.as"
],
dest: path.join(flashTmpDir, "ClipboardInjector.as")
dest: "dist/ZeroClipboard.Core.js"
},
flashJs: {
client: {
src: [
"src/meta/source-banner.tmpl",
"src/flash/JsProxy.as"
"src/javascript/start.js",
"src/javascript/shared/state.js",
"src/javascript/shared/private.js",
"src/javascript/core/state.js",
"src/javascript/core/private.js",
"src/javascript/core/api.js",
"src/javascript/client/state.js",
"src/javascript/client/private.js",
"src/javascript/client/api.js",
"src/javascript/end.js"
],
dest: path.join(flashTmpDir, "JsProxy.as")
dest: "dist/ZeroClipboard.js"
},
flashXss: {
src: [
"src/meta/source-banner.tmpl",
"src/flash/XssUtils.as"
],
dest: path.join(flashTmpDir, "XssUtils.as")
flash: {
files: [
{
src: [
"src/meta/source-banner.tmpl",
"src/flash/ZeroClipboard.as"
],
dest: path.join(flashTmpDir, "ZeroClipboard.as")
},
{
src: [
"src/meta/source-banner.tmpl",
"src/flash/ClipboardInjector.as"
],
dest: path.join(flashTmpDir, "ClipboardInjector.as")
},
{
src: [
"src/meta/source-banner.tmpl",
"src/flash/JsProxy.as"
],
dest: path.join(flashTmpDir, "JsProxy.as")
},
{
src: [
"src/meta/source-banner.tmpl",
"src/flash/XssUtils.as"
],
dest: path.join(flashTmpDir, "XssUtils.as")
}
]
}
},
uglify: {
options: {
preserveComments: "some",
report: "min"
},
js: {
options: {
preserveComments: function(node, comment) {
return comment &&
comment.type === "comment2" &&
/^(!|\*|\*!)\r?\n/.test(comment.value);
},
beautify: {
beautify: true,
// `indent_level` requires jshint -W106
Expand All @@ -111,12 +133,40 @@ module.exports = function(grunt) {
mangle: false,
compress: false
},
src: ["ZeroClipboard.js"],
dest: "ZeroClipboard.js"
files: [
{
src: ["<%= concat.core.dest %>"],
dest: "<%= concat.core.dest %>"
},
{
src: ["<%= concat.client.dest %>"],
dest: "<%= concat.client.dest %>"
}
]
},
minjs: {
src: ["ZeroClipboard.js"],
dest: "ZeroClipboard.min.js"
options: {
preserveComments: function(node, comment) {
return comment &&
comment.type === "comment2" &&
/^(!|\*!)\r?\n/.test(comment.value);
},
sourceMap: true,
// Bundles the contents of "`src`" into the "`dest`.map" source map file. This way,
// consumers only need to host the "*.min.js" and "*.min.map" files rather than
// needing to host all three files: "*.js", "*.min.js", and "*.min.map".
sourceMapIncludeSources: true
},
files: [
{
src: ["<%= concat.core.dest %>"],
dest: "dist/ZeroClipboard.Core.min.js"
},
{
src: ["<%= concat.client.dest %>"],
dest: "dist/ZeroClipboard.min.js"
}
]
}
},
mxmlc: {
Expand All @@ -125,7 +175,7 @@ module.exports = function(grunt) {
},
swf: {
files: {
"ZeroClipboard.swf": ["<%= concat.flashMain.dest %>"]
"dist/ZeroClipboard.swf": ["<%= concat.flash.files[0].dest %>"]
}
}
},
Expand Down Expand Up @@ -153,7 +203,7 @@ module.exports = function(grunt) {
options: {
mode: "444"
},
dist: ["ZeroClipboard.*"],
dist: ["dist/ZeroClipboard.*"],
meta: ["bower.json", "composer.json", "LICENSE"]
},
connect: {
Expand All @@ -164,12 +214,31 @@ module.exports = function(grunt) {
}
},
qunit: {
file: ["test/**/*.js.html"],
file: [
"test/shared/private.tests.js.html",
"test/core/private.tests.js.html",
"test/core/api.tests.js.html",
"test/client/private.tests.js.html",
"test/client/api.tests.js.html",
"test/built/ZeroClipboard.Core.tests.js.html",
"test/built/ZeroClipboard.tests.js.html"
//"test/**/*.tests.js.html"
],
http: {
options: {
urls: grunt.file.expand(["test/**/*.js.html"]).map(function(testPage) {
return "http://localhost:" + localPort + "/" + testPage + "?noglobals=true";
})
urls:
grunt.file.expand([
"test/shared/private.tests.js.html",
"test/core/private.tests.js.html",
"test/core/api.tests.js.html",
"test/client/private.tests.js.html",
"test/client/api.tests.js.html",
"test/built/ZeroClipboard.Core.tests.js.html",
"test/built/ZeroClipboard.tests.js.html"
//"test/**/*.tests.js.html"
]).map(function(testPage) {
return "http://localhost:" + localPort + "/" + testPage + "?noglobals=true";
})
}
}
},
Expand All @@ -190,7 +259,8 @@ module.exports = function(grunt) {
tasks: ["jshint:test", "unittest"]
}
}
});
};
grunt.initConfig(config);

// These plugins provide necessary tasks
grunt.loadNpmTasks("grunt-contrib-jshint");
Expand All @@ -209,11 +279,12 @@ module.exports = function(grunt) {
//
// Task aliases and chains
//
grunt.registerTask("prep-flash", ["clean:flash", "concat:flashMain", "concat:flashClip", "concat:flashJs", "concat:flashXss"]);
grunt.registerTask("validate", ["jshint", "prep-flash", "flexpmd"]);
grunt.registerTask("build", ["clean", "concat", "uglify", "mxmlc", "template", "chmod"]);
grunt.registerTask("build-travis", ["clean:dist", "concat", "mxmlc", "chmod:dist"]);
grunt.registerTask("test", ["connect", "qunit"]);
grunt.registerTask("jshint-prebuild", ["jshint:Gruntfile", "jshint:js", "jshint:test"]);
grunt.registerTask("prep-flash", ["clean:flash", "concat:flash"]);
grunt.registerTask("validate", ["jshint-prebuild", "prep-flash", "flexpmd"]);
grunt.registerTask("build", ["clean", "concat", "jshint:dist", "uglify", "mxmlc", "template", "chmod"]);
grunt.registerTask("build-travis", ["clean:dist", "concat", "jshint:dist", "mxmlc", "chmod:dist"]);
grunt.registerTask("test", ["connect", "qunit"]);

// Default task
grunt.registerTask("default", ["validate", "build", "test"]);
Expand Down
9 changes: 0 additions & 9 deletions ZeroClipboard.min.js

This file was deleted.

Binary file removed ZeroClipboard.swf
Binary file not shown.
2 changes: 1 addition & 1 deletion bower.json
Expand Up @@ -2,7 +2,7 @@
"name": "zeroclipboard",
"description": "The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.",
"version": "2.0.0-beta.5",
"main": ["./ZeroClipboard.js", "./ZeroClipboard.swf"],
"main": ["./dist/ZeroClipboard.js", "./dist/ZeroClipboard.swf"],
"keywords": ["flash","clipboard","copy","cut","paste","zclip","clip","clippy"],
"license": "https://github.com/zeroclipboard/zeroclipboard/blob/master/LICENSE",
"authors": [{"name":"Jon Rohan","url":"http://jonrohan.me/"},{"name":"James M. Greene","email":"james.m.greene@gmail.com","url":"http://jamesgreene.net/"}],
Expand Down
70 changes: 70 additions & 0 deletions dist/.jshintrc
@@ -0,0 +1,70 @@
{
/* Enforcing options */
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"es3": true,
"es5": false,
"forin": true,
"freeze": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"noempty": true,
"nonbsp": true,
"nonew": true,
"plusplus": false,
"quotmark": "double",
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"maxparams": 4,
"maxdepth": 5,
"maxstatements": false,
"maxlen": false, /* IDEAL: 120? */


/* Relaxing options */
"asi": false,
"boss": false,
"debug": false,
"eqnull": true,
"esnext": false,
"evil": false,
"expr": false,
"funcscope": false,
"gcl": false,
"globalstrict": false,
"iterator": false,
"lastsemic": false,
"laxbreak": false,
"laxcomma": false,
"loopfunc": false,
"maxerr": 50,
"moz": false,
"multistr": false,
"notypeof": false,
"proto": false,
"scripturl": false,
"smarttabs": false,
"shadow": false,
"sub": false,
"supernew": false,
"validthis": false,
"noyield": false,

/* Environments */
"browser": true,

/* Global variables */
"globals": {
/* AMD */
"define": false,
/* CommonJS */
"module": false
}
}

0 comments on commit 75ff45d

Please sign in to comment.