-
Notifications
You must be signed in to change notification settings - Fork 153
/
Copy pathtether-dialog.js
55 lines (46 loc) · 1.35 KB
/
tether-dialog.js
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
import { computed, set } from '@ember/object';
import { dasherize } from '@ember/string';
import BasicDialog from './basic-dialog';
export default class TetherDialog extends BasicDialog {
init() {
super.init(...arguments);
this._ensureAttachments();
}
@computed('targetAttachment')
get targetAttachmentClass() {
let targetAttachment = this.targetAttachment || '';
// Convert tether-styled values like 'middle right' to 'right'
targetAttachment = targetAttachment.split(' ').slice(-1)[0];
return `ember-modal-dialog-target-attachment-${dasherize(
targetAttachment,
)} emd-target-attachment-${dasherize(targetAttachment)}`;
}
targetAttachment = null;
attachment = null;
didReceiveAttrs() {
super.didReceiveAttrs(...arguments);
this._ensureAttachments();
}
tetherTarget = null; // element, css selector, view instance, 'viewport', or 'scroll-handle'
@computed
get tetherClassPrefix() {
return 'ember-tether';
}
set tetherClassPrefix(val) {
if (val) {
return val;
}
return 'ember-tether';
}
// offset - passed in
// targetOffset - passed in
// targetModifier - passed in
_ensureAttachments() {
if (!this.attachment) {
set(this, 'attachment', 'middle center');
}
if (!this.targetAttachment) {
set(this, 'targetAttachment', 'middle center');
}
}
}