[LON-CAPA-cvs] cvs: modules /damieng/graphical_editor/loncapa_daxe/web loncapa_daxe.dart
raeburn
raeburn at source.lon-capa.org
Sat Mar 23 19:28:23 EDT 2024
raeburn Sat Mar 23 23:28:23 2024 EDT
Modified files:
/modules/damieng/graphical_editor/loncapa_daxe/web
loncapa_daxe.dart
Log:
- Support "Save and Edit" and "Save and View" buttons in parent window.
Index: modules/damieng/graphical_editor/loncapa_daxe/web/loncapa_daxe.dart
diff -u modules/damieng/graphical_editor/loncapa_daxe/web/loncapa_daxe.dart:1.53 modules/damieng/graphical_editor/loncapa_daxe/web/loncapa_daxe.dart:1.54
--- modules/damieng/graphical_editor/loncapa_daxe/web/loncapa_daxe.dart:1.53 Wed Apr 5 20:26:12 2017
+++ modules/damieng/graphical_editor/loncapa_daxe/web/loncapa_daxe.dart Sat Mar 23 23:28:23 2024
@@ -441,6 +441,29 @@
print(msg);
h.document.body.appendText(msg);
});
+
+/**
+ * Supports buttons in parent window used to save a LON_CAPA problem file in iframe,
+ * followed either by exiting Daxe editor (with display of the problem) or by
+ * continued editing in Daxe editor (with update of problem in preview panel).
+ */
+ String savelcdoc(String next) {
+ doc.save().then((_) {
+ if (next == 'exit') {
+ String msgtarget = h.window.location.protocol+'//'+h.window.location.hostname;
+ h.window.parent.postMessage(doc.filePath,msgtarget);
+ } else {
+ h.IFrameElement previewIFrame = h.document.getElementById('preview_iframe');
+ if (previewIFrame != null) {
+ h.FormElement form = h.document.getElementById('preview_form');
+ form.submit();
+ }
+ }
+ }, onError: (DaxeException ex) {
+ h.window.alert(Strings.get('save.error') + ': ' + ex.message);
+ });
+ }
+ js.context['savelcdoc'] = savelcdoc;
}
More information about the LON-CAPA-cvs
mailing list