diff --git a/assets/custom-functions.js b/assets/custom-functions.js index 88b258916cf332660a6d263d2b4097401b064163..49b296df529af7063d215039b1e10aae69d71e76 100644 --- a/assets/custom-functions.js +++ b/assets/custom-functions.js @@ -75,32 +75,6 @@ $(document).ready(function () { }); }); -// Functions to fullscreen iframe -function requestFullScreen(element) { - var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen; - requestMethod.call(element); -} - -function exitFullScreen() { - const element = window.parent.document - const cancelFullScreen = element.exitFullscreen || element.mozCancelFullScreen || element.webkitExitFullscreen || element.msExitFullscreen; - cancelFullScreen.call(element); -}; - -// Wait for click to go fullscreen -$(document).ready(function () { - $(document).on('click', "#fullscreen-tab", function () { - var element = window.parent.document.getElementById('product-iframe'); - if(window.parent.document.fullscreenElement!=null){ - console.log('Triggering exit'); - exitFullScreen(); - }else { - console.log('Triggering fullscreen'); - requestFullScreen(element); - } - }); -}); - // Remove yellow from rc-slider-mark-text when moved $(document).ready(function () { $(document).on('click','.rc-slider' , function () { @@ -139,3 +113,31 @@ $(document).ready(function () { } }); }); + +// SEND FULLSCREEN REQUEST TO PARENT WINDOW +$(document).ready(function () { + $(document).on('click', "#fullscreen-tab", function () { + parent.postMessage('fullscreen', '*'); + }) +}); + +// DETECT IFRAME AND REMOVE FULLSCREEN BUTTON +$(window).on('load', function removeFullscreen () { + const tab = document.getElementById('fullscreen-tab'); + if (tab != null) { + if (window.self === window.top){ + tab.style.visibility = "hidden"; + } + } else { + setTimeout(removeFullscreen, 5); + } +}); + +// Move datepicker above the time series area +$(document).ready(function () { + $(document).on('click', ".SingleDatePicker", function () { + const element = document.getElementsByClassName('DayPicker')[0]; + element.style.position = 'absolute'; + element.style.bottom = '78px'; + }); +}); diff --git a/assets/style.css b/assets/style.css index c6e521271b9c9f8371509d5ed33d444ab0c9ee0c..9098cc56de453d1ee895b5e2ab52ae6b9f91fe4b 100644 --- a/assets/style.css +++ b/assets/style.css @@ -38,6 +38,25 @@ a.modebar-btn { padding-bottom: 0.8rem !important; } +#fullscreen-tab:hover:after { + color: #F1B545; +} + +#fullscreen-tab::after { + position: absolute; + top: 65%; + right: 9%; + font-variant: normal; + text-rendering: auto; + -webkit-font-smoothing: antialiased; + font-family: "Font Awesome 5 Brands","Font Awesome 5 Free"; + font-size: 25px; + font-weight: 900; + font-style: normal; + content: "\f065"; + color: white; +} + .horizontal-menu { background-color: #2B383E !important; font-family: "Roboto", sans-serif; @@ -193,7 +212,7 @@ input.DateInput_input { } .DateInput_input:after { - display: inline-block; + display: inline-block; margin-left: 0.255em; vertical-align: 0.255em; content: ""; diff --git a/dash_server.py b/dash_server.py index 2f9587047831b1eb22cf2a64fe6d347ef3cfb12f..a760979c1282ee983a03d686803828c38011a6fc 100755 --- a/dash_server.py +++ b/dash_server.py @@ -133,4 +133,4 @@ from tabs.observations_callbacks import * if __name__ == '__main__': app.run_server(debug=True, # use_reloader=False, # processes=4, threaded=False, - host='0.0.0.0', port=7777) + host='0.0.0.0', port=7778) diff --git a/router.py b/router.py index 2cce658a537f1122a7b04a2237aae03c623f8047..efdfcc8bf43b73d819820559591238b9d8462137 100644 --- a/router.py +++ b/router.py @@ -71,7 +71,7 @@ def render_sidebar(tab='forecast-tab', route_selections=ROUTE_DEFAULTS): 'observations-tab' : sidebar_observations(route_selections['obs_option'][0]), #'fullscreen-tab' : 'Full' } - if tabs[tab][0] is 'Full': + if tabs[tab] is 'Full': return return tabs[tab] @@ -124,7 +124,7 @@ def router(url): tab_forecast(window=route_selections['for_option'][0], end_date=route_selections['date'][0]),#'models', 'prob', 'was' tab_evaluation(route_selections['eval_option'][0]), #nrt or scores tab_observations(route_selections['obs_option'][0]),#rgb or visibility - # go_fullscreen(pathname), + go_fullscreen(), ]), ] except: #This handles when user inputs incorrect URL params diff --git a/tabs/fullscreen.py b/tabs/fullscreen.py index 2f87a8d2e06c1487161f450a4a4fd0aa37bf4e1f..50a3b56ebc73830e8ea65f4b9c2cdc3a547d569c 100644 --- a/tabs/fullscreen.py +++ b/tabs/fullscreen.py @@ -1,20 +1,12 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -import dash_bootstrap_components as dbc from dash import dcc -from dash import html -def go_fullscreen(pathname): - if 'daily_dashboard' not in pathname: - return dcc.Tab(label='', - id='fullscreen-tab', - value='fullscreen-tab', - className='horizontal-menu', - ) - else: - return dcc.Tab(label='Fullscreen', - id='fullscreen-tab', - value='fullscreen-tab', - className='horizontal-menu', - ) +def go_fullscreen(): + return dcc.Tab( + id='fullscreen-tab', + value='fullscreen-tab', + disabled=True, + className='horizontal-menu', + ) diff --git a/tests/test_fullscreen.py b/tests/test_fullscreen.py new file mode 100644 index 0000000000000000000000000000000000000000..328f1ec0eb53982eab07b492d0bdec25941b71b6 --- /dev/null +++ b/tests/test_fullscreen.py @@ -0,0 +1,6 @@ +import pytest +import importlib +code = importlib.import_module('tabs.fullscreen') + +def test_fullscreen(): + assert "(id='fullscreen-tab', className='horizontal-menu', disabled=True, value='fullscreen-tab')" in str(code.go_fullscreen())