Commit a68fcd7ab902b7c885988ca127b660955dae02be

Authored by Victor Costa
1 parent d56bc4d4

Add hotspot to display extra content for articles

src/app/article/article-default-view.component.ts
... ... @@ -3,6 +3,7 @@ import {ArticleBlogComponent} from "./types/blog/blog.component";
3 3 import {CommentsComponent} from "./comment/comments.component";
4 4 import {MacroDirective} from "./macro/macro.directive";
5 5 import {ArticleToolbarHotspotComponent} from "../hotspot/article-toolbar-hotspot.component";
  6 +import {ArticleContentHotspotComponent} from "../hotspot/article-content-hotspot.component";
6 7  
7 8 /**
8 9 * @ngdoc controller
... ... @@ -33,7 +34,8 @@ export class ArticleDefaultViewComponent {
33 34 selector: 'noosfero-article',
34 35 template: 'not-used',
35 36 directives: [ArticleDefaultViewComponent, ArticleBlogComponent,
36   - CommentsComponent, MacroDirective, ArticleToolbarHotspotComponent]
  37 + CommentsComponent, MacroDirective, ArticleToolbarHotspotComponent,
  38 + ArticleContentHotspotComponent]
37 39 })
38 40 @Inject("$element", "$scope", "$injector", "$compile")
39 41 export class ArticleViewComponent {
... ...
src/app/article/article.html
... ... @@ -20,7 +20,7 @@
20 20 </span>
21 21 </div>
22 22 </div>
23   -
  23 + <noosfero-hotspot-article-content [article]="ctrl.article"></noosfero-hotspot-article-content>
24 24 <div class="page-body">
25 25 <div bind-html-compile="ctrl.article.body"></div>
26 26 </div>
... ...
src/app/hotspot/article-content-hotspot.component.ts 0 → 100644
... ... @@ -0,0 +1,25 @@
  1 +import {Component, Input, Inject} from "ng-forward";
  2 +import * as plugins from "../../plugins";
  3 +import {dasherize} from "ng-forward/cjs/util/helpers";
  4 +import {PluginHotspot} from "./plugin-hotspot";
  5 +
  6 +@Component({
  7 + selector: "noosfero-hotspot-article-content",
  8 + template: "<span></span>"
  9 +})
  10 +@Inject("$element", "$scope", "$compile")
  11 +export class ArticleContentHotspotComponent extends PluginHotspot {
  12 +
  13 + @Input() article: noosfero.Article;
  14 +
  15 + constructor(
  16 + private $element: any,
  17 + private $scope: ng.IScope,
  18 + private $compile: ng.ICompileService) {
  19 + super("article_extra_content");
  20 + }
  21 +
  22 + addHotspot(directiveName: string) {
  23 + this.$element.append(this.$compile('<' + directiveName + ' [article]="ctrl.article"></' + directiveName + '>')(this.$scope));
  24 + }
  25 +}
... ...