diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..dce3ca74 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,27 @@ +Provide a short description about the changes. + +--- + +Added + +- List new features, functionality + +Changed + +- List changes to existing functionality + +Removed + +- List features or functionality removed + +Fixed + +- List features or functionality that has been fixed + +--- + +## Checklist + +- [ ] Add a short description of the changes. (will be used for public changelog) +- [ ] Fill out Added, Changed, Removed, Fixed and remove any unused lists (will be used for public changelog) +- [ ] Make sure both security and lint tests have passed since continue-on-error is enabled. diff --git a/src/js/3party/vimeo.js b/src/js/3party/vimeo.js index 5447ec06..6751b28c 100644 --- a/src/js/3party/vimeo.js +++ b/src/js/3party/vimeo.js @@ -334,9 +334,8 @@ export default (function() { var buttonImg = button.getElementsByTagName('img')[0]; buttonImg.src = buttonImg.src.includes('expand_more') ? expandLess : expandMore; var transcriptSelect = document.getElementById(transcript.getTranscriptSelectId()); - transcriptSelect.style.display = transcriptSelect.style.display === 'none' ? 'block' : 'none'; + $(transcriptSelect).fadeToggle(250); transcriptSelect.style.marginTop = '1rem'; - var body = document.getElementById(transcriptContentId); var iframe = document.getElementById(iframeId); var bodyDisplayStyle = getComputedStyle(body).display; @@ -346,19 +345,15 @@ export default (function() { } else { slideDownAndAdjustIframe(400, body, iframe); } - - event.preventDefault(); }); function slideUpAndAdjustIframe(duration, element, iframe) { - element.style.display = 'none'; - element.classList.remove('uob-box'); + $(element).slideToggle(250); } function slideDownAndAdjustIframe(duration, element, iframe) { - element.style.display = 'block'; - element.classList.add('uob-box'); + $(element).slideToggle(250); } return { transcriptArea: p, transcriptContentArea: e }; diff --git a/src/js/account-theme.js b/src/js/account-theme.js index f24da2a6..6623c361 100644 --- a/src/js/account-theme.js +++ b/src/js/account-theme.js @@ -3,12 +3,34 @@ import { createApp } from 'vue'; import utilRoot from './utilRoot'; var udirDesignLoaded; - +var themeCookieName = 'use_localhost_theme'; jQuery.extend({ + getCookie: function (name) { + var value = '; ' + document.cookie; + var parts = value.split('; ' + name + '='); + if (parts.length === 2) return parts.pop().split(';').shift(); + return null; + }, + + setCookie: function (name, value, days) { + var expires = ''; + if (days) { + var date = new Date(); + date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); + expires = '; expires=' + date.toUTCString(); + } + document.cookie = name + '=' + value + expires + '; path=/'; + }, + + deleteCookie: function (name) { + document.cookie = + name + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;'; + }, + getScript: function (url, callback) { - var head = document.getElementsByTagName("head")[0]; - var script = document.createElement("script"); + var head = document.getElementsByTagName('head')[0]; + var script = document.createElement('script'); script.src = url; // Handle Script loading @@ -20,8 +42,8 @@ jQuery.extend({ if ( !done && (!this.readyState || - this.readyState == "loaded" || - this.readyState == "complete") + this.readyState == 'loaded' || + this.readyState == 'complete') ) { done = true; if (callback) callback(); @@ -40,24 +62,103 @@ jQuery.extend({ }); jQuery(document).ready(function ($) { - console.log("START."); + console.log('START.'); var redirected = false; + var themeSettings = { + url: SERVER, + js: DESIGNJS, + css: DESIGNCSS, + }; + + var useLocalhostTheme = $.getCookie(themeCookieName) === 'true'; + if (useLocalhostTheme) { + themeSettings.url = 'http://localhost:9000/'; + themeSettings.css = 'kompetanseportalen-localhost.css'; + themeSettings.js = 'kompetanseportalen-localhost.js'; + console.log('Using localhost theme:', themeSettings); + } else { + console.log('Using default theme:', themeSettings); + } + + var isBrandConfigPage = + window.location.pathname === '/accounts/1/brand_configs'; + if (isBrandConfigPage) { + try { + if (isBrandConfigPage) { + var intervalTime = 1000; + var checkInterval; + + function runWhenTemaVisible() { + var isThemeHeadingVisible = $("h1:contains('Tema')").is(':visible'); + + if (isThemeHeadingVisible) { + var content = $('#content'); + if (content.length) { + var buttonWrapper = $( + '
', + ); + + function getButtonLabel() { + var cookieValue = $.getCookie(themeCookieName); + return cookieValue === 'true' + ? 'Switch to default theme' + : 'Switch to localhost theme'; + } + + var themeSwitchButton = $('