angular-duoshuo
Advanced tools
Comparing version 0.4.0 to 0.4.2
{ | ||
"name": "duoshuo", | ||
"version": "0.4.0", | ||
"version": "0.4.2", | ||
"authors": [ | ||
@@ -5,0 +5,0 @@ "turing <o.u.turing@gmail.com>" |
@@ -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})};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); | ||
(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},function(err){if(NProgressExist)NProgress.done();if(errorCallback&&typeof errorCallback==="function"){return errorCallback(err)}return})}});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!");var data={};if(attrs.threadId)data["thread-id"]=attrs.threadId;if(attrs.threadKey)data["thread-key"]=attrs.threadKey;return window.DUOSHUO.createEmbedThread("div",data)}}).directive("duoshuo",function($duoshuo){return{restrict:"AE",replace:true,template:'<div class="ds-thread"></div>',link:function(scope,element,attrs){angular.element(element[0]).append($duoshuo.render(attrs))}}})})(window.angular,window.NProgress); | ||
//# sourceMappingURL=duoshuo.min.js.map |
{ | ||
"name": "angular-duoshuo", | ||
"version": "0.4.0", | ||
"version": "0.4.2", | ||
"description": "a duoshuo SDK for angular.js, pure front-end, cross-domain request supported.", | ||
@@ -5,0 +5,0 @@ "main": "dist/duoshuo.min.js", |
@@ -28,3 +28,9 @@ ;(function(angular, NProgress) { | ||
return; | ||
}, errorCallback); | ||
}, function(err) { | ||
if (NProgressExist) NProgress.done(); | ||
if (errorCallback && typeof(errorCallback) === 'function') { | ||
return errorCallback(err); | ||
} | ||
return; | ||
}); | ||
} | ||
@@ -51,3 +57,6 @@ }); | ||
if (!window.DUOSHUO) throw new Error('duoshuo embed.js required!'); | ||
window.DUOSHUO.EmbedThread(element); | ||
var data = {}; | ||
if (attrs.threadId) data['thread-id'] = attrs.threadId; | ||
if (attrs.threadKey) data['thread-key'] = attrs.threadKey; | ||
return window.DUOSHUO.createEmbedThread('div', data); | ||
}; | ||
@@ -62,3 +71,4 @@ }) | ||
// render comments when dom has been injected. | ||
$duoshuo.render(element[0]); | ||
angular.element(element[0]) | ||
.append($duoshuo.render(attrs)); | ||
} | ||
@@ -65,0 +75,0 @@ }; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11466
104