laravel-jstools
Version:
JS tools for building front-side of Laravel applications
56 lines (55 loc) • 1.55 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JQueryModal = void 0;
const $ = require("jquery");
class JQueryModal {
constructor(id, openModalCallback) {
this.id = id;
this.openModalCallback = openModalCallback;
this.modalId = `#modal-${id}`;
this.prefix = `${this.modalId}__`;
}
isLoaded() {
return this.$modal !== null;
}
load() {
this.$modal = $(this.modalId);
this.$overlay = this.$modal.find(`${this.prefix}overlay`);
this.$title = this.$modal.find(`${this.prefix}title`);
}
hide() {
this.$modal.modal('hide');
}
showOverlay() {
this.$overlay.show();
}
hideOverlay() {
this.$overlay.hide();
}
initOpen(openData) {
if (openData.title) {
this.$title.text(openData.title);
}
// if (this.$btnSubmit && openData.submitText) {
// this.$btnSubmit.text(openData.submitText);
// }
//
// if (openData.cancelText) {
// this.$btnCancel.text(openData.cancelText);
// }
//
// if (openData.bodyText) {
// this.$bodyText.text(openData.bodyText);
// }
//
// this.lockFields(openData.lock || []);
}
open() {
if (!this.isLoaded()) {
this.load();
}
this.initOpen({});
this.$modal.modal('show');
}
}
exports.JQueryModal = JQueryModal;