Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix (hopefully) annoying popups, and language selector in Nottingham
template

- Prevent the onbeforeunload dialog (hopefully)
- The language attribute was added by the Flash wizard. Add similar
  functionality for the HTML5 editor
  • Loading branch information
torinfo committed Apr 24, 2015
1 parent 805f4d5 commit 9b86363
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
47 changes: 29 additions & 18 deletions editor/js/tree.js
Expand Up @@ -34,24 +34,19 @@ var EDITOR = (function ($, parent) {
do_buttons();
build(xml);

jQuery(window).bind('beforeunload', function (e)
{
//save my data
savepreview();
try{
bunload();
}
catch(err)
{
// ignore
}

e.returnValue = language.Alert.exitwizard.prompt;
return language.Alert.exitwizard.prompt;
//return false;
});
window.onbeforeunload = unloadFunction;
},

unloadFunction = function() {
//save my data
savepreviewasync(false);
bunload();

//e.returnValue = language.Alert.exitwizard.prompt;
//return language.Alert.exitwizard.prompt;
//return false;
return null;
}
// Add the buttons
do_buttons = function () {
var insert_page = function() {
Expand Down Expand Up @@ -251,7 +246,12 @@ var EDITOR = (function ($, parent) {
});
},

savepreview = function () {
savepreview = function()
{
savepreviewasync(true);
},

savepreviewasync = function (async) {
var json = build_json("treeroot");
var ajax_call = $.ajax({
url: "editor/upload.php",
Expand All @@ -268,7 +268,9 @@ var EDITOR = (function ($, parent) {
// alert(status + ': ' + error);
//},
dataType: "json",
type: "POST"
type: "POST",
cache:false,
async:async
}
).done(function() {
$('#loader').hide();
Expand Down Expand Up @@ -627,6 +629,15 @@ var EDITOR = (function ($, parent) {
attribute_name = node_options['normal'][i].name;
attribute_value = toolbox.getAttributeValue(attributes, attribute_name, node_options, key);

// The language attribute deserves some special treatment
// If the attribute exists, but the value is an empty string, replace it withe the currently chosen language
if (attribute_name == 'language')
{
if (attribute_value.found && attribute_value.value=="")
{
attribute_value.value = language.$code;
}
}
if (attribute_value.found)
{
toolbox.displayParameter('#mainPanel .wizard', node_options['normal'], attribute_name, attribute_value.value, key);
Expand Down
2 changes: 1 addition & 1 deletion modules/xerte/templates/Nottingham/data.xml
@@ -1 +1 @@
<learningObject targetFolder="Nottingham" name="Learning Object Title" navigation="Linear" textSize="12" theme="default" displayMode="default" />
<learningObject targetFolder="Nottingham" name="Learning Object Title" language="" navigation="Linear" textSize="12" theme="default" displayMode="default" />

0 comments on commit 9b86363

Please sign in to comment.