Skip to content

Commit

Permalink
0.2: NProgress supported
Browse files Browse the repository at this point in the history
ready for shipping
  • Loading branch information
guo-yu committed Aug 4, 2014
1 parent db6680a commit b81cc14
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "upyun",
"version": "0.1.0",
"version": "0.2.0",
"authors": [
"turing <[email protected]>"
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "upyun-form",
"version": "0.1.0",
"version": "0.2.0",
"description": "a pure front-end upyun form upload service, supports both native js and angular.js",
"main": "src/upyun.js",
"directories": {
Expand Down
5 changes: 5 additions & 0 deletions src/upyun.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
if (!window.JSON) throw new Error('JSON required.');
if (!window.FormData) throw new Error('FormData required.');
if (!window.XMLHttpRequest) throw new Error('XMLHttpRequest required.');
var NProgressExist = NProgress && NProgress.start && NProgress.done;

// inject as a angular module
if (angular) {
Expand Down Expand Up @@ -87,6 +88,7 @@

// when server response
req.addEventListener('load', function(result) {
if (NProgressExist) NProgress.done();
var statusCode = result.target.status;
// trying to parse JSON
if (statusCode !== 200)
Expand All @@ -111,6 +113,9 @@

// send data to server
req.send(data);

// ui trigger
if (NProgressExist) NProgress.start();
};

})(window, window.angular);

0 comments on commit b81cc14

Please sign in to comment.