angular-duoshuo
Advanced tools
Comparing version 0.3.0 to 0.4.0
{ | ||
"name": "duoshuo", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"authors": [ | ||
@@ -8,3 +8,3 @@ "turing <o.u.turing@gmail.com>" | ||
"description": "a duoshuo SDK for angular.js, pure front-end, cross-domain request supported.", | ||
"main": "src/duoshuo.js", | ||
"main": "dist/duoshuo.min.js", | ||
"keywords": [ | ||
@@ -11,0 +11,0 @@ "duoshuo", |
@@ -1,2 +0,2 @@ | ||
(function(angular,NProgress){"use strict";if(!angular)throw new Error("angular.js required!");var NProgressExist=NProgress&&NProgress.start&&NProgress.done;angular.module("duoshuo",[]).service("$duoshuo",function($rootScope){var self=this;angular.forEach(["get","post","ajax"],function(method){self[method]=function(endpoint,data,callback,errorCallback,skipCheck){if(!window.DUOSHUO)throw new Error("duoshuo embed.js required!");var API=window.DUOSHUO.API;if(!API)throw new Error("duoshuo embed.js must be unstable version!");if(NProgressExist)NProgress.start();return API[method](endpoint,data,function(result){if(NProgressExist)NProgress.done();callback(result.code===0?null:new Error(result.code+" "+result.errorMessage),result.response,result);if(!skipCheck)$rootScope.$apply();return},errorCallback)}});this.on=function(eve,callback,skipCheck){if(["reset","ready"].indexOf(eve)===0)return callback(new Error("event not found"));var e=eve;if(e==="ready")e="reset";return window.DUOSHUO.visitor.on(e,function(){var self=this;var data=this.data;callback(null,data,self);if(!skipCheck)$rootScope.$apply();return})}})})(window.angular,window.NProgress); | ||
(function(angular,NProgress){"use strict";if(!angular)throw new Error("angular.js required!");var NProgressExist=NProgress&&NProgress.start&&NProgress.done;angular.module("duoshuo",[]).service("$duoshuo",function($rootScope){var self=this;angular.forEach(["get","post","ajax"],function(method){self[method]=function(endpoint,data,callback,errorCallback,skipCheck){if(!window.DUOSHUO)throw new Error("duoshuo embed.js required!");var API=window.DUOSHUO.API;if(!API)throw new Error("duoshuo embed.js must be unstable version!");if(NProgressExist)NProgress.start();return API[method](endpoint,data,function(result){if(NProgressExist)NProgress.done();callback(result.code===0?null:new Error(result.code+" "+result.errorMessage),result.response,result);if(!skipCheck)$rootScope.$apply();return},errorCallback)}});this.on=function(eve,callback,skipCheck){if(["reset","ready"].indexOf(eve)===0)return callback(new Error("event not found"));var e=eve;if(e==="ready")e="reset";return window.DUOSHUO.visitor.on(e,function(){var self=this;var data=this.data;callback(null,data,self);if(!skipCheck)$rootScope.$apply();return})};this.render=function(element){if(!window.DUOSHUO)throw new Error("duoshuo embed.js required!");window.DUOSHUO.EmbedThread(element)}}).directive("duoshuo",function($duoshuo){return{restrict:"AE",replace:true,template:'<div class="ds-thread"></div>',link:function(scope,element,attrs){$duoshuo.render(element[0])}}})})(window.angular,window.NProgress); | ||
//# sourceMappingURL=duoshuo.min.js.map |
{ | ||
"name": "angular-duoshuo", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "a duoshuo SDK for angular.js, pure front-end, cross-domain request supported.", | ||
"main": "src/duoshuo.js", | ||
"main": "dist/duoshuo.min.js", | ||
"scripts": { | ||
@@ -7,0 +7,0 @@ "serve": "node_modules/.bin/serve .", |
@@ -1,2 +0,2 @@ | ||
## angular-duoshuo ![release](http://img.shields.io/github/release/duoshuo/angular-duoshuo.svg) ![npm](http://img.shields.io/npm/v/angular-duoshuo.svg) | ||
## angular-duoshuo ![release](http://img.shields.io/github/release/duoshuo/angular-duoshuo.svg?style=flat) ![npm](http://img.shields.io/npm/v/angular-duoshuo.svg?style=flat) | ||
@@ -3,0 +3,0 @@ a duoshuo SDK for angular.js, pure front-end, cross-domain request supported. |
@@ -46,4 +46,21 @@ ;(function(angular, NProgress) { | ||
}; | ||
// comments renderer | ||
this.render = function(element) { | ||
if (!window.DUOSHUO) throw new Error('duoshuo embed.js required!'); | ||
window.DUOSHUO.EmbedThread(element); | ||
}; | ||
}) | ||
.directive('duoshuo', function($duoshuo){ | ||
return { | ||
restrict: 'AE', | ||
replace: true, | ||
template: '<div class="ds-thread"></div>', | ||
link: function(scope, element, attrs) { | ||
// render comments when dom has been injected. | ||
$duoshuo.render(element[0]); | ||
} | ||
}; | ||
}); | ||
})(window.angular, window.NProgress); |
Sorry, the diff of this file is not supported yet
10502
93