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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163 | 1×
1×
1×
1×
515×
515×
2×
2×
2×
1×
2×
2×
2×
2×
2×
2×
2×
2×
2×
515×
2×
2×
2×
2×
515×
1×
1×
1×
1×
1×
515×
515×
2×
515×
2×
1×
1×
1×
515×
515×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
2×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
513×
1×
513×
1×
1×
513×
1×
1×
513×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-lists", "@syncfusion/ej2-buttons", "@syncfusion/ej2-popups"], function (require, exports, ej2_base_1, ej2_lists_1, ej2_buttons_1, ej2_popups_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var AddUserDialog = (function () {
function AddUserDialog(documentHelper) {
var _this = this;
this.show = function () {
var localObj = new ej2_base_1.L10n('documenteditor', _this.documentHelper.owner.defaultLocale);
localObj.setLocale(_this.documentHelper.owner.locale);
if (!_this.target) {
_this.initUserDialog(localObj, _this.documentHelper.owner.enableRtl);
}
_this.documentHelper.dialog.header = localObj.getConstant('Add Users');
_this.documentHelper.dialog.height = 'auto';
_this.documentHelper.dialog.width = 'auto';
_this.documentHelper.dialog.content = _this.target;
_this.documentHelper.dialog.beforeOpen = _this.loadUserDetails;
_this.documentHelper.dialog.close = _this.documentHelper.updateFocus;
_this.documentHelper.dialog.buttons = [
{
click: _this.okButtonClick,
buttonModel: {
content: localObj.getConstant('Ok'), cssClass: 'e-flat', isPrimary: true
}
},
{
click: _this.hideDialog,
buttonModel: { content: localObj.getConstant('Cancel'), cssClass: 'e-flat' }
}, {
click: _this.deleteButtonClick,
buttonModel: { content: localObj.getConstant('Delete'), cssClass: 'e-flat e-user-delete' }
}
];
_this.documentHelper.dialog.dataBind();
_this.documentHelper.dialog.show();
};
this.loadUserDetails = function () {
_this.userList.dataSource = _this.documentHelper.userCollection.slice();
_this.userList.dataBind();
_this.documentHelper.restrictEditingPane.addedUser.dataSource = _this.documentHelper.userCollection.slice();
_this.documentHelper.restrictEditingPane.addedUser.dataBind();
};
this.okButtonClick = function () {
_this.documentHelper.restrictEditingPane.isAddUser = true;
_this.documentHelper.restrictEditingPane.showStopProtectionPane(false);
_this.documentHelper.restrictEditingPane.addUserCollection();
_this.documentHelper.restrictEditingPane.isAddUser = false;
_this.documentHelper.dialog.hide();
};
this.hideDialog = function () {
_this.textBoxInput.value = '';
_this.documentHelper.dialog.hide();
};
this.onKeyUpOnDisplayBox = function () {
_this.addButton.disabled = _this.textBoxInput.value === '';
};
this.addButtonClick = function () {
if (_this.validateUserName(_this.textBoxInput.value)) {
_this.bindListData(_this.textBoxInput.value);
_this.textBoxInput.value = '';
}
else {
ej2_popups_1.DialogUtility.alert('Invalid user name');
}
};
this.deleteButtonClick = function () {
var index = _this.documentHelper.userCollection.indexOf(_this.userList.getSelectedItems().text);
if (index > -1) {
_this.documentHelper.userCollection.splice(index, 1);
_this.userList.dataSource = _this.documentHelper.userCollection.slice();
_this.userList.dataBind();
}
};
this.documentHelper = documentHelper;
}
AddUserDialog.prototype.initUserDialog = function (localValue, isRtl) {
this.target = ej2_base_1.createElement('div', { className: 'e-de-user-dlg' });
var headerValue = localValue.getConstant('Enter User');
var dlgFields = ej2_base_1.createElement('div', { innerHTML: headerValue, className: 'e-bookmark-dlgfields' });
this.target.appendChild(dlgFields);
var commonDiv = ej2_base_1.createElement('div', { className: 'e-de-user-dlg-common' });
this.target.appendChild(commonDiv);
var adduserDiv = ej2_base_1.createElement('div', { className: 'e-de-user-dlg-list' });
commonDiv.appendChild(adduserDiv);
Iif (isRtl) {
adduserDiv.classList.add('e-de-rtl');
}
this.textBoxInput = ej2_base_1.createElement('input', { className: 'e-input e-de-user-dlg-textbox-input', attrs: { autofocus: 'true' } });
this.textBoxInput.setAttribute('type', 'text');
adduserDiv.appendChild(this.textBoxInput);
this.textBoxInput.addEventListener('keyup', this.onKeyUpOnDisplayBox);
var addButtonElement = ej2_base_1.createElement('button', {
innerHTML: localValue.getConstant('Add'),
attrs: { type: 'button' }
});
adduserDiv.appendChild(addButtonElement);
addButtonElement.addEventListener('click', this.addButtonClick);
this.addButton = new ej2_buttons_1.Button({ cssClass: 'e-de-user-add-btn' });
this.addButton.disabled = true;
this.addButton.appendTo(addButtonElement);
this.addButton.addEventListener('click', this.addButtonClick);
var userCollectionDiv = ej2_base_1.createElement('div');
commonDiv.appendChild(userCollectionDiv);
var userDiv = ej2_base_1.createElement('div', { innerHTML: localValue.getConstant('Users'), className: 'e-de-user-dlg-user' });
userCollectionDiv.appendChild(userDiv);
var listviewDiv = ej2_base_1.createElement('div');
userCollectionDiv.appendChild(listviewDiv);
this.userList = new ej2_lists_1.ListView({
cssClass: 'e-de-user-listview'
});
this.userList.appendTo(listviewDiv);
};
AddUserDialog.prototype.bindListData = function (data) {
Eif (this.documentHelper.userCollection.indexOf(data) === -1) {
this.documentHelper.userCollection.push(data);
}
Eif (this.userList) {
this.userList.dataSource = this.documentHelper.userCollection.slice();
this.userList.dataBind();
}
};
AddUserDialog.prototype.validateUserName = function (value) {
if (value.indexOf('@') === -1) {
return false;
}
else {
var parts = value.split('@');
var domain = parts[1];
Iif (domain.indexOf('.') === -1) {
return false;
}
else {
var domainParts = domain.split('.');
var ext = domainParts[1];
Iif (domainParts.length > 2) {
return false;
}
Iif (ext.length > 4 || ext.length < 2) {
return false;
}
}
}
return true;
};
AddUserDialog.prototype.destroy = function () {
if (this.textBoxInput) {
this.textBoxInput = undefined;
}
if (this.addButton) {
this.addButton.destroy();
this.addButton = undefined;
}
if (this.userList) {
this.userList.destroy();
this.userList = undefined;
}
this.documentHelper = undefined;
};
return AddUserDialog;
}());
exports.AddUserDialog = AddUserDialog;
});
|