/** * Параметры настройки кнопок в футере модального окна */ interface IButton { text: string, class: string, disabled?: boolean; id?: string, click: () => void, } /** * Параметры настройки модального окна */ interface IModalSettings { selectorOrHtml?: string, object?: JQuery, title?: string, titleLowercase?: boolean, subTitle?: string, content?: string, contentClasses?: string, buttons: IButton[], addCancelButton?: boolean, closeClick?: () => void, color?: ModalTitleColors } /** * Размер модального окна * (по умолчанию 670 px) */ enum ModalSizeClasses { // 440 px "sm" = 1, // 670 px "" = 2, // 900 px "xl" = 3 } enum ModalTitleColors { Tenant = "", Default = "head-default", Success = "head-success", Warning = "head-warning", Error = "head-error" } /** * Компонент модальное окно */ class Modal { constructor(public settings: IModalSettings) { let modal = settings.selectorOrHtml ? $(settings.selectorOrHtml) : settings.object; let body = modal.find(".modal-body"); modal.addClass(ModalSizeClasses[modal.attr("modal-size")]); if (settings.buttons || settings.addCancelButton) { var footer = modal.find(".modal-footer"); if (footer.length <= 0) { footer = $(''); if (body) { body.after(footer); } } footer.find('[dynamic="true"]').remove(); if (settings.addCancelButton) { var button = $('