diff --git a/lang/en/moodle.php b/lang/en/moodle.php index ee02e871581ad..6fbf005401eff 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -1269,6 +1269,8 @@ $string['movecoursemodule'] = 'Move resource'; $string['movecoursesection'] = 'Move section'; $string['movecontent'] = 'Move {$a}'; +$string['movecontentafter'] = 'After "{$a}"'; +$string['movecontenttothetop'] = 'To the top of the list'; $string['movecategorycontentto'] = 'Move into'; $string['movecategorysuccess'] = 'Successfully moved category \'{$a->moved}\' into category \'{$a->to}\''; $string['movecategoriessuccess'] = 'Successfully moved {$a->count} categories into category \'{$a->to}\''; diff --git a/lib/amd/build/autoscroll.min.js b/lib/amd/build/autoscroll.min.js new file mode 100644 index 0000000000000..2c179ea2e917f --- /dev/null +++ b/lib/amd/build/autoscroll.min.js @@ -0,0 +1 @@ +define(["jquery"],function(a){var b={SCROLL_THRESHOLD:30,SCROLL_FREQUENCY:1e3/60,SCROLL_SPEED:.5,scrollingId:null,scrollAmount:0,callback:null,start:function(c){a(window).on("mousemove",b.mouseMove),a(window).on("touchmove",b.touchMove),b.callback=c},stop:function(){a(window).off("mousemove",b.mouseMove),a(window).off("touchmove",b.touchMove),null!==b.scrollingId&&b.stopScrolling()},touchMove:function(a){for(var c=0;ca(window).height()-b.SCROLL_THRESHOLD?b.scrollAmount=Math.min(d-(a(window).height()-b.SCROLL_THRESHOLD),b.SCROLL_THRESHOLD):b.scrollAmount=0,b.scrollAmount&&null===b.scrollingId?b.startScrolling():b.scrollAmount||null===b.scrollingId||b.stopScrolling()},startScrolling:function(){var c=a(document).height-a(window).height;b.scrollingId=window.setInterval(function(){var d=a(window).scrollTop(),e=Math.round(b.scrollAmount*b.SCROLL_SPEED);if(d+e<0&&(e=-d),d+e>c&&(e=c-d),0!==e){a(window).scrollTop(d+e);var f=a(window).scrollTop()-d;0!==f&&b.callback&&b.callback(f)}},b.SCROLL_FREQUENCY)},stopScrolling:function(){window.clearInterval(b.scrollingId),b.scrollingId=null}};return{start:b.start,stop:b.stop}}); \ No newline at end of file diff --git a/lib/amd/build/sortable_list.min.js b/lib/amd/build/sortable_list.min.js new file mode 100644 index 0000000000000..d4587b619fa9c --- /dev/null +++ b/lib/amd/build/sortable_list.min.js @@ -0,0 +1 @@ +define(["jquery","core/log","core/autoscroll","core/str","core/modal_factory","core/modal_events","core/notification"],function(a,b,c,d,e,f,g){var h={targetListSelector:null,moveHandlerSelector:null,isHorizontal:!1,autoScroll:!0},i={keyboardDragClass:"dragdrop-keyboard-drag",isDraggedClass:"sortable-list-is-dragged",currentPositionClass:"sortable-list-current-position",sourceListClass:"sortable-list-source",targetListClass:"sortable-list-target",overElementClass:"sortable-list-over-element"};a.event.special.touchstart={setup:function(a,b,c){return!!b.includes("notPassive")&&(this.addEventListener("touchstart",c,{passive:!1}),!0)}};var j=function(b,c){this.info=null,this.proxy=null,this.proxyDelta=null,this.dragCounter=0,this.lastEvent=null,this.config=a.extend({},h,c||{}),this.config.listSelector=b,this.config.targetListSelector||(this.config.targetListSelector=b),"object"==typeof this.config.listSelector?a(this.config.listSelector).on("mousedown touchstart.notPassive",a.proxy(this.dragStartHandler,this)):a("body").on("mousedown touchstart.notPassive",this.config.listSelector,a.proxy(this.dragStartHandler,this)),null!==this.config.moveHandlerSelector&&a("body").on("click keypress",this.config.moveHandlerSelector,a.proxy(this.clickHandler,this))};return j.EVENTS={DRAGSTART:"sortablelist-dragstart",DRAG:"sortablelist-drag",DROP:"sortablelist-drop",DRAGEND:"sortablelist-dragend"},j.prototype.resetDraggedClasses=function(){var b=[i.isDraggedClass,i.currentPositionClass,i.overElementClass,i.targetListClass];for(var c in b)a("."+b[c]).removeClass(b[c]);this.proxy&&(this.proxy.remove(),this.proxy=a())},j.prototype.calculatePositionOnPage=function(b){if(b.originalEvent&&b.originalEvent.touches&&void 0!==b.originalEvent.touches[0]){var c=b.originalEvent.touches[0];b.pageX=c.pageX,b.pageY=c.pageY}void 0===b.pageX?(b.pageX=this.lastEvent.pageX,b.pageY=this.lastEvent.pageY):this.lastEvent=b,void 0===b.clientX&&(b.clientX=Math.round(b.pageX-a(window).scrollLeft()),b.clientY=Math.round(b.pageY-a(window).scrollTop()))},j.prototype.dragStartHandler=function(b){if(null!==this.info){if("click"===this.info.type)return;this.moveElement(this.info.sourceList,this.info.sourceNextElement),this.finishDragging()}if("mousedown"!==b.type||1===b.which){this.calculatePositionOnPage(b);var d=a(b.target).closest(a(b.currentTarget).children());if(d.length&&(null===this.config.moveHandlerSelector||a(b.target).closest(this.config.moveHandlerSelector,d).length)){b.stopPropagation(),b.preventDefault(),this.dragCounter++,this.info={element:d,sourceNextElement:d.next(),sourceList:d.parent(),targetNextElement:d.next(),targetList:d.parent(),type:b.type,dropped:!1,startX:b.pageX,startY:b.pageY,startTime:(new Date).getTime()},a(this.config.targetListSelector).addClass(i.targetListClass);var e=d.offset();d.addClass(i.currentPositionClass),this.proxyDelta={x:e.left-b.pageX,y:e.top-b.pageY},this.proxy=a();var f=this.dragCounter;setTimeout(a.proxy(function(){null!==this.info&&"click"!==this.info.type&&"keypress"!==this.info.type&&this.dragCounter===f&&this.createProxy()},this),500),a(window).on("mousemove touchmove mouseup touchend",a.proxy(this.dragHandler,this)),a(window).on("keypress",a.proxy(this.dragcancelHandler,this)),this.config.autoScroll&&c.start(function(){a(window).trigger("mousemove")}),this.executeCallback(j.EVENTS.DRAGSTART)}}},j.prototype.createProxy=function(){this.proxy=this.info.element.clone(),this.info.sourceList.append(this.proxy),this.proxy.removeAttr("id").removeClass(i.currentPositionClass).addClass(i.isDraggedClass).css({position:"fixed"}),this.proxy.offset({top:this.proxyDelta.y+this.lastEvent.pageY,left:this.proxyDelta.x+this.lastEvent.pageX})},j.prototype.clickHandler=function(b){if(!("keypress"===b.type&&13!==b.originalEvent.keyCode&&32!==b.originalEvent.keyCode||null!==this.info&&"click"===this.info.type)){b.preventDefault(),b.stopPropagation();var c=a(b.currentTarget),d=c.closest(this.config.listSelector),e=c.closest(d.children());e.length&&(this.dragCounter++,this.info={element:e,sourceNextElement:e.next(),sourceList:d,targetNextElement:e.next(),targetList:d,dropped:!1,type:b.type,startTime:(new Date).getTime()},this.executeCallback(j.EVENTS.DRAGSTART),this.displayMoveDialogue(c))}},j.prototype.getPositionInNode=function(a,b,c){if(!c.length)return null;var d=c[0],e=0,f=d.getBoundingClientRect(),g=b-(f.top+window.scrollY),h=a-(f.left+window.scrollX);return h>=-e&&h<=f.width+e&&g>=-e&&g<=f.height+e?{x:h,y:g,xRatio:f.width?h/f.width:0,yRatio:f.height?g/f.height:0}:null},j.prototype.isListHorizontal=function(a){var b=this.config.isHorizontal;return b===!0||b===!1?b:b(a)},j.prototype.dragHandler=function(b){this.calculatePositionOnPage(b),this.proxy.offset({top:-1e3,left:-1e3});var c=a(document.elementFromPoint(b.clientX,b.clientY)),d=c.closest("."+i.targetListClass+" > :not(."+i.isDraggedClass+")"),e=c.closest("."+i.targetListClass),f=this.proxy,g=function(){return!f||!f.length||this!==f[0]};if(a("."+i.overElementClass).removeClass(i.overElementClass),d.addClass(i.overElementClass),this.proxy.offset({top:this.proxyDelta.y+b.pageY,left:this.proxyDelta.x+b.pageX}),e.length&&!e.children().filter(g).length)this.moveElement(e,a());else if(1===d.length&&!this.info.element.find(d[0]).length){var h=this.getPositionInNode(b.pageX,b.pageY,d);if(h){var k=d.parent(),l=this.isListHorizontal(k)?h.xRatio:h.yRatio,m=d.find("."+i.targetListClass),n=this.info.element[0],o=function(){return this!==n},p=!m.children().filter(g).filter(o).length;m.length&&p&&l>.2&&l<.8?this.moveElement(m,a()):l>.5?this.moveElement(k,d.next().filter(g)):this.moveElement(k,d)}}"mouseup"!==b.type&&"touchend"!==b.type||(this.info.endX=b.pageX,this.info.endY=b.pageY,this.info.endTime=(new Date).getTime(),this.info.dropped=!0,this.executeCallback(j.EVENTS.DROP),this.finishDragging())},j.prototype.moveElement=function(a,b){var c=this.info.element;b.length&&b[0]===c[0]||a[0]===this.info.targetList[0]&&b.length===this.info.targetNextElement.length&&b[0]===this.info.targetNextElement[0]||(b.length?a[0].insertBefore(c[0],b[0]):this.proxy&&this.proxy.parent().length&&this.proxy.parent()[0]===a[0]?a[0].insertBefore(c[0],this.proxy[0]):a[0].appendChild(c[0]),this.info.targetList=a,this.info.targetNextElement=b,this.executeCallback(j.EVENTS.DRAG))},j.prototype.finishDragging=function(){this.resetDraggedClasses(),this.config.autoScroll&&c.stop(),a(window).off("mousemove touchmove mouseup touchend",a.proxy(this.dragHandler,this)),a(window).off("keypress",a.proxy(this.dragcancelHandler,this)),this.executeCallback(j.EVENTS.DRAGEND),this.info=null},j.prototype.executeCallback=function(a){this.info.element.trigger(a,this.info)},j.prototype.dragcancelHandler=function(a){"keypress"===a.type&&27===a.originalEvent.keyCode&&(this.moveElement(this.info.sourceList,this.info.sourceNextElement),this.finishDragging())},j.prototype.getElementName=function(b){return a.Deferred().resolve(b.text())},j.prototype.getDestinationName=function(a,b){return b.length?this.getElementName(b).then(function(a){return d.get_string("movecontentafter","moodle",a)}):d.get_string("movecontenttothetop","moodle")},j.prototype.getMoveDialogueTitle=function(a){return this.getElementName(a).then(function(a){return d.get_string("movecontent","moodle",a)})},j.prototype.getDestinationsList=function(){var b=[],c=a(this.config.targetListSelector),d=a("