MDL-47494 ddimageortext: NOBUG hardened code that waits for images loaded before going on.
This commit is contained in:
@@ -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
@@ -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
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user