Changeset 3431559
- Timestamp:
- 01/03/2026 10:27:08 AM (7 weeks ago)
- Location:
- spelhubben-weather
- Files:
-
- 12 edited
- 1 copied
-
tags/1.8.6 (copied) (copied from spelhubben-weather/trunk)
-
tags/1.8.6/assets/map.js (modified) (1 diff)
-
tags/1.8.6/assets/style.css (modified) (1 diff)
-
tags/1.8.6/blocks/spelhubben-weather/block.json (modified) (1 diff)
-
tags/1.8.6/blocks/spelhubben-weather/index.js (modified) (1 diff)
-
tags/1.8.6/includes/class-assets.php (modified) (1 diff)
-
tags/1.8.6/spelhubben-weather.php (modified) (2 diffs)
-
trunk/assets/map.js (modified) (1 diff)
-
trunk/assets/style.css (modified) (1 diff)
-
trunk/blocks/spelhubben-weather/block.json (modified) (1 diff)
-
trunk/blocks/spelhubben-weather/index.js (modified) (1 diff)
-
trunk/includes/class-assets.php (modified) (1 diff)
-
trunk/spelhubben-weather.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
spelhubben-weather/tags/1.8.6/assets/map.js
r3425273 r3431559 34 34 el.dataset.inited = '1'; 35 35 36 // Check if Leaflet is loaded 37 if (typeof L === 'undefined' || !L.map) { 38 console.warn('Leaflet not loaded yet, retrying...', el); 39 // Try again in a moment 40 setTimeout(() => { 41 delete el.dataset.inited; 42 initMap(el); 43 }, 500); 44 return; 45 } 46 36 47 const lat = parseFloat(el.getAttribute('data-lat')); 37 48 const lon = parseFloat(el.getAttribute('data-lon')); 38 if (isNaN(lat) || isNaN(lon)) return; 49 if (isNaN(lat) || isNaN(lon)) { 50 console.warn('Missing or invalid lat/lon for map', el); 51 return; 52 } 39 53 40 const map = L.map(el, { scrollWheelZoom:false, attributionControl:false }); 41 el._svvMap = map; 54 // Ensure element has a computed height before initializing 55 const computedHeight = window.getComputedStyle(el).height; 56 if (!computedHeight || computedHeight === '0px' || computedHeight === 'auto') { 57 console.warn('Map element has no height, retrying...', el); 58 setTimeout(() => { 59 delete el.dataset.inited; 60 initMap(el); 61 }, 500); 62 return; 63 } 42 64 43 map.setView([lat, lon], 12); 44 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom:19 }).addTo(map); 65 try { 66 const map = L.map(el, { scrollWheelZoom:false, attributionControl:false }); 67 el._svvMap = map; 45 68 46 // NOTE: No L.marker here — the pin is never placed. 47 setTimeout(()=>map.invalidateSize(), 200); 69 map.setView([lat, lon], 12); 70 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom:19 }).addTo(map); 71 72 // NOTE: No L.marker here — the pin is never placed. 73 setTimeout(()=>map.invalidateSize(), 200); 74 } catch (e) { 75 console.error('Error initializing map:', e); 76 delete el.dataset.inited; 77 } 48 78 } 49 79 50 function scanMaps(){ document.querySelectorAll('.svv-map').forEach(initMap); } 80 function scanMaps(){ 81 if (typeof L === 'undefined') { 82 // Leaflet not ready, try again 83 requestAnimationFrame(scanMaps); 84 return; 85 } 86 document.querySelectorAll('.svv-map').forEach(initMap); 87 } 51 88 52 89 if (document.readyState === 'loading') { -
spelhubben-weather/tags/1.8.6/assets/style.css
r3425273 r3431559 60 60 61 61 /* Karta */ 62 .svv-map{width:100%; border:1px solid #e6e6e6;border-radius:var(--svv-radius);overflow:hidden;margin-top:calc(10px * var(--svv-scale))}62 .svv-map{width:100%;height:240px;border:1px solid #e6e6e6;border-radius:var(--svv-radius);overflow:hidden;margin-top:calc(10px * var(--svv-scale))} 63 63 .svv-map-attrib{margin-top:calc(6px * var(--svv-scale));font-size:calc(12px * var(--svv-scale));opacity:.8} 64 64 .svv-map-attrib a{text-decoration:none} -
spelhubben-weather/tags/1.8.6/blocks/spelhubben-weather/block.json
r3425273 r3431559 1 1 { 2 2 "apiVersion": 2, 3 "name": "spelhubben /weather",3 "name": "spelhubben-weather/spelhubben-weather", 4 4 "title": "Spelhubben Weather", 5 5 "category": "widgets", -
spelhubben-weather/tags/1.8.6/blocks/spelhubben-weather/index.js
r3425273 r3431559 19 19 ]; 20 20 21 registerBlockType('spelhubben /weather', {21 registerBlockType('spelhubben-weather/spelhubben-weather', { 22 22 edit: (props) => { 23 23 const { attributes, setAttributes } = props; -
spelhubben-weather/tags/1.8.6/includes/class-assets.php
r3431056 r3431559 36 36 */ 37 37 private function should_load_leaflet() { 38 global $post ;38 global $post, $wp_registered_sidebars; 39 39 40 if ( ! isset( $post->post_content ) ) { 41 return false; 40 // Check for shortcodes in post content 41 if ( isset( $post->post_content ) ) { 42 // Check for old shortcode (legacy) 43 if ( has_shortcode( $post->post_content, 'sv-vader' ) ) { 44 return true; 45 } 46 // Check for new shortcode 47 if ( has_shortcode( $post->post_content, 'spelhubben_weather' ) ) { 48 return true; 49 } 50 // Check for Gutenberg blocks 51 if ( has_block( 'spelhubben-weather/spelhubben-weather', $post ) ) { 52 return true; 53 } 54 if ( has_block( 'sv/vader', $post ) ) { 55 return true; 56 } 42 57 } 43 58 44 // Check for shortcode 45 if ( has_shortcode( $post->post_content, 'sv-vader' ) ) { 46 return true; 47 } 48 49 // Check for Gutenberg block 50 if ( has_block( 'spelhubben-weather/spelhubben-weather', $post ) ) { 51 return true; 59 // Check if the sv_vader_widget is active in any sidebar 60 if ( function_exists( 'is_active_widget' ) ) { 61 if ( is_active_widget( false, false, 'sv_vader_widget' ) ) { 62 return true; 63 } 52 64 } 53 65 -
spelhubben-weather/tags/1.8.6/spelhubben-weather.php
r3425273 r3431559 3 3 * Plugin Name: Spelhubben Weather 4 4 * Description: Displays current weather and an optional forecast with a simple consensus across providers (Open-Meteo, SMHI, Yr/MET Norway). Supports shortcode + Gutenberg block + classic widget. Optional Leaflet map, subtle animations, daily forecast, and multiple layouts. 5 * Version: 1.8. 45 * Version: 1.8.6 6 6 * Author: Spelhubben 7 7 * Text Domain: spelhubben-weather … … 19 19 // ── Constants (kept for backward compatibility). 20 20 if ( ! defined( 'SV_VADER_VER' ) ) { 21 define( 'SV_VADER_VER', '1.8. 4' );21 define( 'SV_VADER_VER', '1.8.6' ); 22 22 } 23 23 if ( ! defined( 'SV_VADER_DIR' ) ) { -
spelhubben-weather/trunk/assets/map.js
r3425273 r3431559 34 34 el.dataset.inited = '1'; 35 35 36 // Check if Leaflet is loaded 37 if (typeof L === 'undefined' || !L.map) { 38 console.warn('Leaflet not loaded yet, retrying...', el); 39 // Try again in a moment 40 setTimeout(() => { 41 delete el.dataset.inited; 42 initMap(el); 43 }, 500); 44 return; 45 } 46 36 47 const lat = parseFloat(el.getAttribute('data-lat')); 37 48 const lon = parseFloat(el.getAttribute('data-lon')); 38 if (isNaN(lat) || isNaN(lon)) return; 49 if (isNaN(lat) || isNaN(lon)) { 50 console.warn('Missing or invalid lat/lon for map', el); 51 return; 52 } 39 53 40 const map = L.map(el, { scrollWheelZoom:false, attributionControl:false }); 41 el._svvMap = map; 54 // Ensure element has a computed height before initializing 55 const computedHeight = window.getComputedStyle(el).height; 56 if (!computedHeight || computedHeight === '0px' || computedHeight === 'auto') { 57 console.warn('Map element has no height, retrying...', el); 58 setTimeout(() => { 59 delete el.dataset.inited; 60 initMap(el); 61 }, 500); 62 return; 63 } 42 64 43 map.setView([lat, lon], 12); 44 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom:19 }).addTo(map); 65 try { 66 const map = L.map(el, { scrollWheelZoom:false, attributionControl:false }); 67 el._svvMap = map; 45 68 46 // NOTE: No L.marker here — the pin is never placed. 47 setTimeout(()=>map.invalidateSize(), 200); 69 map.setView([lat, lon], 12); 70 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom:19 }).addTo(map); 71 72 // NOTE: No L.marker here — the pin is never placed. 73 setTimeout(()=>map.invalidateSize(), 200); 74 } catch (e) { 75 console.error('Error initializing map:', e); 76 delete el.dataset.inited; 77 } 48 78 } 49 79 50 function scanMaps(){ document.querySelectorAll('.svv-map').forEach(initMap); } 80 function scanMaps(){ 81 if (typeof L === 'undefined') { 82 // Leaflet not ready, try again 83 requestAnimationFrame(scanMaps); 84 return; 85 } 86 document.querySelectorAll('.svv-map').forEach(initMap); 87 } 51 88 52 89 if (document.readyState === 'loading') { -
spelhubben-weather/trunk/assets/style.css
r3425273 r3431559 60 60 61 61 /* Karta */ 62 .svv-map{width:100%; border:1px solid #e6e6e6;border-radius:var(--svv-radius);overflow:hidden;margin-top:calc(10px * var(--svv-scale))}62 .svv-map{width:100%;height:240px;border:1px solid #e6e6e6;border-radius:var(--svv-radius);overflow:hidden;margin-top:calc(10px * var(--svv-scale))} 63 63 .svv-map-attrib{margin-top:calc(6px * var(--svv-scale));font-size:calc(12px * var(--svv-scale));opacity:.8} 64 64 .svv-map-attrib a{text-decoration:none} -
spelhubben-weather/trunk/blocks/spelhubben-weather/block.json
r3425273 r3431559 1 1 { 2 2 "apiVersion": 2, 3 "name": "spelhubben /weather",3 "name": "spelhubben-weather/spelhubben-weather", 4 4 "title": "Spelhubben Weather", 5 5 "category": "widgets", -
spelhubben-weather/trunk/blocks/spelhubben-weather/index.js
r3425273 r3431559 19 19 ]; 20 20 21 registerBlockType('spelhubben /weather', {21 registerBlockType('spelhubben-weather/spelhubben-weather', { 22 22 edit: (props) => { 23 23 const { attributes, setAttributes } = props; -
spelhubben-weather/trunk/includes/class-assets.php
r3431056 r3431559 36 36 */ 37 37 private function should_load_leaflet() { 38 global $post ;38 global $post, $wp_registered_sidebars; 39 39 40 if ( ! isset( $post->post_content ) ) { 41 return false; 40 // Check for shortcodes in post content 41 if ( isset( $post->post_content ) ) { 42 // Check for old shortcode (legacy) 43 if ( has_shortcode( $post->post_content, 'sv-vader' ) ) { 44 return true; 45 } 46 // Check for new shortcode 47 if ( has_shortcode( $post->post_content, 'spelhubben_weather' ) ) { 48 return true; 49 } 50 // Check for Gutenberg blocks 51 if ( has_block( 'spelhubben-weather/spelhubben-weather', $post ) ) { 52 return true; 53 } 54 if ( has_block( 'sv/vader', $post ) ) { 55 return true; 56 } 42 57 } 43 58 44 // Check for shortcode 45 if ( has_shortcode( $post->post_content, 'sv-vader' ) ) { 46 return true; 47 } 48 49 // Check for Gutenberg block 50 if ( has_block( 'spelhubben-weather/spelhubben-weather', $post ) ) { 51 return true; 59 // Check if the sv_vader_widget is active in any sidebar 60 if ( function_exists( 'is_active_widget' ) ) { 61 if ( is_active_widget( false, false, 'sv_vader_widget' ) ) { 62 return true; 63 } 52 64 } 53 65 -
spelhubben-weather/trunk/spelhubben-weather.php
r3425273 r3431559 3 3 * Plugin Name: Spelhubben Weather 4 4 * Description: Displays current weather and an optional forecast with a simple consensus across providers (Open-Meteo, SMHI, Yr/MET Norway). Supports shortcode + Gutenberg block + classic widget. Optional Leaflet map, subtle animations, daily forecast, and multiple layouts. 5 * Version: 1.8. 45 * Version: 1.8.6 6 6 * Author: Spelhubben 7 7 * Text Domain: spelhubben-weather … … 19 19 // ── Constants (kept for backward compatibility). 20 20 if ( ! defined( 'SV_VADER_VER' ) ) { 21 define( 'SV_VADER_VER', '1.8. 4' );21 define( 'SV_VADER_VER', '1.8.6' ); 22 22 } 23 23 if ( ! defined( 'SV_VADER_DIR' ) ) {
Note: See TracChangeset
for help on using the changeset viewer.