Skip to content

Commit

Permalink
Bugfix: fix dynamic params render in ds-thread
Browse files Browse the repository at this point in the history
  • Loading branch information
guo-yu committed Jan 9, 2015
1 parent 5817839 commit ea9cb4a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
1 change: 0 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "duoshuo",
"version": "0.5.0",
"authors": [
"turing <[email protected]>"
],
Expand Down
2 changes: 1 addition & 1 deletion dist/duoshuo.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/duoshuo.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"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.",
"main": "dist/duoshuo.min.js",
"scripts": {
Expand Down
35 changes: 30 additions & 5 deletions src/duoshuo.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,43 @@
}

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() {
return {
restrict: 'AE',
replace: true,
template: '<div class="' + type + '">',
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])
});
}
};
}
Expand Down

0 comments on commit ea9cb4a

Please sign in to comment.