Test Setup Failed
Push — master ( 5635aa...53af44 )
by Stream
01:00 queued 10s
created

public/js/stand-alone-button.js   A

Complexity

Conditions 1
Paths 8

Size

Total Lines 36
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 19
nc 8
nop 1
dl 0
loc 36
rs 9.45
c 0
b 0
f 0
1
(function( $ ){
2
3
  $.fn.filemanager = function(type, options) {
4
    type = type || 'file';
5
6
    this.on('click', function(e) {
0 ignored issues
show
Unused Code introduced by
The parameter e is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
7
      var route_prefix = (options && options.prefix) ? options.prefix : '/laravel-filemanager';
8
      var target_input = $('#' + $(this).data('input'));
9
      var target_preview = $('#' + $(this).data('preview'));
10
      window.open(route_prefix + '?type=' + type, 'FileManager', 'width=900,height=600');
11
      window.SetUrl = function (items) {
12
        var file_path = items.map(function (item) {
13
          return item.url;
14
        }).join(',');
15
16
        // set the value of the desired input to image url
17
        target_input.val('').val(file_path).trigger('change');
18
19
        // clear previous preview
20
        target_preview.html('');
21
22
        // set or change the preview image src
23
        items.forEach(function (item) {
24
          target_preview.append(
25
            $('<img>').css('height', '5rem').attr('src', item.thumb_url)
26
          );
27
        });
28
29
        // trigger change event
30
        target_preview.trigger('change');
31
      };
32
      return false;
33
    });
34
  }
35
36
})(jQuery);
37