angular-duoshuo
Advanced tools
Comparing version 0.5.0 to 0.5.1
{ | ||
"name": "duoshuo", | ||
"version": "0.5.0", | ||
"authors": [ | ||
@@ -5,0 +4,0 @@ "turing <o.u.turing@gmail.com>" |
@@ -1,2 +0,2 @@ | ||
!function(e,r){"use strict";function o(){function o(e){if(e){if(!e.short_name)throw new Error("duoshuo.config(); `short_name` is required");window.duoshuoQuery=e}}this.config=o,this.$get=["$rootScope",function(o){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 t&&r.start(),c[e](n,i,function(e){t&&r.done(),d(0===e.code?null:new Error(e.code+" "+e.errorMessage),e.response,e),u||o.$apply()},function(e){return t&&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 t=e;return"ready"===t&&(t="reset"),window.DUOSHUO.visitor.on(t,function(){var e=this,t=this.data;r(null,t,e),n||o.$apply()})},n.render=function(){if(!window.DUOSHUO||!window.DUOSHUO.initSelector)throw new Error("createDirective(); duoshuo embed.js is required!");return window.DUOSHUO.initSelector(window.DUOSHUO.selectors[".ds-thread"])},n}]}function n(e){return function(){return{restrict:"AE",replace:!0,template:'<div class="'+e+'">',link:function(){window.DUOSHUO&&window.DUOSHUO.initSelector&&window.DUOSHUO.initSelector(window.DUOSHUO.selectors["."+e])}}}}if(!e)throw new Error("Angular.js required!");var t=r&&r.start&&r.done;e.module("duoshuo",[]).provider("duoshuo",o).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); | ||
!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(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 |
{ | ||
"name": "angular-duoshuo", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "a duoshuo SDK for angular.js, pure front-end, cross-domain request supported.", | ||
@@ -5,0 +5,0 @@ "main": "dist/duoshuo.min.js", |
@@ -105,2 +105,25 @@ ;(function(angular, NProgress) { | ||
function createDirective(type) { | ||
if (type === 'ds-thread') { | ||
return function dsThreadDirective() { | ||
return { | ||
restrict: 'AE', | ||
replace: true, | ||
template: '<div class="ds-thread-wrapper"></div>', | ||
link: function(scope, element, attrs) { | ||
// Render comments when DOM has been injected. | ||
angular.element(document).ready(function() { | ||
var data = {}; | ||
if (attrs.threadId) data['thread-id'] = attrs.threadId; | ||
if (attrs.threadKey) data['thread-key'] = attrs.threadKey; | ||
// Fired after DOM ready | ||
angular | ||
.element(element[0]) | ||
.append(window.DUOSHUO.createEmbedThread('div', data)); | ||
}); | ||
} | ||
}; | ||
}; | ||
} | ||
return function directive() { | ||
@@ -112,8 +135,10 @@ return { | ||
link: function(scope, element, attrs) { | ||
if (!window.DUOSHUO || !window.DUOSHUO.initSelector) | ||
return; | ||
angular.element(document).ready(function() { | ||
if (!window.DUOSHUO || !window.DUOSHUO.initSelector) | ||
return; | ||
// Trigger init selector function | ||
window.DUOSHUO | ||
.initSelector(window.DUOSHUO.selectors['.' + type]) | ||
// Trigger init selector function | ||
window.DUOSHUO | ||
.initSelector(type, window.DUOSHUO.selectors['.' + type]) | ||
}); | ||
} | ||
@@ -120,0 +145,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
14638
160