//= require rails-ujs
//= require activestorage
//= require turbolinks
//= require jquery3
//= require popper
//= require bootstrap-sprockets
//= require jquery.validate.min
//= require additional-methods.min
//= require bootstrap-notify
//= require jquery.cookie.min
//= require select2
//= require jquery.cxselect
//= require bootstrap-datepicker
//= require bootstrap.viewer

//= require_tree ./i18n
//= require_tree ./admins

// ******** select2 global config ********
$.fn.select2.defaults.set('theme', 'bootstrap4');
$.fn.select2.defaults.set('language', 'zh-CN');

Turbolinks.setProgressBarDelay(200);

$(document).on('turbolinks:load', function(){
  $('[data-toggle="tooltip"]').tooltip();
  $('[data-toggle="popover"]').popover();

  // 图片查看大图
  $('img.preview-image').bootstrapViewer();

  // flash alert提示框自动关闭
  if($('.admin-alert-container .alert').length > 0){
    setTimeout(function(){
      $('.admin-alert-container .alert').alert('close');
    }, 2000);
  }
});

// var progressBar = new Turbolinks.ProgressBar();

// $(document).on('ajax:send', function(event){
//   console.log('ajax send', event);
//   progressBar.setValue(0)
//   progressBar.show()
// });
//
// $(document).on('ajax:complete', function(event){
//   console.log('ajax complete', event);
//   progressBar.setValue(1)
//   progressBar.hide() // 分页时不触发,奇怪
// });
// $(document).on('ajax:success', function(event){
//   console.log('ajax success', event);
// });
// $(document).on('ajax:error', function(event){
//   console.log('ajax error', event);
// });

$(function () {
});