33 lines
958 B
PHP
33 lines
958 B
PHP
@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() {
|
|
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 |