From: Jan Szejko Date: Thu, 11 Jan 2018 13:51:16 +0000 (+0100) Subject: attachment list for links + bad links in red X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/1eeb03096b5072b81f245d1b1716d1184e40f05d?ds=sidebyside;hp=23a68120c494341344d4728c5fc4528c94d5c53d attachment list for links + bad links in red --- diff --git a/src/editor/plugins/core/core.js b/src/editor/plugins/core/core.js index 31ac09d..3839a39 100644 --- a/src/editor/plugins/core/core.js +++ b/src/editor/plugins/core/core.js @@ -12,7 +12,8 @@ var _ = require('libs/underscore'), 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) { @@ -556,6 +557,7 @@ var createLinkFromSelection = function(callback, params) { }); }); dialog.show(); + add_attachments(dialog); }; var editLink = function(callback, params) { diff --git a/src/editor/plugins/core/links/box.html b/src/editor/plugins/core/links/box.html index db1b2da..4644537 100644 --- a/src/editor/plugins/core/links/box.html +++ b/src/editor/plugins/core/links/box.html @@ -1,5 +1,5 @@
- <%= text %>
-- + class="bad-link"<% } %>><%= text %>
-- <%= gettext('change') %> | <%= gettext('remove') %> diff --git a/src/editor/plugins/core/links/linkElement.js b/src/editor/plugins/core/links/linkElement.js index 61d2abc..7439804 100644 --- a/src/editor/plugins/core/links/linkElement.js +++ b/src/editor/plugins/core/links/linkElement.js @@ -9,6 +9,7 @@ var $ = require('libs/jquery'), 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); @@ -18,9 +19,16 @@ _.extend(linkElement, { _.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(); @@ -74,6 +82,7 @@ _.extend(linkElement, { }); }); dialog.show(); + add_attachments(dialog); }, deleteLink: function() { diff --git a/src/editor/plugins/core/links/links.less b/src/editor/plugins/core/links/links.less index f9ab609..ac9f662 100644 --- a/src/editor/plugins/core/links/links.less +++ b/src/editor/plugins/core/links/links.less @@ -11,4 +11,8 @@ box-shadow:0 10px 5px #888888; z-index:9999; font-style: normal; + + .bad-link { + color: red; + } } \ No newline at end of file diff --git a/src/editor/styles/main.less b/src/editor/styles/main.less index 6322459..059789e 100644 --- a/src/editor/styles/main.less +++ b/src/editor/styles/main.less @@ -6,6 +6,7 @@ @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'; 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 = $("