feat: Set no wrap on Delete Keymap and Delete Macro icons (#371)

close #369
This commit is contained in:
Róbert Kiss
2017-07-25 00:38:43 +02:00
committed by László Monda
parent c17bf0fd3d
commit 817daafd18
4 changed files with 20 additions and 5 deletions

View File

@@ -27,6 +27,7 @@
[class.disabled]="!deletable" [class.disabled]="!deletable"
data-toggle="tooltip" data-toggle="tooltip"
data-placement="bottom" data-placement="bottom"
html="true"
(click)="removeKeymap()" (click)="removeKeymap()"
></i> ></i>
<i class="fa fa-files-o keymap__duplicate pull-right" <i class="fa fa-files-o keymap__duplicate pull-right"

View File

@@ -18,6 +18,8 @@ import { Keymap } from '../../../config-serializer/config-items/keymap';
import { AppState } from '../../../store'; import { AppState } from '../../../store';
import { KeymapActions } from '../../../store/actions'; import { KeymapActions } from '../../../store/actions';
const DEFAULT_TRASH_TITLE = '<span class="text-nowrap">Delete keymap</span>';
@Component({ @Component({
selector: 'keymap-header', selector: 'keymap-header',
templateUrl: './keymap-header.component.html', templateUrl: './keymap-header.component.html',
@@ -25,6 +27,7 @@ import { KeymapActions } from '../../../store/actions';
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })
export class KeymapHeaderComponent implements OnChanges { export class KeymapHeaderComponent implements OnChanges {
@Input() keymap: Keymap; @Input() keymap: Keymap;
@Input() deletable: boolean; @Input() deletable: boolean;
@Output() downloadClick = new EventEmitter<void>(); @Output() downloadClick = new EventEmitter<void>();
@@ -33,7 +36,7 @@ export class KeymapHeaderComponent implements OnChanges {
@ViewChild('abbr') keymapAbbr: ElementRef; @ViewChild('abbr') keymapAbbr: ElementRef;
starTitle: string; starTitle: string;
trashTitle: string = 'Delete keymap'; trashTitle: string = DEFAULT_TRASH_TITLE;
constructor(private store: Store<AppState>, private renderer: Renderer2) { } constructor(private store: Store<AppState>, private renderer: Renderer2) { }
@@ -92,7 +95,9 @@ export class KeymapHeaderComponent implements OnChanges {
} }
setTrashTitle(): void { setTrashTitle(): void {
this.trashTitle = this.deletable ? 'Delete keymap' : 'The last keymap cannot be deleted.'; this.trashTitle = this.deletable
? DEFAULT_TRASH_TITLE
: '<span class="text-nowrap">The last keymap cannot be deleted.</span>';
} }
onDownloadIconClick(): void { onDownloadIconClick(): void {

View File

@@ -11,7 +11,8 @@
<i class="glyphicon glyphicon-trash macro__remove pull-right" title="" <i class="glyphicon glyphicon-trash macro__remove pull-right" title=""
data-toggle="tooltip" data-toggle="tooltip"
data-placement="bottom" data-placement="bottom"
data-original-title="Remove macro" html="true"
data-original-title="<span class='text-nowrap'>Delete macro</span>"
(click)="removeMacro()" (click)="removeMacro()"
></i> ></i>
<i class="fa fa-files-o macro__duplicate pull-right" title="" <i class="fa fa-files-o macro__duplicate pull-right" title=""

View File

@@ -1,4 +1,5 @@
import { AfterContentInit, Directive, ElementRef, HostBinding, Input, OnChanges, Renderer2, SimpleChanges } from '@angular/core'; import { AfterContentInit, Directive, ElementRef, HostBinding, Input, OnChanges, SimpleChanges } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
@Directive({ @Directive({
selector: '[data-toggle="tooltip"]' selector: '[data-toggle="tooltip"]'
@@ -16,7 +17,7 @@ export class TooltipDirective implements AfterContentInit, OnChanges {
</div> </div>
`; `;
constructor(private elementRef: ElementRef, private renderer: Renderer2) { } constructor(private elementRef: ElementRef, private sanitizer: DomSanitizer) { }
ngAfterContentInit() { ngAfterContentInit() {
this.init(); this.init();
@@ -38,6 +39,13 @@ export class TooltipDirective implements AfterContentInit, OnChanges {
} }
private fixTitle() { private fixTitle() {
jQuery(this.elementRef.nativeElement).tooltip({
placement: this.placement,
html: this.html,
template: this.customTooltipTemplate,
title: this.title
});
jQuery(this.elementRef.nativeElement) jQuery(this.elementRef.nativeElement)
.attr('title', this.title) .attr('title', this.title)
.tooltip('fixTitle'); .tooltip('fixTitle');