+ $('#media-chooser').on('show.bs.modal', function (event) {
+ var input = $("input", $(event.relatedTarget).parent());
+ var modal = $(this);
+ modal.data('target-input', input);
+ var imglist = modal.find('.modal-body');
+ imglist.html('');
+ $.each(self.doc.galleryImages, (i, imgItem) => {
+ img = $("<img>").attr("src", imgItem.thumb).attr('title', imgItem.url).data('url', imgItem.url).on('click', function() {
+ imglist.find('img').removeClass('active');
+ $(this).addClass('active');
+ });
+ imglist.append(img);
+ });
+ })
+ $('#media-chooser .ctrl-ok').on('click', function (event) {
+ $('#media-chooser').data('target-input')
+ .val(
+ (new URL($('#media-chooser .active').data('url'), document.baseURI)).href
+ ).trigger('change');
+ $('#media-chooser').modal('hide');
+ });