diff --git a/app/assets/javascripts/admin_legacy/views/promotional_feature_items/_form.js b/app/assets/javascripts/admin_legacy/views/promotional_feature_items/_form.js deleted file mode 100644 index 6f3da44b117..00000000000 --- a/app/assets/javascripts/admin_legacy/views/promotional_feature_items/_form.js +++ /dev/null @@ -1,53 +0,0 @@ -(function () { - 'use strict' - window.GOVUK = window.GOVUK || {} - - var promotionalFeatureItemsForm = { - init: function init (options) { - this.form = document.querySelector(options.selector) - - var youtubeAndImageRadioFieldset = this.form.querySelector('.image-and-youtube-radios') - if (!youtubeAndImageRadioFieldset) { return } - - this.toggleImageAndYoutubeFieldsVisibility() - this.addRadioButtonEventListeners() - }, - - toggleImageAndYoutubeFieldsVisibility: function toggleImageAndYoutubeFieldsVisibility () { - var form = this.form - var checked = form.querySelector('.image-and-youtube-radios input[type=radio]:checked') - var imageFields = form.querySelector('.image-fields') - var youtubeFields = form.querySelector('.youtube-video-url-fields') - - if (!checked) { - imageFields.hidden = true - youtubeFields.hidden = true - } else if (checked.value === 'image') { - youtubeFields.hidden = true - } else { - imageFields.hidden = true - } - }, - - addRadioButtonEventListeners: function addRadioButtonEventListeners () { - var form = this.form - var radioElements = form.querySelectorAll('.image-and-youtube-radios input[type=radio]') - var imageFields = form.querySelector('.image-fields') - var youtubeFields = form.querySelector('.youtube-video-url-fields') - - for (var i = 0; i < radioElements.length; i++) { - radioElements[i].addEventListener('change', function (event) { - if (event.currentTarget.value === 'youtube_video_url') { - imageFields.hidden = true - youtubeFields.hidden = false - } else { - imageFields.hidden = false - youtubeFields.hidden = true - } - }) - } - } - } - - window.GOVUK.adminPromotionalFeatureItemsForm = promotionalFeatureItemsForm -}()) diff --git a/app/assets/javascripts/admin_legacy/views/statistics_announcement_dates/_form.js b/app/assets/javascripts/admin_legacy/views/statistics_announcement_dates/_form.js deleted file mode 100644 index 3b8c27da520..00000000000 --- a/app/assets/javascripts/admin_legacy/views/statistics_announcement_dates/_form.js +++ /dev/null @@ -1,150 +0,0 @@ -(function () { - 'use strict' - window.GOVUK = window.GOVUK || {} - - var StatisticsAnnouncementDateForm = { - init: function (modelName) { - this.modelName = modelName - this.$precisionInputs = $('input[name="' + modelName + '[precision]"]') - this.$confirmedCheckbox = $('input[name="' + modelName + '[confirmed]"]') - - // Note that the missing ] here is intentional - // Release date fields look like [release_date2i], [release_date3i], etc. - this.$releaseDateInputs = $('select[name*="' + modelName + '[release_date"]') - - // Date examples - this.$exactExample = $('.js-example-exact') - this.$oneMonthExample = $('.js-example-one-month') - this.$twoMonthExample = $('.js-example-two-month') - this.$provisionalLabels = $('.js-label-one-month, .js-label-two-month') - this.$confirmedLabel = $('.js-label-exact') - this.$releaseDateInputs.on('change', this.generateExampleDates) - - this.$confirmedCheckbox.on('click', this.togglePrecision) - this.togglePrecision.apply(this.$confirmedCheckbox) - }, - - togglePrecision: function () { - var that = StatisticsAnnouncementDateForm - - if ($(this).is(':checked')) { - that.fixToExactPrecision() - that.hidePrecisionChoice() - } else { - that.showPrecisionChoice() - } - - that.generateExampleDates() - }, - - generateExampleDates: function () { - var that = StatisticsAnnouncementDateForm - var date = that.getDateFromRecentDateFields() - var dateStatus = that.$confirmedCheckbox.is(':checked') ? ' (confirmed)' : ' (provisional)' - - that.updateExampleDates(date, dateStatus) - }, - - getDateFromRecentDateFields: function () { - var year, - month, - day, - hours, - minutes - - StatisticsAnnouncementDateForm.$releaseDateInputs.each(function (i) { - var value = parseInt($(this).val(), 10) - - switch (i) { - case 0: - year = value - break - case 1: - month = value - 1 - break - case 2: - day = value - break - case 3: - hours = value - break - case 4: - minutes = value - break - } - }) - - return new Date(year, month, day, hours, minutes) - }, - - updateExampleDates: function (date, status) { - var that = StatisticsAnnouncementDateForm - var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', - 'July', 'August', 'September', 'October', 'November', 'December'] - var time = getTime(date) - var dateNextMonth - - // 5 September 2014 4:03pm - that.$exactExample.text( - date.getDate() + ' ' + - monthNames[date.getMonth()] + ' ' + - date.getFullYear() + ' ' + - time + - status) - - // September 2014 - that.$oneMonthExample.text( - monthNames[date.getMonth()] + ' ' + - date.getFullYear() + - status) - - dateNextMonth = new Date(date.getTime()) - dateNextMonth.setMonth(date.getMonth() + 1) - - // September to October 2014 - // December to January 2015 - that.$twoMonthExample.text( - monthNames[date.getMonth()] + ' to ' + - monthNames[dateNextMonth.getMonth()] + ' ' + - dateNextMonth.getFullYear() + - status) - - // via http://stackoverflow.com/questions/8888491 - function getTime (date) { - var hours = date.getHours() - var minutes = date.getMinutes() - var ampm = (hours >= 12) ? 'pm' : 'am' - - hours = hours % 12 - if (hours === 0) { - hours = 12 - } - - if (minutes < 10) { - minutes = '0' + minutes - } - - return hours + ':' + minutes + ampm - } - }, - - fixToExactPrecision: function () { - var that = StatisticsAnnouncementDateForm - $('input[name="' + that.modelName + '[precision]"][value="0"]').prop('checked', true) - }, - - hidePrecisionChoice: function () { - var that = StatisticsAnnouncementDateForm - that.$provisionalLabels.hide() - that.$confirmedLabel.addClass('block-label-read-only') - }, - - showPrecisionChoice: function () { - var that = StatisticsAnnouncementDateForm - that.$provisionalLabels.show() - that.$confirmedLabel.removeClass('block-label-read-only') - } - } - - GOVUK.StatisticsAnnouncementDateForm = StatisticsAnnouncementDateForm -}()) diff --git a/app/assets/stylesheets/admin_legacy/_base.scss b/app/assets/stylesheets/admin_legacy/_base.scss index a9c48b80b02..96a34df6357 100644 --- a/app/assets/stylesheets/admin_legacy/_base.scss +++ b/app/assets/stylesheets/admin_legacy/_base.scss @@ -39,10 +39,3 @@ @import "helpers/navigation-controls"; @import "helpers/statistics-announcements"; @import "helpers/player-container"; - -// VIEWS -// Controller specific styles. Usually named after the controller whos views -// they relate to -@import "views/edition-edit-help"; -@import "views/organisation"; -@import "views/editions/filter-options"; diff --git a/app/assets/stylesheets/admin_legacy/views/_edition-edit-help.scss b/app/assets/stylesheets/admin_legacy/views/_edition-edit-help.scss deleted file mode 100644 index 810f662d93f..00000000000 --- a/app/assets/stylesheets/admin_legacy/views/_edition-edit-help.scss +++ /dev/null @@ -1,6 +0,0 @@ -.govspeak_help { - h3.use-plain-english-title, - h3.style-title { - margin-top: 1em; - } -} diff --git a/app/assets/stylesheets/admin_legacy/views/_organisation.scss b/app/assets/stylesheets/admin_legacy/views/_organisation.scss deleted file mode 100644 index 3ca5bb921c8..00000000000 --- a/app/assets/stylesheets/admin_legacy/views/_organisation.scss +++ /dev/null @@ -1,28 +0,0 @@ -.organisation-form { - .homepage-priority { - @extend %contain-floats; - - label { - display: block; - float: left; - background: transparent image-url("admin/homepage-priority.png") no-repeat 0 0; - padding: 0 0 138px 30px; - width: 175px; - overflow: hidden; - margin-right: 30px; - } - - .news { - background-position: 0 100%; - } - - .service { - background-position: -310px 100%; - } - - span { - padding-top: 3px; - display: block; - } - } -} diff --git a/app/assets/stylesheets/admin_legacy/views/editions/_filter-options.scss b/app/assets/stylesheets/admin_legacy/views/editions/_filter-options.scss deleted file mode 100644 index 15818b0c8c8..00000000000 --- a/app/assets/stylesheets/admin_legacy/views/editions/_filter-options.scss +++ /dev/null @@ -1,54 +0,0 @@ -.filter-options { - background-color: #f5f5f5; - margin-top: 0; - padding: $default-vertical-padding; - - h2 { - font-size: 19px; - } - - .filter-grouping { - @include add-bottom-margin; - - label, - h3 { - font-size: 14px; - line-height: 27px; - margin-bottom: 0; - font-weight: bold; - } - - // to align btn-enter with input - .btn-enter-wrapper { - position: relative; - } - - input.btn-enter { - position: absolute; - top: 4px; - right: 3px; - width: 50px; - background: #999999; - color: #ffffff; - border: none; - @include border-radius(3px); - margin: 0; - padding: 3px; - } - - select { - width: 100%; - } - - .checkbox { - label { - font-weight: normal; - line-height: 18px; - } - - input { - width: auto; - } - } - } -} diff --git a/spec/javascripts/admin_legacy/views/promotional_feature_items/_form.spec.js b/spec/javascripts/admin_legacy/views/promotional_feature_items/_form.spec.js deleted file mode 100644 index 2172c4eb1f4..00000000000 --- a/spec/javascripts/admin_legacy/views/promotional_feature_items/_form.spec.js +++ /dev/null @@ -1,123 +0,0 @@ -describe('GOVUK.Modules.adminPromotionalFeaturesForm', function () { - var form - - beforeEach(function () { - form = document.createElement('form') - form.classList.add('promotional_feature_item') - document.body.append(form) - }) - - afterEach(function () { - form.remove() - }) - - it('hides the image and youtube fields on init when no radios are checked', function () { - form.innerHTML = uncheckedRadioFields() - GOVUK.adminPromotionalFeatureItemsForm.init({ - selector: '.promotional_feature_item' - }) - - var imageFields = form.querySelector('.image-fields') - var youtubeFields = form.querySelector('.youtube-video-url-fields') - - expect(imageFields.hidden).toBe(true) - expect(youtubeFields.hidden).toBe(true) - }) - - it('hides the youtube fields on init when the image radio is checked', function () { - form.innerHTML = checkedImageRadioFields() - GOVUK.adminPromotionalFeatureItemsForm.init({ - selector: '.promotional_feature_item' - }) - - var imageFields = form.querySelector('.image-fields') - var youtubeFields = form.querySelector('.youtube-video-url-fields') - - expect(imageFields.hidden).toBe(false) - expect(youtubeFields.hidden).toBe(true) - }) - - it('hides the image fields on init when the youtube_video_url radio is checked', function () { - form.innerHTML = checkedYoutubeVideoUrlRadioFields() - GOVUK.adminPromotionalFeatureItemsForm.init({ - selector: '.promotional_feature_item' - }) - - var imageFields = form.querySelector('.image-fields') - var youtubeFields = form.querySelector('.youtube-video-url-fields') - - expect(imageFields.hidden).toBe(true) - expect(youtubeFields.hidden).toBe(false) - }) - - it('hides the youtube fields when the image radio is checked', function () { - form.innerHTML = uncheckedRadioFields() - GOVUK.adminPromotionalFeatureItemsForm.init({ - selector: '.promotional_feature_item' - }) - - var imageRadio = form.querySelector('#promotional_feature_promotional_feature_items_attributes_0_image_or_youtube_video_url_image') - imageRadio.dispatchEvent(new Event('change')) - - var imageFields = form.querySelector('.image-fields') - var youtubeFields = form.querySelector('.youtube-video-url-fields') - - expect(imageFields.hidden).toBe(false) - expect(youtubeFields.hidden).toBe(true) - }) - - it('hides the image fields when the youtube_video_url radio is checked', function () { - form.innerHTML = uncheckedRadioFields() - GOVUK.adminPromotionalFeatureItemsForm.init({ - selector: '.promotional_feature_item' - }) - - var youtubeRadio = form.querySelector('#promotional_feature_promotional_feature_items_attributes_0_image_or_youtube_video_url_youtube_video_url') - youtubeRadio.dispatchEvent(new Event('change')) - - var imageFields = form.querySelector('.image-fields') - var youtubeFields = form.querySelector('.youtube-video-url-fields') - - expect(imageFields.hidden).toBe(true) - expect(youtubeFields.hidden).toBe(false) - }) - - function uncheckedRadioFields () { - return ( - '
' - ) - } - - function checkedImageRadioFields () { - return ( - '' - ) - } - - function checkedYoutubeVideoUrlRadioFields () { - return ( - '' - ) - } -}) diff --git a/spec/javascripts/admin_legacy/views/statistics_announcement_dates/_form.spec.js b/spec/javascripts/admin_legacy/views/statistics_announcement_dates/_form.spec.js deleted file mode 100644 index 87cdcdbac9e..00000000000 --- a/spec/javascripts/admin_legacy/views/statistics_announcement_dates/_form.spec.js +++ /dev/null @@ -1,120 +0,0 @@ -describe('GOVUK.StatisticsAnnouncementDateForm', function () { - var container - beforeEach(function () { - container = $('