Skip to content

Commit

Permalink
Update from js-template
Browse files Browse the repository at this point in the history
Refresh for cohort 013
  • Loading branch information
Antony Donovan committed Jul 19, 2016
1 parent d919713 commit 0b523c3
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"nonew": true,
"strict": "global",
"undef": true,
"unused": true
"unused": true,
"varstmt": true
}
13 changes: 8 additions & 5 deletions forms.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Forms

Developers should use `getFormFields` to retrieve data from html forms for API
requests:
requests.

`getFormFields` only retrieves data from form elements with a name attribute.

The object returned can be used to validate the form data.

**in `api.js`**

Expand All @@ -10,7 +14,6 @@ Developers should use `getFormFields` to retrieve data from html forms for API

const ajaxDefaults = {
url: 'http://localhost:3000',
processData: false,
};

const myRequest = (data, success, fail) => {
Expand All @@ -33,13 +36,13 @@ const success = (data) => {
// handle success
};

const fail = (err) => {
const failure = (err) => {
// handle failure
};

module.exports = {
success,
fail,
failure,
}
```

Expand All @@ -56,7 +59,7 @@ $(() => {
$('#my-form').on('submit', function (e) {
let data = getFormFields(this);
e.preventDefault();
api.myRequest(data, ui.success, ui.fail);
api.myRequest(data, ui.success, ui.failure);
});
});
```
4 changes: 1 addition & 3 deletions grunt/jscs.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"options": {
"config": ".jscsrc",
"esnext": true,
"verbose": true
"config": ".jscsrc"
},

"status": {
Expand Down
9 changes: 5 additions & 4 deletions grunt/webpack-dev-server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

let clone = require('clone');

// clone the webpack config to separate configuration of webpack and dev server
let webpackConfig = clone(require('./webpack').options);

Expand All @@ -9,14 +10,14 @@ webpackConfig.entry.vendor.unshift('webpack-dev-server/client?http://localhost:8

module.exports = {
options: {
webpack: webpackConfig
webpack: webpackConfig,
},

start: {
keepAlive: true,
webpack: {
devtool: 'source-map',
debug: 'true'
}
}
debug: 'true',
},
},
};
40 changes: 20 additions & 20 deletions grunt/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ module.exports = {

output: {
path: './',
filename: '[name].js'
filename: '[name].js',
},

plugins: [
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js'),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery"
})
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
}),
],

module: {
Expand All @@ -32,48 +32,48 @@ module.exports = {
exclude: /(node_modules|bower_components)/,
loader: 'babel',
query: {
presets: ['es2015']
}
presets: ['es2015'],
},
},
{
test: /\.css/,
loader: 'style!css',
includePaths: [path.resolve(__dirname, "./node_modules")]
includePaths: [path.resolve(__dirname, './node_modules')],
},
{
test: /\.scss/,
loader: 'style!css!sass',
includePaths: [path.resolve(__dirname, "./node_modules")]
includePaths: [path.resolve(__dirname, './node_modules')],
},
{
test: /\.woff[\d]?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff"
loader: 'url-loader?limit=10000&mimetype=application/font-woff',
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "file-loader"
test: /\.(ttf|eot|svg|png|jpg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader',
},
{
test: /\.(hbs|handlebars)$/,
loader: 'handlebars-loader'
loader: 'handlebars-loader',
},
{
test: /\.html\.(hbs|handlebars)$/,
loader: 'handlebars-loader!html'
}
]
loader: 'handlebars-loader!html',
},
],
},

stats: {
colors: true,
modules: true,
reasons: true
}
reasons: true,
},
},

build: {
failOnError: true,
watch: false,
keepalive: false
}
keepalive: false,
},
};
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@
"private": true,
"license": "MIT",
"dependencies": {
"jquery": "^2.2.2"
"jquery": "^2.2.0"
},
"devDependencies": {
"babel-core": "^6.7.4",
"babel-core": "^6.10.4",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-es2015": "^6.9.0",
"bootstrap-sass": "^3.3.6",
"clone": "^1.0.2",
"css-loader": "^0.23.1",
"expose-loader": "^0.7.1",
"file-loader": "^0.8.5",
"grunt": "^0.4.5",
"grunt-concurrent": "^2.2.1",
"grunt-contrib-jasmine": "^1.0.0",
"file-loader": "^0.9.0",
"grunt": "^1.0.1",
"grunt-concurrent": "^2.3.0",
"grunt-contrib-jasmine": "^1.0.3",
"grunt-contrib-jshint": "^1.0.0",
"grunt-jscs": "^2.8.0",
"grunt-jsonlint": "^1.0.7",
"grunt-nodemon": "^0.4.1",
"grunt-jscs": "^3.0.1",
"grunt-jsonlint": "^1.1.0",
"grunt-nodemon": "^0.4.2",
"grunt-open": "^0.2.3",
"grunt-webpack": "^1.0.11",
"handlebars": "^4.0.5",
"handlebars-loader": "^1.2.0",
"handlebars-loader": "^1.3.0",
"html-loader": "^0.4.3",
"load-grunt-config": "^0.19.1",
"load-grunt-config": "^0.19.2",
"node-libs-browser": "^1.0.0",
"node-sass": "^3.4.2",
"sass-loader": "^3.2.0",
"node-sass": "^3.8.0",
"sass-loader": "^4.0.0",
"style-loader": "^0.13.1",
"time-grunt": "^1.3.0",
"url-loader": "^0.5.7",
"webpack": "^1.12.14",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1"
}
}

0 comments on commit 0b523c3

Please sign in to comment.