diff --git a/resources/views/load/layout/modal.blade.php b/resources/views/load/layout/modal.blade.php
index eb850bbb..eb8965ac 100644
--- a/resources/views/load/layout/modal.blade.php
+++ b/resources/views/load/layout/modal.blade.php
@@ -1,105 +1,213 @@
@if(!defined('LOAD_MODAL'))
@push('js')
+ @component('boilerplate::minify')
+
+ function changeModalContent(dialog, url, callback) {
+ dialog.init(function() {
+ $.get(url, function(data) {
+ dialog.find('.bootbox-body').html(data);
+ });
+ });
+ }
+
+ function viewModal(url, size, title) {
+ var dialog = bootbox.dialog({
+ title: title ? title : 'Web viewer',
+ message: '',
+ size: size ? size : 'xl',
+ scrollable: true,
+ });
+ }
+
+ function viewWindow(url, size, title) {
+ var width = (size == 'sm') ? 400 : 600;
+ var title = title ? title : 'Web viewer';
+ window.open(url, title, "menubar=no, status=no, scrollbars=no, menubar=no, width=" + width + ", height=400");
+ }
+
+ function buildModalButtons(form_id, no_confirm, callback) {
+ return no_confirm ? '' : {
+ cancel: {
+ label: ' {{ __("Core.cancel") }}',
+ className: 'btn-secondary'
+ },
+ confirm: {
+ label: ' {{ __("Core.save") }}',
+ className: 'btn-success',
+ callback: function() {
+ return submitModal(form_id, callback);
+ }
+ },
+ };
+ }
+
+ function submitModal(form_id, callback) {
+ if (typeof(tinyMCE) != 'undefined') {
+ tinyMCE.triggerSave();
+ }
+ var $form = $(form_id);
+ console.log('submitModal ' + form_id);
+ if ($form.valid()) {
+ deactivateButton($form);
+ console.log('check valid');
+ $form.submit();
+ }
+ return false;
+ }
+
+ function handlePostModal(form_id, url_save, callback, onPostModal) {
+ // console.log('handlePostModal');
+ // initValidator();
+ var response = false;
+ $(form_id).submit(function(e) {
+ e.preventDefault();
+ console.log('handlepostmodal submit');
+
+ if (onPostModal) {
+ response = eval(onPostModal);
+ } else {
+ response = postModal(form_id, url_save, callback);
+ }
+ // console.log(response);
+ });
+ return response;
+ }
+
+ function postModal(form_id, url_save, callback) {
+ console.log('postModal');
+ console.log(form_id);
+ console.log(callback);
+ var ret = false;
+ var $form = $(form_id);
+ var myForm = document.getElementById(form_id.substring(1));
+
+ $.ajax({
+ url: url_save,
+ type: 'POST',
+ data: new FormData(myForm),
+ success: function (data) {
+ if (callback) {
+ eval(callback);
+ }
+ if (!data.error) {
+ bootbox.hideAll();
+ }
+ },
+ crossDomain: true,
+ headers: {
+ "accept": "application/json",
+ "Access-Control-Allow-Origin":"*"
+ },
+ cache: false,
+ contentType: false,
+ processData: false
+ });
+
+ return ret;
+ }
+
+ function openWindow(url, target) {
+ target = (typeof(target) == 'undefined') ? '_blank' : target;
+ if (target == '_blank') {
+ var anchor = document.createElement('a');
+ anchor.href = url;
+ anchor.target = "_blank";
+ anchor.click();
+ } else {
+ window.location = url;
+ }
+ }
+
+ function reactivateButton($form) {
+ console.log('activateButton');
+ var $button = $form.closest('.modal-content').find('.bootbox-accept').first();
+ if ($button.attr("disabled")) {
+ $button.prop("disabled", false);
+ $button.html(" {{ __('Core.save') }}");
+ }
+ }
+
+ function deactivateButton($form) {
+ console.log('deactivateButton');
+ console.log($form);
+ var $button = $form.closest('.modal-content').find('.bootbox-accept').first();
+ console.log($button);
+ $button.prop("disabled", true);
+ $button.html(" {{ __('Core.processing') }}");
+ }
+
+
+ @endcomponent
@endpush
@php(define('LOAD_MODAL', true))
-@endif
\ No newline at end of file
+@endif