Add preview from father, add new features

This commit is contained in:
Ludovic CANDELLIER
2021-04-11 00:36:41 +02:00
parent f781158e36
commit f5ca57fdf2
58 changed files with 1482 additions and 532 deletions

View File

@@ -0,0 +1,16 @@
@if(!defined('LOAD_CHEVRON'))
@push('scripts')
<script>
function initChevron(sel) {
var selector = (typeof(sel) == 'undefined') ? '.card-header .btn-link' : sel;
$(selector).click(function() {
$(this).find('i').toggleClass('fa-chevron-right fa-chevron-down')
});
}
</script>
@endpush
@php(define('LOAD_CHEVRON', true))
@endif

View File

@@ -0,0 +1,114 @@
@if(!defined('LOAD_MODAL'))
@push('js')
<script>
function openModal(title, form_id, url_open, url_save, callback, size, no_confirm) {
var status = 0;
var dialog = bootbox.dialog({
title: title,
message: '<p><i class="fa fa-spin fa-spinner"></i> {{ __('loading') }} ...</p>',
size: size ? size : 'large',
scrollable: true,
onHide: function(e) {
console.log(status);
},
buttons: buildModalButtons(form_id, no_confirm)
});
/*
changeModalContent(dialog, url_open);
var callback = handlePostModal(form_id,url_save, callback);
handlePostModal(form_id,url_save, callback);
*/
dialog.init(function() {
$.get(url_open, function(data) {
dialog.find('.bootbox-body').html(data);
handlePostModal(form_id,url_save, callback);
});
});
}
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: '<iframe style="border:0;" src="' + url + '" height="400" width="100%"></iframe>',
size: size ? size : 'xl',
scrollable: true,
});
}
function buildModalButtons(form_id, no_confirm) {
if (!no_confirm) {
var buttons = {
cancel: {
label: '{{ __('cancel') }}',
className: 'btn-secondary'
},
confirm: {
label: '{{ __('save') }}',
className: 'btn-success',
callback: function() {
submitModal(form_id);
}
},
};
} else {
buttons = '';
}
return buttons;
}
function submitModal(form_id) {
/*
var data = $(form_id).serialize();
$.post(url_save, data)
.done(function(data) {
if (callback) {
eval(callback);
}
});
*/
if (typeof(tinyMCE) != 'undefined') {
tinyMCE.triggerSave();
}
var oForm = 'form' + form_id;
$(oForm).submit();
status = 1;
}
function handlePostModal(form_id,url_save, callback) {
var oForm = 'form'+form_id;
$(oForm).submit(function(e) {
e.preventDefault();
var formData = new FormData(this);
$.ajax({
url: url_save,
type: 'POST',
data: formData,
success: function (data) {
if (callback) {
eval(callback);
}
},
cache: false,
contentType: false,
processData: false
});
});
}
</script>
@endpush
@php(define('LOAD_MODAL', true))
@endif

View File

@@ -0,0 +1,29 @@
@if(!defined('LOAD_NICESCROLL'))
@push('scripts')
<script type="text/javascript" src="{{ asset('/assets/plugins/jquery.slimscroll.min.js') }}"></script>
<script>
function initScroll(selector) {
var selector = (typeof(selector) == 'undefined') ? '.nicescrollable' : selector;
$(selector).niceScroll({
horizrailenabled: false,
cursorborder: "0",
cursorwidth: "8px",
cursorcolor: "#fff",
zindex: "5555",
autohidemode: true,
bouncescroll: true,
mousescrollstep: 40,
scrollspeed: 100,
background: "#cdcdcd",
cursoropacitymin: 0.3,
cursoropacitymax: 0.7,
cursorborderradius: 0,
railpadding: {top:0,right:1,left:0,bottom:0}
});
}
</script>
@endpush
@php(define('LOAD_NICESCROLL', true))
@endif

View File

@@ -0,0 +1,6 @@
@if(!defined('LOAD_SLIMSCROLL'))
@push('scripts')
<script type="text/javascript" src="{{ asset('/assets/plugins/jquery.slimscroll.min.js') }}"></script>
@endpush
@php(define('LOAD_SLIMSCROLL', true))
@endif

View File

@@ -0,0 +1,39 @@
@if(!defined('LOAD_TABS'))
@push('scripts')
<script>
function addTab(name, id, txt, url) {
var navContainer = $('#'+name);
var tabContainer = $('#'+name + '-tab');
var newTab = name + '-' + id;
var newTabId = '#' + newTab;
// create the tab
$('<a href="'+newTabId+'" data-toggle="tab" class="nav-item nav-link" role="tab">'+txt+'</a>').appendTo(navContainer);
var url_open = url + id;
$.get(url_open, function(content) {
$('<div class="tab-pane fade pt-0 pb-0" id="'+newTab+'"><div class="card mb-0 card-outline card-info"><div class="card-body">'+content+'</div></div></div>').appendTo(tabContainer);
// make the new tab active
// console.log('#' + tabname + ' .nav-item a:last');
// $('#' + tabname + ' .nav-item a:last').tab('show');
});
}
function removeTab(name, id) {
var tabId = '#' + name + '-' + id;
// console.log('#' + name + "a[href='" + tabId + "'])");
$('#' + name + " a[href='" + tabId + "']").remove();
// console.log('remove ' + tabId);
$(tabId).remove();
}
</script>
@endpush
@php(define('LOAD_TABS', true))
@endif