X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/23a68120c494341344d4728c5fc4528c94d5c53d..1eeb03096b5072b81f245d1b1716d1184e40f05d:/src/editor/views/attachments/add_attachments.js diff --git a/src/editor/views/attachments/add_attachments.js b/src/editor/views/attachments/add_attachments.js new file mode 100644 index 0000000..250b2b8 --- /dev/null +++ b/src/editor/views/attachments/add_attachments.js @@ -0,0 +1,34 @@ +define(function(require) { + 'use strict'; + + var $ = require('libs/jquery'); + + return function (dialog) { + var body = $(".modal-body", dialog.$el); + var input = $("input[name=href]", body); + $.ajax(config.documentGalleryUrl, { + dataType: 'json', + success: function (data, status, jqxhr) { + for (var i in data) { + var img = $(""); + var button = $("").attr('type', 'button').addClass('choice'); + var div = $("
"); + button.append(img); + button.append(data[i]['name']); + img.attr("src", data[i]['thumbnail_url']); + img.attr("title", data[i]['name']); + button.attr('for', 'attachment' + i); + div.append(button); + div.attr("data-output", 'file://' + data[i]['name']); + div.on('click', function () { + input.val($(this).attr('data-output')); + }); + body.append(div); + } + var editlink = $("" + gettext("Manage attachments") + ""); + editlink.attr('href', config.documentGalleryUrl); + body.append(editlink); + } + }); + }; +});