Overview
Comment: | Open text editor after creating a new text file, also resize the iframe correctly |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | stable |
Files: | files | file ages | folders |
SHA3-256: |
2e84f0e59a741b9b4fcbcadda9b2c497 |
User & Date: | bohwaz on 2021-11-29 16:15:02 |
Other Links: | manifest | tags |
Context
2021-11-29
| ||
16:40 | Fix: also update file_path when moving a category check-in: ed44155002 user: bohwaz tags: trunk, stable | |
16:15 | Open text editor after creating a new text file, also resize the iframe correctly check-in: 2e84f0e59a user: bohwaz tags: trunk, stable | |
16:13 | Fix saving edit of wiki pages in documents check-in: cc108197d8 user: bohwaz tags: trunk, stable | |
Changes
Modified src/templates/common/files/edit_code.tpl from [bf7571f93a] to [7057de99c4].
︙ | ︙ | |||
8 9 10 11 12 13 14 | <p class="submit"> {csrf_field key=$csrf_key} {button type="submit" name="save" label="Enregistrer" shape="right" class="main"} </p> </form> | | > > | 8 9 10 11 12 13 14 15 16 17 18 19 | <p class="submit"> {csrf_field key=$csrf_key} {button type="submit" name="save" label="Enregistrer" shape="right" class="main"} </p> </form> <script type="text/javascript" src="{$admin_url}static/scripts/code_editor.js?{$version_hash}"></script> <script type="text/javascript"> {include file="admin/_foot.tpl"} |
Modified src/www/admin/common/files/edit.php from [5a8ed5bb74] to [fdf8c053f5].
︙ | ︙ | |||
21 22 23 24 25 26 27 | $form->runIf('content', function () use ($file) { $file->setContent(f('content')); if (qg('js') !== null) { die('{"success":true}'); } | < | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | $form->runIf('content', function () use ($file) { $file->setContent(f('content')); if (qg('js') !== null) { die('{"success":true}'); } }, $csrf_key, Utils::getSelfURI()); $tpl->assign('file', $file); if (!$editor) { $tpl->assign('file', $file); $tpl->display('common/file_upload.tpl'); } else { $content = $file->fetch(); $tpl->assign(compact('csrf_key', 'content')); $tpl->display(sprintf('common/files/edit_%s.tpl', $editor)); } |
Modified src/www/admin/docs/new_file.php from [b548528de7] to [4505ff7d98].
︙ | ︙ | |||
22 23 24 25 26 27 28 | $name .= '.skriv'; } File::validatePath($parent . '/' . $name); $name = File::filterName($name); $file = File::createAndStore($parent, $name, null, ''); | > > | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | $name .= '.skriv'; } File::validatePath($parent . '/' . $name); $name = File::filterName($name); $file = File::createAndStore($parent, $name, null, ''); Utils::redirect('!common/files/edit.php?p=' . rawurlencode($file->path)); }, $csrf_key); $tpl->assign(compact('csrf_key')); $tpl->display('docs/new_file.tpl'); |
Modified src/www/admin/static/scripts/code_editor.js from [81fbe437c7] to [9902ec3c83].
︙ | ︙ | |||
85 86 87 88 89 90 91 92 93 | return false; }; } else { appendButton('fullscreen', 'Plein écran', code.toggleFullscreen); } }); }()); | > > | 85 86 87 88 89 90 91 92 93 94 95 | return false; }; } else { appendButton('fullscreen', 'Plein écran', code.toggleFullscreen); } g.setParentDialogHeight('90%'); }); }()); |
Modified src/www/admin/static/scripts/global.js from [8f3eacf771] to [258cac2531].
︙ | ︙ | |||
160 161 162 163 164 165 166 167 168 169 170 | var iframe = document.createElement('iframe'); iframe.src = url; iframe.name = 'dialog'; iframe.id = 'frameDialog'; iframe.frameborder = '0'; iframe.scrolling = 'yes'; iframe.width = iframe.height = 0; iframe.addEventListener('load', () => { iframe.contentWindow.onkeyup = (e) => { if (e.key == 'Escape') g.closeDialog(); }; // We need to wait a bit for the height to be correct, not sure why window.setTimeout(() => { | > | > > > > > > > > > | > > > > > > | | | | | | | > | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | var iframe = document.createElement('iframe'); iframe.src = url; iframe.name = 'dialog'; iframe.id = 'frameDialog'; iframe.frameborder = '0'; iframe.scrolling = 'yes'; iframe.width = iframe.height = 0; iframe.setAttribute('data-height', height); iframe.addEventListener('load', () => { iframe.contentWindow.onkeyup = (e) => { if (e.key == 'Escape') g.closeDialog(); }; // We need to wait a bit for the height to be correct, not sure why window.setTimeout(() => { iframe.style.height = iframe.dataset.height == 'auto' ? iframe.contentWindow.document.body.offsetHeight + 'px' : iframe.dataset.height; }, 100); }); g.openDialog(iframe, callback); return iframe; }; g.reloadParentDialog = () => { if (!window.parent.g.dialog) { return; } location.href = window.parent.g.dialog.querySelector('iframe').getAttribute('src'); }; g.setParentDialogHeight = (height) => { if (!window.parent.g.dialog) { return; } window.parent.g.dialog.querySelector('iframe').setAttribute('data-height', height); g.resizeParentDialog(height); }; g.resizeParentDialog = (forced_height) => { if (!window.parent.g.dialog) { return; } let height; if (forced_height) { height = forced_height; } else { let body_height = document.body.offsetHeight; let parent_height = window.parent.innerHeight; if (body_height > parent_height * 0.9) { height = '90%'; } else { height = body_height + 'px'; } } window.parent.g.dialog.childNodes[1].style.height = height; }; g.closeDialog = function () { if (null === g.dialog) { |
︙ | ︙ |