angular-duoshuo
Version:
a duoshuo SDK for angular.js, pure front-end, cross-domain request supported.
2 lines • 2.18 kB
JavaScript
!function(e,r){"use strict";function t(){function t(e){if(e){if(!e.short_name)throw new Error("duoshuo.config(); `short_name` is required");window.duoshuoQuery=e}}this.config=t,this.$get=["$rootScope",function(t){var n={};return e.forEach(["get","post","ajax"],function(e){n[e]=function(n,i,d,s,u){if(!window.DUOSHUO)throw new Error("duoshuo embed.js is required!");var c=window.DUOSHUO.API;if(!c)throw new Error("duoshuo embed.js must be unstable version!");return o&&r.start(),c[e](n,i,function(e){o&&r.done(),d(0===e.code?null:new Error(e.code+" "+e.errorMessage),e.response,e),u||t.$apply()},function(e){return o&&r.done(),s&&"function"==typeof s?s(e):void 0})}}),n.on=function(e,r,n){if(0===["reset","ready"].indexOf(e))return r(new Error("event not found"));var o=e;return"ready"===o&&(o="reset"),window.DUOSHUO.visitor.on(o,function(){var e=this,o=this.data;r(null,o,e),n||t.$apply()})},n.render=function(){if(!window.DUOSHUO||!window.DUOSHUO.initSelector)throw new Error("createDirective(); duoshuo embed.js is required!");return window.DUOSHUO.initSelector(".ds-thread",window.DUOSHUO.selectors[".ds-thread"])},n}]}function n(r){return"ds-thread"===r?function(){return{restrict:"AE",replace:!0,template:'<div class="ds-thread-wrapper"></div>',link:function(r,t,n){e.element(document).ready(function(){var r={};n.threadId&&(r["thread-id"]=n.threadId),n.threadKey&&(r["thread-key"]=n.threadKey),e.element(t[0]).append(window.DUOSHUO.createEmbedThread("div",r))})}}}:function(){return{restrict:"AE",replace:!0,template:'<div class="'+r+'">',link:function(){e.element(document).ready(function(){window.DUOSHUO&&window.DUOSHUO.initSelector&&window.DUOSHUO.initSelector("."+r,window.DUOSHUO.selectors["."+r])})}}}}if(!e)throw new Error("Angular.js required!");var o=r&&r.start&&r.done;e.module("duoshuo",[]).provider("duoshuo",t).directive("dsThread",n("ds-thread")).directive("dsRecentComments",n("ds-recent-comments")).directive("dsRecentVisitors",n("ds-recent-visitors")).directive("dsThreadCount",n("ds-thread-count")).directive("dsTopThreads",n("ds-top-threads")).directive("dsLogin",n("ds-login"))}(window.angular,window.NProgress);
//# sourceMappingURL=duoshuo.min.js.map