1 define(function(require) {
4 var $ = require('libs/jquery');
6 return function (dialog) {
7 var body = $(".modal-body", dialog.$el);
8 var input = $("input[name=href]", body);
9 $.ajax(config.documentGalleryUrl, {
11 success: function (data, status, jqxhr) {
13 var img = $("<img style='margin-right: 1em'>");
14 var button = $("<button/>").attr('type', 'button').addClass('choice');
15 var div = $("<div style='border: 1px solid white'/>");
17 button.append(data[i]['name']);
18 img.attr("src", data[i]['thumbnail_url']);
19 img.attr("title", data[i]['name']);
20 button.attr('for', 'attachment' + i);
22 div.attr("data-output", 'file://' + data[i]['name']);
23 div.on('click', function () {
24 input.val($(this).attr('data-output'));
28 var editlink = $("<a target='_blank'>" + gettext("Manage attachments") + "</a>");
29 editlink.attr('href', config.documentGalleryUrl);
30 body.append(editlink);