-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathlocked-component-dialog.component.ts
87 lines (61 loc) · 2.61 KB
/
locked-component-dialog.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { Component, ViewChild, OnInit } from '@angular/core';
import { Ng2DynamicDialogComponent } from 'ng2-dynamic-dialog';
import { Ng2DynamicDialogContent } from 'ng2-dynamic-dialog';
import { Ng2DynamicDialogStyle } from 'ng2-dynamic-dialog';
import { Ng2DynamicDialogCallbacks } from 'ng2-dynamic-dialog';
import { LockedContentComponent } from './locked-content/locked-content.component';
@Component({
moduleId: __filename,
selector: 'locked-component-dialog',
templateUrl: 'locked-component-dialog.component.html',
styleUrls: ['locked-component-dialog.component.css'],
})
export class LockedComponentDialogComponent implements OnInit {
@ViewChild(Ng2DynamicDialogComponent)
private modalDialog: Ng2DynamicDialogComponent;
// Initialisation
ngOnInit() {
this.setDialogStyles();
this.setDialogCallbacks();
}
// Shows the dialog
show() {
// Set the content
let dialogContent = new Ng2DynamicDialogContent();
// Show our dialog
dialogContent.title = 'Locking Dialogs Manually';
dialogContent.button1 = 'Lock Me';
dialogContent.button2 = 'Close Me';
dialogContent.height = 410;
dialogContent.width = 430;
dialogContent.componentContent = LockedContentComponent;
this.modalDialog.show(dialogContent);
}
//
// Sets the style of the dialog
//
private setDialogStyles() {
// Initialise the style of the dialog
let dialogStyle = new Ng2DynamicDialogStyle();
// Background style - we don't want one
dialogStyle.background = 'ng2-dynamic-dialog-samples-locked-component-background';
dialogStyle.dialog = 'ng2-dynamic-dialog-samples-locked-component-dialog';
dialogStyle.title = 'ng2-dynamic-dialog-samples-locked-component-title';
dialogStyle.buttonClose.image = 'assets/close.png';
dialogStyle.iconLocked.image = 'assets/locked-icon.gif';
dialogStyle.button.general.idle = 'ng2-dynamic-dialog-samples-locked-component-button';
dialogStyle.button.general.hover = 'ng2-dynamic-dialog-samples-locked-component-button:hover';
// Set it
this.modalDialog.setStyle(dialogStyle);
}
//
// Sets the callbacks for this dialog
//
private setDialogCallbacks() {
// We're not setting any callbacks, just showing how an owner can be passed to a component callback
let dialogCallbacks: Ng2DynamicDialogCallbacks = new Ng2DynamicDialogCallbacks();
dialogCallbacks.owner = this;
// Set the callbacks
this.modalDialog.setCallbacks(dialogCallbacks);
}
}