Skip to content

Commit

Permalink
0.4: add comments renderer and directive
Browse files Browse the repository at this point in the history
ready for shipping
  • Loading branch information
guo-yu committed Aug 12, 2014
1 parent 1a1ca16 commit be97c9c
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## angular-duoshuo ![release](http://img.shields.io/github/release/duoshuo/angular-duoshuo.svg) ![npm](http://img.shields.io/npm/v/angular-duoshuo.svg)
## angular-duoshuo ![release](http://img.shields.io/github/release/duoshuo/angular-duoshuo.svg?style=flat) ![npm](http://img.shields.io/npm/v/angular-duoshuo.svg?style=flat)

a duoshuo SDK for angular.js, pure front-end, cross-domain request supported.

Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "duoshuo",
"version": "0.3.0",
"version": "0.4.0",
"authors": [
"turing <[email protected]>"
],
"description": "a duoshuo SDK for angular.js, pure front-end, cross-domain request supported.",
"main": "src/duoshuo.js",
"main": "dist/duoshuo.min.js",
"keywords": [
"duoshuo",
"duoshuo-sdk",
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.

1 change: 1 addition & 0 deletions examples/example.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var app = angular.module('app', ['duoshuo']);

app.controller('duoshuo', function($scope, $duoshuo) {
$scope.demokey = 'dede-dede';
// inspect current user
$duoshuo.on('ready', function(err, data) {
if (err) return console.error(err);
Expand Down
3 changes: 2 additions & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ <h3 ng-show="responseJSON">当前用户数据:</h3>
<div class="threads" ng-repeat="thread in threads">
<h3 ng-bind="thread.title" ng-show="thread.title !== ''"></h3>
</div>
<div duoshuo data-thread-key="{{demokey}}"></div>
</div>
<script>
var duoshuoQuery = {
Expand All @@ -32,7 +33,7 @@ <h3 ng-bind="thread.title" ng-show="thread.title !== ''"></h3>
</script>
<script src="http://static.duoshuo.com/embed.unstable.js"></script>
<script src="../bower_components/angular/angular.min.js"></script>
<script src="../dist/duoshuo.min.js"></script>
<script src="../src/duoshuo.js"></script>
<script src="./example.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "angular-duoshuo",
"version": "0.3.0",
"version": "0.4.0",
"description": "a duoshuo SDK for angular.js, pure front-end, cross-domain request supported.",
"main": "src/duoshuo.js",
"main": "dist/duoshuo.min.js",
"scripts": {
"serve": "node_modules/.bin/serve .",
"build": "node_modules/.bin/uglifyjs src/duoshuo.js -o dist/duoshuo.min.js --source-map dist/duoshuo.min.js.map --source-map-url duoshuo.min.js.map",
Expand Down
17 changes: 17 additions & 0 deletions src/duoshuo.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@
return;
});
};

// comments renderer
this.render = function(element) {
if (!window.DUOSHUO) throw new Error('duoshuo embed.js required!');
window.DUOSHUO.EmbedThread(element);
};
})
.directive('duoshuo', function($duoshuo){
return {
restrict: 'AE',
replace: true,
template: '<div class="ds-thread"></div>',
link: function(scope, element, attrs) {
// render comments when dom has been injected.
$duoshuo.render(element[0]);
}
};
});

})(window.angular, window.NProgress);

0 comments on commit be97c9c

Please sign in to comment.