1 // http://civicrm.org/licensing
3 function openKCFinder(field
) {
6 callBack: function(url
) {
7 field
.val(url
).change();
8 // calculate the image default width, height
9 // and assign to respective fields
10 var ajaxUrl
= CRM
.url('civicrm/ajax/rest', 'className=CRM_Badge_Page_AJAX&fnName=getImageProp&json=1&img=' + url
);
11 $.getJSON(ajaxUrl
).done(function ( response
) {
12 var widthId
= 'width_' + field
.attr('id');
13 var heightId
= 'height_' + field
.attr('id');
14 $('#' + widthId
).val(response
.width
.toFixed(0));
15 $('#' + heightId
).val(response
.height
.toFixed(0));
17 window
.KCFinder
= null;
21 window
.open(CRM
.kcfinderPath
+ 'kcfinder/browse.php?cms=civicrm&type=images', 'kcfinder_textbox',
22 'status=0, toolbar=0, location=0, menubar=0, directories=0, ' +
23 'resizable=1, scrollbars=0, width=800, height=600'
27 $('input[id^="image_"]')
30 $(this).siblings('.clear-image').css({visibility
: $(this).val() ? '' : 'hidden'});
34 $('.clear-image').click(function() {
35 $(this).closest('tr').find('input[type=text]').val('').change();