empty text nodes after spans
[fnpeditor.git] / src / editor / views / attachments / add_attachments.js
1 define(function(require) {
2     'use strict';
3
4     var $ = require('libs/jquery');
5
6     return function (dialog) {
7         var body = $(".modal-body", dialog.$el);
8         var input = $("input[name=href]", body);
9         $.ajax(config.documentGalleryUrl, {
10             dataType: 'json',
11             success: function (data, status, jqxhr) {
12                 for (var i in data) {
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'/>");
16                     button.append(img);
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);
21                     div.append(button);
22                     div.attr("data-output", 'file://' + data[i]['name']);
23                     div.on('click', function () {
24                         input.val($(this).attr('data-output'));
25                     });
26                     body.append(div);
27                 }
28                 var editlink = $("<a target='_blank'>" + gettext("Manage attachments") + "</a>");
29                 editlink.attr('href', config.documentGalleryUrl);
30                 body.append(editlink);
31             }
32         });
33     };
34 });