Skip to content

Commit 6197f93

Browse files
committed
0.2.0: bugfix, access DUOSHUO instance later
ready for bug fix shipping
1 parent d0d18d9 commit 6197f93

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

src/duoshuo.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
;(function(angular, duoshuo, API, configs, NProgress) {
1+
;(function(angular, NProgress) {
22

33
'use strict';
44

55
if (!angular) throw new Error('angular.js required!');
6-
if (!duoshuo) throw new Error('duoshuo embed.js required!');
7-
if (!API) throw new Error('duoshuo embed.js must be unstable version!');
8-
if (!configs) throw new Error('duoshuoQuery object required!');
9-
if (!configs.short_name) throw new Error('duoshuo short_name required!');
10-
11-
var NProgressExist = NProgress && NProgress.start && NProgress.stop;
6+
var NProgressExist = NProgress && NProgress.start && NProgress.done;
127

138
angular.module('duoshuo', [])
149
.service('$duoshuo', function($rootScope) {
@@ -17,9 +12,12 @@
1712
// lowlevel api set
1813
angular.forEach(['get', 'post', 'ajax'], function(method) {
1914
self[method] = function(endpoint, data, callback, skipCheck) {
15+
if (!window.DUOSHUO) throw new Error('duoshuo embed.js required!');
16+
var API = window.DUOSHUO.API;
17+
if (!API) throw new Error('duoshuo embed.js must be unstable version!');
2018
if (NProgressExist) NProgress.start();
2119
return API[method](endpoint, data, function(d) {
22-
if (NProgressExist) NProgress.stop();
20+
if (NProgressExist) NProgress.done();
2321
callback(d);
2422
if (!skipCheck) $rootScope.$apply();
2523
return;
@@ -33,7 +31,7 @@
3331
return callback(new Error('event not found'));
3432
var e = eve;
3533
if (e === 'ready') e = 'reset';
36-
return DUOSHUO.visitor.on(e, function() {
34+
return window.DUOSHUO.visitor.on(e, function() {
3735
var self = this;
3836
var data = this.data;
3937
callback(null, data, self);
@@ -43,10 +41,4 @@
4341
};
4442
});
4543

46-
})(
47-
window.angular,
48-
window.DUOSHUO,
49-
window.DUOSHUO.API,
50-
window.duoshuoQuery,
51-
window.NProgress
52-
);
44+
})(window.angular, window.NProgress);

0 commit comments

Comments
 (0)