Repository navigation
Expand file tree
/
Copy pathInputfieldImagePicker.js
More file actions
55 lines (45 loc) · 1.84 KB
/
Copy pathInputfieldImagePicker.js
File metadata and controls
55 lines (45 loc) · 1.84 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
$(document).ready(function () {
$(".InputfieldImagePickerInput").on('change textInput input', function () {
var sid = $(this).data('sid');
var img = $("#pv_" + sid);
img.css('display', 'inline-block');
img.attr("src", $(this).val());
});
$(document).on("click", ".InputfieldImagePickerOpen", function (e) {
loadIframeLinkPicker(e.currentTarget);
$(this).removeClass('ui-state-active');
return false;
});
function loadIframeLinkPicker(opener) {
var sid = $(opener).attr('data-sid');
var insertLinkLabel = ' ' + document.pp_translations_title;
var cancelLabel = document.pp_translations_cancel;
var $iframe; // set after modalSettings down
// settings for modal window
var modalSettings = {
title: "<i class='fa fa-image'></i> " + insertLinkLabel,
buttons: [{
html: "<i class='fa fa-times-circle'></i> " + cancelLabel,
click: function () {
$iframe.dialog("close");
},
class: 'ui-priority-secondary'
}
]
};
// create modal window
var $iframe = pwModalWindow(document.pp_pickerpage + '?sid=' + encodeURIComponent(sid), modalSettings, 'medium');
// modal window load event
$iframe.load(function () {
var $i = $iframe.contents();
$(".selectableimg", $i).click(function () {
var newUrl = $(this).data("origurl").replace(/^.*\/\/[^\/]+/, '')
$("#isi_" + sid).val(newUrl);
var img = $("#pv_" + sid);
img.css('display', 'inline-block');
img.attr("src", this.src);
$iframe.dialog("close");
});
}); // load
}
});