You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.3KB

  1. import "./form.scss"
  2. $(document).ready(function () {
  3. initFileManager();
  4. });
  5. $('.field-collection').bind('collection-add-item', function (){
  6. initFileManager();
  7. });
  8. function initFileManager() {
  9. $('.lc-filemanager-delete').off('click');
  10. $('.lc-filemanager-delete').on('click', function (e) {
  11. let $field = $(this);
  12. $('#' + $field.data('id')).val("");
  13. $('#' + $field.data('id') + '_preview').prop('src',"");
  14. $('#' + $field.data('id') + '_preview_text').html('Aucun fichier');
  15. });
  16. $('.lc-filemanager-open').off('click');
  17. $('.lc-filemanager-open').on('click', function (e) {
  18. let $field = $(this);
  19. $('#lc-filemanager-frame').off('load');
  20. $("#lc-filemanager-frame").on('load', function () {
  21. $('#lc-filemanager-frame').contents().on('click', '.select', function () {
  22. var path = $(this).attr('data-path')
  23. $('#' + $field.data('id')).val(path);
  24. $('#' + $field.data('id') + '_preview').prop('src',path);
  25. $('#' + $field.data('id') + '_preview_text').html(path);
  26. $('#lc-filemanager-modal').modal('hide');
  27. });
  28. });
  29. $("#lc-filemanager-frame").prop('src', $field.data('target'));
  30. $('#lc-filemanager-modal').modal('show');
  31. });
  32. }