diff --git a/bower.json b/bower.json index a1a2a5b..e6b3917 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "duoshuo", - "version": "0.4.4", + "version": "0.4.5", "authors": [ "turing " ], diff --git a/dist/duoshuo.min.js b/dist/duoshuo.min.js index e7e8422..6878540 100644 --- a/dist/duoshuo.min.js +++ b/dist/duoshuo.min.js @@ -1,2 +1,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},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(attrs){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:'
',link:function(scope,element,attrs){angular.element(element[0]).append($duoshuo.render(attrs))}}})})(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(attrs){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:'
',link:function(scope,element,attrs){angular.element(document).ready(function(){angular.element(element[0]).append($duoshuo.render(attrs))})}}})})(window.angular,window.NProgress); //# sourceMappingURL=duoshuo.min.js.map \ No newline at end of file diff --git a/dist/duoshuo.min.js.map b/dist/duoshuo.min.js.map index 540f1c3..b4e96a5 100644 --- a/dist/duoshuo.min.js.map +++ b/dist/duoshuo.min.js.map @@ -1 +1 @@ -{"version":3,"file":"dist/duoshuo.min.js","sources":["src/duoshuo.js"],"names":["angular","NProgress","Error","NProgressExist","start","done","module","service","$rootScope","self","this","forEach","method","endpoint","data","callback","errorCallback","skipCheck","window","DUOSHUO","API","result","code","errorMessage","response","$apply","err","on","eve","indexOf","e","visitor","render","attrs","threadId","threadKey","createEmbedThread","directive","$duoshuo","restrict","replace","template","link","scope","element","append"],"mappings":"CAAC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,QAC9C,IAAID,MAAME,UAAWrB,KAAK,cAAgBmB,MAAME,SAChD,OAAOjB,QAAOC,QAAQiB,kBAAkB,MAAOtB,SAGlDuB,UAAU,UAAW,SAASC,UAC7B,OACEC,SAAU,KACVC,QAAS,KACTC,SAAU,gCACVC,KAAM,SAASC,MAAOC,QAASX,OAE7BjC,QAAQ4C,QAAQA,QAAQ,IACrBC,OAAOP,SAASN,OAAOC,cAK/Bf,OAAOlB,QAASkB,OAAOjB"} \ No newline at end of file +{"version":3,"file":"dist/duoshuo.min.js","sources":["src/duoshuo.js"],"names":["angular","NProgress","Error","NProgressExist","start","done","module","service","$rootScope","self","this","forEach","method","endpoint","data","callback","errorCallback","skipCheck","window","DUOSHUO","API","result","code","errorMessage","response","$apply","err","on","eve","indexOf","e","visitor","render","attrs","threadId","threadKey","createEmbedThread","directive","$duoshuo","restrict","replace","template","link","scope","element","document","ready","append"],"mappings":"CAAC,SAAUA,QAASC,WAElB,YAEA,KAAKD,QAAS,KAAM,IAAIE,OAAM,uBAC9B,IAAIC,gBAAiBF,WAAaA,UAAUG,OAASH,UAAUI,IAE/DL,SAAQM,OAAO,cACdC,QAAQ,WAAY,SAASC,YAC5B,GAAIC,MAAOC,IAGXV,SAAQW,SAAS,MAAO,OAAQ,QAAS,SAASC,QAChDH,KAAKG,QAAU,SAASC,SAAUC,KAAMC,SAAUC,cAAeC,WAC/D,IAAKC,OAAOC,QAAS,KAAM,IAAIjB,OAAM,6BACrC,IAAIkB,KAAMF,OAAOC,QAAQC,GACzB,KAAKA,IAAK,KAAM,IAAIlB,OAAM,6CAC1B,IAAIC,eAAgBF,UAAUG,OAC9B,OAAOgB,KAAIR,QAAQC,SAAUC,KAAM,SAASO,QAC1C,GAAIlB,eAAgBF,UAAUI,MAC9BU,UACGM,OAAOC,OAAS,EAAK,KAAO,GAAIpB,OAAMmB,OAAOC,KAAO,IAAMD,OAAOE,cAClEF,OAAOG,SACPH,OAEF,KAAKJ,UAAWT,WAAWiB,QAC3B,SACC,SAASC,KACV,GAAIvB,eAAgBF,UAAUI,MAC9B,IAAIW,qBAAuB,iBAAoB,WAAY,CACzD,MAAOA,eAAcU,KAEvB,WAMNhB,MAAKiB,GAAK,SAASC,IAAKb,SAAUE,WAChC,IAAK,QAAS,SAASY,QAAQD,OAAS,EACtC,MAAOb,UAAS,GAAIb,OAAM,mBAC5B,IAAI4B,GAAIF,GACR,IAAIE,IAAM,QAASA,EAAI,OACvB,OAAOZ,QAAOC,QAAQY,QAAQJ,GAAGG,EAAG,WAClC,GAAIrB,MAAOC,IACX,IAAII,MAAOJ,KAAKI,IAChBC,UAAS,KAAMD,KAAML,KACrB,KAAKQ,UAAWT,WAAWiB,QAC3B,UAKJf,MAAKsB,OAAS,SAASC,OACrB,IAAKf,OAAOC,QAAS,KAAM,IAAIjB,OAAM,6BACrC,IAAIY,QACJ,IAAImB,MAAMC,SAAUpB,KAAK,aAAemB,MAAMC,QAC9C,IAAID,MAAME,UAAWrB,KAAK,cAAgBmB,MAAME,SAChD,OAAOjB,QAAOC,QAAQiB,kBAAkB,MAAOtB,SAGlDuB,UAAU,UAAW,SAASC,UAC7B,OACEC,SAAU,KACVC,QAAS,KACTC,SAAU,wCACVC,KAAM,SAASC,MAAOC,QAASX,OAE7BjC,QAAQ4C,QAAQC,UAAUC,MAAM,WAE9B9C,QAAQ4C,QAAQA,QAAQ,IACrBG,OAAOT,SAASN,OAAOC,gBAMjCf,OAAOlB,QAASkB,OAAOjB"} \ No newline at end of file diff --git a/package.json b/package.json index d021792..71602d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-duoshuo", - "version": "0.4.4", + "version": "0.4.5", "description": "a duoshuo SDK for angular.js, pure front-end, cross-domain request supported.", "main": "dist/duoshuo.min.js", "scripts": { diff --git a/src/duoshuo.js b/src/duoshuo.js index 82058db..6915b5c 100644 --- a/src/duoshuo.js +++ b/src/duoshuo.js @@ -63,11 +63,14 @@ return { restrict: 'AE', replace: true, - template: '
', + template: '
', link: function(scope, element, attrs) { // render comments when dom has been injected. - angular.element(element[0]) - .append($duoshuo.render(attrs)); + angular.element(document).ready(function() { + // fired after dom ready + angular.element(element[0]) + .append($duoshuo.render(attrs)); + }); } }; });