diff --git a/bower.json b/bower.json index 202ec03..89d002f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "upyun", - "version": "0.1.0", + "version": "0.2.0", "authors": [ "turing " ], diff --git a/package.json b/package.json index 9127f74..ee08321 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/upyun.js b/src/upyun.js index 9f798c3..b87c5c1 100644 --- a/src/upyun.js +++ b/src/upyun.js @@ -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) { @@ -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) @@ -111,6 +113,9 @@ // send data to server req.send(data); + + // ui trigger + if (NProgressExist) NProgress.start(); }; })(window, window.angular);