Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | 93x 93x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 15x 5x | import { IButton } from '../zd-button/interfaces';
import { Component } from '../zd-component/component';
import { IAlert } from './interfaces';
/**
* Base class for Alert component.
*/
export class Alert extends Component implements IAlert {
/**
* Align the component towards the bottom
*/
public bottom = true;
/**
* Slot to display flat buttons
*/
public buttonsSlot: IButton[] = [];
/**
* Applies specified color to the control.
* It can be the name of material color or an hexadecimal color
*/
public color = '';
/**
* Applies specified color to the dismiss button.
* It can be the name of material color or an hexadecimal color
*/
public dismissColor = '';
/**
* Align the component towards the left
*/
public left = true;
/**
* Creates a better spacing for multiple content lines
*/
public multiLine = false;
/**
* Align the component towards the right
*/
public right = false;
/**
* Controls dismiss button visibility
*/
public showDismiss = false;
/**
* Time (in milliseconds) to wait until alert is automatically hidden.
* Use 0 to keep open indefinitely.
*/
public timeout = 5000;
/**
* Text displayed on alert
*/
public text = '';
/**
* Align the content towards the top
*/
public top = false;
/**
* Stacks alert content and actions vertically
*/
public vertical = false;
public id = 0;
protected defaultValues = {
name: this.name,
color: this.color,
text: this.text,
timeout: this.timeout,
top: this.top,
right: this.right,
bottom: this.bottom,
left: this.left,
vertical: this.vertical,
multiLine: this.multiLine,
showDismiss: this.showDismiss,
dismissColor: this.dismissColor,
buttonsSlot: this.buttonsSlot,
id: this.id,
};
/**
* Creates a new Alert
* @param props Alert structure
*/
constructor(props: IAlert) {
super(props);
this.assignAlertProperties(props);
}
/**
* Assign all alert properties
* @param alert Alert structure
*/
public assignAlertProperties(alert: IAlert) {
this.name = this.getInitValue('name', alert.name, this.defaultValues.name);
this.color = this.getInitValue('color', alert.color, this.defaultValues.color);
this.text = this.getInitValue('text', alert.text, this.defaultValues.text);
this.timeout = this.getInitValue('timeout', alert.timeout, this.defaultValues.timeout);
this.top = this.getInitValue('top', alert.top, this.defaultValues.top);
this.right = this.getInitValue('right', alert.right, this.defaultValues.right);
this.bottom = this.getInitValue('bottom', alert.bottom, this.defaultValues.bottom);
this.left = this.getInitValue('left', alert.left, this.defaultValues.left);
this.vertical = this.getInitValue('vertical', alert.vertical, this.defaultValues.vertical);
this.multiLine = this.getInitValue('multiLine', alert.multiLine, this.defaultValues.multiLine);
this.showDismiss = this.getInitValue('showDismiss', alert.showDismiss, this.defaultValues.showDismiss);
this.dismissColor = this.getInitValue('dismissColor', alert.dismissColor, this.defaultValues.dismissColor);
this.buttonsSlot = alert.buttonsSlot || this.defaultValues.buttonsSlot;
this.id = alert.id || this.defaultValues.id;
this.isVisible = false;
// call createAccessors because this component's onCreated is not
// supposed to trigger
this.createAccessors();
}
/**
* Displays alert
*/
public show() {
this.isVisible = true;
}
/**
* Hides alert
*/
public hide() {
this.isVisible = false;
}
}
|