2018-06-19 16:55:50 +02:00
|
|
|
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';
|
2018-06-19 16:55:50 +02:00
|
|
|
|
2018-07-12 14:11:31 +02:00
|
|
|
/**
|
|
|
|
* 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'
|
2018-07-12 14:11:31 +02:00
|
|
|
*
|
|
|
|
* 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 {
|
2018-07-12 14:11:31 +02:00
|
|
|
/**
|
2019-02-02 17:06:23 +01:00
|
|
|
* To manipulate the browser title bar, adds the Suffix "OpenSlides"
|
2018-07-12 14:11:31 +02:00
|
|
|
*
|
|
|
|
* Might be a config variable later at some point
|
|
|
|
*/
|
2019-02-02 17:06:23 +01:00
|
|
|
private titleSuffix = ' - OpenSlides';
|
2018-06-19 16:55:50 +02:00
|
|
|
|
2019-02-26 15:30:16 +01:00
|
|
|
/**
|
|
|
|
* Holds the coordinates where a swipe gesture was used
|
|
|
|
*/
|
|
|
|
protected swipeCoord?: [number, number];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Holds the time when the user was swiping
|
|
|
|
*/
|
|
|
|
protected swipeTime?: number;
|
|
|
|
|
2019-08-22 17:47:31 +02:00
|
|
|
/**
|
|
|
|
* Determine to display a save hint
|
|
|
|
*/
|
|
|
|
public saveHint: boolean;
|
|
|
|
|
2018-11-20 13:31:56 +01:00
|
|
|
/**
|
|
|
|
* Settings for the TinyMCE editor selector
|
|
|
|
*/
|
|
|
|
public tinyMceSettings = {
|
2019-07-01 11:23:33 +02:00
|
|
|
base_url: '/tinymce', // Root for resources
|
|
|
|
suffix: '.min', // Suffix to use when loading resources
|
|
|
|
theme: 'silver',
|
2019-02-24 15:57:27 +01:00
|
|
|
language: null,
|
|
|
|
language_url: null,
|
2018-11-20 13:31:56 +01:00
|
|
|
inline: false,
|
|
|
|
statusbar: false,
|
|
|
|
browser_spellcheck: true,
|
|
|
|
image_advtab: true,
|
2019-02-24 15:57:27 +01:00
|
|
|
image_description: false,
|
|
|
|
link_title: false,
|
2018-11-20 13:31:56 +01:00
|
|
|
height: 320,
|
2019-07-01 11:23:33 +02:00
|
|
|
plugins: `autolink charmap code fullscreen image imagetools
|
|
|
|
lists link paste searchreplace`,
|
|
|
|
menubar: false,
|
|
|
|
contextmenu: false,
|
2019-03-08 10:00:26 +01:00
|
|
|
toolbar: `styleselect | bold italic underline strikethrough |
|
|
|
|
forecolor backcolor removeformat | bullist numlist |
|
2019-07-01 11:23:33 +02:00
|
|
|
link image charmap | code fullscreen`,
|
|
|
|
mobile: {
|
|
|
|
theme: 'mobile',
|
|
|
|
plugins: ['autosave', 'lists', 'autolink']
|
|
|
|
}
|
2018-11-20 13:31:56 +01:00
|
|
|
};
|
|
|
|
|
2019-03-11 10:38:18 +01:00
|
|
|
public constructor(protected titleService: Title, protected translate: TranslateService) {
|
|
|
|
this.tinyMceSettings.language_url = '/assets/tinymce/langs/' + this.translate.currentLang + '.js';
|
|
|
|
this.tinyMceSettings.language = this.translate.currentLang;
|
2019-02-24 15:57:27 +01:00
|
|
|
}
|
2018-06-19 16:55:50 +02:00
|
|
|
|
2018-07-12 14:11:31 +02:00
|
|
|
/**
|
|
|
|
* Set the title in web browser using angulars TitleService
|
|
|
|
* @param prefix The title prefix. Should be translated 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);
|
2018-06-19 16:55:50 +02:00
|
|
|
}
|
2019-03-04 18:28:21 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper for indexed *ngFor components
|
|
|
|
*
|
|
|
|
* @param index
|
|
|
|
*/
|
|
|
|
public trackByIndex(index: number): number {
|
|
|
|
return index;
|
|
|
|
}
|
2019-08-22 17:47:31 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TinyMCE Init callback. Used for certain mobile editors
|
|
|
|
* @param event
|
|
|
|
*/
|
|
|
|
protected onInitTinyMce(event: any): void {
|
|
|
|
console.log('tinyMCE event: ', event);
|
|
|
|
|
|
|
|
if (event.event.target.settings.theme === 'mobile') {
|
|
|
|
console.log('is mobile editor');
|
|
|
|
this.saveHint = true;
|
|
|
|
} else {
|
|
|
|
console.log('is no mobile editor');
|
|
|
|
event.editor.focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected onLeaveTinyMce(event: any): void {
|
|
|
|
console.log('tinyevent:', event.event.type);
|
|
|
|
this.saveHint = false;
|
|
|
|
// console.log("event: ", event.event.type);
|
|
|
|
}
|
2018-06-19 16:55:50 +02:00
|
|
|
}
|