OpenSlides/client/src/app/base.component.ts

60 lines
2.0 KiB
TypeScript
Raw Normal View History

import { Title } from '@angular/platform-browser';
2019-02-08 17:24:32 +01:00
2018-08-03 15:16:40 +02:00
import { TranslateService } from '@ngx-translate/core';
/**
* Provides functionalities that will be used by most components
2019-02-02 17:06:23 +01:00
* currently able to set the title with the suffix ' - OpenSlides'
*
* A BaseComponent is an OpenSlides Component.
* Components in the 'Side'- or 'projector' Folder are BaseComponents
*/
2019-02-08 17:24:32 +01:00
export abstract class BaseComponent {
/**
2019-02-02 17:06:23 +01:00
* To manipulate the browser title bar, adds the Suffix "OpenSlides"
*
* Might be a config variable later at some point
*/
2019-02-02 17:06:23 +01:00
private titleSuffix = ' - OpenSlides';
2018-11-20 13:31:56 +01:00
/**
* Settings for the TinyMCE editor selector
*/
public tinyMceSettings = {
language: null,
language_url: null,
2018-11-20 13:31:56 +01:00
skin_url: '/assets/tinymce/skins/lightgray',
inline: false,
statusbar: false,
browser_spellcheck: true,
image_advtab: true,
image_description: false,
link_title: false,
2018-11-20 13:31:56 +01:00
height: 320,
// TODO: image_list: images,
plugins: `autolink charmap code colorpicker fullscreen image imagetools
lists link paste searchreplace textcolor`,
2018-11-20 13:31:56 +01:00
menubar: '',
toolbar: `styleselect | bold italic underline strikethrough
| forecolor backcolor removeformat | bullist numlist |
link image charmap | code fullscreen`
2018-11-20 13:31:56 +01:00
};
public constructor(protected titleService?: Title, protected translate?: TranslateService) {
if (this.translate) {
this.tinyMceSettings.language_url = '/assets/tinymce/langs/' + this.translate.currentLang + '.js';
this.tinyMceSettings.language = this.translate.currentLang;
}
}
/**
* Set the title in web browser using angulars TitleService
* @param prefix The title prefix. Should be translated here.
* TODO Might translate the prefix here?
*/
2018-08-29 13:21:25 +02:00
public setTitle(prefix: string): void {
2018-08-03 15:16:40 +02:00
const translatedPrefix = this.translate.instant(prefix);
this.titleService.setTitle(translatedPrefix + this.titleSuffix);
}
}