Skip to content

Commit

Permalink
Merge branch 'release-2.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
David Kudera committed Jan 22, 2014
2 parents 77072b1 + 7ec73ec commit 466fb67
Show file tree
Hide file tree
Showing 20 changed files with 4,972 additions and 4,905 deletions.
49 changes: 47 additions & 2 deletions README.md
Expand Up @@ -2,24 +2,37 @@
[![Dependency Status](https://gemnasium.com/sakren/node-browser-http.png)](https://gemnasium.com/sakren/node-browser-http)
[![Build Status](https://travis-ci.org/sakren/node-browser-http.png?branch=master)](https://travis-ci.org/sakren/node-browser-http)

[![Donate](http://b.repl.ca/v1/donate-PayPal-brightgreen.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YJCJ4FWVRDT4A)

# http-browser

Simple (but advanced) library for working with http in browser (like for example jQuery.ajax).

http-browser uses [q](https://npmjs.org/package/q) promise pattern and is instance of [EventEmitter](http://nodejs.org/api/events.html).
Can be used for example with [simq](https://npmjs.org/package/simq).
http-browser uses [q](https://github.com/kriskowal/q) promise pattern and is instance of [EventEmitter](http://nodejs.org/api/events.html).

You can use it for example with [simq](https://github.com/sakren/node-simq) as you are used to from node environment or use
standalone build with expanded package into window:

## Installation


```
$ npm install browser-http
```

or for standalone version just choose desired version and include it.
* [Development version](https://github.com/sakren/node-browser-http/blob/master/http.js)
* [Minified version](https://github.com/sakren/node-browser-http/blob/master/http.min.js)


## Usage

```
var http = require('browser-http');
// or standalone version:
var http = window.http; // you can of course just call http directly without window at the beginning
http.request('http://www.google.com', {type: 'GET'}).then(function(response) {
console.log(response.text);
}, function(e) {
Expand Down Expand Up @@ -161,6 +174,11 @@ framework, but can be used on any other project.
new (require('browser-http/Extensions/Loading'));
```

standalone version:
```
new http.Extensions.Loading;
```

Every time new request is send, your cursor is changed into `progress` cursor. After receiving response from server, cursor
is changed into `auto`.

Expand All @@ -170,6 +188,11 @@ is changed into `auto`.
new (require('browser-http/Extensions/Redirect'));
```

standalone version:
```
new http.Extensions.Redirect;
```

If your server sends json data with `redirect` variable, then you will be redirected to address in this variable.

#### Snippets
Expand All @@ -179,6 +202,11 @@ var Snippets = require('browser-http/Extensions/Snippets');
new Snippets(window.jQuery);
```

standalone version:
```
new http.Extensions.Snippets(window.jQuery);
```

If in response data is `snippets` object with html id and content pairs, then browser-http will iterate throw this object,
find element in page with given id and change content of this element into the one from given data.

Expand All @@ -191,6 +219,11 @@ var Links = require('browser-http/Extensions/Links');
new Links(window.jQuery);
```

standalone version:
```
new http.Extensions.Links(window.jQuery);
```

This is not true extension for browser-http. It listen for all click events on `a` links with class `ajax` but not with
class `not-ajax` and after this click, it creates ajax request.

Expand All @@ -207,6 +240,11 @@ var Forms = require('browser-http/Extensions/Forms');
new Forms(window.jQuery);
```

standalone version:
```
new http.Extensions.Forms(window.jQuery);
```

## Tests

```
Expand All @@ -218,6 +256,9 @@ $ npm test
```
var http = require('browser-http/Mocks/Http');
// standalone version:
var http = http.Mocks.Http;
afterEach(function() {
http.restore();
});
Expand Down Expand Up @@ -249,6 +290,10 @@ it('should load some data and check received data', function(done) {

## Changelog

* 2.2.0
+ Added support for environments without `require` (like with [simq](https://github.com/sakren/node-simq))
+ Tests uses minified standalone version of browser-http

* 2.1.1
+ Removed forgotten tests building

Expand Down
13 changes: 13 additions & 0 deletions config/minified.json
@@ -0,0 +1,13 @@
{
"includes": [
"./setup.json"
],
"packages": {
"browser-http": {
"target": "./http.min.js"
}
},
"debugger": {
"minify": true
}
}
21 changes: 21 additions & 0 deletions config/setup.json
@@ -0,0 +1,21 @@
{
"packages": {
"browser-http": {
"modules": [
"events",
"./lib/*.js"
],
"ignore": {
"packageFiles": true
},
"run": [
"/lib/Expand.js"
]
}
},
"debugger": {
"minify": false,
"expose": false,
"filesStats": false
}
}
13 changes: 13 additions & 0 deletions config/source.json
@@ -0,0 +1,13 @@
{
"includes": [
"./setup.json"
],
"packages": {
"browser-http": {
"target": "./http.js"
}
},
"debugger": {
"minify": false
}
}

0 comments on commit 466fb67

Please sign in to comment.