MDL-47494 ddimageortext: NOBUG hardened code that waits for images loaded before going on.

This commit is contained in:
Jamie Pratt
2011-09-09 13:03:11 +07:00
parent a3be6d9da1
commit 97bb83259f
3 changed files with 11 additions and 5 deletions
@@ -31,8 +31,8 @@ $string['correctansweris'] = 'The correct answer is: {$a}';
$string['ddimagetoimage'] = 'Drag and drop: images onto image';
$string['ddimagetoimage_help'] = 'Select a background image file, select draggable images and define the drop zones on the background image to which they must be dragged.';
$string['ddimagetoimagesummary'] = 'Images are dragged and dropped into drop zones on a background image.';
$string['draggableimage'] = 'Draggable image';
$string['draggableimageheader'] = 'Draggable image {$a}';
$string['draggableimage'] = 'Draggable item';
$string['draggableimageheader'] = 'Draggable item {$a}';
$string['dropzone'] = 'Drop zone {$a}';
$string['dropzoneheader'] = 'Drop zones';
$string['editingddimagetoimage'] = 'Editing drag and drop: images onto image';
+6 -1
View File
@@ -9,7 +9,11 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
Y.extend(DDIMAGETOIMAGE_DD, Y.Base, {
doc : null,
polltimer : null,
afterimageloaddone : false,
poll_for_image_load : function (e, waitforimageconstrain, pause, doafterwords) {
if (this.afterimageloaddone) {
return;
}
var bgdone = this.doc.bg_img().get('complete');
if (waitforimageconstrain) {
bgdone = bgdone && this.doc.bg_img().hasClass('constrained');
@@ -26,7 +30,7 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
}
return !done;
});
if (alldragsloaded && alldragsloaded) {
if (bgdone && alldragsloaded) {
if (this.polltimer !== null) {
this.polltimer.cancel();
this.polltimer = null;
@@ -38,6 +42,7 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
} else {
doafterwords.call(this);
}
this.afterimageloaddone = true;
} else if (this.polltimer === null) {
var pollarguments = [null, waitforimageconstrain, pause, doafterwords];
this.polltimer =
+3 -2
View File
@@ -14,8 +14,8 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
Y.one(this.get('topnode')).append('<div class="ddarea"><div class="droparea"></div>'+
'<div class="dragitems"></div>'+
'<div class="dropzones"></div></div>');
//this.doc = this.doc_structure(this);
//this.draw_dd_area();
this.doc = this.doc_structure(this);
this.draw_dd_area();
},
draw_dd_area : function() {
@@ -34,6 +34,7 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
e.drag.get('node').setData('gooddrop', true);
});
this.afterimageloaddone = false;
this.doc.bg_img().on('load', this.constrain_image_size, this, 'bgimage');
this.doc.drag_image_homes()
.on('load', this.constrain_image_size, this, 'dragimage');