mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-69104 Questions: Drag and drop question family don't work with iOS
- Drag and Drop marker question type - Drag and Drop onto image question type - Drag and Drop into text question type
This commit is contained in:
parent
c11e2517a7
commit
5fa8f1c811
9 changed files with 58 additions and 41 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -336,6 +336,7 @@ define(['jquery', 'core/dragdrop', 'core/key_codes'], function($, dragDrop, keys
|
||||||
cloneDrag.removeClass('beingdragged');
|
cloneDrag.removeClass('beingdragged');
|
||||||
cloneDrag.removeAttr('tabindex');
|
cloneDrag.removeAttr('tabindex');
|
||||||
hiddenDrag.after(cloneDrag);
|
hiddenDrag.after(cloneDrag);
|
||||||
|
questionManager.addEventHandlersToDrag(cloneDrag);
|
||||||
drag.offset(cloneDrag.offset());
|
drag.offset(cloneDrag.offset());
|
||||||
} else {
|
} else {
|
||||||
hiddenDrag.addClass('active');
|
hiddenDrag.addClass('active');
|
||||||
|
@ -529,6 +530,7 @@ define(['jquery', 'core/dragdrop', 'core/key_codes'], function($, dragDrop, keys
|
||||||
cloneDrag.removeClass('beingdragged');
|
cloneDrag.removeClass('beingdragged');
|
||||||
cloneDrag.removeAttr('tabindex');
|
cloneDrag.removeAttr('tabindex');
|
||||||
hiddenDrag.after(cloneDrag);
|
hiddenDrag.after(cloneDrag);
|
||||||
|
questionManager.addEventHandlersToDrag(cloneDrag);
|
||||||
nextDrag.offset(cloneDrag.offset());
|
nextDrag.offset(cloneDrag.offset());
|
||||||
} else {
|
} else {
|
||||||
hiddenDrag.addClass('active');
|
hiddenDrag.addClass('active');
|
||||||
|
@ -623,7 +625,7 @@ define(['jquery', 'core/dragdrop', 'core/key_codes'], function($, dragDrop, keys
|
||||||
{
|
{
|
||||||
duration: 'fast',
|
duration: 'fast',
|
||||||
done: function() {
|
done: function() {
|
||||||
$('body').trigger('dragmoved', [drag, target, thisQ]);
|
$('body').trigger('qtype_ddimageortext-dragmoved', [drag, target, thisQ]);
|
||||||
M.util.js_complete('qtype_ddimageortext-animate-' + thisQ.containerId);
|
M.util.js_complete('qtype_ddimageortext-animate-' + thisQ.containerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -962,17 +964,16 @@ define(['jquery', 'core/dragdrop', 'core/key_codes'], function($, dragDrop, keys
|
||||||
* Set up the event handlers that make this question type work. (Done once per page.)
|
* Set up the event handlers that make this question type work. (Done once per page.)
|
||||||
*/
|
*/
|
||||||
setupEventHandlers: function() {
|
setupEventHandlers: function() {
|
||||||
|
// We do not use the body event here to prevent the other event on Mobile device, such as scroll event.
|
||||||
|
questionManager.addEventHandlersToDrag($('.que.ddimageortext:not(.qtype_ddimageortext-readonly) .draghome'));
|
||||||
$('body')
|
$('body')
|
||||||
.on('mousedown touchstart',
|
|
||||||
'.que.ddimageortext:not(.qtype_ddimageortext-readonly) .draghome',
|
|
||||||
questionManager.handleDragStart)
|
|
||||||
.on('keydown',
|
.on('keydown',
|
||||||
'.que.ddimageortext:not(.qtype_ddimageortext-readonly) .dropzones .dropzone',
|
'.que.ddimageortext:not(.qtype_ddimageortext-readonly) .dropzones .dropzone',
|
||||||
questionManager.handleKeyPress)
|
questionManager.handleKeyPress)
|
||||||
.on('keydown',
|
.on('keydown',
|
||||||
'.que.ddimageortext:not(.qtype_ddimageortext-readonly) .draghome.placed:not(.beingdragged)',
|
'.que.ddimageortext:not(.qtype_ddimageortext-readonly) .draghome.placed:not(.beingdragged)',
|
||||||
questionManager.handleKeyPress)
|
questionManager.handleKeyPress)
|
||||||
.on('dragmoved', questionManager.handleDragMoved);
|
.on('qtype_ddimageortext-dragmoved', questionManager.handleDragMoved);
|
||||||
$(window).on('resize', function() {
|
$(window).on('resize', function() {
|
||||||
questionManager.handleWindowResize(false);
|
questionManager.handleWindowResize(false);
|
||||||
});
|
});
|
||||||
|
@ -989,6 +990,15 @@ define(['jquery', 'core/dragdrop', 'core/key_codes'], function($, dragDrop, keys
|
||||||
}, 100);
|
}, 100);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binding the drag/touch event again for newly created element.
|
||||||
|
*
|
||||||
|
* @param {jQuery} element Element to bind the event
|
||||||
|
*/
|
||||||
|
addEventHandlersToDrag: function(element) {
|
||||||
|
element.on('mousedown touchstart', questionManager.handleDragStart);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle mouse down / touch start events on drags.
|
* Handle mouse down / touch start events on drags.
|
||||||
* @param {Event} e the DOM event.
|
* @param {Event} e the DOM event.
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -568,6 +568,7 @@ define(['jquery', 'core/dragdrop', 'qtype_ddmarker/shapes', 'core/key_codes'], f
|
||||||
this.getDragClone(drag)
|
this.getDragClone(drag)
|
||||||
.removeClass('active')
|
.removeClass('active')
|
||||||
.after(dragclone);
|
.after(dragclone);
|
||||||
|
questionManager.addEventHandlersToMarker(dragclone);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -678,31 +679,9 @@ define(['jquery', 'core/dragdrop', 'qtype_ddmarker/shapes', 'core/key_codes'], f
|
||||||
* Set up the event handlers that make this question type work. (Done once per page.)
|
* Set up the event handlers that make this question type work. (Done once per page.)
|
||||||
*/
|
*/
|
||||||
setupEventHandlers: function() {
|
setupEventHandlers: function() {
|
||||||
$('body')
|
// We do not use the body event here to prevent the other event on Mobile device, such as scroll event.
|
||||||
.on('mousedown touchstart',
|
questionManager.addEventHandlersToMarker($('.que.ddmarker:not(.qtype_ddmarker-readonly) div.draghomes .marker'));
|
||||||
'.que.ddmarker:not(.qtype_ddmarker-readonly) div.draghomes .marker', questionManager.handleDragStart)
|
questionManager.addEventHandlersToMarker($('.que.ddmarker:not(.qtype_ddmarker-readonly) div.droparea .marker'));
|
||||||
.on('mousedown touchstart',
|
|
||||||
'.que.ddmarker:not(.qtype_ddmarker-readonly) div.droparea .marker', questionManager.handleDragStart)
|
|
||||||
.on('keydown keypress',
|
|
||||||
'.que.ddmarker:not(.qtype_ddmarker-readonly) div.draghomes .marker', questionManager.handleKeyPress)
|
|
||||||
.on('keydown keypress',
|
|
||||||
'.que.ddmarker:not(.qtype_ddmarker-readonly) div.droparea .marker', questionManager.handleKeyPress)
|
|
||||||
.on('focusin',
|
|
||||||
'.que.ddmarker:not(.qtype_ddmarker-readonly) div.draghomes .marker', function(e) {
|
|
||||||
questionManager.handleKeyboardFocus(e, true);
|
|
||||||
})
|
|
||||||
.on('focusin',
|
|
||||||
'.que.ddmarker:not(.qtype_ddmarker-readonly) div.droparea .marker', function(e) {
|
|
||||||
questionManager.handleKeyboardFocus(e, true);
|
|
||||||
})
|
|
||||||
.on('focusout',
|
|
||||||
'.que.ddmarker:not(.qtype_ddmarker-readonly) div.draghomes .marker', function(e) {
|
|
||||||
questionManager.handleKeyboardFocus(e, false);
|
|
||||||
})
|
|
||||||
.on('focusout',
|
|
||||||
'.que.ddmarker:not(.qtype_ddmarker-readonly) div.droparea .marker', function(e) {
|
|
||||||
questionManager.handleKeyboardFocus(e, false);
|
|
||||||
});
|
|
||||||
$(window).on('resize', function() {
|
$(window).on('resize', function() {
|
||||||
questionManager.handleWindowResize(false);
|
questionManager.handleWindowResize(false);
|
||||||
});
|
});
|
||||||
|
@ -719,6 +698,23 @@ define(['jquery', 'core/dragdrop', 'qtype_ddmarker/shapes', 'core/key_codes'], f
|
||||||
}, 100);
|
}, 100);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binding the event again for newly created element.
|
||||||
|
*
|
||||||
|
* @param {jQuery} element Element to bind the event
|
||||||
|
*/
|
||||||
|
addEventHandlersToMarker: function(element) {
|
||||||
|
element
|
||||||
|
.on('mousedown touchstart', questionManager.handleDragStart)
|
||||||
|
.on('keydown keypress', questionManager.handleKeyPress)
|
||||||
|
.focusin(function(e) {
|
||||||
|
questionManager.handleKeyboardFocus(e, true);
|
||||||
|
})
|
||||||
|
.focusout(function(e) {
|
||||||
|
questionManager.handleKeyboardFocus(e, false);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle mouse down / touch start events on markers.
|
* Handle mouse down / touch start events on markers.
|
||||||
* @param {Event} e the DOM event.
|
* @param {Event} e the DOM event.
|
||||||
|
|
2
question/type/ddwtos/amd/build/ddwtos.min.js
vendored
2
question/type/ddwtos/amd/build/ddwtos.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -212,6 +212,7 @@ define(['jquery', 'core/dragdrop', 'core/key_codes'], function($, dragDrop, keys
|
||||||
var cloneDrag = drag.clone();
|
var cloneDrag = drag.clone();
|
||||||
cloneDrag.removeClass('beingdragged');
|
cloneDrag.removeClass('beingdragged');
|
||||||
hiddenDrag.after(cloneDrag);
|
hiddenDrag.after(cloneDrag);
|
||||||
|
questionManager.addEventHandlersToDrag(cloneDrag);
|
||||||
drag.offset(cloneDrag.offset());
|
drag.offset(cloneDrag.offset());
|
||||||
} else {
|
} else {
|
||||||
hiddenDrag.addClass('active');
|
hiddenDrag.addClass('active');
|
||||||
|
@ -404,6 +405,7 @@ define(['jquery', 'core/dragdrop', 'core/key_codes'], function($, dragDrop, keys
|
||||||
cloneDrag.removeClass('beingdragged');
|
cloneDrag.removeClass('beingdragged');
|
||||||
cloneDrag.removeAttr('tabindex');
|
cloneDrag.removeAttr('tabindex');
|
||||||
hiddenDrag.after(cloneDrag);
|
hiddenDrag.after(cloneDrag);
|
||||||
|
questionManager.addEventHandlersToDrag(cloneDrag);
|
||||||
nextDrag.offset(cloneDrag.offset());
|
nextDrag.offset(cloneDrag.offset());
|
||||||
} else {
|
} else {
|
||||||
hiddenDrag.addClass('active');
|
hiddenDrag.addClass('active');
|
||||||
|
@ -498,7 +500,7 @@ define(['jquery', 'core/dragdrop', 'core/key_codes'], function($, dragDrop, keys
|
||||||
{
|
{
|
||||||
duration: 'fast',
|
duration: 'fast',
|
||||||
done: function() {
|
done: function() {
|
||||||
$('body').trigger('dragmoved', [drag, target, thisQ]);
|
$('body').trigger('qtype_ddwtos-dragmoved', [drag, target, thisQ]);
|
||||||
M.util.js_complete('qtype_ddwtos-animate-' + thisQ.containerId);
|
M.util.js_complete('qtype_ddwtos-animate-' + thisQ.containerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -738,16 +740,25 @@ define(['jquery', 'core/dragdrop', 'core/key_codes'], function($, dragDrop, keys
|
||||||
* Set up the event handlers that make this question type work. (Done once per page.)
|
* Set up the event handlers that make this question type work. (Done once per page.)
|
||||||
*/
|
*/
|
||||||
setupEventHandlers: function() {
|
setupEventHandlers: function() {
|
||||||
$('body').on('mousedown touchstart',
|
// We do not use the body event here to prevent the other event on Mobile device, such as scroll event.
|
||||||
'.que.ddwtos:not(.qtype_ddwtos-readonly) span.draghome',
|
questionManager.addEventHandlersToDrag($('.que.ddwtos:not(.qtype_ddwtos-readonly) span.draghome'));
|
||||||
questionManager.handleDragStart)
|
$('body')
|
||||||
.on('keydown',
|
.on('keydown',
|
||||||
'.que.ddwtos:not(.qtype_ddwtos-readonly) span.drop',
|
'.que.ddwtos:not(.qtype_ddwtos-readonly) span.drop',
|
||||||
questionManager.handleKeyPress)
|
questionManager.handleKeyPress)
|
||||||
.on('keydown',
|
.on('keydown',
|
||||||
'.que.ddwtos:not(.qtype_ddwtos-readonly) span.draghome.placed:not(.beingdragged)',
|
'.que.ddwtos:not(.qtype_ddwtos-readonly) span.draghome.placed:not(.beingdragged)',
|
||||||
questionManager.handleKeyPress)
|
questionManager.handleKeyPress)
|
||||||
.on('dragmoved', questionManager.handleDragMoved);
|
.on('qtype_ddwtos-dragmoved', questionManager.handleDragMoved);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binding the drag/touch event again for newly created element.
|
||||||
|
*
|
||||||
|
* @param {jQuery} element Element to bind the event
|
||||||
|
*/
|
||||||
|
addEventHandlersToDrag: function(element) {
|
||||||
|
element.on('mousedown touchstart', questionManager.handleDragStart);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue