Permalink
Browse files

Updated Intercooler to support JS and modules.

Updated build system, NPM updated package.json itself, thus reformatting
it as it was not in proper formatting before.

Fixed trailing spaces in intercooler.js as the linter was angry with it.

Brought in grunt-umd and set it up.

Bumped version number by patch as there should be no interface changes.

Ran unit tests, all passed except Coverage (which did not pass before
either).

Ran local testing in ES6 babel system, tests passed.

Committing to GH to submit PR to upstream.
  • Loading branch information...
1 parent 78c4a46 commit 388d61db800d088c5a1103e662c850e3adf1909d @OvermindDL1 OvermindDL1 committed Sep 13, 2016
Showing with 3,546 additions and 24 deletions.
  1. +4 −0 .gitignore
  2. +26 −2 Gruntfile.js
  3. +22 −21 package.json
  4. +1 −1 src/intercooler.js
  5. +1,649 −0 www/release/intercooler-1.0.1.js
  6. +2 −0 www/release/intercooler-1.0.1.min.js
  7. +1,842 −0 www/release/unit-tests-1.0.1.html
View
@@ -5,3 +5,7 @@ www/.last_published
www/_site/
node_modules
rails-demo
+
+# Dist folder is only for deployment to bower/npm/etc...
+# Dist should contain unversioned files as bower/npm/etc is what does the versioning for these files
+/dist/*
View
@@ -3,12 +3,29 @@ module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
+ umd: {
+ intercooler: {
+ options: {
+ src: 'src/intercooler.js',
+ dest: 'www/release/intercooler-<%= pkg.version %>.js',
+ amdModuleId: 'intercooler', // The `require('intercooler')` id used to import, lower-case name is traditional
+ objectToExport: 'Intercooler',
+ globalAlias: 'Intercooler', // Always force an Intercooler object
+ deps: {
+ 'default': [{jquery: '$'}],
+ amd: [{jquery: '$'}],
+ cjs: [{jquery: '$'}],
+ global: [{jQuery: '$'}] // Capital Q because that is how jQuery is in the global scope unlike the others
+ }
+ }
+ }
+ },
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
- src: 'src/intercooler.js',
+ src: 'www/release/intercooler-<%= pkg.version %>.js',
dest: 'www/release/intercooler-<%= pkg.version %>.min.js'
}
},
@@ -30,15 +47,22 @@ module.exports = function (grunt) {
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-regex-replace');
+ grunt.loadNpmTasks('grunt-umd');
+
+ grunt.registerTask('dist', "Copy Distribution files", function () {
+ grunt.file.copy('www/release/intercooler-' + grunt.config.get('pkg').version + '.js', 'dist/intercooler.js');
+ grunt.file.copy('www/release/intercooler-' + grunt.config.get('pkg').version + '.min.js', 'dist/intercooler.min.js');
+ });
grunt.registerTask('release', "Releases a new version of the library", function () {
- grunt.file.copy("src/intercooler.js", 'www/release/intercooler-' + grunt.config.get('pkg').version + '.js');
grunt.file.copy("src/intercooler-debugger.js", 'www/release/intercooler-debugger.js');
grunt.file.copy("test/blanket.min.js", 'www/release/blanket.min.js');
grunt.file.copy("test/jquery.mockjax.js", 'www/release/jquery.mockjax.js');
grunt.file.copy("test/unit_tests.html", 'www/release/unit-tests-' + grunt.config.get('pkg').version + '.html');
+ grunt.task.run('umd:intercooler');
grunt.task.run('uglify');
grunt.task.run('regex-replace');
+ grunt.task.run('dist');
});
// Default task(s).
View
@@ -1,27 +1,28 @@
{
"name": "intercooler",
- "version": "1.0.0",
- "description": "Making AJAX as easy as anchor tags",
- "homepage": "http://intercoolerjs.org",
- "author": {
- "name": "LeadDyno, LLC",
- "url": "http://www.leaddyno.com"
- },
- "keywords": [
- "ajax",
- "anchor",
- "attribute"
- ],
- "license": "MIT",
- "repository": {
- "type": "git",
- "url": "git://github.com/LeadDyno/intercooler-js"
+ "version": "1.0.1",
+ "description": "Making AJAX as easy as anchor tags",
+ "homepage": "http://intercoolerjs.org",
+ "author": {
+ "name": "LeadDyno, LLC",
+ "url": "http://www.leaddyno.com"
+ },
+ "keywords": [
+ "ajax",
+ "anchor",
+ "attribute"
+ ],
+ "license": "MIT",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/LeadDyno/intercooler-js"
},
"devDependencies": {
- "grunt": "~0.4.2",
- "grunt-contrib-jshint": "~0.6.3",
- "grunt-contrib-nodeunit": "~0.2.0",
- "grunt-contrib-uglify": "~0.2.2",
- "grunt-regex-replace": "~0.2.7"
+ "grunt": "^1.0.0",
+ "grunt-contrib-jshint": "^1.0.0",
+ "grunt-contrib-nodeunit": "^1.0.0",
+ "grunt-contrib-uglify": "^2.0.0",
+ "grunt-regex-replace": "^0.3.0",
+ "grunt-umd": "^2.3.6"
}
}
View
@@ -219,7 +219,7 @@ var Intercooler = Intercooler || (function() {
elt.trigger("beforeHeaders.ic", [elt, xhr]);
log(elt, "response headers: " + xhr.getAllResponseHeaders(), "DEBUG");
var target = null;
-
+
// set page title by header
if (xhr.getResponseHeader("X-IC-Title")) {
document.title = xhr.getResponseHeader("X-IC-Title");
Oops, something went wrong.

0 comments on commit 388d61d

Please sign in to comment.