Commit de0338ef authored by Dan MacFarlane's avatar Dan MacFarlane Committed by GitHub
Browse files

Merge pull request #4 from binarious/refactor/styleguide

Follow Angular2 Styleguide
parents 167b244b 658ea4b8
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
import { Component } from '@angular/core';

import { Mention } from '../mention/mention';
import { COMMON_NAMES } from './common-names';
import { TinyMCE } from './tinymce.component';

@Component({
  selector: 'app-root',
+2 −2
Original line number Diff line number Diff line
import { Component, ElementRef, NgZone, Input, ViewChild } from '@angular/core';

import { Mention } from '../mention/mention';
import { MentionDirective } from '../mention/mention.directive';
import { COMMON_NAMES } from './common-names';

declare var tinymce: any;
@@ -23,7 +23,7 @@ declare var tinymce: any;
})
export class TinyMCE {
  @Input() htmlContent;
  @ViewChild(Mention) mention: Mention;
  @ViewChild(MentionDirective) mention: MentionDirective;
  protected items:string[] = COMMON_NAMES;
  constructor(private _elementRef: ElementRef, private _zone: NgZone) {}
  ngAfterViewInit() {
+2 −2
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ import { getCaretCoordinates } from './caret-coords';
    </ul>
    `
})
export class MentionList {
export class MentionListComponent {
  items = [];
  activeIndex:number = 0;
  hidden = false;
+5 −5
Original line number Diff line number Diff line
import { Directive, ElementRef, Input, ComponentFactoryResolver, ViewContainerRef } from "@angular/core";

import { MentionList } from './mention-list';
import { MentionListComponent } from './mention-list.component';
import { getValue, insertValue, getCaretPosition, setCaretPosition } from './mention-utils';

const KEY_BACKSPACE = 8;
@@ -27,11 +27,11 @@ const KEY_2 = 50;
    '(keydown)': 'keyHandler($event)',
  }
})
export class Mention {
export class MentionDirective {
  items: string [];
  startPos:number;
  startNode;
  searchList: MentionList;
  searchList: MentionListComponent;
  escapePressed:boolean;
  iframe:any; // optional
  constructor(
@@ -154,7 +154,7 @@ export class Mention {

  showSearchList(nativeElement: HTMLInputElement) {
    if (this.searchList == null) {
      let componentFactory = this._componentResolver.resolveComponentFactory(MentionList);
      let componentFactory = this._componentResolver.resolveComponentFactory(MentionListComponent);
      let componentRef = this._viewContainerRef.createComponent(componentFactory);
      this.searchList = componentRef.instance
      this.searchList.items = this.items;
+7 −7
Original line number Diff line number Diff line
import { CommonModule } from '@angular/common';
import { NgModule, ModuleWithProviders } from '@angular/core';

import { Mention } from './mention';
import { MentionList } from './mention-list';
import { MentionDirective } from './mention.directive';
import { MentionListComponent } from './mention-list.component';

@NgModule({
    imports: [
        CommonModule
    ],
    exports: [
        Mention,
        MentionList
        MentionDirective,
        MentionListComponent
    ],
    entryComponents: [
        MentionList
        MentionListComponent
    ],
    declarations: [
        Mention,
        MentionList
        MentionDirective,
        MentionListComponent
    ]
})
export class MentionModule {