diff --git a/app/assets/javascripts/modules/attachment-insert.js b/app/assets/javascripts/modules/attachment-insert.js new file mode 100644 index 0000000..318fc67 --- /dev/null +++ b/app/assets/javascripts/modules/attachment-insert.js @@ -0,0 +1,44 @@ +;(function (global) { + 'use strict' + + var GOVUK = global.GOVUK || {} + GOVUK.Modules = GOVUK.Modules || {} + + GOVUK.Modules.AttachmentInsert = function () { + this.start = function (element) { + element.on('click', '.js-attachment', insertAttachment); + element.on('click', '.js-upload-attachment', showForm); + element.on('click', '.js-upload-close', hideForm); + + // https://stackoverflow.com/questions/11076975 + function insertAttachment(evt) { + evt.preventDefault(); + var markdown = $(this).data('markdown'); + var cursorPos = $('#body').prop('selectionStart'); + + if (cursorPos === 0 && $('#body').val().length > 0) { + cursorPos = $('#body').val().length; + } + + var v = $('#body').val(); + var textBefore = v.substring(0, cursorPos); + var textAfter = v.substring(cursorPos, v.length); + $('#body').val(textBefore + '\n' + markdown + textAfter).focus(); + } + + function showForm(evt) { + evt.preventDefault(); + element.find('.js-upload-form').show(); + element.find('.js-select-form').hide(); + } + + function hideForm(evt) { + evt.preventDefault(); + element.find('.js-upload-form').hide(); + element.find('.js-select-form').show(); + } + } + } + + global.GOVUK = GOVUK +})(window) diff --git a/app/assets/javascripts/vendor/modal-dialog.js b/app/assets/javascripts/vendor/modal-dialog.js index 62b78fc..8942618 100755 --- a/app/assets/javascripts/vendor/modal-dialog.js +++ b/app/assets/javascripts/vendor/modal-dialog.js @@ -62,7 +62,7 @@ setFocusOnLastFocusedEl: function () { if (GOVUK.modalDialog.$lastFocusedEl) { window.setTimeout(function () { - GOVUK.modalDialog.$lastFocusedEl.focus() + //GOVUK.modalDialog.$lastFocusedEl.focus() }, 0) } }, diff --git a/app/assets/sass/application.scss b/app/assets/sass/application.scss index 230c3d9..e468a04 100755 --- a/app/assets/sass/application.scss +++ b/app/assets/sass/application.scss @@ -131,6 +131,22 @@ $govuk-gutter-half: ($govuk-gutter / 2); position: relative; } +.govuk-c-button { + color: $govuk-white !important; +} + +.inserts { + @include govuk-font-regular-19; + + background-color: $govuk-grey-4; + border: 2px solid $govuk-black; + border-bottom-color: $govuk-border-colour; + padding: 10px; + margin-bottom: -2px; + position: relative; + z-index: 1; +} + .contextual-guidance { @include govuk-responsive-padding($govuk-spacing-responsive-5, "top"); background: #fff; diff --git a/app/views/attachment-done.html b/app/views/attachment-done.html new file mode 100644 index 0000000..c638e25 --- /dev/null +++ b/app/views/attachment-done.html @@ -0,0 +1,22 @@ +{% extends "layout.html" %} +{% block page_title %}Attachment added{% endblock %} + +{% block content %} + +Back +
+
+
+

+ You’ve added an attachment +

+ +

Now you can insert it in the copy:

+ Insert in the copy +

+ Go back to draft +

+
+
+
+{% endblock %} diff --git a/app/views/attachment.html b/app/views/attachment.html index 8fc9c3a..c63bfc5 100644 --- a/app/views/attachment.html +++ b/app/views/attachment.html @@ -18,7 +18,7 @@ Back
-
+

diff --git a/app/views/includes/attachment-list.html b/app/views/includes/attachment-list.html new file mode 100644 index 0000000..7f8942f --- /dev/null +++ b/app/views/includes/attachment-list.html @@ -0,0 +1,15 @@ +{% if attachment_count > 0 %} +
+ +
+{% endif %} diff --git a/app/views/includes/scripts.html b/app/views/includes/scripts.html index 960d64c..5602404 100755 --- a/app/views/includes/scripts.html +++ b/app/views/includes/scripts.html @@ -16,6 +16,7 @@ + {% if useAutoStoreData %} diff --git a/app/views/title-summary-body.html b/app/views/title-summary-body.html index 360cf31..178724f 100755 --- a/app/views/title-summary-body.html +++ b/app/views/title-summary-body.html @@ -15,6 +15,8 @@ {% set prefix = 'drug-safety-update' %} {% endif %} +{% set attachment_count = data['attachment-count'] | int %} + Back
@@ -114,9 +116,17 @@

Writing guidance

-
@@ -149,5 +159,52 @@

Markdown guidance

{% endif %} + + + + +
{% endblock %}