Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Removed iframe-height.js and its implementations (#1063)
Barok Dagim961626c5eb97
diff --git a/src/layouts/blank.vue b/src/layouts/blank.vueindex ec6171bfa..f0c51008f 100644--- a/src/layouts/blank.vue+++ b/src/layouts/blank.vue@@ -9,8 +9,6 @@<script>import { computed, defineComponent } from '@nuxtjs/composition-api'-import iframeHeight from '~/mixins/iframe-height'-import { useNavStore } from '~/stores/nav'import VTranslationStatusBanner from '~/components/VTranslationStatusBanner.vue'@@ -20,7 +18,6 @@ import VMigrationNotice from '~/components/VMigrationNotice.vue'export default defineComponent({name: 'Blank',components: { VMigrationNotice, VTranslationStatusBanner },- mixins: [iframeHeight],setup() {const navStore = useNavStore()const isReferredFromCc = computed(() => navStore.isReferredFromCc)diff --git a/src/layouts/default.vue b/src/layouts/default.vueindex 114d4afe3..3bf219530 100644--- a/src/layouts/default.vue+++ b/src/layouts/default.vue@@ -28,8 +28,6 @@ import { isMinScreen } from '~/composables/use-media-query'import { useFilterSidebarVisibility } from '~/composables/use-filter-sidebar-visibility'-import iframeHeight from '~/mixins/iframe-height'-import { useNavStore } from '~/stores/nav'import VMigrationNotice from '~/components/VMigrationNotice.vue'@@ -52,7 +50,6 @@ const embeddedPage = {VGlobalAudioSection,},layout: 'embedded',- mixins: [iframeHeight],head() {return this.$nuxtI18nHead({ addSeoAttributes: true, addDirAttribute: true })},diff --git a/src/locales/po-files/openverse.pot b/src/locales/po-files/openverse.potindex 88b37cbea..694f0e518 100644--- a/src/locales/po-files/openverse.pot+++ b/src/locales/po-files/openverse.pot@@ -4,7 +4,7 @@ msgid ""msgstr """Project-Id-Version: Openverse \n""Report-Msgid-Bugs-To: https://github.com/wordpress/openverse/issues \n"-"POT-Creation-Date: 2022-03-04T12:13:48+00:00\n"+"POT-Creation-Date: 2022-03-07T19:35:50+00:00\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=UTF-8\n""Content-Transfer-Encoding: 8bit\n"@@ -1121,7 +1121,7 @@ msgid "Couldn't find image with id ###id###"msgstr ""#. Do not translate words between ### ###.-#: src/pages/audio/_id.vue:67+#: src/pages/audio/_id.vue:65msgctxt "error.media-not-found"msgid "Couldn't find ###mediaType### with id ###id###"msgstr ""diff --git a/src/middleware/middleware.js b/src/middleware/middleware.jsindex 247b3e1e9..7a8beb7fd 100644--- a/src/middleware/middleware.js+++ b/src/middleware/middleware.js@@ -3,7 +3,7 @@ import { sendWindowMessage } from '~/utils/send-message'import { useNavStore } from '~/stores/nav'/**- * In embedded mode, the app sends its size and url+ * In embedded mode, the app sends its url* to the outer window to improve the user experience.** The app is in embedded mode by default. To set it to@@ -12,8 +12,7 @@ import { useNavStore } from '~/stores/nav'** Messages sent to the outer window have the following format:* {type: <event type>, value: <event value>}.- * Currently, two event types are used:- * - `resize` sends the height of the window (see `src/mixins/iframe-height.js`)+ * Currently, one event type is used:* - `urlChange` sends the relative path of the URL on every URL change.*/export default function ({ query, route, $pinia }) {diff --git a/src/mixins/iframe-height.js b/src/mixins/iframe-height.jsdeleted file mode 100644index 74c25f83d..000000000--- a/src/mixins/iframe-height.js+++ /dev/null@@ -1,60 +0,0 @@-import debounce from 'lodash.debounce'--import { sendWindowMessage } from '~/utils/send-message'-import { useNavStore } from '~/stores/nav'--/**- * When the app is in embedded mode, it passes the full height- * of its content to the parent window so that the parent window- * sets the correct iframe height to avoid double scrollbars- */-export default {- data: () => ({ height: 0, observer: null }),- mounted() {- const isEmbedded = useNavStore().isEmbedded- if (isEmbedded) {- this.notifyOuterWindow(document.documentElement.scrollHeight)- this.observer = this.createResizeObserver()- this.observer?.observe(document.documentElement)- }- },- beforeDestroy() {- window.removeEventListener('resize', this.notifyOuterWindow)- // The observer could be null if the user switches from- // embedded to standalone version, so we check if it exists- // before disconnecting it- if (this.observer) {- this.observer.disconnect()- }- },- methods: {- createResizeObserver() {- if (!window.ResizeObserver) return null-- return new ResizeObserver(- debounce((entries) => {- for (let entry of entries) {- if (entry.contentBoxSize) {- if (entry.contentBoxSize[0]) {- this.height = Math.ceil(entry.contentBoxSize[0].blockSize)- } else {- this.height = Math.ceil(entry.contentBoxSize.blockSize)- }- }- }- }, 1)- )- },- notifyOuterWindow(height) {- sendWindowMessage({- type: 'resize',- value: { height },- })- },- },- watch: {- height: function (newHeight) {- this.notifyOuterWindow(newHeight)- },- },-}diff --git a/src/pages/audio/_id.vue b/src/pages/audio/_id.vueindex db7b6fa99..4ce969bfd 100644--- a/src/pages/audio/_id.vue+++ b/src/pages/audio/_id.vue@@ -24,7 +24,6 @@import { mapState } from 'vuex'import { FETCH_MEDIA_ITEM } from '~/constants/action-types'-import iframeHeight from '~/mixins/iframe-height'import { AUDIO } from '~/constants/media'import getAttributionHtml from '~/utils/attribution-html'import { getFullLicenseName } from '~/utils/license'@@ -32,7 +31,6 @@ import { MEDIA } from '~/constants/store-modules'const AudioDetailPage = {name: 'AudioDetailPage',- mixins: [iframeHeight],data() {return {showBackToSearchLink: false,diff --git a/test/iframe-test.html b/test/iframe-test.htmlindex 3a5886da1..ea15b1eda 100644--- a/test/iframe-test.html+++ b/test/iframe-test.html@@ -101,10 +101,8 @@}let handler+switch (data.type) {- case 'resize':- handler = updateHeight- breakcase 'urlChange':handler = updatePathbreak