Add preview from father, add new features
This commit is contained in:
77
resources/views/load/form/appender.blade.php
Normal file
77
resources/views/load/form/appender.blade.php
Normal file
@@ -0,0 +1,77 @@
|
||||
@if(!defined('LOAD_APPENDER'))
|
||||
@push('js')
|
||||
<script>
|
||||
|
||||
(function ($) {
|
||||
$.fn.appender = function (settings) {
|
||||
let appendArea = this;
|
||||
let rowHtml = $(settings.rowSection)[0].outerHTML;
|
||||
|
||||
settings.hideSection ? $(settings.rowSection).remove() : "";
|
||||
|
||||
let rowCounter = 1;
|
||||
|
||||
if (settings.rowNumberStart) {
|
||||
rowCounter = Number(settings.rowNumberStart);
|
||||
}
|
||||
|
||||
$(document).on('click', settings.addBtn, function (event) {
|
||||
$(appendArea).append(rowHtml);
|
||||
|
||||
if (settings.appendEffect === 'fade') {
|
||||
$(settings.rowSection).last().hide().fadeIn();
|
||||
} else if (settings.appendEffect === 'slide') {
|
||||
$(settings.rowSection).last().hide().slideDown(200);
|
||||
}
|
||||
|
||||
$(settings.rowSection).last().addClass(settings.addClass);
|
||||
|
||||
$(settings.rowNumber).last().text(rowCounter);
|
||||
|
||||
type = (settings.type) ? settings.type : settings.rowSection;
|
||||
|
||||
$(type).each(function(rowIndex) {
|
||||
$(this).find('input[name]').each(function() {
|
||||
var name = $(this).attr('name');
|
||||
name = name.replace(/\[[0-9]?\]/g, '['+rowIndex+']');
|
||||
$(this).attr('name',name);
|
||||
});
|
||||
$(this).find('select[name]').each(function() {
|
||||
var name = $(this).attr('name');
|
||||
name = name.replace(/\[[0-9]?\]/g, '['+rowIndex+']');
|
||||
$(this).attr('name',name);
|
||||
});
|
||||
$(this).find('textarea[name]').each(function() {
|
||||
var name = $(this).attr('name');
|
||||
name = name.replace(/\[[0-9]?\]/g, '['+rowIndex+']');
|
||||
$(this).attr('name',name);
|
||||
});
|
||||
$(this).find('.appender').each(function() {
|
||||
$(this).data('id',rowIndex);
|
||||
});
|
||||
});
|
||||
|
||||
rowCounter++;
|
||||
|
||||
if (settings.callback) {
|
||||
settings.callback();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
if (settings.deleteBtn) {
|
||||
$(document).on('click', settings.deleteBtn, function (e) {
|
||||
$(e.target).closest(settings.rowSection).remove();
|
||||
if (settings.callback) {
|
||||
settings.callback();
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
}(jQuery));
|
||||
</script>
|
||||
@endpush
|
||||
@php(define('LOAD_APPENDER', true))
|
||||
@endif
|
||||
6
resources/views/load/form/builder/formbuilder.blade.php
Normal file
6
resources/views/load/form/builder/formbuilder.blade.php
Normal file
@@ -0,0 +1,6 @@
|
||||
@if(!defined('LOAD_FORMBUILDER'))
|
||||
@push('scripts')
|
||||
<script src="{{ asset('/assets/plugins/formBuilder/form-builder.min.js') }}"></script>
|
||||
@endpush
|
||||
@php(define('LOAD_FORMBUILDER', true))
|
||||
@endif
|
||||
9
resources/views/load/form/builder/formio.blade.php
Normal file
9
resources/views/load/form/builder/formio.blade.php
Normal file
@@ -0,0 +1,9 @@
|
||||
@if(!defined('LOAD_FORMIOJS'))
|
||||
@push('css')
|
||||
<link rel="stylesheet" href="{{ asset('/assets/plugins/formiojs/formio.full.min.css') }}">
|
||||
@endpush
|
||||
@push('scripts')
|
||||
<script src="{{ asset('/assets/plugins/formiojs/formio.full.min.js') }}"></script>
|
||||
@endpush
|
||||
@php(define('LOAD_FORMIOJS', true))
|
||||
@endif
|
||||
39
resources/views/load/form/check_fields.blade.php
Normal file
39
resources/views/load/form/check_fields.blade.php
Normal file
@@ -0,0 +1,39 @@
|
||||
function checkCollapsedFields(selector)
|
||||
{
|
||||
var fields = selector + ' input,' + selector + ' textarea,' + selector + ' select';
|
||||
console.log(fields);
|
||||
|
||||
var nb_fields = $(fields).length;
|
||||
console.log(nb_fields);
|
||||
var nb_required = $(fields).filter('[required]').length;
|
||||
console.log(nb_required);
|
||||
var nb_filled = 0;
|
||||
var nb_necessary = 0;
|
||||
|
||||
$(fields).each(function(i, field){
|
||||
if ($(field).val() != '')
|
||||
{
|
||||
nb_filled++;
|
||||
}
|
||||
});
|
||||
|
||||
$(fields).filter('[required]').each(function(i, required){
|
||||
if ($(required).val() != '')
|
||||
{
|
||||
nb_necessary++;
|
||||
}
|
||||
});
|
||||
|
||||
var result = nb_filled + " / " + nb_fields;
|
||||
result = result + " | " + nb_necessary + " / " + nb_required;
|
||||
|
||||
console.log(result);
|
||||
|
||||
var check = $(selector).parent().find('.check');
|
||||
console.log(check);
|
||||
|
||||
// $(selector).parent().find('.check').html(result);
|
||||
if (nb_necessary < nb_required) {
|
||||
$(selector).collapse('show');
|
||||
}
|
||||
}
|
||||
22
resources/views/load/form/color.blade.php
Normal file
22
resources/views/load/form/color.blade.php
Normal file
@@ -0,0 +1,22 @@
|
||||
@if(!defined('LOAD_COLOR'))
|
||||
@push('scripts')
|
||||
<script src="{{ asset('/assets/plugins/jquery-minicolors/jquery.minicolors.min.js') }}"></script>
|
||||
|
||||
<script>
|
||||
function initColor(sel) {
|
||||
var selector = (typeof(sel) == 'undefined') ? '.color' : sel;
|
||||
var settings = {
|
||||
position: 'bottom left',
|
||||
theme: 'bootstrap'
|
||||
};
|
||||
$(selector).minicolors(settings);
|
||||
}
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
|
||||
@push('css')
|
||||
<link rel="stylesheet" href="{{ asset('/assets/plugins/jquery-minicolors/jquery.minicolors.css') }}">
|
||||
@endpush
|
||||
@php(define('LOAD_COLOR', true))
|
||||
@endif
|
||||
25
resources/views/load/form/duallist.blade.php
Normal file
25
resources/views/load/form/duallist.blade.php
Normal file
@@ -0,0 +1,25 @@
|
||||
@if(!defined('LOAD_DUALLIST'))
|
||||
@push('scripts')
|
||||
<script src="{{ asset('/assets/plugins/bootstrap4-duallistbox/jquery.bootstrap-duallistbox.min.js') }}"></script>
|
||||
|
||||
<script>
|
||||
function initDualList(sel) {
|
||||
var selector = (typeof(sel) == 'undefined') ? '.duallist' : sel;
|
||||
var settings = {
|
||||
nonSelectedListLabel: 'Non-selected',
|
||||
selectedListLabel: 'Selected',
|
||||
preserveSelectionOnMove: 'moved',
|
||||
moveOnSelect: true,
|
||||
nonSelectedFilter: ''
|
||||
};
|
||||
$(selector).bootstrapDualListbox(settings);
|
||||
}
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
|
||||
@push('css')
|
||||
<link rel="stylesheet" href="{{ asset('/assets/plugins/bootstrap4-duallistbox/bootstrap-duallistbox.min.css') }}">
|
||||
@endpush
|
||||
@php(define('LOAD_DUALLIST', true))
|
||||
@endif
|
||||
15
resources/views/load/form/editor/editor.blade.php
Normal file
15
resources/views/load/form/editor/editor.blade.php
Normal file
@@ -0,0 +1,15 @@
|
||||
@if(!defined('LOAD_EDITOR'))
|
||||
|
||||
@include('load.form.editor.tinymce')
|
||||
|
||||
@push('js')
|
||||
<script>
|
||||
function initEditor(selector) {
|
||||
var selector = '.editor';
|
||||
$(selector).tinymce({});
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@php(define('LOAD_EDITOR', true))
|
||||
@endif
|
||||
41
resources/views/load/form/editor/tinymce.blade.php
Normal file
41
resources/views/load/form/editor/tinymce.blade.php
Normal file
@@ -0,0 +1,41 @@
|
||||
@if(!defined('LOAD_TINYMCE'))
|
||||
@push('js')
|
||||
<script src="{!! mix('/js/tinymce/tinymce.min.js', '/assets/vendor/boilerplate') !!}"></script>
|
||||
<script>
|
||||
tinymce.defaultSettings = {
|
||||
plugins: "autoresize fullscreen codemirror link lists table media image imagetools paste customalign stickytoolbar",
|
||||
toolbar: "undo redo | styleselect | bold italic underline | customalignleft aligncenter customalignright | link media image | bullist numlist | table | code fullscreen",
|
||||
contextmenu: "link image imagetools table spellchecker bold italic underline",
|
||||
sticky_toolbar_container: '.tox-editor-header',
|
||||
toolbar_drawer: "sliding",
|
||||
sticky_offset: $('nav.main-header').outerHeight(),
|
||||
codemirror: { config: { theme: 'storm' } },
|
||||
menubar: false,
|
||||
removed_menuitems: 'newdocument',
|
||||
remove_linebreaks: false,
|
||||
forced_root_block: false,
|
||||
force_p_newlines: true,
|
||||
relative_urls: false,
|
||||
verify_html: false,
|
||||
branding: false,
|
||||
statusbar: false,
|
||||
browser_spellcheck: true,
|
||||
encoding: 'UTF-8',
|
||||
image_uploadtab: false,
|
||||
paste_preprocess: function(plugin, args) {
|
||||
args.content = args.content.replace(/<(\/)*(\\?xml:|meta|link|span|font|del|ins|st1:|[ovwxp]:)((.|\s)*?)>/gi, ''); // Unwanted tags
|
||||
args.content = args.content.replace(/\s(class|style|type|start)=("(.*?)"|(\w*))/gi, ''); // Unwanted attributes
|
||||
args.content = args.content.replace(/<(p|a|div|span|strike|strong|i|u)[^>]*?>(\s| |<br\/>|\r|\n)*?<\/(p|a|div|span|strike|strong|i|u)>/gi, ''); // Empty tags
|
||||
},
|
||||
skin : "boilerplate",
|
||||
language: '{{ App::getLocale() }}'
|
||||
};
|
||||
|
||||
function initEditor(sel) {
|
||||
var selector = (typeof(sel) == 'undefined') ? '.editor' : sel;
|
||||
$(selector).tinymce({});
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
@php(define('LOAD_TINYMCE', true))
|
||||
@endif
|
||||
18
resources/views/load/form/select2.blade.php
Normal file
18
resources/views/load/form/select2.blade.php
Normal file
@@ -0,0 +1,18 @@
|
||||
@if(!defined('LOAD_SELECT2'))
|
||||
@push('scripts')
|
||||
<script src="{!! mix('/js/select2/select2.full.min.js', '/assets/vendor/boilerplate') !!}"></script>
|
||||
<script src="{!! asset('/assets/vendor/boilerplate/js/select2/i18n/'.config('boilerplate.app.locale').'.js') !!}"></script>
|
||||
<script>
|
||||
function initSelect2() {
|
||||
$(".select2").select2({
|
||||
placeholder: "{{ __('select_a_value') }}",
|
||||
allowClear: false,
|
||||
width: {
|
||||
value: '100%'
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
@php(define('LOAD_SELECT2', true))
|
||||
@endif
|
||||
25
resources/views/load/form/set_options.blade.php
Normal file
25
resources/views/load/form/set_options.blade.php
Normal file
@@ -0,0 +1,25 @@
|
||||
@if(!defined('LOAD_SET_OPTIONS'))
|
||||
@push('js')
|
||||
<script>
|
||||
function setOptions(selector,data,selected,all) {
|
||||
// console.log(data);
|
||||
console.log(selector);
|
||||
var $el = $(selector);
|
||||
$el.empty(); // remove old options
|
||||
if (all) {
|
||||
$el.append($("<option></option>").attr("value",'').text('{{ __("all") }}'));
|
||||
}
|
||||
$.each(data, function(key, name) {
|
||||
if (key != null) {
|
||||
if (key == selected) {
|
||||
$el.append($("<option selected='selected'></option>").attr("value", key).text(name));
|
||||
} else {
|
||||
$el.append($("<option></option>").attr("value", key).text(name));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
@php(define('LOAD_SET_OPTIONS', true))
|
||||
@endif
|
||||
34
resources/views/load/form/toggle.blade.php
Normal file
34
resources/views/load/form/toggle.blade.php
Normal file
@@ -0,0 +1,34 @@
|
||||
@if(!defined('LOAD_TOGGLE'))
|
||||
@push('scripts')
|
||||
<script src="{{ asset('/assets/plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js') }}"></script>
|
||||
|
||||
<script>
|
||||
function initToggle(url, sel, data, callback) {
|
||||
var selector = (typeof(sel) == 'undefined') ? '.toggle' : sel;
|
||||
if (typeof(data) == 'undefined') {
|
||||
var data = {};
|
||||
}
|
||||
$(selector).bootstrapToggle();
|
||||
|
||||
$('input' + selector).change(function() {
|
||||
console.log($(this));
|
||||
data['id'] = $(this).data('id');
|
||||
data['active'] = $(this).is(':checked');
|
||||
if (data['id'] && (typeof(url) != 'undefined') && (url != '')) {
|
||||
var dataJson = Object.assign({}, data);
|
||||
$.post(url, dataJson);
|
||||
}
|
||||
if (typeof(callback) != 'undefined') {
|
||||
eval(callback);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
|
||||
@push('css')
|
||||
<link rel="stylesheet" href="{{ asset('/assets/plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css') }}">
|
||||
@endpush
|
||||
@php(define('LOAD_TOGGLE', true))
|
||||
@endif
|
||||
25
resources/views/load/form/upload/fileinput.blade.php
Normal file
25
resources/views/load/form/upload/fileinput.blade.php
Normal file
@@ -0,0 +1,25 @@
|
||||
@if(!defined('LOAD_FILEINPUT'))
|
||||
@push('css')
|
||||
<link rel="stylesheet" href="{!! mix('/js/fileinput/bootstrap-fileinput.min.css', '/assets/vendor/boilerplate') !!}">
|
||||
@endpush
|
||||
@push('js')
|
||||
<script src="{!! mix('/js/fileinput/bootstrap-fileinput.min.js', '/assets/vendor/boilerplate') !!}"></script>
|
||||
@if(App::getLocale() !== 'en')
|
||||
<script src="{!! asset('/assets/vendor/boilerplate/js/fileinput/locales/'.config('boilerplate.app.locale').'.js') !!}"></script>
|
||||
<script>
|
||||
$.fn.fileinput.defaults.language = '{{ config('boilerplate.app.locale') }}';
|
||||
</script>
|
||||
@endif
|
||||
@endpush
|
||||
<script>
|
||||
function initUpload(selector) {
|
||||
var selector = '.file';
|
||||
$(selector).fileinput({
|
||||
showCaption: false,
|
||||
dropZoneEnabled: false,
|
||||
showUpload: false,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@php(define('LOAD_FILEINPUT', true))
|
||||
@endif
|
||||
29
resources/views/load/form/upload/upload.blade.php
Normal file
29
resources/views/load/form/upload/upload.blade.php
Normal file
@@ -0,0 +1,29 @@
|
||||
@if(!defined('LOAD_FILEINPUT'))
|
||||
@push('css')
|
||||
<link rel="stylesheet" href="{!! mix('/js/fileinput/bootstrap-fileinput.min.css', '/assets/vendor/boilerplate') !!}">
|
||||
@endpush
|
||||
|
||||
@push('js')
|
||||
<script src="{!! mix('/js/fileinput/bootstrap-fileinput.min.js', '/assets/vendor/boilerplate') !!}"></script>
|
||||
@if(App::getLocale() !== 'en')
|
||||
<script src="{!! asset('/assets/vendor/boilerplate/js/fileinput/locales/' . App::getLocale() . '.js') !!}"></script>
|
||||
<script>
|
||||
$.fn.fileinput.defaults.language = '{{ App::getLocale() }}';
|
||||
</script>
|
||||
@endif
|
||||
|
||||
<script>
|
||||
function initUpload(sel) {
|
||||
var selector = (typeof(sel) == 'undefined') ? '.file' : sel;
|
||||
$(selector).fileinput({
|
||||
showCaption: false,
|
||||
dropZoneEnabled: false,
|
||||
showUpload: false,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
|
||||
@php(define('LOAD_FILEINPUT', true))
|
||||
@endif
|
||||
16
resources/views/load/form/url.blade.php
Normal file
16
resources/views/load/form/url.blade.php
Normal file
@@ -0,0 +1,16 @@
|
||||
@if(!defined('LOAD_URL'))
|
||||
@include('load.layout.modal')
|
||||
@push('js')
|
||||
<script>
|
||||
function initLoadUrl(sel) {
|
||||
var selector = (typeof(sel) == 'undefined') ? '.btn-web' : sel;
|
||||
|
||||
$(selector).off().click(function() {
|
||||
var url = $(this).closest('.input-group').find('.url').val();
|
||||
viewModal(url);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
@php(define('LOAD_URL', true))
|
||||
@endif
|
||||
114
resources/views/load/layout/modal.blade.php
Normal file
114
resources/views/load/layout/modal.blade.php
Normal 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
|
||||
29
resources/views/load/layout/nicescroll.blade.php
Normal file
29
resources/views/load/layout/nicescroll.blade.php
Normal 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
|
||||
6
resources/views/load/layout/slimscroll.blade.php
Normal file
6
resources/views/load/layout/slimscroll.blade.php
Normal 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
|
||||
39
resources/views/load/layout/tabs.blade.php
Normal file
39
resources/views/load/layout/tabs.blade.php
Normal 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
|
||||
Reference in New Issue
Block a user