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.

setup-ckfinder.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. $(window).on('load', function () {
  2. $('.lc-ckfinder-wrap').each(function(){
  3. $widget = $(this);
  4. if($widget.find('.lc-ckfinder-field').val() !== ''){
  5. $widget.find('.lc-ckfinder-illu').css('background-image', "url('"+$widget.find('.lc-ckfinder-field').val()+"')");
  6. $widget.find('.lc-ckfinder-remove').show();
  7. }
  8. $widget.find('.lc-ckfinder-button').on( 'click', function( e ) {
  9. e.preventDefault();
  10. CKFinder.popup( {
  11. chooseFiles: true,
  12. onInit: function( finder ) {
  13. finder.on( 'files:choose', function( evt ) {
  14. var file = evt.data.files.first();
  15. $widget.find('.lc-ckfinder-illu').css('background-image', "url('"+file.getUrl()+"')");
  16. $widget.find('.lc-ckfinder-remove').show();
  17. $widget.find('.lc-ckfinder-field').val(file.getUrl());
  18. } );
  19. finder.on( 'file:choose:resizedImage', function( evt ) {
  20. var output = document.getElementById( '{{ id }}' );
  21. output.value = evt.data.resizedUrl;
  22. } );
  23. }
  24. } );
  25. } );
  26. $widget.find('.lc-ckfinder-remove').on('click', function () {
  27. $widget.find('.lc-ckfinder-remove').hide();
  28. $widget.find('.lc-ckfinder-illu').css('background-image', 'none');
  29. $widget.find('.lc-ckfinder-field').val("");
  30. })
  31. });
  32. if ($('.field-ckfinder_file_chooser').length > 0) {
  33. CKFinder.config({connectorPath: '/ckfinder/connector'});
  34. }
  35. });