Skip to content

Commit d0d18d9

Browse files
committed
0.2.0: support NProgress
1 parent e205dea commit d0d18d9

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "duoshuo",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"authors": [
55
"turing <o.u.turing@gmail.com>"
66
],

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-duoshuo",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "a duoshuo SDK for angular.js, pure front-end, cross-domain request supported.",
55
"main": "src/duoshuo.js",
66
"scripts": {

src/duoshuo.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
;(function(angular, duoshuo, API, configs) {
1+
;(function(angular, duoshuo, API, configs, NProgress) {
22

33
'use strict';
44

@@ -8,14 +8,18 @@
88
if (!configs) throw new Error('duoshuoQuery object required!');
99
if (!configs.short_name) throw new Error('duoshuo short_name required!');
1010

11+
var NProgressExist = NProgress && NProgress.start && NProgress.stop;
12+
1113
angular.module('duoshuo', [])
1214
.service('$duoshuo', function($rootScope) {
1315
var self = this;
1416

1517
// lowlevel api set
1618
angular.forEach(['get', 'post', 'ajax'], function(method) {
1719
self[method] = function(endpoint, data, callback, skipCheck) {
20+
if (NProgressExist) NProgress.start();
1821
return API[method](endpoint, data, function(d) {
22+
if (NProgressExist) NProgress.stop();
1923
callback(d);
2024
if (!skipCheck) $rootScope.$apply();
2125
return;
@@ -43,5 +47,6 @@
4347
window.angular,
4448
window.DUOSHUO,
4549
window.DUOSHUO.API,
46-
window.duoshuoQuery
50+
window.duoshuoQuery,
51+
window.NProgress
4752
);

0 commit comments

Comments
 (0)