|
1 | 1 | (() => { |
2 | 2 | // ** получение существующих, создание "новых" элементов (глобальное объявление) |
| 3 | + const page = document.getElementById('page'); |
3 | 4 | const crm = document.getElementById('crm'); |
4 | 5 | const crmSearch = document.getElementById('crm-search'); |
5 | 6 | const crmOutput = document.getElementById('crm-output'); |
|
229 | 230 | const addBtnGrayIcon = document.createElement('span'); |
230 | 231 | const addBtnText = document.createElement('span'); |
231 | 232 | const addModalWrap = document.createElement('div'); |
| 233 | + const addModalDialog = document.createElement('div'); |
| 234 | + const addModalContent = document.createElement('div'); |
| 235 | + const addModalHeader = document.createElement('div'); |
| 236 | + const addModalHeaderTitle = document.createElement('h1'); |
| 237 | + const addModalHeaderXBtn = document.createElement('button'); |
| 238 | + const addModalBody = document.createElement('div'); |
| 239 | + const addModalBodyForm = document.createElement('form'); |
| 240 | + const addModalBodySurnameInputWrap = document.createElement('div'); |
| 241 | + const addModalBodySurnameInput = document.createElement('input'); |
| 242 | + const addModalBodyNameInputWrap = document.createElement('div'); |
| 243 | + const addModalBodyNameInput = document.createElement('input'); |
| 244 | + const addModalBodyPatronymicInputWrap = document.createElement('div'); |
| 245 | + const addModalBodyPatronymicInput = document.createElement('input'); |
| 246 | + const addModalFooter = document.createElement('div'); |
| 247 | + const addModalFooterAddBtnWrap = document.createElement('div'); |
| 248 | + const addModalFooterAddBtn = document.createElement('button'); |
| 249 | + const addModalFooterSaveBtn = document.createElement('button'); |
| 250 | + const addModalFooterCancelBtn = document.createElement('button'); |
232 | 251 |
|
| 252 | + addBtnWrap.classList.add('crm__add-btn-wrap'); |
233 | 253 | addBtn.classList.add('crm__add-btn'); |
234 | 254 | addBtnDefaultIcon.classList.add('crm__add-btn-icon', 'default-add-icon'); |
235 | 255 | addBtnWhiteIcon.classList.add('crm__add-btn-icon', 'white-add-icon'); |
236 | 256 | addBtnGrayIcon.classList.add('crm__add-btn-icon', 'gray-add-icon'); |
237 | 257 | addBtnText.classList.add('crm__add-btn-text'); |
| 258 | + addModalWrap.classList.add('modal', 'crm__add-btn-modal', 'fade'); |
| 259 | + addModalDialog.classList.add( |
| 260 | + 'modal__add-dialog', |
| 261 | + 'modal-dialog', |
| 262 | + 'modal-dialog-centered' |
| 263 | + ); |
| 264 | + addModalContent.classList.add('modal__add-content-wrap', 'modal-content'); |
| 265 | + addModalHeader.classList.add('modal__add-header', 'modal-header'); |
| 266 | + addModalHeaderTitle.classList.add('modal__add-header-title', 'modal-title'); |
| 267 | + addModalHeaderXBtn.classList.add('modal__add-header-x-btn', 'btn-close'); |
| 268 | + addModalBody.classList.add('modal__add-body', 'modal-body'); |
| 269 | + addModalBodyForm.classList.add('modal__add-body-form'); |
| 270 | + addModalBodySurnameInputWrap.classList.add( |
| 271 | + 'modal__add-body-input-wrap', |
| 272 | + 'add-surname-input-wrap' |
| 273 | + ); |
| 274 | + addModalBodySurnameInput.classList.add( |
| 275 | + 'modal__add-body-input', |
| 276 | + 'add-surname-input', |
| 277 | + 'form-control' |
| 278 | + ); |
| 279 | + addModalBodyNameInputWrap.classList.add( |
| 280 | + 'modal__add-body-input-wrap', |
| 281 | + 'add-name-input-wrap' |
| 282 | + ); |
| 283 | + addModalBodyNameInput.classList.add( |
| 284 | + 'modal__add-body-input', |
| 285 | + 'add-name-input', |
| 286 | + 'form-control' |
| 287 | + ); |
| 288 | + addModalBodyPatronymicInputWrap.classList.add( |
| 289 | + 'modal__add-body-input-wrap', |
| 290 | + 'add-patronymic-input-wrap' |
| 291 | + ); |
| 292 | + addModalBodyPatronymicInput.classList.add( |
| 293 | + 'modal__add-body-input', |
| 294 | + 'add-patronymic-input', |
| 295 | + 'form-control' |
| 296 | + ); |
| 297 | + addModalFooter.classList.add('modal__add-footer', 'modal-footer'); |
| 298 | + addModalFooterAddBtnWrap.classList.add('modal__add-footer-add-btn-wrap'); |
| 299 | + addModalFooterAddBtn.classList.add('modal__add-footer-add-btn'); |
| 300 | + addModalFooterSaveBtn.classList.add('modal__add-footer-save-btn'); |
| 301 | + addModalFooterCancelBtn.classList.add('modal__add-footer-cancel-btn'); |
| 302 | + |
| 303 | + addBtn.setAttribute('id', 'add-btn'); |
| 304 | + addBtn.setAttribute('type', 'button'); |
| 305 | + addBtn.setAttribute('data-bs-toggle', 'modal'); |
| 306 | + addBtn.setAttribute('data-bs-target', '#add-btn-modal'); |
| 307 | + addModalWrap.setAttribute('id', 'add-btn-modal'); |
| 308 | + addModalWrap.setAttribute('tabindex', '-1'); |
| 309 | + addModalWrap.setAttribute('aria-hidden', 'true'); |
| 310 | + addModalHeaderXBtn.setAttribute('type', 'button'); |
| 311 | + addModalHeaderXBtn.setAttribute('data-bs-dismiss', 'modal'); |
| 312 | + addModalHeaderXBtn.setAttribute('aria-label', 'Close'); |
| 313 | + addModalBodyForm.setAttribute('id', 'add-modal-form'); |
| 314 | + addModalBodyForm.setAttribute('action', '#'); |
| 315 | + addModalBodyForm.setAttribute('novalidate', ''); |
| 316 | + addModalBodySurnameInput.setAttribute('id', 'add-surname-input'); |
| 317 | + addModalBodySurnameInput.setAttribute('type', 'text'); |
| 318 | + addModalBodySurnameInput.setAttribute('pattern', '[А-Яа-яЁё\\-]+'); |
| 319 | + addModalBodySurnameInput.setAttribute('placeholder', 'Фамилия'); |
| 320 | + addModalBodySurnameInput.setAttribute('required', ''); |
| 321 | + addModalBodyNameInput.setAttribute('id', 'add-name-input'); |
| 322 | + addModalBodyNameInput.setAttribute('type', 'text'); |
| 323 | + addModalBodyNameInput.setAttribute('pattern', '[А-Яа-яЁё\\-]+'); |
| 324 | + addModalBodyNameInput.setAttribute('placeholder', 'Имя'); |
| 325 | + addModalBodyNameInput.setAttribute('required', ''); |
| 326 | + addModalBodyPatronymicInput.setAttribute('id', 'add-patronymic-input'); |
| 327 | + addModalBodyPatronymicInput.setAttribute('type', 'text'); |
| 328 | + addModalBodyPatronymicInput.setAttribute('pattern', '[А-Яа-яЁё\\-]+'); |
| 329 | + addModalBodyPatronymicInput.setAttribute('placeholder', 'Отчество'); |
| 330 | + addModalBodyPatronymicInput.setAttribute('required', ''); |
| 331 | + addModalFooterAddBtn.setAttribute('id', 'add-modal-footer-add-btn'); |
| 332 | + addModalFooterAddBtn.setAttribute('type', 'button'); |
| 333 | + addModalFooterSaveBtn.setAttribute('id', 'add-modal-footer-save-btn'); |
| 334 | + addModalFooterSaveBtn.setAttribute('type', 'button'); |
| 335 | + addModalFooterCancelBtn.setAttribute('id', 'add-modal-footer-cancel-btn'); |
| 336 | + addModalFooterCancelBtn.setAttribute('type', 'button'); |
| 337 | + addModalFooterCancelBtn.setAttribute('data-bs-dismiss', 'modal'); |
238 | 338 |
|
239 | 339 | addBtnText.textContent = 'Добавить клиента'; |
| 340 | + addModalHeaderTitle.textContent = 'Новый клиент'; |
| 341 | + addModalFooterAddBtn.textContent = 'Добавить контакт'; |
| 342 | + addModalFooterSaveBtn.textContent = 'Сохранить'; |
| 343 | + addModalFooterCancelBtn.textContent = 'Отмена'; |
240 | 344 |
|
241 | 345 | addBtn.append(addBtnDefaultIcon, addBtnWhiteIcon, addBtnGrayIcon, addBtnText); |
242 | | - addBtnWrap.append(addBtn, addModalWrap); |
243 | | - crmAddContainer.append(addBtnWrap); |
| 346 | + addBtnWrap.append(addBtn); |
| 347 | + addModalHeader.append(addModalHeaderTitle, addModalHeaderXBtn); |
| 348 | + addModalBodySurnameInputWrap.append(addModalBodySurnameInput); |
| 349 | + addModalBodyNameInputWrap.append(addModalBodyNameInput); |
| 350 | + addModalBodyPatronymicInputWrap.append(addModalBodyPatronymicInput); |
| 351 | + addModalBodyForm.append( |
| 352 | + addModalBodySurnameInputWrap, |
| 353 | + addModalBodyNameInputWrap, |
| 354 | + addModalBodyPatronymicInputWrap |
| 355 | + ); |
| 356 | + addModalBody.append(addModalBodyForm); |
| 357 | + addModalFooterAddBtnWrap.append(addModalFooterAddBtn); |
| 358 | + addModalFooter.append( |
| 359 | + addModalFooterAddBtnWrap, |
| 360 | + addModalFooterSaveBtn, |
| 361 | + addModalFooterCancelBtn |
| 362 | + ); |
| 363 | + addModalContent.append(addModalHeader, addModalBody, addModalFooter); |
| 364 | + addModalDialog.append(addModalContent); |
| 365 | + addModalWrap.append(addModalDialog); |
| 366 | + crmAddContainer.append(addBtnWrap, addModalWrap); |
244 | 367 |
|
245 | 368 | // основные блоки/составляющие элементы приложения |
246 | 369 | crm.append(crmSearch, crmOutput, crmAdd); |
|
0 commit comments