Dialog = require('views/dialog/dialog'),
canvasElements = require('plugins/core/canvasElements'),
metadataEditor = require('plugins/core/metadataEditor/metadataEditor'),
- edumed = require('plugins/core/edumed/edumed');
+ edumed = require('plugins/core/edumed/edumed'),
+ add_attachments = require('views/attachments/add_attachments');
var exerciseFix = function(newNodes) {
});
});
dialog.show();
+ add_attachments(dialog);
};
var editLink = function(callback, params) {
<div link-box style="white-space: nowrap">
- <a link target="_blank" href="<%= url %>"><%= text %></a> <br/>--
+ <a link target="_blank" href="<%= url %>"<% if(bad) { %> class="bad-link"<% } %>><%= text %></a> <br/>--
<span>
<a class="change" href="#"><%= gettext('change') %></a> |
<a class="delete" href="#"><%= gettext('remove') %></a>
genericElement = require('modules/documentCanvas/canvas/genericElement'),
Dialog = require('views/dialog/dialog'),
boxTemplate = require('libs/text!./box.html'),
+ add_attachments = require('views/attachments/add_attachments'),
linkElement = Object.create(genericElement);
_.bindAll(this, 'changeLink', 'deleteLink');
var linkText = this.wlxmlNode.getAttr('href') || '',
- linkUrl = this.getUrl(linkText);
+ linkUrl = this.getUrl(linkText),
+ badLink;
- this.box = $(_.template(boxTemplate)({text: linkText, url: linkUrl}));
+ if (linkText.substr(0,7) === 'file://') {
+ var filename = linkText.substr(7);
+ // ugly
+ badLink = (window.materials.indexOf(filename) < 0);
+ }
+
+ this.box = $(_.template(boxTemplate)({text: linkText, url: linkUrl, bad: badLink}));
this.box.find('.change').on('click', this.changeLink);
this.box.find('.delete').on('click', this.deleteLink);
this.box.hide();
});
});
dialog.show();
+ add_attachments(dialog);
},
deleteLink: function() {
box-shadow:0 10px 5px #888888;
z-index:9999;
font-style: normal;
+
+ .bad-link {
+ color: red;
+ }
}
\ No newline at end of file
@import '../views/openSelect/openSelect.less';
@import '../views/dialog/dialog.less';
@import '../views/menu/menu.less';
+@import '../views/attachments/attachments.less';
@import '../modules/rng/rng.less';
@import '../modules/documentCanvas/documentCanvas.less';
@import '../modules/sourceEditor/sourceEditor.less';
--- /dev/null
+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 = $("<img style='margin-right: 1em'>");
+ var button = $("<button/>").attr('type', 'button').addClass('choice');
+ var div = $("<div style='border: 1px solid white'/>");
+ 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 = $("<a target='_blank'>" + gettext("Manage attachments") + "</a>");
+ editlink.attr('href', config.documentGalleryUrl);
+ body.append(editlink);
+ }
+ });
+ };
+});
--- /dev/null
+.modal-body button.choice {
+ min-width: 400px;
+ text-align: left;
+}
\ No newline at end of file