Aknaproff/resources/views/layouts/partials/javascript.blade.php

475 lines
19 KiB
PHP
Raw Normal View History

2023-09-21 12:45:08 +00:00
@php
$is_download = isset($is_download) ? $is_download : false;
$form = !empty($form) ? $form : '';
@endphp
2023-09-21 14:20:06 +00:00
<!-- reCaptcha -->
2023-09-21 12:45:08 +00:00
<script src="//www.google.com/recaptcha/api.js?v={{$asset_version}}" async defer></script>
<script type="text/javascript">
2023-09-21 14:20:06 +00:00
if (typeof jQuery == 'undefined') {
document.write('<script src="//code.jquery.com/jquery-3.4.1.min.js?v={{$asset_version}}"></' + 'script>');
2023-09-21 12:45:08 +00:00
}
</script>
<!-- Bootstrap Js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js?v={{$asset_version}}"></script>
<script src="//stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js?v={{$asset_version}}"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/npm/moment@2.24.0/moment.min.js?v={{$asset_version}}"></script>
<script src="//cdn.jsdelivr.net/npm/toastr@2.1.4/build/toastr.min.js?v={{$asset_version}}"></script>
<script src="//cdn.jsdelivr.net/npm/jquery-validation@1.17.0/dist/jquery.validate.min.js?v={{$asset_version}}"></script>
2023-09-21 14:20:06 +00:00
<script type="text/javascript"
src="//cdnjs.cloudflare.com/ajax/libs/rangeslider.js/2.3.2/rangeslider.min.js?v={{$asset_version}}"></script>
<script type="text/javascript"
src="//cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.1.2/js/tempusdominus-bootstrap-4.min.js?v={{$asset_version}}"></script>
2023-09-21 12:45:08 +00:00
2023-09-21 14:20:06 +00:00
<script type="text/javascript"
src="//cdnjs.cloudflare.com/ajax/libs/dropzone/5.5.1/min/dropzone.min.js?v={{$asset_version}}"></script>
2023-09-21 12:45:08 +00:00
2023-09-21 14:20:06 +00:00
<script type="text/javascript"
src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.10/js/bootstrap-select.min.js?v={{$asset_version}}"></script>
<script type="text/javascript"
src="//cdnjs.cloudflare.com/ajax/libs/summernote/0.8.12/summernote-bs4.min.js?v={{$asset_version}}"></script>
2023-09-21 12:45:08 +00:00
<!-- Boostrap star rating -->
2023-09-21 14:20:06 +00:00
<script
src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-star-rating/4.0.6/js/star-rating.min.js?v={{$asset_version}}"
type="text/javascript"></script>
2023-09-21 12:45:08 +00:00
<!-- if you need to use a theme, then include the theme Js file -->
2023-09-21 14:20:06 +00:00
<script
src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-star-rating/4.0.6/themes/krajee-svg/theme.js?v={{$asset_version}}"></script>
2023-09-21 12:45:08 +00:00
<!-- optionally if you need translation for your language then include locale file as mentioned below -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-star-rating/4.0.6/js/locales/<lang>.js"></script> -->
<!-- signature pad (https://github.com/szimek/signature_pad)-->
<script src="https://cdn.jsdelivr.net/npm/signature_pad@2.3.2/dist/signature_pad.min.js?v={{$asset_version}}"></script>
<script src="{{asset('/plugins/countdowntimer/countdowntimer.min.js').'?v='.$asset_version}}"></script>
@if(!$is_download)
2023-09-21 14:01:58 +00:00
2023-09-21 12:45:08 +00:00
<!-- app js values -->
<script type="application/javascript">
var APP = {};
APP.APP_URL = "{{config('app.url')}}";
APP.CURRENCY_SYMBOL = "{{env('CURRENCY_SYMBOL')}}";
APP.ACELLE_MAIL_NAME = "{{config('constants.ACELLE_MAIL_NAME')}}";
APP.ACELLE_MAIL_ENABLED = false;
APP.APP_MEDIA_URL = "{{asset('/uploads/'.config('constants.doc_path').'/')}}";
APP.PDF_PLACEHOLDER = "{{asset('/img/pdf_placeholder.png')}}";
APP.MAX_UPLOAD_SIZE = "{{config('constants.max_upload_size')}}";
APP.MAX_PDF_UPLOAD_SIZE = "{{config('constants.pdf_upload_size')}}";
@if(!empty(config('constants.ACELLE_MAIL_NAME')) && !empty(config('constants.ACELLE_MAIL_API')))
APP.ACELLE_MAIL_ENABLED = true;
@endif
$.ajaxSetup({
2023-09-21 14:20:06 +00:00
beforeSend: function (jqXHR, settings) {
2023-09-21 12:45:08 +00:00
if (settings.url.indexOf('http') === -1) {
settings.url = APP.APP_URL + settings.url;
}
},
});
</script>
<script type="text/javascript">
//function to print page
function printElement(elem) {
var domClone = elem.cloneNode(true);
var printSection = document.getElementById("printSection");
2023-09-21 14:01:58 +00:00
2023-09-21 12:45:08 +00:00
if (!printSection) {
var printSection = document.createElement("div");
printSection.id = "printSection";
document.body.appendChild(printSection);
}
printSection.innerHTML = "";
printSection.appendChild(domClone);
window.print();
}
</script>
2023-09-21 14:20:06 +00:00
<script
src="//cdn.jsdelivr.net/npm/jquery-validation-unobtrusive@3.2.10/dist/jquery.validate.unobtrusive.min.js?v={{$asset_version}}"></script>
2023-09-21 12:45:08 +00:00
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11?v={{$asset_version}}"></script>
2023-09-21 14:20:06 +00:00
<script type="text/javascript"
src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js?v={{$asset_version}}"></script>
<script type="text/javascript"
src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js?v={{$asset_version}}"></script>
<script type="text/javascript"
src="//cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.10.18/b-1.5.6/b-colvis-1.5.6/b-flash-1.5.6/b-html5-1.5.6/b-print-1.5.6/fc-3.3.1/fh-3.1.4/datatables.min.js?v={{$asset_version}}"></script>
2023-09-21 12:45:08 +00:00
<!-- ladda.js -->
2023-09-21 14:20:06 +00:00
<script type="text/javascript"
src="//cdnjs.cloudflare.com/ajax/libs/Ladda/1.0.6/spin.min.js?v={{$asset_version}}"></script>
<script type="text/javascript"
src="//cdnjs.cloudflare.com/ajax/libs/Ladda/1.0.6/ladda.min.js?v={{$asset_version}}"></script>
2023-09-21 12:45:08 +00:00
<!-- localization -->
<script src="{{ url('/js/lang.js') . '?v=' . $asset_version }}"></script>
<script src="{{ asset(mix('js/app.js')) }}" defer></script>
<!-- intro.js -->
2023-09-21 14:20:06 +00:00
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.9.3/intro.min.js?v={{$asset_version}}"></script>
2023-09-21 12:45:08 +00:00
<script src="{{ asset('js/iframeResizercontentWindow.js') }}"></script>
@endif
<script type="text/javascript">
jQuery.validator.setDefaults({
2023-09-21 14:20:06 +00:00
errorPlacement: function (error, element) {
2023-09-21 12:45:08 +00:00
if (element.hasClass('select2') && element.parent().hasClass('input-group')) {
error.insertAfter(element.parent());
} else if (element.hasClass('select2')) {
error.insertAfter(element.next('span.select2-container'));
} else if (element.parent().hasClass('input-group')) {
error.insertAfter(element.parent());
} else if (element.parent().hasClass('multi-input')) {
error.insertAfter(element.closest('.multi-input'));
2023-09-21 14:20:06 +00:00
} else if (element.hasClass('summer_note')) {
2023-09-21 12:45:08 +00:00
error.insertAfter(element.next('.note-editor'));
2023-09-21 14:20:06 +00:00
} else if (element.hasClass('custom-control-input')) {
2023-09-21 12:45:08 +00:00
error.insertAfter(element.parent().parent().parent());
2023-09-21 14:20:06 +00:00
} else if (element.hasClass('star_rating')) {
2023-09-21 12:45:08 +00:00
error.insertAfter(element.parent().parent());
} else if (element.hasClass('switch')) {
error.insertAfter(element.parent().parent());
} else if (element.hasClass('signature')) {
error.insertAfter(element.parent());
} else {
error.insertAfter(element);
}
},
2023-09-21 14:20:06 +00:00
invalidHandler: function () {
2023-09-21 12:45:08 +00:00
toastr.error("{{ __('messages.some_error_in_input_field') }}");
}
});
2023-09-21 14:01:58 +00:00
2023-09-21 14:20:06 +00:00
$(document).ready(function () {
2023-09-21 12:45:08 +00:00
@if(!$is_download)
2023-09-21 14:20:06 +00:00
jQuery.extend($.fn.dataTable.defaults, {
fixedHeader: false,
aLengthMenu: [
[25, 50, 100, 200, 500, 1000, -1], [25, 50, 100, 200, 500, 1000, "{{__('messages.all')}}"]
],
iDisplayLength: 25,
dom: 'lfrtip',
"language": {
"emptyTable": "{{__('messages.emptyTable')}}",
"info": "{{__('messages.dt_info')}}",
"infoEmpty": "{{__('messages.infoEmpty')}}",
"infoFiltered": "{{__('messages.infoFiltered')}}",
"lengthMenu": "{{__('messages.lengthMenu')}}",
"loadingRecords": "{{__('messages.loadingRecords')}}",
"processing": "{{__('messages.processing')}}",
"search": "{{__('messages.search')}}",
"zeroRecords": "{{__('messages.zeroRecords')}}",
"paginate": {
"first": "{{__('messages.first')}}",
"last": "{{__('messages.last')}}",
"next": "{{__('messages.next')}}",
"previous": "{{__('messages.previous')}}"
},
buttons: {
copyTitle: "{{__('messages.copy_to_clipboard')}}",
copySuccess: {
_: "{{__('messages.copied_n_rows_to_clipboard')}}"
2023-09-21 12:45:08 +00:00
}
}
2023-09-21 14:20:06 +00:00
}
});
2023-09-21 12:45:08 +00:00
2023-09-21 14:20:06 +00:00
$.ajaxSetup({
headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}
});
2023-09-21 12:45:08 +00:00
@endif
2023-09-21 14:20:06 +00:00
$('button[type=reset]').on('click', function () {
$(this).parents('form').find('input').val('');
window.location.href = $(this).parents('form').attr('action');
});
2023-09-21 12:45:08 +00:00
});
2023-09-21 14:20:06 +00:00
function initialize_datetimepicker(element_name, element_date, start_date, end_date, date_format, time_format, disabled_days, enable_time_picker, time_picker_inline) {
2023-09-21 12:45:08 +00:00
var start = null;
var end = null;
var format = '';
var display_time = null;
var disabled_week_days = '';
var side_by_side = time_picker_inline;
if (disabled_days.length > 0) {
disabled_week_days = disabled_days.join(',');
}
//format
if (date_format != null) {
format = date_format.toUpperCase();
}
if (enable_time_picker) {
display_time = 'hh:mm A';
if (time_format == '24') {
display_time = 'HH:mm';
}
format += ' ' + display_time;
}
// start date
if (start_date == 'none') {
start = false;
} else if (start_date == 'today') {
start = moment();
} else if (start_date == 'current_year') {
start = moment().startOf('year');
} else if (start_date == 'current_month') {
start = moment().startOf('month');
}
//end date
if (end_date == 'none') {
end = false;
} else if (end_date == 'today') {
end = moment().add(0, 'd');
} else if (end_date == 'current_year') {
end = moment().endOf('year');
} else if (end_date == 'current_month') {
end = moment().endOf('month');
}
2023-09-21 14:20:06 +00:00
$('#' + element_name).datetimepicker({
2023-09-21 12:45:08 +00:00
icons: {
time: 'far fa-clock',
},
format: format,
minDate: start,
maxDate: end,
daysOfWeekDisabled: [disabled_week_days],
showClear: true,
ignoreReadonly: true,
sideBySide: side_by_side,
2023-09-21 14:20:06 +00:00
defaultDate: element_date.length ? moment(element_date, format) : ''
2023-09-21 12:45:08 +00:00
});
}
function initialize_rangeslider(element_name) {
2023-09-21 14:20:06 +00:00
$('#' + element_name).rangeslider({
2023-09-21 12:45:08 +00:00
polyfill: false,
//Callback function
2023-09-21 14:20:06 +00:00
onInit: function () {
2023-09-21 12:45:08 +00:00
},
// Callback function
2023-09-21 14:20:06 +00:00
onSlide: function (position, value) {
$('.' + element_name).text(value);
2023-09-21 12:45:08 +00:00
},
});
}
2023-09-21 14:01:58 +00:00
2023-09-21 12:45:08 +00:00
Dropzone.autoDiscover = false;
2023-09-21 14:20:06 +00:00
2023-09-21 12:45:08 +00:00
function initialize_dropzone(element_name, file_upload_msg, no_of_files_can_be_uploaded, max_file_size, allowed_file_type, url = null) {
2023-09-21 14:01:58 +00:00
2023-09-21 12:45:08 +00:00
var file_remove_url = "library/delete_file.php";
if (url == null) {
url = "{{ url('/file-upload')}}";
file_remove_url = "{{ url('/file-delete')}}";
}
var file_names = [];
2023-09-21 14:20:06 +00:00
if ($('input#' + element_name).val().length > 0) {
file_names.push($('input#' + element_name).val());
2023-09-21 12:45:08 +00:00
}
2023-09-21 14:20:06 +00:00
$('#' + element_name).dropzone({
2023-09-21 12:45:08 +00:00
paramName: "file",
addRemoveLinks: true,
url: url,
maxFilesize: max_file_size,
dictDefaultMessage: file_upload_msg,
maxFiles: no_of_files_can_be_uploaded,
headers: {
2023-09-21 14:20:06 +00:00
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
2023-09-21 12:45:08 +00:00
acceptedFiles: allowed_file_type,
2023-09-21 14:20:06 +00:00
init: function () {
2023-09-21 12:45:08 +00:00
//function to be use on editing a form, to display existing files
2023-09-21 14:20:06 +00:00
if ($('input#' + element_name).val().length > 0) {
2023-09-21 12:45:08 +00:00
window[`${element_name}_myDropzone`] = this;
2023-09-21 14:20:06 +00:00
var file_obj = {files: $('input#' + element_name).val()};
2023-09-21 12:45:08 +00:00
$.ajax({
method: "GET",
url: '/existing-file-display',
dataType: "json",
data: file_obj,
2023-09-21 14:20:06 +00:00
success: function (result) {
2023-09-21 12:45:08 +00:00
if (result.success) {
2023-09-21 14:20:06 +00:00
$.each(result.files, function (key, file) {
var mockFile = {name: file.name, uploaded_as: file.uploaded_as, size: file.size};
2023-09-21 12:45:08 +00:00
window[`${element_name}_myDropzone`].emit("addedfile", mockFile);
window[`${element_name}_myDropzone`].emit("thumbnail", mockFile, file.path);
window[`${element_name}_myDropzone`].emit("complete", mockFile);
});
}
}
});
}
//function to be use on removeing a file
2023-09-21 14:20:06 +00:00
this.on("removedfile", function (file) {
2023-09-21 12:45:08 +00:00
$.ajax({
url: file_remove_url,
2023-09-21 14:20:06 +00:00
data: {"file_name": file.uploaded_as},
2023-09-21 12:45:08 +00:00
type: "POST",
2023-09-21 14:20:06 +00:00
success: function (result) {
if (typeof (result) == 'string') {
2023-09-21 12:45:08 +00:00
var result = JSON.parse(result);
}
2023-09-21 14:20:06 +00:00
if (result.success == 1) {
2023-09-21 12:45:08 +00:00
toastr.success(result.msg);
var index = file_names.indexOf(file.uploaded_as);
2023-09-21 14:01:58 +00:00
2023-09-21 14:20:06 +00:00
if (index != -1) {
file_names.splice(index, 1);
2023-09-21 12:45:08 +00:00
}
2023-09-21 14:01:58 +00:00
2023-09-21 14:20:06 +00:00
var elementVal = $('input#' + element_name).val();
2023-09-21 12:45:08 +00:00
var oldVal = elementVal.split(",");
index = oldVal.indexOf(file.uploaded_as);
2023-09-21 14:20:06 +00:00
if (index != -1) {
oldVal.splice(index, 1);
2023-09-21 12:45:08 +00:00
}
var newVal = oldVal.join(",");
2023-09-21 14:20:06 +00:00
$('input#' + element_name).val(newVal);
2023-09-21 12:45:08 +00:00
} else {
toastr.error(result.msg);
}
}
});
});
},
2023-09-21 14:20:06 +00:00
success: function (file, response) {
if (typeof (response) == 'string') {
2023-09-21 12:45:08 +00:00
var response = JSON.parse(response);
}
if (response.success == true) {
toastr.success(response.msg);
file_names.push(response.path);
file.uploaded_as = response.path;
2023-09-21 14:20:06 +00:00
$('input#' + element_name).val(file_names); //store file_names
2023-09-21 12:45:08 +00:00
} else {
toastr.error(response.msg);
}
}
});
}
function initialize_text_editor(element_name, placeholder, height) {
2023-09-21 14:01:58 +00:00
2023-09-21 14:20:06 +00:00
$('#' + element_name).summernote({
2023-09-21 12:45:08 +00:00
placeholder: placeholder,
height: height
});
2023-09-21 14:01:58 +00:00
}
2023-09-21 12:45:08 +00:00
2023-09-21 14:20:06 +00:00
function initialize_star_rating(element_name) {
$("#" + element_name).rating({
2023-09-21 12:45:08 +00:00
theme: 'krajee-fas',
filledStar: '<i class="fas fa-star"></i>',
emptyStar: '<i class="fas fa-star"></i>'
});
}
function initialize_datetimepicker_for_form_scheduling() {
$('div#start_date_time').datetimepicker({
icons: {
time: 'far fa-clock',
},
format: 'YYYY-MM-DD hh:mm A',
minDate: moment(),
showClear: true,
ignoreReadonly: true
});
$('div#end_date_time').datetimepicker({
icons: {
time: 'far fa-clock',
},
format: 'YYYY-MM-DD hh:mm A',
minDate: moment(),
showClear: true,
ignoreReadonly: true
});
}
function initialize_signature_pad(element) {
var signaturePad = element;
var canvas = document.getElementById(element);
signaturePad = new SignaturePad(canvas, {
2023-09-21 14:20:06 +00:00
onEnd: function (event) {
2023-09-21 12:45:08 +00:00
var element = $(this)[0]._canvas.id
var signature = $(this)[0].toDataURL();
2023-09-21 14:20:06 +00:00
$('#output_' + element).val(signature);
2023-09-21 12:45:08 +00:00
}
});
2023-09-21 14:01:58 +00:00
2023-09-21 14:20:06 +00:00
if ($('#output_' + element).val().length > 0) {
2023-09-21 12:45:08 +00:00
2023-09-21 14:20:06 +00:00
signaturePad.fromDataURL($('#output_' + element).val());
2023-09-21 12:45:08 +00:00
}
2023-09-21 14:01:58 +00:00
2023-09-21 14:20:06 +00:00
$(document).on('click', '#clear_' + element, function () {
signaturePad.clear();
$('#output_' + $(this).data('name')).val('');
2023-09-21 12:45:08 +00:00
});
2023-09-21 14:20:06 +00:00
$(document).on('click', '#undo_' + element, function () {
var data = signaturePad.toData();
2023-09-21 12:45:08 +00:00
if (data) {
data.pop(); // remove the last dot or line
signaturePad.fromData(data); //draw signature from array of data
if (data.length > 0) {
var signature = signaturePad.toDataURL();
2023-09-21 14:20:06 +00:00
$('#output_' + $(this).data('name')).val(signature);
2023-09-21 12:45:08 +00:00
} else {
2023-09-21 14:20:06 +00:00
$('#output_' + $(this).data('name')).val('');
2023-09-21 12:45:08 +00:00
}
}
});
}
2023-09-21 14:20:06 +00:00
function initializeToastrSettingsForForm(position) {
2023-09-21 12:45:08 +00:00
var toastr_position = 'toast-top-right';
if (position) {
toastr_position = position;
}
toastr.options = {
2023-09-21 14:20:06 +00:00
"positionClass": toastr_position
2023-09-21 12:45:08 +00:00
}
}
function initialize_countdowntimer(element) {
2023-09-21 14:20:06 +00:00
$("#" + element.name).countdowntimer({
2023-09-21 12:45:08 +00:00
hours: element.hours,
minutes: element.minutes,
seconds: element.seconds,
2023-09-21 14:20:06 +00:00
size: element.size,
labelsFormat: element.labels_format,
borderColor: element.border_color,
2023-09-21 12:45:08 +00:00
fontColor: element.font_color,
2023-09-21 14:20:06 +00:00
backgroundColor: element.bg_color,
2023-09-21 12:45:08 +00:00
timeSeparator: element.time_separator,
displayFormat: element.display_format
});
}
</script>
<!-- Application additional js -->
@if(!$is_download && !isset($nav))
@if(!empty($__additional_js))
{!!$__additional_js!!}
2023-09-21 14:01:58 +00:00
@endif
@endif