Skip to content

Commit ea9cb4a

Browse files
committed
Bugfix: fix dynamic params render in ds-thread
1 parent 5817839 commit ea9cb4a

5 files changed

Lines changed: 33 additions & 9 deletions

File tree

bower.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "duoshuo",
3-
"version": "0.5.0",
43
"authors": [
54
"turing <o.u.turing@gmail.com>"
65
],

dist/duoshuo.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/duoshuo.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-duoshuo",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"description": "a duoshuo SDK for angular.js, pure front-end, cross-domain request supported.",
55
"main": "dist/duoshuo.min.js",
66
"scripts": {

src/duoshuo.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,43 @@
102102
}
103103

104104
function createDirective(type) {
105+
if (type === 'ds-thread') {
106+
return function dsThreadDirective() {
107+
return {
108+
restrict: 'AE',
109+
replace: true,
110+
template: '<div class="ds-thread-wrapper"></div>',
111+
link: function(scope, element, attrs) {
112+
// Render comments when DOM has been injected.
113+
angular.element(document).ready(function() {
114+
var data = {};
115+
if (attrs.threadId) data['thread-id'] = attrs.threadId;
116+
if (attrs.threadKey) data['thread-key'] = attrs.threadKey;
117+
118+
// Fired after DOM ready
119+
angular
120+
.element(element[0])
121+
.append(window.DUOSHUO.createEmbedThread('div', data));
122+
});
123+
}
124+
};
125+
};
126+
}
127+
105128
return function directive() {
106129
return {
107130
restrict: 'AE',
108131
replace: true,
109132
template: '<div class="' + type + '">',
110133
link: function(scope, element, attrs) {
111-
if (!window.DUOSHUO || !window.DUOSHUO.initSelector)
112-
return;
134+
angular.element(document).ready(function() {
135+
if (!window.DUOSHUO || !window.DUOSHUO.initSelector)
136+
return;
113137

114-
// Trigger init selector function
115-
window.DUOSHUO
116-
.initSelector(window.DUOSHUO.selectors['.' + type])
138+
// Trigger init selector function
139+
window.DUOSHUO
140+
.initSelector(type, window.DUOSHUO.selectors['.' + type])
141+
});
117142
}
118143
};
119144
}

0 commit comments

Comments
 (0)