|
1075 | 1075 | + '</div>' |
1076 | 1076 | + '</div>' |
1077 | 1077 |
|
1078 | | - // Scope row — separate layoutRow so the grid equalizes heights across all three columns |
| 1078 | + // Download scope row — aligned to download column via empty placeholders |
1079 | 1079 | + '<div class="layoutRow" style="margin-bottom: 4px;">' |
1080 | | - + '<div class="column-4" style="display: flex;">' |
1081 | | - + '<button class="' + (canSaveToServer ? 'pressed' : '') + '" style="flex: 1; padding: 8px; text-align: center; pointer-events: none;"' |
1082 | | - + (canSaveToServer ? '' : ' disabled') + '>' |
1083 | | - + labels['DownloadAllData'] |
1084 | | - + '</button>' |
1085 | | - + '</div>' |
1086 | | - + '<div class="column-4" style="display: flex;">' |
1087 | | - + '<button class="' + (canSaveToLocal ? 'pressed' : '') + '" style="flex: 1; padding: 8px; text-align: center; pointer-events: none;"' |
1088 | | - + (canSaveToLocal ? '' : ' disabled') + '>' |
1089 | | - + labels['DownloadAllData'] |
1090 | | - + '</button>' |
| 1080 | + + '<div class="column-4"></div>' |
| 1081 | + + '<div class="column-4"></div>' |
| 1082 | + + '<div class="column-4">' |
| 1083 | + + '<div style="display: flex; gap: 12px;">' |
| 1084 | + + '<label><input type="radio" name="downloadScope" value="currentHv" checked> ' + labels['DownloadCurrentHypervideo'] + '</label>' |
| 1085 | + + '<label><input type="radio" name="downloadScope" value="allData"> ' + labels['DownloadAllData'] + '</label>' |
1091 | 1086 | + '</div>' |
1092 | | - + '<div class="column-4" style="display: flex;">' |
1093 | | - + '<button class="scopeCurrentHv pressed" style="flex: 1; padding: 8px; text-align: center;">' |
1094 | | - + labels['DownloadCurrentHypervideo'] |
1095 | | - + '</button>' |
1096 | | - + '<button class="scopeAllData" style="flex: 1; padding: 8px; text-align: center; margin-left: -2px;">' |
1097 | | - + labels['DownloadAllData'] |
1098 | | - + '</button>' |
1099 | 1087 | + '</div>' |
1100 | 1088 | + '</div>' |
1101 | 1089 |
|
|
1107 | 1095 | + '<div class="downloadFormatSection">' |
1108 | 1096 | + '<small>' + labels['DownloadFormat'] + '</small>' |
1109 | 1097 | + '<div style="display: flex; gap: 12px; margin-top: 4px;">' |
1110 | | - + '<label><input type="radio" name="downloadFormat" value="json" checked> JSON</label>' |
1111 | | - + '<label><input type="radio" name="downloadFormat" value="html"> HTML</label>' |
| 1098 | + + '<label><input type="radio" name="downloadFormat" value="html" checked> HTML</label>' |
| 1099 | + + '<label><input type="radio" name="downloadFormat" value="json"> JSON</label>' |
1112 | 1100 | + '</div>' |
1113 | | - + '<div class="downloadHtmlDataPath" style="display: none; margin-top: 6px;">' |
| 1101 | + + '<div style="margin-top: 6px;">' |
1114 | 1102 | + '<small>' + labels['DownloadResourceBaseUrl'] + '</small>' |
1115 | 1103 | + '<input type="text" name="htmlDataPath" placeholder="https://example.com/_data/" style="margin-top: 2px;">' |
1116 | 1104 | + '</div>' |
|
1127 | 1115 | + '</div>'; |
1128 | 1116 | var saveAsDialog = _saveAsWrapper.firstElementChild; |
1129 | 1117 |
|
1130 | | - var scopeCurrentHvBtn = saveAsDialog.querySelector('.scopeCurrentHv'); |
1131 | | - var scopeAllDataBtn = saveAsDialog.querySelector('.scopeAllData'); |
1132 | 1118 | var formatSection = saveAsDialog.querySelector('.downloadFormatSection'); |
1133 | | - var htmlDataPathDiv = saveAsDialog.querySelector('.downloadHtmlDataPath'); |
1134 | 1119 | var optionsSection = saveAsDialog.querySelector('.downloadOptionsSection'); |
1135 | 1120 |
|
1136 | 1121 | // Default htmlDataPath to the absolute URL of the current _data/ directory |
1137 | 1122 | var _dataPathInput = saveAsDialog.querySelector('[name="htmlDataPath"]'); |
1138 | 1123 | var _resolvedDataURL = FrameTrail.module('RouteNavigation').resolveDataURL(''); |
1139 | 1124 | _dataPathInput.value = new URL(_resolvedDataURL, window.location.href).href; |
1140 | 1125 |
|
1141 | | - scopeCurrentHvBtn.addEventListener('click', function() { |
1142 | | - scopeCurrentHvBtn.classList.add('pressed'); |
1143 | | - scopeAllDataBtn.classList.remove('pressed'); |
1144 | | - formatSection.style.display = ''; |
1145 | | - optionsSection.style.display = 'none'; |
1146 | | - }); |
1147 | | - |
1148 | | - scopeAllDataBtn.addEventListener('click', function() { |
1149 | | - scopeAllDataBtn.classList.add('pressed'); |
1150 | | - scopeCurrentHvBtn.classList.remove('pressed'); |
1151 | | - formatSection.style.display = 'none'; |
1152 | | - optionsSection.style.display = ''; |
1153 | | - }); |
1154 | | - |
1155 | | - // Show/hide dataPath input when HTML format is selected |
1156 | | - formatSection.querySelectorAll('[name="downloadFormat"]').forEach(function(radio) { |
| 1126 | + saveAsDialog.querySelectorAll('[name="downloadScope"]').forEach(function(radio) { |
1157 | 1127 | radio.addEventListener('change', function() { |
1158 | | - htmlDataPathDiv.style.display = (radio.value === 'html' && radio.checked) ? '' : 'none'; |
| 1128 | + var isAllData = radio.value === 'allData' && radio.checked; |
| 1129 | + formatSection.style.display = isAllData ? 'none' : ''; |
| 1130 | + optionsSection.style.display = isAllData ? '' : 'none'; |
1159 | 1131 | }); |
1160 | 1132 | }); |
1161 | 1133 |
|
|
1182 | 1154 | var hvID = FrameTrail.module('RouteNavigation').hypervideoID; |
1183 | 1155 | downloadAdapter._frameTrailInstance = FrameTrail; |
1184 | 1156 |
|
1185 | | - var isAllData = scopeAllDataBtn.classList.contains('pressed'); |
| 1157 | + var isAllData = saveAsDialog.querySelector('[name="downloadScope"][value="allData"]').checked; |
1186 | 1158 |
|
1187 | 1159 | if (isAllData) { |
1188 | 1160 | var includeMedia = saveAsDialog.querySelector('[name="includeMedia"]').checked; |
|
1199 | 1171 | } |
1200 | 1172 | } else { |
1201 | 1173 | var format = saveAsDialog.querySelector('[name="downloadFormat"]:checked').value; |
| 1174 | + var dataPath = saveAsDialog.querySelector('[name="htmlDataPath"]').value.trim(); |
1202 | 1175 | if (format === 'html') { |
1203 | | - var dataPath = saveAsDialog.querySelector('[name="htmlDataPath"]').value.trim(); |
1204 | 1176 | downloadAdapter._generateStandaloneHTML(hvID, dataPath); |
1205 | 1177 | } else { |
1206 | | - downloadAdapter._performDownload(hvID); |
| 1178 | + downloadAdapter._performDownload(hvID, dataPath); |
1207 | 1179 | } |
1208 | 1180 | } |
1209 | 1181 |
|
|
0 commit comments