Skip to content

Commit

Permalink
Updated Intercooler to support JS and modules.
Browse files Browse the repository at this point in the history
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
OvermindDL1 committed Sep 13, 2016
1 parent 78c4a46 commit 388d61d
Show file tree
Hide file tree
Showing 7 changed files with 3,546 additions and 24 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -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/*
28 changes: 26 additions & 2 deletions Gruntfile.js
Expand Up @@ -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'
}
},
Expand All @@ -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).
Expand Down
43 changes: 22 additions & 21 deletions package.json
@@ -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"
}
}
2 changes: 1 addition & 1 deletion src/intercooler.js
Expand Up @@ -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");
Expand Down

0 comments on commit 388d61d

Please sign in to comment.