mirror of
https://github.com/symfony/demo.git
synced 2026-03-24 00:02:32 +01:00
54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
import './styles/admin.css';
|
|
import * as bootstrap from 'bootstrap';
|
|
import 'typeahead.js';
|
|
import Bloodhound from "bloodhound-js";
|
|
import './js/jquery_global.js';
|
|
import $ from 'jquery';
|
|
import 'bootstrap-tagsinput';
|
|
import './styles/bootstrap-tagsinput.css';
|
|
|
|
$(function() {
|
|
// Bootstrap-tagsinput initialization
|
|
// https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/
|
|
var $input = $('input[data-toggle="tagsinput"]');
|
|
if ($input.length) {
|
|
var source = new Bloodhound({
|
|
local: $input.data('tags'),
|
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
|
datumTokenizer: Bloodhound.tokenizers.whitespace
|
|
});
|
|
source.initialize();
|
|
|
|
$input.tagsinput({
|
|
trimValue: true,
|
|
focusClass: 'focus',
|
|
typeaheadjs: {
|
|
name: 'tags',
|
|
source: source.ttAdapter()
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
// Handling the modal confirmation message.
|
|
$(document).on('submit', 'form[data-confirmation]', function (event) {
|
|
var $form = $(this),
|
|
$confirm = $('#confirmationModal');
|
|
|
|
if ($confirm.data('result') !== 'yes') {
|
|
//cancel submit event
|
|
event.preventDefault();
|
|
|
|
$confirm
|
|
.off('click', '#btnYes')
|
|
.on('click', '#btnYes', function () {
|
|
$confirm.data('result', 'yes');
|
|
$form.find('input[type="submit"]').attr('disabled', 'disabled');
|
|
$form.trigger('submit');
|
|
});
|
|
|
|
const myModal = new bootstrap.Modal($confirm);
|
|
myModal.show();
|
|
}
|
|
});
|