1 // http://civicrm.org/licensing
3 function openKCFinder(field
) {
5 callBack: function(url
) {
7 // calculate the image default width, height
8 // and assign to respective fields
9 var ajaxUrl
= CRM
.url('civicrm/ajax/rest', 'className=CRM_Badge_Page_AJAX&fnName=getImageProp&json=1&img=' + url
);
15 success: function ( response
) {
16 var widthId
= 'width_' + field
.attr('id');
17 var heightId
= 'height_' + field
.attr('id');
18 $('#' + widthId
).val(response
.width
.toFixed(0));
19 $('#' + heightId
).val(response
.height
.toFixed(0));
22 window
.KCFinder
= null;
26 window
.open(CRM
.kcfinderPath
+ 'kcfinder/browse.php?cms=civicrm&type=images', 'kcfinder_textbox',
27 'status=0, toolbar=0, location=0, menubar=0, directories=0, ' +
28 'resizable=1, scrollbars=0, width=800, height=600'
32 $('input[id^="image_"]').click(function(){
33 openKCFinder($(this));
36 $('.clear-image').click(function(){
37 var imgName
= $(this).attr('imgname');
38 $('#' + imgName
).val('');
39 $('#width_' + imgName
).val('');
40 $('#height_' + imgName
).val('');