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.

37 line
1.2KB

  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. });
  15. $('.lc-filemanager-open').off('click');
  16. $('.lc-filemanager-open').on('click', function (e) {
  17. let $field = $(this);
  18. $('#lc-filemanager-frame').off('load');
  19. $("#lc-filemanager-frame").on('load', function () {
  20. $('#lc-filemanager-frame').contents().on('click', '.select', function () {
  21. var path = $(this).attr('data-path')
  22. $('#' + $field.data('id')).val(path);
  23. $('#' + $field.data('id') + '_preview').prop('src',path);
  24. $('#lc-filemanager-modal').modal('hide');
  25. });
  26. });
  27. $("#lc-filemanager-frame").prop('src', $field.data('target'));
  28. $('#lc-filemanager-modal').modal('show');
  29. });
  30. }