|
| 1 | +require('eonasdan-bootstrap-datetimepicker'); |
| 2 | + |
| 3 | +require('imports-loader?define=>false!typeahead.js/dist/typeahead.jquery.min.js'); |
| 4 | +const Bloodhound = require('imports-loader?define=>false!typeahead.js/dist/bloodhound.js'); |
| 5 | +window.Bloodhound = Bloodhound; |
| 6 | +require('../scss/bootstrap-tagsinput.scss'); |
| 7 | +require('bootstrap-tagsinput'); |
| 8 | + |
| 9 | +$(function() { |
| 10 | + // Datetime picker initialization. |
| 11 | + // See http://eonasdan.github.io/bootstrap-datetimepicker/ |
| 12 | + $('[data-toggle="datetimepicker"]').datetimepicker({ |
| 13 | + icons: { |
| 14 | + time: 'fa fa-clock-o', |
| 15 | + date: 'fa fa-calendar', |
| 16 | + up: 'fa fa-chevron-up', |
| 17 | + down: 'fa fa-chevron-down', |
| 18 | + previous: 'fa fa-chevron-left', |
| 19 | + next: 'fa fa-chevron-right', |
| 20 | + today: 'fa fa-check-circle-o', |
| 21 | + clear: 'fa fa-trash', |
| 22 | + close: 'fa fa-remove' |
| 23 | + } |
| 24 | + }); |
| 25 | + |
| 26 | + // Bootstrap-tagsinput initialization |
| 27 | + // http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/ |
| 28 | + var $input = $('input[data-toggle="tagsinput"]'); |
| 29 | + if ($input.length) { |
| 30 | + var source = new Bloodhound({ |
| 31 | + local: $input.data('tags'), |
| 32 | + queryTokenizer: Bloodhound.tokenizers.whitespace, |
| 33 | + datumTokenizer: Bloodhound.tokenizers.whitespace |
| 34 | + }); |
| 35 | + source.initialize(); |
| 36 | + $input.tagsinput({ |
| 37 | + trimValue: true, |
| 38 | + focusClass: 'focus', |
| 39 | + typeahead: { |
| 40 | + name: 'tags', |
| 41 | + source: source.ttAdapter() |
| 42 | + } |
| 43 | + }); |
| 44 | + } |
| 45 | +}) |
| 46 | + |
| 47 | +// Handling the modal confirmation message. |
| 48 | +$(document).on('submit', 'form[data-confirmation]', function (event) { |
| 49 | + var $form = $(this), |
| 50 | + $confirm = $('#confirmationModal'); |
| 51 | + |
| 52 | + if ($confirm.data('result') !== 'yes') { |
| 53 | + //cancel submit event |
| 54 | + event.preventDefault(); |
| 55 | + |
| 56 | + $confirm |
| 57 | + .off('click', '#btnYes') |
| 58 | + .on('click', '#btnYes', function () { |
| 59 | + $confirm.data('result', 'yes'); |
| 60 | + $form.find('input[type="submit"]').attr('disabled', 'disabled'); |
| 61 | + $form.submit(); |
| 62 | + }) |
| 63 | + .modal('show'); |
| 64 | + } |
| 65 | +}); |
0 commit comments