-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlfm.js
33 lines (25 loc) · 961 Bytes
/
lfm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(function( $ ){
$.fn.filemanager = function(type = 'image', abspath = '/') {
if (type === 'image' || type === 'images') {
type = 'Images';
} else {
type = 'Files';
}
let input_id = this.data('input');
let preview_id = this.data('preview');
this.on('click', function(e) {
localStorage.setItem('target_input', input_id);
localStorage.setItem('target_preview', preview_id);
window.open(abspath + '/laravel-filemanager?type=' + type, 'FileManager', 'width=900,height=600');
return false;
});
}
})(jQuery);
function SetUrl(url){
//set the value of the desired input to image url
let target_input = $('#' + localStorage.getItem('target_input'));
target_input.val(url);
//set or change the preview image src
let target_preview = $('#' + localStorage.getItem('target_preview'));
target_preview.attr('src',url);
}