*/
eventHandlersInitialised: false,
+ /**
+ * {Object} ensures that the drag event handlers are only initialised once per question,
+ * indexed by containerId (id on the .que div).
+ */
+ dragEventHandlersInitialised: {},
+
/**
* {boolean} is printing or not.
*/
questionManager.setupEventHandlers();
questionManager.eventHandlersInitialised = true;
}
+ if (!questionManager.dragEventHandlersInitialised.hasOwnProperty(containerId)) {
+ questionManager.dragEventHandlersInitialised[containerId] = true;
+ // We do not use the body event here to prevent the other event on Mobile device, such as scroll event.
+ var questionContainer = document.getElementById(containerId);
+ if (questionContainer.classList.contains('ddimageortext') &&
+ !questionContainer.classList.contains('qtype_ddimageortext-readonly')) {
+ // TODO: Convert all the jQuery selectors and events to native Javascript.
+ questionManager.addEventHandlersToDrag($(questionContainer).find('.draghome'));
+ }
+ }
},
/**
* Set up the event handlers that make this question type work. (Done once per page.)
*/
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')
.on('keydown',
'.que.ddimageortext:not(.qtype_ddimageortext-readonly) .dropzones .dropzone',