From 416ffeed36ef6a0d5965fdaa7bd6dca1af19bdb6 Mon Sep 17 00:00:00 2001 From: Mathew May Date: Thu, 2 Nov 2023 09:32:53 +0800 Subject: [PATCH] MDL-79871 qtype_ordering: Remove shipped core libs Part of: MDL-79863 --- .../type/ordering/amd/build/autoscroll.min.js | 21 -- .../ordering/amd/build/autoscroll.min.js.map | 1 - .../ordering/amd/build/drag_reorder.min.js | 2 +- .../amd/build/drag_reorder.min.js.map | 2 +- .../type/ordering/amd/build/dragdrop.min.js | 20 - .../ordering/amd/build/dragdrop.min.js.map | 1 - .../type/ordering/amd/build/key_codes.min.js | 16 - .../ordering/amd/build/key_codes.min.js.map | 1 - question/type/ordering/amd/src/autoscroll.js | 212 ----------- .../type/ordering/amd/src/drag_reorder.js | 4 +- question/type/ordering/amd/src/dragdrop.js | 343 ------------------ question/type/ordering/amd/src/key_codes.js | 47 --- 12 files changed, 4 insertions(+), 666 deletions(-) delete mode 100644 question/type/ordering/amd/build/autoscroll.min.js delete mode 100644 question/type/ordering/amd/build/autoscroll.min.js.map delete mode 100644 question/type/ordering/amd/build/dragdrop.min.js delete mode 100644 question/type/ordering/amd/build/dragdrop.min.js.map delete mode 100644 question/type/ordering/amd/build/key_codes.min.js delete mode 100644 question/type/ordering/amd/build/key_codes.min.js.map delete mode 100644 question/type/ordering/amd/src/autoscroll.js delete mode 100644 question/type/ordering/amd/src/dragdrop.js delete mode 100644 question/type/ordering/amd/src/key_codes.js diff --git a/question/type/ordering/amd/build/autoscroll.min.js b/question/type/ordering/amd/build/autoscroll.min.js deleted file mode 100644 index 9ee152f113d..00000000000 --- a/question/type/ordering/amd/build/autoscroll.min.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - * JavaScript to provide automatic scrolling, e.g. during a drag operation. - * - * This is a copy of a library that was added to Moodle core in Moodle 3.6, - * so we can support older Moodle versions. - * - * Note: this module is defined statically. It is a singleton. You - * can only have one use of it active at any time. However, since this - * is usually used in relation to drag-drop, and since you only ever - * drag one thing at a time, this is not a problem in practice. - * - * @module qtype_ordering/autoscroll - * @class autoscroll - * @package qtype_ordering - * @copyright 2016 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @since 3.6 - */ -define("qtype_ordering/autoscroll",["jquery"],(function($){var autoscroll={SCROLL_THRESHOLD:30,SCROLL_FREQUENCY:1e3/60,SCROLL_SPEED:.5,scrollingId:null,scrollAmount:0,callback:null,start:function(callback){$(window).on("mousemove",autoscroll.mouseMove),$(window).on("touchmove",autoscroll.touchMove),autoscroll.callback=callback},stop:function(){$(window).off("mousemove",autoscroll.mouseMove),$(window).off("touchmove",autoscroll.touchMove),null!==autoscroll.scrollingId&&autoscroll.stopScrolling()},touchMove:function(e){for(var i=0;i$(window).height()-autoscroll.SCROLL_THRESHOLD?autoscroll.scrollAmount=Math.min(clientY-($(window).height()-autoscroll.SCROLL_THRESHOLD),autoscroll.SCROLL_THRESHOLD):autoscroll.scrollAmount=0,autoscroll.scrollAmount&&null===autoscroll.scrollingId?autoscroll.startScrolling():autoscroll.scrollAmount||null===autoscroll.scrollingId||autoscroll.stopScrolling()},startScrolling:function(){var maxScroll=$(document).height()-$(window).height();autoscroll.scrollingId=window.setInterval((function(){var y=$(window).scrollTop(),offset=Math.round(autoscroll.scrollAmount*autoscroll.SCROLL_SPEED);if(y+offset<0&&(offset=-y),y+offset>maxScroll&&(offset=maxScroll-y),0!==offset){$(window).scrollTop(y+offset);var realOffset=$(window).scrollTop()-y;0!==realOffset&&autoscroll.callback&&autoscroll.callback(realOffset)}}),autoscroll.SCROLL_FREQUENCY)},stopScrolling:function(){window.clearInterval(autoscroll.scrollingId),autoscroll.scrollingId=null}};return{start:autoscroll.start,stop:autoscroll.stop}})); - -//# sourceMappingURL=autoscroll.min.js.map \ No newline at end of file diff --git a/question/type/ordering/amd/build/autoscroll.min.js.map b/question/type/ordering/amd/build/autoscroll.min.js.map deleted file mode 100644 index bf97197e3b7..00000000000 --- a/question/type/ordering/amd/build/autoscroll.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"autoscroll.min.js","sources":["../src/autoscroll.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/*\n * JavaScript to provide automatic scrolling, e.g. during a drag operation.\n *\n * This is a copy of a library that was added to Moodle core in Moodle 3.6,\n * so we can support older Moodle versions.\n *\n * Note: this module is defined statically. It is a singleton. You\n * can only have one use of it active at any time. However, since this\n * is usually used in relation to drag-drop, and since you only ever\n * drag one thing at a time, this is not a problem in practice.\n *\n * @module qtype_ordering/autoscroll\n * @class autoscroll\n * @package qtype_ordering\n * @copyright 2016 The Open University\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 3.6\n */\ndefine(['jquery'], function($) {\n /**\n * @alias module:qtype_ordering/autoscroll\n */\n var autoscroll = {\n /**\n * Size of area near edge of screen that triggers scrolling.\n * @private\n */\n SCROLL_THRESHOLD: 30,\n\n /**\n * How frequently to scroll window.\n * @private\n */\n SCROLL_FREQUENCY: 1000 / 60,\n\n /**\n * How many pixels to scroll per unit (1 = max scroll 30).\n * @private\n */\n SCROLL_SPEED: 0.5,\n\n /**\n * Set if currently scrolling up/down.\n * @private\n */\n scrollingId: null,\n\n /**\n * Speed we are supposed to scroll (range 1 to SCROLL_THRESHOLD).\n * @private\n */\n scrollAmount: 0,\n\n /**\n * Optional callback called when it scrolls\n * @private\n */\n callback: null,\n\n /**\n * Starts automatically scrolling if user moves near edge of window.\n * This should be called in response to mouse down or touch start.\n *\n * @public\n * @param {Function} callback Optional callback that is called every time it scrolls\n */\n start: function(callback) {\n $(window).on('mousemove', autoscroll.mouseMove);\n $(window).on('touchmove', autoscroll.touchMove);\n autoscroll.callback = callback;\n },\n\n /**\n * Stops automatically scrolling. This should be called in response to mouse up or touch end.\n *\n * @public\n */\n stop: function() {\n $(window).off('mousemove', autoscroll.mouseMove);\n $(window).off('touchmove', autoscroll.touchMove);\n if (autoscroll.scrollingId !== null) {\n autoscroll.stopScrolling();\n }\n },\n\n /**\n * Event handler for touch move.\n *\n * @private\n * @param {Object} e Event\n */\n touchMove: function(e) {\n for (var i = 0; i < e.changedTouches.length; i++) {\n autoscroll.handleMove(e.changedTouches[i].clientX, e.changedTouches[i].clientY);\n }\n },\n\n /**\n * Event handler for mouse move.\n *\n * @private\n * @param {Object} e Event\n */\n mouseMove: function(e) {\n autoscroll.handleMove(e.clientX, e.clientY);\n },\n\n /**\n * Handles user moving.\n *\n * @private\n * @param {number} clientX X\n * @param {number} clientY Y\n */\n handleMove: function(clientX, clientY) {\n // If near the bottom or top, start auto-scrolling.\n if (clientY < autoscroll.SCROLL_THRESHOLD) {\n autoscroll.scrollAmount = -Math.min(autoscroll.SCROLL_THRESHOLD - clientY, autoscroll.SCROLL_THRESHOLD);\n } else if (clientY > $(window).height() - autoscroll.SCROLL_THRESHOLD) {\n autoscroll.scrollAmount = Math.min(clientY - ($(window).height() - autoscroll.SCROLL_THRESHOLD),\n autoscroll.SCROLL_THRESHOLD);\n } else {\n autoscroll.scrollAmount = 0;\n }\n if (autoscroll.scrollAmount && autoscroll.scrollingId === null) {\n autoscroll.startScrolling();\n } else if (!autoscroll.scrollAmount && autoscroll.scrollingId !== null) {\n autoscroll.stopScrolling();\n }\n },\n\n /**\n * Starts automatic scrolling.\n *\n * @private\n */\n startScrolling: function() {\n var maxScroll = $(document).height() - $(window).height();\n autoscroll.scrollingId = window.setInterval(function() {\n // Work out how much to scroll.\n var y = $(window).scrollTop();\n var offset = Math.round(autoscroll.scrollAmount * autoscroll.SCROLL_SPEED);\n if (y + offset < 0) {\n offset = -y;\n }\n if (y + offset > maxScroll) {\n offset = maxScroll - y;\n }\n if (offset === 0) {\n return;\n }\n\n // Scroll.\n $(window).scrollTop(y + offset);\n var realOffset = $(window).scrollTop() - y;\n if (realOffset === 0) {\n return;\n }\n\n // Inform callback\n if (autoscroll.callback) {\n autoscroll.callback(realOffset);\n }\n\n }, autoscroll.SCROLL_FREQUENCY);\n },\n\n /**\n * Stops the automatic scrolling.\n *\n * @private\n */\n stopScrolling: function() {\n window.clearInterval(autoscroll.scrollingId);\n autoscroll.scrollingId = null;\n }\n };\n\n return {\n /**\n * Starts automatic scrolling if user moves near edge of window.\n * This should be called in response to mouse down or touch start.\n *\n * @public\n * @param {Function} callback Optional callback that is called every time it scrolls\n */\n start: autoscroll.start,\n\n /**\n * Stops automatic scrolling. This should be called in response to mouse up or touch end.\n *\n * @public\n */\n stop: autoscroll.stop\n };\n\n});\n"],"names":["define","$","autoscroll","SCROLL_THRESHOLD","SCROLL_FREQUENCY","SCROLL_SPEED","scrollingId","scrollAmount","callback","start","window","on","mouseMove","touchMove","stop","off","stopScrolling","e","i","changedTouches","length","handleMove","clientX","clientY","Math","min","height","startScrolling","maxScroll","document","setInterval","y","scrollTop","offset","round","realOffset","clearInterval"],"mappings":";;;;;;;;;;;;;;;;;;AAiCAA,mCAAO,CAAC,WAAW,SAASC,OAIpBC,WAAa,CAKbC,iBAAkB,GAMlBC,iBAAkB,IAAO,GAMzBC,aAAc,GAMdC,YAAa,KAMbC,aAAc,EAMdC,SAAU,KASVC,MAAO,SAASD,UACZP,EAAES,QAAQC,GAAG,YAAaT,WAAWU,WACrCX,EAAES,QAAQC,GAAG,YAAaT,WAAWW,WACrCX,WAAWM,SAAWA,UAQ1BM,KAAM,WACFb,EAAES,QAAQK,IAAI,YAAab,WAAWU,WACtCX,EAAES,QAAQK,IAAI,YAAab,WAAWW,WACP,OAA3BX,WAAWI,aACXJ,WAAWc,iBAUnBH,UAAW,SAASI,OACX,IAAIC,EAAI,EAAGA,EAAID,EAAEE,eAAeC,OAAQF,IACzChB,WAAWmB,WAAWJ,EAAEE,eAAeD,GAAGI,QAASL,EAAEE,eAAeD,GAAGK,UAU/EX,UAAW,SAASK,GAChBf,WAAWmB,WAAWJ,EAAEK,QAASL,EAAEM,UAUvCF,WAAY,SAASC,QAASC,SAEtBA,QAAUrB,WAAWC,iBACrBD,WAAWK,cAAgBiB,KAAKC,IAAIvB,WAAWC,iBAAmBoB,QAASrB,WAAWC,kBAC/EoB,QAAUtB,EAAES,QAAQgB,SAAWxB,WAAWC,iBACjDD,WAAWK,aAAeiB,KAAKC,IAAIF,SAAWtB,EAAES,QAAQgB,SAAWxB,WAAWC,kBAC1ED,WAAWC,kBAEfD,WAAWK,aAAe,EAE1BL,WAAWK,cAA2C,OAA3BL,WAAWI,YACtCJ,WAAWyB,iBACHzB,WAAWK,cAA2C,OAA3BL,WAAWI,aAC9CJ,WAAWc,iBASnBW,eAAgB,eACRC,UAAY3B,EAAE4B,UAAUH,SAAWzB,EAAES,QAAQgB,SACjDxB,WAAWI,YAAcI,OAAOoB,aAAY,eAEpCC,EAAI9B,EAAES,QAAQsB,YACdC,OAAST,KAAKU,MAAMhC,WAAWK,aAAeL,WAAWG,iBACzD0B,EAAIE,OAAS,IACbA,QAAUF,GAEVA,EAAIE,OAASL,YACbK,OAASL,UAAYG,GAEV,IAAXE,QAKJhC,EAAES,QAAQsB,UAAUD,EAAIE,YACpBE,WAAalC,EAAES,QAAQsB,YAAcD,EACtB,IAAfI,YAKAjC,WAAWM,UACXN,WAAWM,SAAS2B,eAGzBjC,WAAWE,mBAQlBY,cAAe,WACXN,OAAO0B,cAAclC,WAAWI,aAChCJ,WAAWI,YAAc,aAI1B,CAQHG,MAAOP,WAAWO,MAOlBK,KAAMZ,WAAWY"} \ No newline at end of file diff --git a/question/type/ordering/amd/build/drag_reorder.min.js b/question/type/ordering/amd/build/drag_reorder.min.js index e31dcac97a8..2f7e030446f 100644 --- a/question/type/ordering/amd/build/drag_reorder.min.js +++ b/question/type/ordering/amd/build/drag_reorder.min.js @@ -8,6 +8,6 @@ * @copyright 2018 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -define("qtype_ordering/drag_reorder",["jquery",require.specified("core/dragdrop")?"core/dragdrop":"qtype_ordering/dragdrop",require.specified("core/key_codes")?"core/key_codes":"qtype_ordering/key_codes"],(function($,drag,keys){return function(config){var outer,inner,combined,dragStart=null,originalOrder=null,itemDragging=null,itemMoving=null,proxy=null,orderList=null,dragMove=function(){var list=itemDragging.closest(config.list),closestItem=null,closestDistance=null;if(list.find(config.item).each((function(index,element){var distance=distanceBetweenElements(element,proxy);(null===closestItem||distance.\n\n/*\n * Generic library to allow things in a vertical list to be re-ordered using drag and drop.\n *\n * To make a set of things draggable, create a new instance of this object passing the\n * necessary config, as explained in the comment on the constructor.\n *\n * @package qtype_ordering\n * @copyright 2018 The Open University\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * @module qtype_ordering/drag_reorder\n */\ndefine([\n 'jquery',\n require.specified('core/dragdrop') ? 'core/dragdrop' : 'qtype_ordering/dragdrop',\n require.specified('core/key_codes') ? 'core/key_codes' : 'qtype_ordering/key_codes'\n], function(\n $,\n drag,\n keys\n) {\n\n /**\n * Constructor.\n *\n * To make a list draggable, create a new instance of this object, passing the necessary config.\n * For example:\n * {\n * // Selector for the list (or lists) to be reordered.\n * list: 'ul.my-list',\n *\n * // Selector, relative to the list selector, for the items that can be moved.\n * item: '> li',\n *\n * // The user actually drags a proxy object, which is constructed from this string,\n * // and then added directly as a child of . The token %%ITEM_HTML%% is\n * // replaced with the innerHtml of the item being dragged. The token %%ITEM_CLASS_NAME%%\n * // is replaced with the class attribute of the item being dragged. Because of this,\n * // the styling of the contents of your list item needs to work for the proxy, as well as\n * // for items in place in the context of the list. Your CSS also needs to ensure\n * // that this proxy has position: absolute. You probably want other styles, like a\n * // drop shadow. Using class osep-itemmoving might be all you need to do.\n * proxyHtml: '
%%ITEM_HTML%%
,\n *\n * // While the proxy is being dragged, this class is added to the item being moved.\n * // You can probably use \"osep-itemmoving\" here.\n * itemMovingClass: \"osep-itemmoving\",\n *\n * // This is a callback which, when called with the DOM node for an item,\n * // returns the string that uniquely identifies each item.\n * // Therefore, the result of the drag action will be represented by the array\n * // obtained by calling this method on each item in the list in order.\n * idGetter: function(item) { return $(node).data('id'); },\n *\n * // This is a callback which, when called with the DOM node for an item,\n * // returns a string that is the name of the item.\n * nameGetter: function(item) { return $(node).text(); },\n *\n * // Function that will be called when a re-order starts (optional, can be not set).\n * // Useful if you need to save information about the initial state.\n * // This function should have two parameters. The first will be a\n * // jQuery object for the list that was reordered, the second will\n * // be the jQuery object for the item moved - which will not yet have been moved.\n * // Note, it is quite possible for reorderStart to be called with no\n * // subsequent call to reorderDone.\n * reorderStart: function($list, $item) { ... }\n *\n * // Function that will be called when a drag has finished, and the list\n * // has been reordered. This function should have three parameters. The first will be\n * // a jQuery object for the list that was reordered, the second will be the jQuery\n * // object for the item moved, and the third will be the new order, which is\n * // an array of ids obtained by calling idGetter on each item in the list in order.\n * // This callback will only be called in the new order is actually different from the old order.\n * reorderDone: function($list, $item, newOrder) { ... }\n *\n * // Function that is alwasy called when a re-order ends (optional, can be not set)\n * // whether or not the order has changed. Useful if you need to undo changes made\n * // in reorderStart, since reorderDone is only called if the new order is different\n * // from the original order.\n * reorderEnd: function($list, $item) { ... }\n * }\n *\n * There is a subtlety ( === hack?) that you can use. If you have items in your list that do not\n * have a drag handle, they they are considered to be placeholders in otherwise empty containers.\n * See how block_userlinks does it, if this seems like it might be useful. nameGetter should return\n * the container name for these items.\n *\n * @param {Object} config As above.\n */\n return function(config) {\n var dragStart = null, // Information about when and where the drag started.\n originalOrder = null, // Array of ids.\n itemDragging = null, // Item being moved by dragging (jQuery object).\n itemMoving = null, // Item being moved using the accessible modal (jQuery object).\n proxy = null, // Drag proxy (jQuery object).\n orderList = null; // Order list (jQuery object).\n\n var startDrag = function(event, details) {\n orderList = $(config.list);\n\n dragStart = {\n time: new Date().getTime(),\n x: details.x,\n y: details.y\n };\n\n itemDragging = $(event.currentTarget).closest(config.itemInPage);\n\n if (typeof config.reorderStart !== 'undefined') {\n config.reorderStart(itemDragging.closest(config.list), itemDragging);\n }\n\n originalOrder = getCurrentOrder();\n proxy = $(config.proxyHtml.replace('%%ITEM_HTML%%', itemDragging.html())\n .replace('%%ITEM_CLASS_NAME%%', itemDragging.attr('class'))\n .replace('%%LIST_CLASS_NAME%%', orderList.attr('class')));\n\n $(document.body).append(proxy);\n proxy.css('position', 'absolute');\n proxy.css(itemDragging.offset());\n proxy.width(itemDragging.outerWidth());\n proxy.height(itemDragging.outerHeight());\n itemDragging.addClass(config.itemMovingClass);\n updateProxy(itemDragging);\n\n // Start drag.\n drag.start(event, proxy, dragMove, dragEnd);\n\n };\n\n var dragMove = function() {\n var list = itemDragging.closest(config.list);\n var closestItem = null;\n var closestDistance = null;\n list.find(config.item).each(function(index, element) {\n var distance = distanceBetweenElements(element, proxy);\n if (closestItem === null || distance < closestDistance) {\n closestItem = $(element);\n closestDistance = distance;\n }\n });\n\n if (closestItem[0] === itemDragging[0]) {\n return;\n }\n var offsetValue = 0;\n // Set offset depending on if item is being dragged downwards/upwards.\n if (midY(proxy) < midY(closestItem)) {\n offsetValue = 20;\n window.console.log(\"For midY(proxy) < midY(closestItem) offset is: \" + offsetValue);\n } else {\n offsetValue = -20;\n window.console.log(\"For midY(proxy) < midY(closestItem) offset is: \" + offsetValue);\n }\n if (midY(proxy) + offsetValue < midY(closestItem)) {\n itemDragging.insertBefore(closestItem);\n } else {\n itemDragging.insertAfter(closestItem);\n }\n updateProxy(itemDragging);\n };\n\n /**\n * Update proxy's position.\n * @param {jQuery} itemDragging\n */\n var updateProxy = function(itemDragging) {\n var list = itemDragging.closest('ol, ul');\n var items = list.find('li');\n var count = items.length;\n for (var i = 0; i < count; ++i) {\n if (itemDragging[0] === items[i]) {\n proxy.find('li').attr('value', i + 1);\n break;\n }\n }\n };\n\n /**\n * It outer and inner are two CSS selectors, which may contain commas,\n * then combine them safely. So combineSelectors('a, b', 'c, d')\n * gives 'a c, a d, b c, b d'.\n * @param {Selector} outer\n * @param {Selector} inner\n * @returns {string}\n */\n var combineSelectors = function(outer, inner) {\n var combined = [];\n outer.split(',').forEach(function(firstSelector) {\n inner.split(',').forEach(function(secondSelector) {\n combined.push(firstSelector.trim() + ' ' + secondSelector.trim());\n });\n });\n return combined.join(', ');\n };\n\n var dragEnd = function(x, y) {\n if (typeof config.reorderEnd !== 'undefined') {\n config.reorderEnd(itemDragging.closest(config.list), itemDragging);\n }\n\n var newOrder = getCurrentOrder();\n if (!arrayEquals(originalOrder, newOrder)) {\n // Order has changed, call the callback.\n config.reorderDone(itemDragging.closest(config.list), itemDragging, newOrder);\n\n } else if (new Date().getTime() - dragStart.time < 500 &&\n Math.abs(dragStart.x - x) < 10 && Math.abs(dragStart.y - y) < 10) {\n // This was really a click. Set the focus on the current item.\n itemDragging[0].focus();\n }\n proxy.remove();\n proxy = null;\n itemDragging.removeClass(config.itemMovingClass);\n itemDragging = null;\n dragStart = null;\n };\n\n /**\n * Items can be moved and placed using certain keys.\n * Tab for tabbing though and choose the item to be moved\n * space, arrow-right arrow-down for moving current element forewards.\n * arrow-right arrow-down for moving the current element backwards.\n * @param {Object} e the event\n * @param {jQuery} current the current moving item\n */\n var itemMovedByKeyboard = function(e, current) {\n switch (e.keyCode) {\n case keys.space:\n case keys.arrowRight:\n case keys.arrowDown:\n e.preventDefault();\n e.stopPropagation();\n var next = current.next();\n if (next.length) {\n next.insertBefore(current);\n }\n break;\n\n case keys.arrowLeft:\n case keys.arrowUp:\n e.preventDefault();\n e.stopPropagation();\n var prev = current.prev();\n if (prev.length) {\n prev.insertAfter(current);\n }\n break;\n }\n };\n\n /**\n * Get the x-position of the middle of the DOM node represented by the given jQuery object.\n * @param {jQuery} jQuery wrapping a DOM node.\n * @returns {number} Number the x-coordinate of the middle (left plus half outerWidth).\n */\n var midX = function(jQuery) {\n return jQuery.offset().left + jQuery.outerWidth() / 2;\n };\n\n /**\n * Get the y-position of the middle of the DOM node represented by the given jQuery object.\n * @param {jQuery} jQuery wrapping a DOM node.\n * @returns {number} Number the y-coordinate of the middle (top plus half outerHeight).\n */\n var midY = function(jQuery) {\n return jQuery.offset().top + jQuery.outerHeight() / 2;\n };\n\n /**\n * Calculate the distance between the centres of two elements.\n * @param {Selector|Element|jQuery} element1 selector, element or jQuery.\n * @param {Selector|Element|jQuery} element2 selector, element or jQuery.\n * @return {number} number the distance in pixels.\n */\n var distanceBetweenElements = function(element1, element2) {\n var e1 = $(element1);\n var e2 = $(element2);\n var dx = midX(e1) - midX(e2);\n var dy = midY(e1) - midY(e2);\n return Math.sqrt(dx * dx + dy * dy);\n };\n\n /**\n * Get the current order of the list containing itemDragging.\n * @returns {Array} Array of strings, the id of each element in order.\n */\n var getCurrentOrder = function() {\n return (itemDragging || itemMoving).closest(config.list).find(config.item).map(\n function(index, item) {\n return config.idGetter(item);\n }).get();\n };\n\n /**\n * Compare two arrays, which just contain simple values like ints or strings,\n * to see if they are equal.\n * @param {Array} a1 first array.\n * @param {Array} a2 second array.\n * @return {Boolean} boolean true if they both contain the same elements in the same order, else false.\n */\n var arrayEquals = function(a1, a2) {\n return a1.length === a2.length &&\n a1.every(function(v, i) {\n return v === a2[i];\n });\n };\n config.itemInPage = combineSelectors(config.list, config.item);\n\n // AJAX for section drag and click-to-move.\n $(config.list).on('mousedown touchstart', config.item, function(event) {\n var details = drag.prepare(event);\n if (details.start) {\n startDrag(event, details);\n }\n });\n\n $(config.list).on('keydown', config.item, function(event) {\n itemMoving = $(event.currentTarget).closest(config.itemInPage);\n originalOrder = getCurrentOrder();\n itemMovedByKeyboard(event, itemMoving);\n var newOrder = getCurrentOrder();\n if (!arrayEquals(originalOrder, newOrder)) {\n // Order has changed, call the callback.\n config.reorderDone(itemMoving.closest(config.list), itemMoving, newOrder);\n }\n });\n\n // Make the items tabbable.\n $(config.itemInPage).attr('tabindex', '0');\n };\n});\n"],"names":["define","require","specified","$","drag","keys","config","outer","inner","combined","dragStart","originalOrder","itemDragging","itemMoving","proxy","orderList","dragMove","list","closest","closestItem","closestDistance","find","item","each","index","element","distance","distanceBetweenElements","offsetValue","midY","window","console","log","insertBefore","insertAfter","updateProxy","items","count","length","i","attr","dragEnd","x","y","reorderEnd","newOrder","getCurrentOrder","arrayEquals","Date","getTime","time","Math","abs","focus","reorderDone","remove","removeClass","itemMovingClass","midX","jQuery","offset","left","outerWidth","top","outerHeight","element1","element2","e1","e2","dx","dy","sqrt","map","idGetter","get","a1","a2","every","v","itemInPage","split","forEach","firstSelector","secondSelector","push","trim","join","on","event","details","prepare","start","currentTarget","reorderStart","proxyHtml","replace","html","document","body","append","css","width","height","addClass","startDrag","e","current","keyCode","space","arrowRight","arrowDown","preventDefault","stopPropagation","next","arrowLeft","arrowUp","prev","itemMovedByKeyboard"],"mappings":";;;;;;;;;;AA6BAA,qCAAO,CACH,SACAC,QAAQC,UAAU,iBAAmB,gBAAkB,0BACvDD,QAAQC,UAAU,kBAAoB,iBAAmB,6BAC1D,SACCC,EACAC,KACAC,aAsEO,SAASC,YAiGoBC,MAAOC,MAC/BC,SAjGJC,UAAY,KACZC,cAAgB,KAChBC,aAAe,KACfC,WAAa,KACbC,MAAQ,KACRC,UAAY,KAmCZC,SAAW,eACPC,KAAOL,aAAaM,QAAQZ,OAAOW,MACnCE,YAAc,KACdC,gBAAkB,QACtBH,KAAKI,KAAKf,OAAOgB,MAAMC,MAAK,SAASC,MAAOC,aACpCC,SAAWC,wBAAwBF,QAASX,QAC5B,OAAhBK,aAAwBO,SAAWN,mBACnCD,YAAchB,EAAEsB,SAChBL,gBAAkBM,aAItBP,YAAY,KAAOP,aAAa,QAGhCgB,YAAc,EAEdC,KAAKf,OAASe,KAAKV,cACnBS,YAAc,GACdE,OAAOC,QAAQC,IAAI,kDAAoDJ,eAEvEA,aAAe,GACfE,OAAOC,QAAQC,IAAI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AOC,YAIzBtF,EAAEG,OAAOW,MAAMsE,GAAG,UAAWjF,OAAOgB,MAAM,SAASkE,OAC/C3E,WAAaV,EAAEqF,MAAMI,eAAe1E,QAAQZ,OAAOyE,YACnDpE,cAAgBmC,kBA7FM,SAAS2D,EAAGC,gBAC1BD,EAAEE,cACDtG,KAAKuG,WACLvG,KAAKwG,gBACLxG,KAAKyG,UACNL,EAAEM,iBACFN,EAAEO,sBACEC,KAAOP,QAAQO,OACfA,KAAK3E,QACL2E,KAAKhF,aAAayE,oBAIrBrG,KAAK6G,eACL7G,KAAK8G,QACNV,EAAEM,iBACFN,EAAEO,sBACEI,KAAOV,QAAQU,OACfA,KAAK9E,QACL8E,KAAKlF,YAAYwE,UA2E7BW,CAAoB7B,MAAO3E,gBACvBgC,SAAWC,kBACVC,YAAYpC,cAAekC,WAE5BvC,OAAOgD,YAAYzC,WAAWK,QAAQZ,OAAOW,MAAOJ,WAAYgC,aAKxE1C,EAAEG,OAAOyE,YAAYvC,KAAK,WAAY"} \ No newline at end of file +{"version":3,"file":"drag_reorder.min.js","sources":["../src/drag_reorder.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/*\n * Generic library to allow things in a vertical list to be re-ordered using drag and drop.\n *\n * To make a set of things draggable, create a new instance of this object passing the\n * necessary config, as explained in the comment on the constructor.\n *\n * @package qtype_ordering\n * @copyright 2018 The Open University\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * @module qtype_ordering/drag_reorder\n */\ndefine([\n 'jquery',\n 'core/dragdrop',\n 'core/key_codes'\n], function(\n $,\n drag,\n keys\n) {\n\n /**\n * Constructor.\n *\n * To make a list draggable, create a new instance of this object, passing the necessary config.\n * For example:\n * {\n * // Selector for the list (or lists) to be reordered.\n * list: 'ul.my-list',\n *\n * // Selector, relative to the list selector, for the items that can be moved.\n * item: '> li',\n *\n * // The user actually drags a proxy object, which is constructed from this string,\n * // and then added directly as a child of . The token %%ITEM_HTML%% is\n * // replaced with the innerHtml of the item being dragged. The token %%ITEM_CLASS_NAME%%\n * // is replaced with the class attribute of the item being dragged. Because of this,\n * // the styling of the contents of your list item needs to work for the proxy, as well as\n * // for items in place in the context of the list. Your CSS also needs to ensure\n * // that this proxy has position: absolute. You probably want other styles, like a\n * // drop shadow. Using class osep-itemmoving might be all you need to do.\n * proxyHtml: '
%%ITEM_HTML%%
,\n *\n * // While the proxy is being dragged, this class is added to the item being moved.\n * // You can probably use \"osep-itemmoving\" here.\n * itemMovingClass: \"osep-itemmoving\",\n *\n * // This is a callback which, when called with the DOM node for an item,\n * // returns the string that uniquely identifies each item.\n * // Therefore, the result of the drag action will be represented by the array\n * // obtained by calling this method on each item in the list in order.\n * idGetter: function(item) { return $(node).data('id'); },\n *\n * // This is a callback which, when called with the DOM node for an item,\n * // returns a string that is the name of the item.\n * nameGetter: function(item) { return $(node).text(); },\n *\n * // Function that will be called when a re-order starts (optional, can be not set).\n * // Useful if you need to save information about the initial state.\n * // This function should have two parameters. The first will be a\n * // jQuery object for the list that was reordered, the second will\n * // be the jQuery object for the item moved - which will not yet have been moved.\n * // Note, it is quite possible for reorderStart to be called with no\n * // subsequent call to reorderDone.\n * reorderStart: function($list, $item) { ... }\n *\n * // Function that will be called when a drag has finished, and the list\n * // has been reordered. This function should have three parameters. The first will be\n * // a jQuery object for the list that was reordered, the second will be the jQuery\n * // object for the item moved, and the third will be the new order, which is\n * // an array of ids obtained by calling idGetter on each item in the list in order.\n * // This callback will only be called in the new order is actually different from the old order.\n * reorderDone: function($list, $item, newOrder) { ... }\n *\n * // Function that is alwasy called when a re-order ends (optional, can be not set)\n * // whether or not the order has changed. Useful if you need to undo changes made\n * // in reorderStart, since reorderDone is only called if the new order is different\n * // from the original order.\n * reorderEnd: function($list, $item) { ... }\n * }\n *\n * There is a subtlety ( === hack?) that you can use. If you have items in your list that do not\n * have a drag handle, they they are considered to be placeholders in otherwise empty containers.\n * See how block_userlinks does it, if this seems like it might be useful. nameGetter should return\n * the container name for these items.\n *\n * @param {Object} config As above.\n */\n return function(config) {\n var dragStart = null, // Information about when and where the drag started.\n originalOrder = null, // Array of ids.\n itemDragging = null, // Item being moved by dragging (jQuery object).\n itemMoving = null, // Item being moved using the accessible modal (jQuery object).\n proxy = null, // Drag proxy (jQuery object).\n orderList = null; // Order list (jQuery object).\n\n var startDrag = function(event, details) {\n orderList = $(config.list);\n\n dragStart = {\n time: new Date().getTime(),\n x: details.x,\n y: details.y\n };\n\n itemDragging = $(event.currentTarget).closest(config.itemInPage);\n\n if (typeof config.reorderStart !== 'undefined') {\n config.reorderStart(itemDragging.closest(config.list), itemDragging);\n }\n\n originalOrder = getCurrentOrder();\n proxy = $(config.proxyHtml.replace('%%ITEM_HTML%%', itemDragging.html())\n .replace('%%ITEM_CLASS_NAME%%', itemDragging.attr('class'))\n .replace('%%LIST_CLASS_NAME%%', orderList.attr('class')));\n\n $(document.body).append(proxy);\n proxy.css('position', 'absolute');\n proxy.css(itemDragging.offset());\n proxy.width(itemDragging.outerWidth());\n proxy.height(itemDragging.outerHeight());\n itemDragging.addClass(config.itemMovingClass);\n updateProxy(itemDragging);\n\n // Start drag.\n drag.start(event, proxy, dragMove, dragEnd);\n\n };\n\n var dragMove = function() {\n var list = itemDragging.closest(config.list);\n var closestItem = null;\n var closestDistance = null;\n list.find(config.item).each(function(index, element) {\n var distance = distanceBetweenElements(element, proxy);\n if (closestItem === null || distance < closestDistance) {\n closestItem = $(element);\n closestDistance = distance;\n }\n });\n\n if (closestItem[0] === itemDragging[0]) {\n return;\n }\n var offsetValue = 0;\n // Set offset depending on if item is being dragged downwards/upwards.\n if (midY(proxy) < midY(closestItem)) {\n offsetValue = 20;\n window.console.log(\"For midY(proxy) < midY(closestItem) offset is: \" + offsetValue);\n } else {\n offsetValue = -20;\n window.console.log(\"For midY(proxy) < midY(closestItem) offset is: \" + offsetValue);\n }\n if (midY(proxy) + offsetValue < midY(closestItem)) {\n itemDragging.insertBefore(closestItem);\n } else {\n itemDragging.insertAfter(closestItem);\n }\n updateProxy(itemDragging);\n };\n\n /**\n * Update proxy's position.\n * @param {jQuery} itemDragging\n */\n var updateProxy = function(itemDragging) {\n var list = itemDragging.closest('ol, ul');\n var items = list.find('li');\n var count = items.length;\n for (var i = 0; i < count; ++i) {\n if (itemDragging[0] === items[i]) {\n proxy.find('li').attr('value', i + 1);\n break;\n }\n }\n };\n\n /**\n * It outer and inner are two CSS selectors, which may contain commas,\n * then combine them safely. So combineSelectors('a, b', 'c, d')\n * gives 'a c, a d, b c, b d'.\n * @param {Selector} outer\n * @param {Selector} inner\n * @returns {string}\n */\n var combineSelectors = function(outer, inner) {\n var combined = [];\n outer.split(',').forEach(function(firstSelector) {\n inner.split(',').forEach(function(secondSelector) {\n combined.push(firstSelector.trim() + ' ' + secondSelector.trim());\n });\n });\n return combined.join(', ');\n };\n\n var dragEnd = function(x, y) {\n if (typeof config.reorderEnd !== 'undefined') {\n config.reorderEnd(itemDragging.closest(config.list), itemDragging);\n }\n\n var newOrder = getCurrentOrder();\n if (!arrayEquals(originalOrder, newOrder)) {\n // Order has changed, call the callback.\n config.reorderDone(itemDragging.closest(config.list), itemDragging, newOrder);\n\n } else if (new Date().getTime() - dragStart.time < 500 &&\n Math.abs(dragStart.x - x) < 10 && Math.abs(dragStart.y - y) < 10) {\n // This was really a click. Set the focus on the current item.\n itemDragging[0].focus();\n }\n proxy.remove();\n proxy = null;\n itemDragging.removeClass(config.itemMovingClass);\n itemDragging = null;\n dragStart = null;\n };\n\n /**\n * Items can be moved and placed using certain keys.\n * Tab for tabbing though and choose the item to be moved\n * space, arrow-right arrow-down for moving current element forewards.\n * arrow-right arrow-down for moving the current element backwards.\n * @param {Object} e the event\n * @param {jQuery} current the current moving item\n */\n var itemMovedByKeyboard = function(e, current) {\n switch (e.keyCode) {\n case keys.space:\n case keys.arrowRight:\n case keys.arrowDown:\n e.preventDefault();\n e.stopPropagation();\n var next = current.next();\n if (next.length) {\n next.insertBefore(current);\n }\n break;\n\n case keys.arrowLeft:\n case keys.arrowUp:\n e.preventDefault();\n e.stopPropagation();\n var prev = current.prev();\n if (prev.length) {\n prev.insertAfter(current);\n }\n break;\n }\n };\n\n /**\n * Get the x-position of the middle of the DOM node represented by the given jQuery object.\n * @param {jQuery} jQuery wrapping a DOM node.\n * @returns {number} Number the x-coordinate of the middle (left plus half outerWidth).\n */\n var midX = function(jQuery) {\n return jQuery.offset().left + jQuery.outerWidth() / 2;\n };\n\n /**\n * Get the y-position of the middle of the DOM node represented by the given jQuery object.\n * @param {jQuery} jQuery wrapping a DOM node.\n * @returns {number} Number the y-coordinate of the middle (top plus half outerHeight).\n */\n var midY = function(jQuery) {\n return jQuery.offset().top + jQuery.outerHeight() / 2;\n };\n\n /**\n * Calculate the distance between the centres of two elements.\n * @param {Selector|Element|jQuery} element1 selector, element or jQuery.\n * @param {Selector|Element|jQuery} element2 selector, element or jQuery.\n * @return {number} number the distance in pixels.\n */\n var distanceBetweenElements = function(element1, element2) {\n var e1 = $(element1);\n var e2 = $(element2);\n var dx = midX(e1) - midX(e2);\n var dy = midY(e1) - midY(e2);\n return Math.sqrt(dx * dx + dy * dy);\n };\n\n /**\n * Get the current order of the list containing itemDragging.\n * @returns {Array} Array of strings, the id of each element in order.\n */\n var getCurrentOrder = function() {\n return (itemDragging || itemMoving).closest(config.list).find(config.item).map(\n function(index, item) {\n return config.idGetter(item);\n }).get();\n };\n\n /**\n * Compare two arrays, which just contain simple values like ints or strings,\n * to see if they are equal.\n * @param {Array} a1 first array.\n * @param {Array} a2 second array.\n * @return {Boolean} boolean true if they both contain the same elements in the same order, else false.\n */\n var arrayEquals = function(a1, a2) {\n return a1.length === a2.length &&\n a1.every(function(v, i) {\n return v === a2[i];\n });\n };\n config.itemInPage = combineSelectors(config.list, config.item);\n\n // AJAX for section drag and click-to-move.\n $(config.list).on('mousedown touchstart', config.item, function(event) {\n var details = drag.prepare(event);\n if (details.start) {\n startDrag(event, details);\n }\n });\n\n $(config.list).on('keydown', config.item, function(event) {\n itemMoving = $(event.currentTarget).closest(config.itemInPage);\n originalOrder = getCurrentOrder();\n itemMovedByKeyboard(event, itemMoving);\n var newOrder = getCurrentOrder();\n if (!arrayEquals(originalOrder, newOrder)) {\n // Order has changed, call the callback.\n config.reorderDone(itemMoving.closest(config.list), itemMoving, newOrder);\n }\n });\n\n // Make the items tabbable.\n $(config.itemInPage).attr('tabindex', '0');\n };\n});\n"],"names":["define","$","drag","keys","config","outer","inner","combined","dragStart","originalOrder","itemDragging","itemMoving","proxy","orderList","dragMove","list","closest","closestItem","closestDistance","find","item","each","index","element","distance","distanceBetweenElements","offsetValue","midY","window","console","log","insertBefore","insertAfter","updateProxy","items","count","length","i","attr","dragEnd","x","y","reorderEnd","newOrder","getCurrentOrder","arrayEquals","Date","getTime","time","Math","abs","focus","reorderDone","remove","removeClass","itemMovingClass","midX","jQuery","offset","left","outerWidth","top","outerHeight","element1","element2","e1","e2","dx","dy","sqrt","map","idGetter","get","a1","a2","every","v","itemInPage","split","forEach","firstSelector","secondSelector","push","trim","join","on","event","details","prepare","start","currentTarget","reorderStart","proxyHtml","replace","html","document","body","append","css","width","height","addClass","startDrag","e","current","keyCode","space","arrowRight","arrowDown","preventDefault","stopPropagation","next","arrowLeft","arrowUp","prev","itemMovedByKeyboard"],"mappings":";;;;;;;;;;AA6BAA,qCAAO,CACH,SACA,gBACA,mBACD,SACCC,EACAC,KACAC,aAsEO,SAASC,YAiGoBC,MAAOC,MAC/BC,SAjGJC,UAAY,KACZC,cAAgB,KAChBC,aAAe,KACfC,WAAa,KACbC,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AEG,OAAOwF,UAAUC,QAAQ,gBAAiBnF,aAAaoF,QAC5DD,QAAQ,sBAAuBnF,aAAa4B,KAAK,UACjDuD,QAAQ,sBAAuBhF,UAAUyB,KAAK,WAEnDrC,EAAE8F,SAASC,MAAMC,OAAOrF,OACxBA,MAAMsF,IAAI,WAAY,YACtBtF,MAAMsF,IAAIxF,aAAagD,UACvB9C,MAAMuF,MAAMzF,aAAakD,cACzBhD,MAAMwF,OAAO1F,aAAaoD,eAC1BpD,aAAa2F,SAASjG,OAAOmD,iBAC7BtB,YAAYvB,cAGZR,KAAKuF,MAAMH,MAAO1E,MAAOE,SAAUyB,SA2L/B+D,CAAUhB,MAAOC,YAIzBtF,EAAEG,OAAOW,MAAMsE,GAAG,UAAWjF,OAAOgB,MAAM,SAASkE,OAC/C3E,WAAaV,EAAEqF,MAAMI,eAAe1E,QAAQZ,OAAOyE,YACnDpE,cAAgBmC,kBA7FM,SAAS2D,EAAGC,gBAC1BD,EAAEE,cACDtG,KAAKuG,WACLvG,KAAKwG,gBACLxG,KAAKyG,UACNL,EAAEM,iBACFN,EAAEO,sBACEC,KAAOP,QAAQO,OACfA,KAAK3E,QACL2E,KAAKhF,aAAayE,oBAIrBrG,KAAK6G,eACL7G,KAAK8G,QACNV,EAAEM,iBACFN,EAAEO,sBACEI,KAAOV,QAAQU,OACfA,KAAK9E,QACL8E,KAAKlF,YAAYwE,UA2E7BW,CAAoB7B,MAAO3E,gBACvBgC,SAAWC,kBACVC,YAAYpC,cAAekC,WAE5BvC,OAAOgD,YAAYzC,WAAWK,QAAQZ,OAAOW,MAAOJ,WAAYgC,aAKxE1C,EAAEG,OAAOyE,YAAYvC,KAAK,WAAY"} \ No newline at end of file diff --git a/question/type/ordering/amd/build/dragdrop.min.js b/question/type/ordering/amd/build/dragdrop.min.js deleted file mode 100644 index 42137936ab1..00000000000 --- a/question/type/ordering/amd/build/dragdrop.min.js +++ /dev/null @@ -1,20 +0,0 @@ -/* - * JavaScript to handle drag operations, including automatic scrolling. - * - * This is a copy of a library that was added to Moodle core in Moodle 3.6, - * so we can support older Moodle versions. - * - * Note: this module is defined statically. It is a singleton. You - * can only have one use of it active at any time. However, you - * can only drag one thing at a time, this is not a problem in practice. - * - * @module qtype_ordering/dragdrop - * @class dragdrop - * @package qtype_ordering - * @copyright 2016 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @since 3.6 - */ -define("qtype_ordering/dragdrop",["jquery","qtype_ordering/autoscroll"],(function($,autoScroll){var dragdrop={eventCaptureOptions:{passive:!1,capture:!0},dragProxy:null,onMove:null,onDrop:null,initialPosition:null,initialX:null,initialY:null,touching:null,prepare:function(event){if(event.preventDefault(),"touchstart"===event.type?null===dragdrop.touching&&event.changedTouches.length>0:1===event.which){var details=dragdrop.getEventXY(event);return details.start=!0,details}return{start:!1}},start:function(event,dragProxy,onMove,onDrop){var xy=dragdrop.getEventXY(event);switch(dragdrop.initialX=xy.x,dragdrop.initialY=xy.y,dragdrop.initialPosition=dragProxy.offset(),dragdrop.dragProxy=dragProxy,dragdrop.onMove=onMove,dragdrop.onDrop=onDrop,event.type){case"mousedown":dragdrop.addEventSpecial("mousemove",dragdrop.mouseMove),dragdrop.addEventSpecial("mouseup",dragdrop.mouseUp);break;case"touchstart":dragdrop.addEventSpecial("touchend",dragdrop.touchEnd),dragdrop.addEventSpecial("touchcancel",dragdrop.touchEnd),dragdrop.addEventSpecial("touchmove",dragdrop.touchMove),dragdrop.touching=event.changedTouches[0].identifier;break;default:throw new Error("Unexpected event type: "+event.type)}autoScroll.start(dragdrop.scroll)},addEventSpecial:function(event,handler){try{window.addEventListener(event,handler,dragdrop.eventCaptureOptions)}catch(ex){dragdrop.eventCaptureOptions=!0,window.addEventListener(event,handler,dragdrop.eventCaptureOptions)}},getEventXY:function(event){switch(event.type){case"touchstart":return{x:event.changedTouches[0].pageX,y:event.changedTouches[0].pageY};case"mousedown":return{x:event.pageX,y:event.pageY};default:throw new Error("Unexpected event type: "+event.type)}},touchMove:function(e){e.preventDefault();for(var i=0;i.\n\n/*\n * JavaScript to handle drag operations, including automatic scrolling.\n *\n * This is a copy of a library that was added to Moodle core in Moodle 3.6,\n * so we can support older Moodle versions.\n *\n * Note: this module is defined statically. It is a singleton. You\n * can only have one use of it active at any time. However, you\n * can only drag one thing at a time, this is not a problem in practice.\n *\n * @module qtype_ordering/dragdrop\n * @class dragdrop\n * @package qtype_ordering\n * @copyright 2016 The Open University\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 3.6\n */\ndefine(['jquery', 'qtype_ordering/autoscroll'], function($, autoScroll) {\n /**\n * @alias module:qtype_ordering/dragdrop\n */\n var dragdrop = {\n /**\n * A boolean or options argument depending on whether browser supports passive events.\n * @private\n */\n eventCaptureOptions: {passive: false, capture: true},\n\n /**\n * Drag proxy if any.\n * @private\n */\n dragProxy: null,\n\n /**\n * Function called on move.\n * @private\n */\n onMove: null,\n\n /**\n * Function called on drop.\n * @private\n */\n onDrop: null,\n\n /**\n * Initial position of proxy at drag start.\n */\n initialPosition: null,\n\n /**\n * Initial page X of cursor at drag start.\n */\n initialX: null,\n\n /**\n * Initial page Y of cursor at drag start.\n */\n initialY: null,\n\n /**\n * If touch event is in progress, this will be the id, otherwise null\n */\n touching: null,\n\n /**\n * Prepares to begin a drag operation - call with a mousedown or touchstart event.\n *\n * If the returned object has 'start' true, then you can set up a drag proxy, and call\n * start. This function will call preventDefault automatically regardless of whether\n * starting or not.\n *\n * @public\n * @param {Object} event Event (should be either mousedown or touchstart)\n * @return {Object} Object with start (boolean flag) and x, y (only if flag true) values\n */\n prepare: function(event) {\n event.preventDefault();\n var start;\n if (event.type === 'touchstart') {\n // For touch, start if there's at least one touch and we are not currently doing\n // a touch event.\n start = (dragdrop.touching === null) && event.changedTouches.length > 0;\n } else {\n // For mousedown, start if it's the left button.\n start = event.which === 1;\n }\n if (start) {\n var details = dragdrop.getEventXY(event);\n details.start = true;\n return details;\n } else {\n return {start: false};\n }\n },\n\n /**\n * Call to start a drag operation, in response to a mouse down or touch start event.\n * Normally call this after calling prepare and receiving start true (you can probably\n * skip prepare if only supporting drag not touch).\n *\n * Note: The caller is responsible for creating a 'drag proxy' which is the\n * thing that actually gets dragged. At present, this doesn't really work\n * properly unless it is added directly within the body tag.\n *\n * You also need to ensure that there is CSS so the proxy is absolutely positioned,\n * and styled to look like it is floating.\n *\n * You also need to absolutely position the proxy where you want it to start.\n *\n * @public\n * @param {Object} event Event (should be either mousedown or touchstart)\n * @param {jQuery} dragProxy An absolute-positioned element for dragging\n * @param {Object} onMove Function that receives X and Y page locations for a move\n * @param {Object} onDrop Function that receives X and Y page locations when dropped\n */\n start: function(event, dragProxy, onMove, onDrop) {\n var xy = dragdrop.getEventXY(event);\n dragdrop.initialX = xy.x;\n dragdrop.initialY = xy.y;\n dragdrop.initialPosition = dragProxy.offset();\n dragdrop.dragProxy = dragProxy;\n dragdrop.onMove = onMove;\n dragdrop.onDrop = onDrop;\n\n switch (event.type) {\n case 'mousedown':\n // Cannot use jQuery 'on' because events need to not be passive.\n dragdrop.addEventSpecial('mousemove', dragdrop.mouseMove);\n dragdrop.addEventSpecial('mouseup', dragdrop.mouseUp);\n break;\n case 'touchstart':\n dragdrop.addEventSpecial('touchend', dragdrop.touchEnd);\n dragdrop.addEventSpecial('touchcancel', dragdrop.touchEnd);\n dragdrop.addEventSpecial('touchmove', dragdrop.touchMove);\n dragdrop.touching = event.changedTouches[0].identifier;\n break;\n default:\n throw new Error('Unexpected event type: ' + event.type);\n }\n autoScroll.start(dragdrop.scroll);\n },\n\n /**\n * Adds an event listener with special event capture options (capture, not passive). If the\n * browser does not support passive events, it will fall back to the boolean for capture.\n *\n * @private\n * @param {Object} event Event type string\n * @param {Object} handler Handler function\n */\n addEventSpecial: function(event, handler) {\n try {\n window.addEventListener(event, handler, dragdrop.eventCaptureOptions);\n } catch (ex) {\n dragdrop.eventCaptureOptions = true;\n window.addEventListener(event, handler, dragdrop.eventCaptureOptions);\n }\n },\n\n /**\n * Gets X/Y co-ordinates of an event, which can be either touchstart or mousedown.\n *\n * @private\n * @param {Object} event Event (should be either mousedown or touchstart)\n * @return {Object} X/Y co-ordinates\n */\n getEventXY: function(event) {\n switch (event.type) {\n case 'touchstart':\n return {x: event.changedTouches[0].pageX,\n y: event.changedTouches[0].pageY};\n case 'mousedown':\n return {x: event.pageX, y: event.pageY};\n default:\n throw new Error('Unexpected event type: ' + event.type);\n }\n },\n\n /**\n * Event handler for touch move.\n *\n * @private\n * @param {Object} e Event\n */\n touchMove: function(e) {\n e.preventDefault();\n for (var i = 0; i < e.changedTouches.length; i++) {\n if (e.changedTouches[i].identifier === dragdrop.touching) {\n dragdrop.handleMove(e.changedTouches[i].pageX, e.changedTouches[i].pageY);\n }\n }\n },\n\n /**\n * Event handler for mouse move.\n *\n * @private\n * @param {Object} e Event\n */\n mouseMove: function(e) {\n dragdrop.handleMove(e.pageX, e.pageY);\n },\n\n /**\n * Shared handler for move event (mouse or touch).\n *\n * @private\n * @param {number} pageX X co-ordinate\n * @param {number} pageY Y co-ordinate\n */\n handleMove: function(pageX, pageY) {\n // Move the drag proxy, not letting you move it out of screen or window bounds.\n var current = dragdrop.dragProxy.offset();\n var topOffset = current.top - parseInt(dragdrop.dragProxy.css('top'));\n var leftOffset = current.left - parseInt(dragdrop.dragProxy.css('left'));\n var maxY = $(document).height() - dragdrop.dragProxy.outerHeight() - topOffset;\n var maxX = $(document).width() - dragdrop.dragProxy.outerWidth() - leftOffset;\n var minY = -topOffset;\n var minX = -leftOffset;\n var initial = dragdrop.initialPosition;\n var position = {\n top: Math.max(minY, Math.min(maxY, initial.top + (pageY - dragdrop.initialY) - topOffset)),\n left: Math.max(minX, Math.min(maxX, initial.left + (pageX - dragdrop.initialX) - leftOffset))\n };\n dragdrop.dragProxy.css(position);\n\n // Trigger move handler.\n dragdrop.onMove(pageX, pageY, dragdrop.dragProxy);\n },\n\n /**\n * Event handler for touch end.\n *\n * @private\n * @param {Object} e Event\n */\n touchEnd: function(e) {\n e.preventDefault();\n for (var i = 0; i < e.changedTouches.length; i++) {\n if (e.changedTouches[i].identifier === dragdrop.touching) {\n dragdrop.handleEnd(e.changedTouches[i].pageX, e.changedTouches[i].pageY);\n }\n }\n },\n\n /**\n * Event handler for mouse up.\n *\n * @private\n * @param {Object} e Event\n */\n mouseUp: function(e) {\n dragdrop.handleEnd(e.pageX, e.pageY);\n },\n\n /**\n * Shared handler for end drag (mouse or touch).\n *\n * @private\n * @param {number} pageX X\n * @param {number} pageY Y\n */\n handleEnd: function(pageX, pageY) {\n if (dragdrop.touching !== null) {\n window.removeEventListener('touchend', dragdrop.touchEnd, dragdrop.eventCaptureOptions);\n window.removeEventListener('touchcancel', dragdrop.touchEnd, dragdrop.eventCaptureOptions);\n window.removeEventListener('touchmove', dragdrop.touchMove, dragdrop.eventCaptureOptions);\n dragdrop.touching = null;\n } else {\n window.removeEventListener('mousemove', dragdrop.mouseMove, dragdrop.eventCaptureOptions);\n window.removeEventListener('mouseup', dragdrop.mouseUp, dragdrop.eventCaptureOptions);\n }\n autoScroll.stop();\n dragdrop.onDrop(pageX, pageY, dragdrop.dragProxy);\n },\n\n /**\n * Called when the page scrolls.\n *\n * @private\n * @param {number} offset Amount of scroll\n */\n scroll: function(offset) {\n // Move the proxy to match.\n var maxY = $(document).height() - dragdrop.dragProxy.outerHeight();\n var currentPosition = dragdrop.dragProxy.offset();\n currentPosition.top = Math.min(maxY, currentPosition.top + offset);\n dragdrop.dragProxy.css(currentPosition);\n }\n };\n\n return {\n /**\n * Prepares to begin a drag operation - call with a mousedown or touchstart event.\n *\n * If the returned object has 'start' true, then you can set up a drag proxy, and call\n * start. This function will call preventDefault automatically regardless of whether\n * starting or not.\n *\n * @param {Object} event Event (should be either mousedown or touchstart)\n * @return {Object} Object with start (boolean flag) and x, y (only if flag true) values\n */\n prepare: dragdrop.prepare,\n\n /**\n * Call to start a drag operation, in response to a mouse down or touch start event.\n * Normally call this after calling prepare and receiving start true (you can probably\n * skip prepare if only supporting drag not touch).\n *\n * Note: The caller is responsible for creating a 'drag proxy' which is the\n * thing that actually gets dragged. At present, this doesn't really work\n * properly unless it is added directly within the body tag.\n *\n * You also need to ensure that there is CSS so the proxy is absolutely positioned,\n * and styled to look like it is floating.\n *\n * You also need to absolutely position the proxy where you want it to start.\n *\n * @param {Object} event Event (should be either mousedown or touchstart)\n * @param {jQuery} dragProxy An absolute-positioned element for dragging\n * @param {Object} onMove Function that receives X and Y page locations for a move\n * @param {Object} onDrop Function that receives X and Y page locations when dropped\n */\n start: dragdrop.start\n };\n});\n"],"names":["define","$","autoScroll","dragdrop","eventCaptureOptions","passive","capture","dragProxy","onMove","onDrop","initialPosition","initialX","initialY","touching","prepare","event","preventDefault","type","changedTouches","length","which","details","getEventXY","start","xy","x","y","offset","addEventSpecial","mouseMove","mouseUp","touchEnd","touchMove","identifier","Error","scroll","handler","window","addEventListener","ex","pageX","pageY","e","i","handleMove","current","topOffset","top","parseInt","css","leftOffset","left","maxY","document","height","outerHeight","maxX","width","outerWidth","minY","minX","initial","position","Math","max","min","handleEnd","removeEventListener","stop","currentPosition"],"mappings":";;;;;;;;;;;;;;;;;AAgCAA,iCAAO,CAAC,SAAU,8BAA8B,SAASC,EAAGC,gBAIpDC,SAAW,CAKXC,oBAAqB,CAACC,SAAS,EAAOC,SAAS,GAM/CC,UAAW,KAMXC,OAAQ,KAMRC,OAAQ,KAKRC,gBAAiB,KAKjBC,SAAU,KAKVC,SAAU,KAKVC,SAAU,KAaVC,QAAS,SAASC,UACdA,MAAMC,iBAEa,eAAfD,MAAME,KAGyB,OAAtBd,SAASU,UAAsBE,MAAMG,eAAeC,OAAS,EAG9C,IAAhBJ,MAAMK,MAEP,KACHC,QAAUlB,SAASmB,WAAWP,cAClCM,QAAQE,OAAQ,EACTF,cAEA,CAACE,OAAO,IAwBvBA,MAAO,SAASR,MAAOR,UAAWC,OAAQC,YAClCe,GAAKrB,SAASmB,WAAWP,cAC7BZ,SAASQ,SAAWa,GAA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C4B,OAAQ,SAASR,YAETyB,KAAOnD,EAAEoD,UAAUC,SAAWnD,SAASI,UAAUgD,cACjDc,gBAAkBlE,SAASI,UAAUoB,SACzC0C,gBAAgBtB,IAAMgB,KAAKE,IAAIb,KAAMiB,gBAAgBtB,IAAMpB,QAC3DxB,SAASI,UAAU0C,IAAIoB,yBAIxB,CAWHvD,QAASX,SAASW,QAqBlBS,MAAOpB,SAASoB"} \ No newline at end of file diff --git a/question/type/ordering/amd/build/key_codes.min.js b/question/type/ordering/amd/build/key_codes.min.js deleted file mode 100644 index cee0113e44b..00000000000 --- a/question/type/ordering/amd/build/key_codes.min.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - * A list of human readable names for the keycodes. - * - * This is a copy of a library that was added to Moodle core in Moodle 3.2, - * so we can support older Moodle versions. - * - * @module qtype_ordering/key_codes - * @class key_codes - * @package qtype_ordering - * @copyright 2016 Ryan Wyllie - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @since 3.2 - */ -define("qtype_ordering/key_codes",[],(function(){return{tab:9,enter:13,escape:27,space:32,end:35,home:36,arrowLeft:37,arrowUp:38,arrowRight:39,arrowDown:40,8:56,asterix:106,pageUp:33,pageDown:34}})); - -//# sourceMappingURL=key_codes.min.js.map \ No newline at end of file diff --git a/question/type/ordering/amd/build/key_codes.min.js.map b/question/type/ordering/amd/build/key_codes.min.js.map deleted file mode 100644 index ae7ef7fbf64..00000000000 --- a/question/type/ordering/amd/build/key_codes.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"key_codes.min.js","sources":["../src/key_codes.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/*\n * A list of human readable names for the keycodes.\n *\n * This is a copy of a library that was added to Moodle core in Moodle 3.2,\n * so we can support older Moodle versions.\n *\n * @module qtype_ordering/key_codes\n * @class key_codes\n * @package qtype_ordering\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 3.2\n */\ndefine([], function() {\n\n return /** @alias module:qtype_ordering/key_codes */ {\n 'tab': 9,\n 'enter': 13,\n 'escape': 27,\n 'space': 32,\n 'end': 35,\n 'home': 36,\n 'arrowLeft': 37,\n 'arrowUp': 38,\n 'arrowRight': 39,\n 'arrowDown': 40,\n '8': 56,\n 'asterix': 106,\n 'pageUp': 33,\n 'pageDown': 34,\n };\n});\n"],"names":["define"],"mappings":";;;;;;;;;;;;;AA4BAA,kCAAO,IAAI,iBAE8C,KAC1C,QACE,UACC,SACD,OACF,QACC,aACK,WACF,cACG,aACD,KACR,WACM,WACD,YACE"} \ No newline at end of file diff --git a/question/type/ordering/amd/src/autoscroll.js b/question/type/ordering/amd/src/autoscroll.js deleted file mode 100644 index 832acc8afbe..00000000000 --- a/question/type/ordering/amd/src/autoscroll.js +++ /dev/null @@ -1,212 +0,0 @@ -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/* - * JavaScript to provide automatic scrolling, e.g. during a drag operation. - * - * This is a copy of a library that was added to Moodle core in Moodle 3.6, - * so we can support older Moodle versions. - * - * Note: this module is defined statically. It is a singleton. You - * can only have one use of it active at any time. However, since this - * is usually used in relation to drag-drop, and since you only ever - * drag one thing at a time, this is not a problem in practice. - * - * @module qtype_ordering/autoscroll - * @class autoscroll - * @package qtype_ordering - * @copyright 2016 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @since 3.6 - */ -define(['jquery'], function($) { - /** - * @alias module:qtype_ordering/autoscroll - */ - var autoscroll = { - /** - * Size of area near edge of screen that triggers scrolling. - * @private - */ - SCROLL_THRESHOLD: 30, - - /** - * How frequently to scroll window. - * @private - */ - SCROLL_FREQUENCY: 1000 / 60, - - /** - * How many pixels to scroll per unit (1 = max scroll 30). - * @private - */ - SCROLL_SPEED: 0.5, - - /** - * Set if currently scrolling up/down. - * @private - */ - scrollingId: null, - - /** - * Speed we are supposed to scroll (range 1 to SCROLL_THRESHOLD). - * @private - */ - scrollAmount: 0, - - /** - * Optional callback called when it scrolls - * @private - */ - callback: null, - - /** - * Starts automatically scrolling if user moves near edge of window. - * This should be called in response to mouse down or touch start. - * - * @public - * @param {Function} callback Optional callback that is called every time it scrolls - */ - start: function(callback) { - $(window).on('mousemove', autoscroll.mouseMove); - $(window).on('touchmove', autoscroll.touchMove); - autoscroll.callback = callback; - }, - - /** - * Stops automatically scrolling. This should be called in response to mouse up or touch end. - * - * @public - */ - stop: function() { - $(window).off('mousemove', autoscroll.mouseMove); - $(window).off('touchmove', autoscroll.touchMove); - if (autoscroll.scrollingId !== null) { - autoscroll.stopScrolling(); - } - }, - - /** - * Event handler for touch move. - * - * @private - * @param {Object} e Event - */ - touchMove: function(e) { - for (var i = 0; i < e.changedTouches.length; i++) { - autoscroll.handleMove(e.changedTouches[i].clientX, e.changedTouches[i].clientY); - } - }, - - /** - * Event handler for mouse move. - * - * @private - * @param {Object} e Event - */ - mouseMove: function(e) { - autoscroll.handleMove(e.clientX, e.clientY); - }, - - /** - * Handles user moving. - * - * @private - * @param {number} clientX X - * @param {number} clientY Y - */ - handleMove: function(clientX, clientY) { - // If near the bottom or top, start auto-scrolling. - if (clientY < autoscroll.SCROLL_THRESHOLD) { - autoscroll.scrollAmount = -Math.min(autoscroll.SCROLL_THRESHOLD - clientY, autoscroll.SCROLL_THRESHOLD); - } else if (clientY > $(window).height() - autoscroll.SCROLL_THRESHOLD) { - autoscroll.scrollAmount = Math.min(clientY - ($(window).height() - autoscroll.SCROLL_THRESHOLD), - autoscroll.SCROLL_THRESHOLD); - } else { - autoscroll.scrollAmount = 0; - } - if (autoscroll.scrollAmount && autoscroll.scrollingId === null) { - autoscroll.startScrolling(); - } else if (!autoscroll.scrollAmount && autoscroll.scrollingId !== null) { - autoscroll.stopScrolling(); - } - }, - - /** - * Starts automatic scrolling. - * - * @private - */ - startScrolling: function() { - var maxScroll = $(document).height() - $(window).height(); - autoscroll.scrollingId = window.setInterval(function() { - // Work out how much to scroll. - var y = $(window).scrollTop(); - var offset = Math.round(autoscroll.scrollAmount * autoscroll.SCROLL_SPEED); - if (y + offset < 0) { - offset = -y; - } - if (y + offset > maxScroll) { - offset = maxScroll - y; - } - if (offset === 0) { - return; - } - - // Scroll. - $(window).scrollTop(y + offset); - var realOffset = $(window).scrollTop() - y; - if (realOffset === 0) { - return; - } - - // Inform callback - if (autoscroll.callback) { - autoscroll.callback(realOffset); - } - - }, autoscroll.SCROLL_FREQUENCY); - }, - - /** - * Stops the automatic scrolling. - * - * @private - */ - stopScrolling: function() { - window.clearInterval(autoscroll.scrollingId); - autoscroll.scrollingId = null; - } - }; - - return { - /** - * Starts automatic scrolling if user moves near edge of window. - * This should be called in response to mouse down or touch start. - * - * @public - * @param {Function} callback Optional callback that is called every time it scrolls - */ - start: autoscroll.start, - - /** - * Stops automatic scrolling. This should be called in response to mouse up or touch end. - * - * @public - */ - stop: autoscroll.stop - }; - -}); diff --git a/question/type/ordering/amd/src/drag_reorder.js b/question/type/ordering/amd/src/drag_reorder.js index eafa42fd6ec..1459bfd1d88 100644 --- a/question/type/ordering/amd/src/drag_reorder.js +++ b/question/type/ordering/amd/src/drag_reorder.js @@ -29,8 +29,8 @@ */ define([ 'jquery', - require.specified('core/dragdrop') ? 'core/dragdrop' : 'qtype_ordering/dragdrop', - require.specified('core/key_codes') ? 'core/key_codes' : 'qtype_ordering/key_codes' + 'core/dragdrop', + 'core/key_codes' ], function( $, drag, diff --git a/question/type/ordering/amd/src/dragdrop.js b/question/type/ordering/amd/src/dragdrop.js deleted file mode 100644 index 88b9a69cc7a..00000000000 --- a/question/type/ordering/amd/src/dragdrop.js +++ /dev/null @@ -1,343 +0,0 @@ -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/* - * JavaScript to handle drag operations, including automatic scrolling. - * - * This is a copy of a library that was added to Moodle core in Moodle 3.6, - * so we can support older Moodle versions. - * - * Note: this module is defined statically. It is a singleton. You - * can only have one use of it active at any time. However, you - * can only drag one thing at a time, this is not a problem in practice. - * - * @module qtype_ordering/dragdrop - * @class dragdrop - * @package qtype_ordering - * @copyright 2016 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @since 3.6 - */ -define(['jquery', 'qtype_ordering/autoscroll'], function($, autoScroll) { - /** - * @alias module:qtype_ordering/dragdrop - */ - var dragdrop = { - /** - * A boolean or options argument depending on whether browser supports passive events. - * @private - */ - eventCaptureOptions: {passive: false, capture: true}, - - /** - * Drag proxy if any. - * @private - */ - dragProxy: null, - - /** - * Function called on move. - * @private - */ - onMove: null, - - /** - * Function called on drop. - * @private - */ - onDrop: null, - - /** - * Initial position of proxy at drag start. - */ - initialPosition: null, - - /** - * Initial page X of cursor at drag start. - */ - initialX: null, - - /** - * Initial page Y of cursor at drag start. - */ - initialY: null, - - /** - * If touch event is in progress, this will be the id, otherwise null - */ - touching: null, - - /** - * Prepares to begin a drag operation - call with a mousedown or touchstart event. - * - * If the returned object has 'start' true, then you can set up a drag proxy, and call - * start. This function will call preventDefault automatically regardless of whether - * starting or not. - * - * @public - * @param {Object} event Event (should be either mousedown or touchstart) - * @return {Object} Object with start (boolean flag) and x, y (only if flag true) values - */ - prepare: function(event) { - event.preventDefault(); - var start; - if (event.type === 'touchstart') { - // For touch, start if there's at least one touch and we are not currently doing - // a touch event. - start = (dragdrop.touching === null) && event.changedTouches.length > 0; - } else { - // For mousedown, start if it's the left button. - start = event.which === 1; - } - if (start) { - var details = dragdrop.getEventXY(event); - details.start = true; - return details; - } else { - return {start: false}; - } - }, - - /** - * Call to start a drag operation, in response to a mouse down or touch start event. - * Normally call this after calling prepare and receiving start true (you can probably - * skip prepare if only supporting drag not touch). - * - * Note: The caller is responsible for creating a 'drag proxy' which is the - * thing that actually gets dragged. At present, this doesn't really work - * properly unless it is added directly within the body tag. - * - * You also need to ensure that there is CSS so the proxy is absolutely positioned, - * and styled to look like it is floating. - * - * You also need to absolutely position the proxy where you want it to start. - * - * @public - * @param {Object} event Event (should be either mousedown or touchstart) - * @param {jQuery} dragProxy An absolute-positioned element for dragging - * @param {Object} onMove Function that receives X and Y page locations for a move - * @param {Object} onDrop Function that receives X and Y page locations when dropped - */ - start: function(event, dragProxy, onMove, onDrop) { - var xy = dragdrop.getEventXY(event); - dragdrop.initialX = xy.x; - dragdrop.initialY = xy.y; - dragdrop.initialPosition = dragProxy.offset(); - dragdrop.dragProxy = dragProxy; - dragdrop.onMove = onMove; - dragdrop.onDrop = onDrop; - - switch (event.type) { - case 'mousedown': - // Cannot use jQuery 'on' because events need to not be passive. - dragdrop.addEventSpecial('mousemove', dragdrop.mouseMove); - dragdrop.addEventSpecial('mouseup', dragdrop.mouseUp); - break; - case 'touchstart': - dragdrop.addEventSpecial('touchend', dragdrop.touchEnd); - dragdrop.addEventSpecial('touchcancel', dragdrop.touchEnd); - dragdrop.addEventSpecial('touchmove', dragdrop.touchMove); - dragdrop.touching = event.changedTouches[0].identifier; - break; - default: - throw new Error('Unexpected event type: ' + event.type); - } - autoScroll.start(dragdrop.scroll); - }, - - /** - * Adds an event listener with special event capture options (capture, not passive). If the - * browser does not support passive events, it will fall back to the boolean for capture. - * - * @private - * @param {Object} event Event type string - * @param {Object} handler Handler function - */ - addEventSpecial: function(event, handler) { - try { - window.addEventListener(event, handler, dragdrop.eventCaptureOptions); - } catch (ex) { - dragdrop.eventCaptureOptions = true; - window.addEventListener(event, handler, dragdrop.eventCaptureOptions); - } - }, - - /** - * Gets X/Y co-ordinates of an event, which can be either touchstart or mousedown. - * - * @private - * @param {Object} event Event (should be either mousedown or touchstart) - * @return {Object} X/Y co-ordinates - */ - getEventXY: function(event) { - switch (event.type) { - case 'touchstart': - return {x: event.changedTouches[0].pageX, - y: event.changedTouches[0].pageY}; - case 'mousedown': - return {x: event.pageX, y: event.pageY}; - default: - throw new Error('Unexpected event type: ' + event.type); - } - }, - - /** - * Event handler for touch move. - * - * @private - * @param {Object} e Event - */ - touchMove: function(e) { - e.preventDefault(); - for (var i = 0; i < e.changedTouches.length; i++) { - if (e.changedTouches[i].identifier === dragdrop.touching) { - dragdrop.handleMove(e.changedTouches[i].pageX, e.changedTouches[i].pageY); - } - } - }, - - /** - * Event handler for mouse move. - * - * @private - * @param {Object} e Event - */ - mouseMove: function(e) { - dragdrop.handleMove(e.pageX, e.pageY); - }, - - /** - * Shared handler for move event (mouse or touch). - * - * @private - * @param {number} pageX X co-ordinate - * @param {number} pageY Y co-ordinate - */ - handleMove: function(pageX, pageY) { - // Move the drag proxy, not letting you move it out of screen or window bounds. - var current = dragdrop.dragProxy.offset(); - var topOffset = current.top - parseInt(dragdrop.dragProxy.css('top')); - var leftOffset = current.left - parseInt(dragdrop.dragProxy.css('left')); - var maxY = $(document).height() - dragdrop.dragProxy.outerHeight() - topOffset; - var maxX = $(document).width() - dragdrop.dragProxy.outerWidth() - leftOffset; - var minY = -topOffset; - var minX = -leftOffset; - var initial = dragdrop.initialPosition; - var position = { - top: Math.max(minY, Math.min(maxY, initial.top + (pageY - dragdrop.initialY) - topOffset)), - left: Math.max(minX, Math.min(maxX, initial.left + (pageX - dragdrop.initialX) - leftOffset)) - }; - dragdrop.dragProxy.css(position); - - // Trigger move handler. - dragdrop.onMove(pageX, pageY, dragdrop.dragProxy); - }, - - /** - * Event handler for touch end. - * - * @private - * @param {Object} e Event - */ - touchEnd: function(e) { - e.preventDefault(); - for (var i = 0; i < e.changedTouches.length; i++) { - if (e.changedTouches[i].identifier === dragdrop.touching) { - dragdrop.handleEnd(e.changedTouches[i].pageX, e.changedTouches[i].pageY); - } - } - }, - - /** - * Event handler for mouse up. - * - * @private - * @param {Object} e Event - */ - mouseUp: function(e) { - dragdrop.handleEnd(e.pageX, e.pageY); - }, - - /** - * Shared handler for end drag (mouse or touch). - * - * @private - * @param {number} pageX X - * @param {number} pageY Y - */ - handleEnd: function(pageX, pageY) { - if (dragdrop.touching !== null) { - window.removeEventListener('touchend', dragdrop.touchEnd, dragdrop.eventCaptureOptions); - window.removeEventListener('touchcancel', dragdrop.touchEnd, dragdrop.eventCaptureOptions); - window.removeEventListener('touchmove', dragdrop.touchMove, dragdrop.eventCaptureOptions); - dragdrop.touching = null; - } else { - window.removeEventListener('mousemove', dragdrop.mouseMove, dragdrop.eventCaptureOptions); - window.removeEventListener('mouseup', dragdrop.mouseUp, dragdrop.eventCaptureOptions); - } - autoScroll.stop(); - dragdrop.onDrop(pageX, pageY, dragdrop.dragProxy); - }, - - /** - * Called when the page scrolls. - * - * @private - * @param {number} offset Amount of scroll - */ - scroll: function(offset) { - // Move the proxy to match. - var maxY = $(document).height() - dragdrop.dragProxy.outerHeight(); - var currentPosition = dragdrop.dragProxy.offset(); - currentPosition.top = Math.min(maxY, currentPosition.top + offset); - dragdrop.dragProxy.css(currentPosition); - } - }; - - return { - /** - * Prepares to begin a drag operation - call with a mousedown or touchstart event. - * - * If the returned object has 'start' true, then you can set up a drag proxy, and call - * start. This function will call preventDefault automatically regardless of whether - * starting or not. - * - * @param {Object} event Event (should be either mousedown or touchstart) - * @return {Object} Object with start (boolean flag) and x, y (only if flag true) values - */ - prepare: dragdrop.prepare, - - /** - * Call to start a drag operation, in response to a mouse down or touch start event. - * Normally call this after calling prepare and receiving start true (you can probably - * skip prepare if only supporting drag not touch). - * - * Note: The caller is responsible for creating a 'drag proxy' which is the - * thing that actually gets dragged. At present, this doesn't really work - * properly unless it is added directly within the body tag. - * - * You also need to ensure that there is CSS so the proxy is absolutely positioned, - * and styled to look like it is floating. - * - * You also need to absolutely position the proxy where you want it to start. - * - * @param {Object} event Event (should be either mousedown or touchstart) - * @param {jQuery} dragProxy An absolute-positioned element for dragging - * @param {Object} onMove Function that receives X and Y page locations for a move - * @param {Object} onDrop Function that receives X and Y page locations when dropped - */ - start: dragdrop.start - }; -}); diff --git a/question/type/ordering/amd/src/key_codes.js b/question/type/ordering/amd/src/key_codes.js deleted file mode 100644 index dadd56bc51c..00000000000 --- a/question/type/ordering/amd/src/key_codes.js +++ /dev/null @@ -1,47 +0,0 @@ -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/* - * A list of human readable names for the keycodes. - * - * This is a copy of a library that was added to Moodle core in Moodle 3.2, - * so we can support older Moodle versions. - * - * @module qtype_ordering/key_codes - * @class key_codes - * @package qtype_ordering - * @copyright 2016 Ryan Wyllie - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @since 3.2 - */ -define([], function() { - - return /** @alias module:qtype_ordering/key_codes */ { - 'tab': 9, - 'enter': 13, - 'escape': 27, - 'space': 32, - 'end': 35, - 'home': 36, - 'arrowLeft': 37, - 'arrowUp': 38, - 'arrowRight': 39, - 'arrowDown': 40, - '8': 56, - 'asterix': 106, - 'pageUp': 33, - 'pageDown': 34, - }; -});