From 1fabfc4c8096ed21c67fa948b797e789796845a2 Mon Sep 17 00:00:00 2001 From: Taro Matsuzawa Date: Thu, 25 Jul 2024 10:54:42 +0900 Subject: [PATCH] revert fixes and add flag for edit mode --- app/helpers/gtt_map_helper.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/helpers/gtt_map_helper.rb b/app/helpers/gtt_map_helper.rb index 22e2226..cc77cdc 100644 --- a/app/helpers/gtt_map_helper.rb +++ b/app/helpers/gtt_map_helper.rb @@ -67,9 +67,18 @@ def map_tag(map: nil, layers: map&.layers, if (!#{show}) { document.addEventListener('contentUpdated', function(){ var target = document.getElementById('#{uid}'); + target.classList.add('map-editable'); window.createGttClient(target); contentObserver(); }, { once: true }); + var target = document.getElementById('#{uid}'); + if ( + document.readyState === 'complete' + && !target.hasChildNodes() + && document.getElementsByClassName('map-editable').length === 1 + ) { + window.createGttClient(target); + } } document.addEventListener('DOMContentLoaded', function(){ var target = document.getElementById('#{uid}');