diff --git a/lib/yui/build/moodle-core-blocks/moodle-core-blocks-debug.js b/lib/yui/build/moodle-core-blocks/moodle-core-blocks-debug.js index 18f13976ba0..e281e73c1d7 100644 --- a/lib/yui/build/moodle-core-blocks/moodle-core-blocks-debug.js +++ b/lib/yui/build/moodle-core-blocks/moodle-core-blocks-debug.js @@ -447,11 +447,13 @@ MANAGER.prototype = { */ initializer: function() { Y.log('Initialising drag and drop for blocks.', 'info'); - var regionnames = this.get('regions'), - i = 0, - region, - regionname, - dragdelegation; + var regionnames = this.get('regions'); + var i = 0; + var dragContainer; + var dragdelegation; + var region; + var regionContainer; + var regionname; // Evil required by M.core.dragdrop. this.groups = ['block']; @@ -471,10 +473,11 @@ MANAGER.prototype = { for (i in regionnames) { regionname = regionnames[i]; + regionContainer = Y.one('#block-region-' + regionname); region = new BLOCKREGION({ manager: this, region: regionname, - node: Y.one('#block-region-' + regionname) + node: regionContainer, }); this.regionobjects[regionname] = region; @@ -496,11 +499,24 @@ MANAGER.prototype = { invalid: '.block-hider-hide, .block-hider-show, .moveto, .block_fake', dragConfig: {groups: this.groups} }); + dragdelegation.dd.plug(Y.Plugin.DDProxy, { // Don't move the node at the end of the drag moveOnEnd: false }); - dragdelegation.dd.plug(Y.Plugin.DDWinScroll); + + if (regionContainer === null) { + dragdelegation.dd.plug(Y.Plugin.DDWinScroll); + } else { + dragContainer = regionContainer.ancestor('.drag-container', true); + if (dragContainer) { + dragdelegation.dd.plug(Y.Plugin.DDNodeScroll, { + node: dragContainer, + }); + } else { + dragdelegation.dd.plug(Y.Plugin.DDWinScroll); + } + } // On the DD Manager start operation, we enable all block regions so that they can be drop targets. This // must be done *before* drag:start but after dragging has been initialised. @@ -600,6 +616,23 @@ MANAGER.prototype = { } }, + dragOver: function(e) { + var nearestRegion = e.drop.get('node').ancestor('.drag-container', true); + if (nearestRegion) { + if (e.drag[Y.Plugin.DDNodeScroll]) { + if (e.drag[Y.Plugin.DDNodeScroll].get('node') === nearestRegion) { + // Do not bother resetting the region - it has not changed. + return; + } else { + e.drag.unplug(Y.Plugin.DDNodeScroll); + } + } + e.drag.plug(Y.Plugin.DDNodeScroll, { + node: nearestRegion, + }); + } + }, + /** * Called by M.core.dragdrop.global_drop_over when something is dragged over a drop target. * @method drop_over diff --git a/lib/yui/build/moodle-core-blocks/moodle-core-blocks-min.js b/lib/yui/build/moodle-core-blocks/moodle-core-blocks-min.js index 3b1c49cf410..fd937e1481b 100644 --- a/lib/yui/build/moodle-core-blocks/moodle-core-blocks-min.js +++ b/lib/yui/build/moodle-core-blocks/moodle-core-blocks-min.js @@ -1,2 +1,2 @@ -YUI.add("moodle-core-blocks",function(a,e){var o,s,u="/lib/ajax/blocks.php",r="block",d="block-region",l="block_adminblock",n="editing_move",p="header",g="region-content",t="skip-block",h="skip-block-to",_="page-my-index",b="region-main",f="blocks-moving",c={DRAGHANDLE:"."+p+" .commands .moodle-core-dragdrop-draghandle"},i=function(){i.superclass.constructor.apply(this,arguments)};a.extend(i,M.core.dragdrop,{skipnodetop:null,skipnodebottom:null,dragsourceregion:null,initializer:function(){var e,o,t,i;if(this.groups=["block"],this.samenodeclass=r,this.parentnodeclass=g,0<(e=a.Node.all("body#"+_+" #"+b+" > ."+g)).size()&&((e=e.item(0)).addClass(d),e.set("id",g),e.one("div").addClass(g)),0===(e=a.Node.all("div."+d)).size())return!1;e.size()!==this.get("regions").length&&(o=a.Node.create("
").addClass(d),t=a.Node.create("
").addClass(g),o.appendChild(t),t=e.filter("#region-pre"),i=e.filter("#region-post"),0===t.size()&&1===i.size()?(o.setAttrs({id:"region-pre"}),i.item(0).insert(o,"before"),e.unshift(o)):0===i.size()&&1===t.size()&&(o.setAttrs({id:"region-post"}),t.item(0).insert(o,"after"),e.push(o))),e.each(function(e){var o;new a.DD.Drop({node:e.one("div."+g),groups:this.groups,padding:"40 240 40 240"}),(o=new a.DD.Delegate({container:e,nodes:"."+r,target:!0,handles:[c.DRAGHANDLE],invalid:".block-hider-hide, .block-hider-show, .moveto",dragConfig:{groups:this.groups}})).dd.plug(a.Plugin.DDProxy,{moveOnEnd:!1}),o.dd.plug(a.Plugin.DDWinScroll),e.all("."+r).each(function(e){var o=e.one("a."+n);o&&(o.replace(this.get_drag_handle(o.getAttribute("title"),"","iconsmall",!0)),e.one(c.DRAGHANDLE).setStyle("cursor","move"))},this)},this)},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(e){e=e.ancestor("div."+d).get("id").replace(/region-/i,"");return-1===a.Array.indexOf(this.get("regions"),e)?(window.right_to_left()&&("post"===e?e="pre":"pre"===e&&(e="post")),"side-"+e):e},get_region_id:function(e){return e.get("id").replace(/region-/i,"")},drag_start:function(e){e=e.target;this.dragsourceregion=e.get("node").ancestor("div."+d),e.get("node").previous()&&e.get("node").previous().hasClass(t)&&(this.skipnodetop=e.get("node").previous()),e.get("node").next()&&e.get("node").next().hasClass(h)&&(this.skipnodebottom=e.get("node").next()),a.one("body").addClass(f)},drop_over:function(e){var o,t=e.drag.get("node"),e=e.drop.get("node");if(e.hasClass(this.parentnodeclass)&&e.one("."+l)&&e.one("."+l).next("."+r)&&e.prepend(t),this.dragsourceregion.contains(e))return!1;t=a.one("body"),o=this.get_region_id(this.dragsourceregion),t.hasClass("side-"+o+"-only")&&t.removeClass("side-"+o+"-only"),o=this.get_region_id(e.ancestor("div."+d)),0===this.dragsourceregion.all("."+r).size()&&this.dragsourceregion.get("id").match(/(region-pre|region-post)/i)&&(t.hasClass("side-"+o+"-only")||t.addClass("side-"+o+"-only"))},drag_end:function(){this.skipnodetop=null,this.skipnodebottom=null,this.dragsourceregion=null,a.one("body").removeClass(f)},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(i){var n,e=i.drag,e=e.get("node"),o=i.drop.get("node");e.previous()&&e.previous().hasClass(t)&&e.insert(e.previous(),"after"),this.skipnodetop&&e.insert(this.skipnodetop,"before"),this.skipnodebottom&&e.insert(this.skipnodebottom,"after"),n=M.util.add_lightbox(a,e),o={sesskey:M.cfg.sesskey,courseid:this.get("courseid"),pagelayout:this.get("pagelayout"),pagetype:this.get("pagetype"),subpage:this.get("subpage"),contextid:this.get("contextid"),action:"move",bui_moveid:this.get_block_id(e),bui_newregion:this.get_block_region(o)},this.get("cmid")&&(o.cmid=this.get("cmid")),e.next("."+this.samenodeclass)&&!e.next("."+this.samenodeclass).hasClass(l)&&(o.bui_beforeid=this.get_block_id(e.next("."+this.samenodeclass))),a.io(M.cfg.wwwroot+u,{method:"POST",data:o,on:{start:function(){n.show()},success:function(e,o){window.setTimeout(function(){n.hide()},250);try{var t=a.JSON.parse(o.responseText);t.error&&new M.core.ajaxException(t)}catch(i){}},failure:function(e,o){this.ajax_failure(o),n.hide()}},context:this})}},{NAME:"core-blocks-dragdrop",ATTRS:{courseid:{value:null},cmid:{value:null},contextid:{value:null},pagelayout:{value:null},pagetype:{value:null},subpage:{value:null},regions:{value:null}}}),M.core=M.core||{},M.core.blockdraganddrop=M.core.blockdraganddrop||{},M.core.blockdraganddrop._isusingnewblocksmethod=null,M.core.blockdraganddrop.is_using_blocks_render_method=function(){var e,o;return null===this._isusingnewblocksmethod&&(e=a.all(".block-region[data-blockregion]").size(),o=a.all(".block-region").size(),this._isusingnewblocksmethod=o===e),this._isusingnewblocksmethod},M.core.blockdraganddrop.init=function(e){new(this.is_using_blocks_render_method()?o:i)(e)},M.core_blocks=M.core_blocks||{},M.core_blocks.init_dragdrop=function(e){M.core.blockdraganddrop.init(e)},(o=function(){o.superclass.constructor.apply(this,arguments)}).prototype={skipnodetop:null,skipnodebottom:null,regionobjects:{},initializer:function(){var e,o,t,i=this.get("regions"),n=0;for(n in this.groups=["block"],this.samenodeclass=r,this.parentnodeclass=d,this.detectkeyboarddirection=!0,0<(t=a.Node.all("body#"+_+" #"+b+" > ."+g)).size()&&((t=t.item(0)).addClass(d),t.set("id",g),t.one("div").addClass(g)),i)o=i[n],e=new s({manager:this,region:o,node:a.one("#block-region-"+o)}),this.regionobjects[o]=e,new a.DD.Drop({node:e.get_droptarget(),groups:this.groups,padding:"40 240 40 240"}),(o=new a.DD.Delegate({container:e.get_droptarget(),nodes:"."+r,target:!0,handles:[c.DRAGHANDLE],invalid:".block-hider-hide, .block-hider-show, .moveto, .block_fake",dragConfig:{groups:this.groups}})).dd.plug(a.Plugin.DDProxy,{moveOnEnd:!1}),o.dd.plug(a.Plugin.DDWinScroll),a.DD.DDM.on("ddm:start",this.enable_all_regions,this),e.change_block_move_icons(this)},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(e){return(e=e.test("[data-blockregion]")?e:e.ancestor( -"[data-blockregion]")).getData("blockregion")},get_region_object:function(e){return this.regionobjects[this.get_block_region(e)]},enable_all_regions:function(){var e,o=a.DD.DDM.activeDrag.get("groups");if(o&&-1!==a.Array.indexOf(o,"block"))for(e in this.regionobjects)this.regionobjects.hasOwnProperty(e)&&this.regionobjects[e].enable()},disable_regions_if_required:function(){var e=0;for(e in this.regionobjects)this.regionobjects[e].disable_if_required()},drag_start:function(e){e=e.target;e.get("node").previous()&&e.get("node").previous().hasClass(t)&&(this.skipnodetop=e.get("node").previous()),e.get("node").next()&&e.get("node").next().hasClass(h)&&(this.skipnodebottom=e.get("node").next())},drop_over:function(e){var o=e.drag.get("node"),e=e.drop.get("node");e.hasClass(g)&&e.one("."+l)&&e.one("."+l).next("."+r)&&e.prepend(o)},drop_end:function(){this.skipnodetop=null,this.skipnodebottom=null,this.disable_regions_if_required()},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(i){var n,e=i.drag.get("node"),o=i.drop.get("node");e.previous()&&e.previous().hasClass(t)&&e.insert(e.previous(),"after"),this.skipnodetop&&e.insert(this.skipnodetop,"before"),this.skipnodebottom&&e.insert(this.skipnodebottom,"after"),n=M.util.add_lightbox(a,e),o={sesskey:M.cfg.sesskey,courseid:this.get("courseid"),pagelayout:this.get("pagelayout"),pagetype:this.get("pagetype"),subpage:this.get("subpage"),contextid:this.get("contextid"),action:"move",bui_moveid:this.get_block_id(e),bui_newregion:this.get_block_region(o)},this.get("cmid")&&(o.cmid=this.get("cmid")),e.next("."+r)&&!e.next("."+r).hasClass(l)&&(o.bui_beforeid=this.get_block_id(e.next("."+r))),a.io(M.cfg.wwwroot+u,{method:"POST",data:o,on:{start:function(){n.show()},success:function(e,o){window.setTimeout(function(){n.hide()},250);try{var t=a.JSON.parse(o.responseText);t.error&&new M.core.ajaxException(t)}catch(i){}},failure:function(e,o){this.ajax_failure(o),n.hide()},complete:function(){this.disable_regions_if_required()}},context:this})}},a.extend(o,M.core.dragdrop,o.prototype,{NAME:"core-blocks-dragdrop-manager",ATTRS:{courseid:{value:null},cmid:{value:null},contextid:{value:null},pagelayout:{value:null},pagetype:{value:null},subpage:{value:null},regions:{value:[]}}}),(s=function(){s.superclass.constructor.apply(this,arguments)}).prototype={initializer:function(){var e=this.get("node"),e=e||this.create_and_add_node(),o=a.one("body"),e=0').addClass(d).setData("blockregion",t),i=this.get("manager").get("regions"),n=!1,s=!1,r=!1;for(e in i)i[e].match(/(pre|left)/)?n=i[e]:i[e].match(/(post|right)/)&&(s=i[e]);return!1!==n&&!1!==s&&(t===n?(t=a.one("#block-region-"+s))&&(t.insert(o,"before"),r=!0):(t=a.one("#block-region-"+n))&&(t.insert(o,"after"),r=!0)),!1===r&&a.one("body").append(o),this.set("node",o),o},change_block_move_icons:function(o){var t;this.get("node").all("."+r+" a."+n).each(function(e){e.setStyle("cursor","move"),t=o.get_drag_handle(e.getAttribute("title"),"","icon",!0),e.replace(t)})},get_has_region_class:function(){return"has-region-"+this.get("region")},get_empty_region_class:function(){return"empty-region-"+this.get("region")},get_used_region_class:function(){return"used-region-"+this.get("region")},get_droptarget:function(){var e=this.get("node");return e.test('[data-droptarget="1"]')?e:e.one('[data-droptarget="1"]')},enable:function(){a.one("body").addClass(this.get_used_region_class()).removeClass(this.get_empty_region_class())},disable_if_required:function(){0===this.get("node").all("."+r).size()&&a.one("body").addClass(this.get_empty_region_class()).removeClass(this.get_used_region_class())}},a.extend(s,a.Base,s.prototype,{NAME:"core-blocks-dragdrop-blockregion",ATTRS:{manager:{writeOnce:"initOnly",validator:function(e){return a.Lang.isObject(e)&&e instanceof o}},region:{writeOnce:"initOnly",validator:function(e){return a.Lang.isString(e)}},node:{validator:function(e){return a.Lang.isObject(e)||a.Lang.isNull(e)}},hasblocks:{value:!1,validator:function(e){return a.Lang.isBoolean(e)}}}})},"@VERSION@",{requires:["base","node","io","dom","dd","dd-scroll","moodle-core-dragdrop","moodle-core-notification"]}); \ No newline at end of file +YUI.add("moodle-core-blocks",function(a,e){var o,d,r="/lib/ajax/blocks.php",l="block",g="block-region",s="block_adminblock",n="editing_move",p="header",c="region-content",t="skip-block",h="skip-block-to",_="page-my-index",b="region-main",f="blocks-moving",u={DRAGHANDLE:"."+p+" .commands .moodle-core-dragdrop-draghandle"},i=function(){i.superclass.constructor.apply(this,arguments)};a.extend(i,M.core.dragdrop,{skipnodetop:null,skipnodebottom:null,dragsourceregion:null,initializer:function(){var e,o,t,i;if(this.groups=["block"],this.samenodeclass=l,this.parentnodeclass=c,0<(e=a.Node.all("body#"+_+" #"+b+" > ."+c)).size()&&((e=e.item(0)).addClass(g),e.set("id",c),e.one("div").addClass(c)),0===(e=a.Node.all("div."+g)).size())return!1;e.size()!==this.get("regions").length&&(o=a.Node.create("
").addClass(g),t=a.Node.create("
").addClass(c),o.appendChild(t),t=e.filter("#region-pre"),i=e.filter("#region-post"),0===t.size()&&1===i.size()?(o.setAttrs({id:"region-pre"}),i.item(0).insert(o,"before"),e.unshift(o)):0===i.size()&&1===t.size()&&(o.setAttrs({id:"region-post"}),t.item(0).insert(o,"after"),e.push(o))),e.each(function(e){var o;new a.DD.Drop({node:e.one("div."+c),groups:this.groups,padding:"40 240 40 240"}),(o=new a.DD.Delegate({container:e,nodes:"."+l,target:!0,handles:[u.DRAGHANDLE],invalid:".block-hider-hide, .block-hider-show, .moveto",dragConfig:{groups:this.groups}})).dd.plug(a.Plugin.DDProxy,{moveOnEnd:!1}),o.dd.plug(a.Plugin.DDWinScroll),e.all("."+l).each(function(e){var o=e.one("a."+n);o&&(o.replace(this.get_drag_handle(o.getAttribute("title"),"","iconsmall",!0)),e.one(u.DRAGHANDLE).setStyle("cursor","move"))},this)},this)},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(e){e=e.ancestor("div."+g).get("id").replace(/region-/i,"");return-1===a.Array.indexOf(this.get("regions"),e)?(window.right_to_left()&&("post"===e?e="pre":"pre"===e&&(e="post")),"side-"+e):e},get_region_id:function(e){return e.get("id").replace(/region-/i,"")},drag_start:function(e){e=e.target;this.dragsourceregion=e.get("node").ancestor("div."+g),e.get("node").previous()&&e.get("node").previous().hasClass(t)&&(this.skipnodetop=e.get("node").previous()),e.get("node").next()&&e.get("node").next().hasClass(h)&&(this.skipnodebottom=e.get("node").next()),a.one("body").addClass(f)},drop_over:function(e){var o,t=e.drag.get("node"),e=e.drop.get("node");if(e.hasClass(this.parentnodeclass)&&e.one("."+s)&&e.one("."+s).next("."+l)&&e.prepend(t),this.dragsourceregion.contains(e))return!1;t=a.one("body"),o=this.get_region_id(this.dragsourceregion),t.hasClass("side-"+o+"-only")&&t.removeClass("side-"+o+"-only"),o=this.get_region_id(e.ancestor("div."+g)),0===this.dragsourceregion.all("."+l).size()&&this.dragsourceregion.get("id").match(/(region-pre|region-post)/i)&&(t.hasClass("side-"+o+"-only")||t.addClass("side-"+o+"-only"))},drag_end:function(){this.skipnodetop=null,this.skipnodebottom=null,this.dragsourceregion=null,a.one("body").removeClass(f)},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(i){var n,e=i.drag,e=e.get("node"),o=i.drop.get("node");e.previous()&&e.previous().hasClass(t)&&e.insert(e.previous(),"after"),this.skipnodetop&&e.insert(this.skipnodetop,"before"),this.skipnodebottom&&e.insert(this.skipnodebottom,"after"),n=M.util.add_lightbox(a,e),o={sesskey:M.cfg.sesskey,courseid:this.get("courseid"),pagelayout:this.get("pagelayout"),pagetype:this.get("pagetype"),subpage:this.get("subpage"),contextid:this.get("contextid"),action:"move",bui_moveid:this.get_block_id(e),bui_newregion:this.get_block_region(o)},this.get("cmid")&&(o.cmid=this.get("cmid")),e.next("."+this.samenodeclass)&&!e.next("."+this.samenodeclass).hasClass(s)&&(o.bui_beforeid=this.get_block_id(e.next("."+this.samenodeclass))),a.io(M.cfg.wwwroot+r,{method:"POST",data:o,on:{start:function(){n.show()},success:function(e,o){window.setTimeout(function(){n.hide()},250);try{var t=a.JSON.parse(o.responseText);t.error&&new M.core.ajaxException(t)}catch(i){}},failure:function(e,o){this.ajax_failure(o),n.hide()}},context:this})}},{NAME:"core-blocks-dragdrop",ATTRS:{courseid:{value:null},cmid:{value:null},contextid:{value:null},pagelayout:{value:null},pagetype:{value:null},subpage:{value:null},regions:{value:null}}}),M.core=M.core||{},M.core.blockdraganddrop=M.core.blockdraganddrop||{},M.core.blockdraganddrop._isusingnewblocksmethod=null,M.core.blockdraganddrop.is_using_blocks_render_method=function(){var e,o;return null===this._isusingnewblocksmethod&&(e=a.all(".block-region[data-blockregion]").size(),o=a.all(".block-region").size(),this._isusingnewblocksmethod=o===e),this._isusingnewblocksmethod},M.core.blockdraganddrop.init=function(e){new(this.is_using_blocks_render_method()?o:i)(e)},M.core_blocks=M.core_blocks||{},M.core_blocks.init_dragdrop=function(e){M.core.blockdraganddrop.init(e)},(o=function(){o.superclass.constructor.apply(this,arguments)}).prototype={skipnodetop:null,skipnodebottom:null,regionobjects:{},initializer:function(){var e,o,t,i,n,s=this.get("regions"),r=0;for(r in this.groups=["block"],this.samenodeclass=l,this.parentnodeclass=g,this.detectkeyboarddirection=!0,0<(n=a.Node.all("body#"+_+" #"+b+" > ."+c)).size()&&((n=n.item(0)).addClass(g),n.set("id",c),n.one("div").addClass(c)),s)i=s[r],t=a.one("#block-region-"+i),o=new d({manager:this,region:i,node:t}),this.regionobjects[i]=o,new a.DD.Drop({node:o.get_droptarget(),groups:this.groups,padding:"40 240 40 240"}),(i=new a.DD.Delegate({container:o.get_droptarget(),nodes:"."+l,target:!0,handles:[u.DRAGHANDLE],invalid:".block-hider-hide, .block-hider-show, .moveto, .block_fake",dragConfig:{groups:this.groups}})).dd.plug(a.Plugin.DDProxy,{moveOnEnd:!1}),null!==t&&(e=t.ancestor(".drag-container",!0))?i.dd.plug(a.Plugin.DDNodeScroll,{node:e}):i.dd.plug(a.Plugin.DDWinScroll),a.DD.DDM.on("ddm:start",this.enable_all_regions,this),o.change_block_move_icons(this)},get_block_id:function(e){return Number(e.get("id").replace( +/inst/i,""))},get_block_region:function(e){return(e=e.test("[data-blockregion]")?e:e.ancestor("[data-blockregion]")).getData("blockregion")},get_region_object:function(e){return this.regionobjects[this.get_block_region(e)]},enable_all_regions:function(){var e,o=a.DD.DDM.activeDrag.get("groups");if(o&&-1!==a.Array.indexOf(o,"block"))for(e in this.regionobjects)this.regionobjects.hasOwnProperty(e)&&this.regionobjects[e].enable()},disable_regions_if_required:function(){var e=0;for(e in this.regionobjects)this.regionobjects[e].disable_if_required()},drag_start:function(e){e=e.target;e.get("node").previous()&&e.get("node").previous().hasClass(t)&&(this.skipnodetop=e.get("node").previous()),e.get("node").next()&&e.get("node").next().hasClass(h)&&(this.skipnodebottom=e.get("node").next())},dragOver:function(e){var o=e.drop.get("node").ancestor(".drag-container",!0);if(o){if(e.drag[a.Plugin.DDNodeScroll]){if(e.drag[a.Plugin.DDNodeScroll].get("node")===o)return;e.drag.unplug(a.Plugin.DDNodeScroll)}e.drag.plug(a.Plugin.DDNodeScroll,{node:o})}},drop_over:function(e){var o=e.drag.get("node"),e=e.drop.get("node");e.hasClass(c)&&e.one("."+s)&&e.one("."+s).next("."+l)&&e.prepend(o)},drop_end:function(){this.skipnodetop=null,this.skipnodebottom=null,this.disable_regions_if_required()},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(i){var n,e=i.drag.get("node"),o=i.drop.get("node");e.previous()&&e.previous().hasClass(t)&&e.insert(e.previous(),"after"),this.skipnodetop&&e.insert(this.skipnodetop,"before"),this.skipnodebottom&&e.insert(this.skipnodebottom,"after"),n=M.util.add_lightbox(a,e),o={sesskey:M.cfg.sesskey,courseid:this.get("courseid"),pagelayout:this.get("pagelayout"),pagetype:this.get("pagetype"),subpage:this.get("subpage"),contextid:this.get("contextid"),action:"move",bui_moveid:this.get_block_id(e),bui_newregion:this.get_block_region(o)},this.get("cmid")&&(o.cmid=this.get("cmid")),e.next("."+l)&&!e.next("."+l).hasClass(s)&&(o.bui_beforeid=this.get_block_id(e.next("."+l))),a.io(M.cfg.wwwroot+r,{method:"POST",data:o,on:{start:function(){n.show()},success:function(e,o){window.setTimeout(function(){n.hide()},250);try{var t=a.JSON.parse(o.responseText);t.error&&new M.core.ajaxException(t)}catch(i){}},failure:function(e,o){this.ajax_failure(o),n.hide()},complete:function(){this.disable_regions_if_required()}},context:this})}},a.extend(o,M.core.dragdrop,o.prototype,{NAME:"core-blocks-dragdrop-manager",ATTRS:{courseid:{value:null},cmid:{value:null},contextid:{value:null},pagelayout:{value:null},pagetype:{value:null},subpage:{value:null},regions:{value:[]}}}),(d=function(){d.superclass.constructor.apply(this,arguments)}).prototype={initializer:function(){var e=this.get("node"),e=e||this.create_and_add_node(),o=a.one("body"),e=0').addClass(g).setData("blockregion",t),i=this.get("manager").get("regions"),n=!1,s=!1,r=!1;for(e in i)i[e].match(/(pre|left)/)?n=i[e]:i[e].match(/(post|right)/)&&(s=i[e]);return!1!==n&&!1!==s&&(t===n?(t=a.one("#block-region-"+s))&&(t.insert(o,"before"),r=!0):(t=a.one("#block-region-"+n))&&(t.insert(o,"after"),r=!0)),!1===r&&a.one("body").append(o),this.set("node",o),o},change_block_move_icons:function(o){var t;this.get("node").all("."+l+" a."+n).each(function(e){e.setStyle("cursor","move"),t=o.get_drag_handle(e.getAttribute("title"),"","icon",!0),e.replace(t)})},get_has_region_class:function(){return"has-region-"+this.get("region")},get_empty_region_class:function(){return"empty-region-"+this.get("region")},get_used_region_class:function(){return"used-region-"+this.get("region")},get_droptarget:function(){var e=this.get("node");return e.test('[data-droptarget="1"]')?e:e.one('[data-droptarget="1"]')},enable:function(){a.one("body").addClass(this.get_used_region_class()).removeClass(this.get_empty_region_class())},disable_if_required:function(){0===this.get("node").all("."+l).size()&&a.one("body").addClass(this.get_empty_region_class()).removeClass(this.get_used_region_class())}},a.extend(d,a.Base,d.prototype,{NAME:"core-blocks-dragdrop-blockregion",ATTRS:{manager:{writeOnce:"initOnly",validator:function(e){return a.Lang.isObject(e)&&e instanceof o}},region:{writeOnce:"initOnly",validator:function(e){return a.Lang.isString(e)}},node:{validator:function(e){return a.Lang.isObject(e)||a.Lang.isNull(e)}},hasblocks:{value:!1,validator:function(e){return a.Lang.isBoolean(e)}}}})},"@VERSION@",{requires:["base","node","io","dom","dd","dd-scroll","moodle-core-dragdrop","moodle-core-notification"]}); \ No newline at end of file diff --git a/lib/yui/build/moodle-core-blocks/moodle-core-blocks.js b/lib/yui/build/moodle-core-blocks/moodle-core-blocks.js index c4c7a57b517..9f1d8541bbd 100644 --- a/lib/yui/build/moodle-core-blocks/moodle-core-blocks.js +++ b/lib/yui/build/moodle-core-blocks/moodle-core-blocks.js @@ -443,11 +443,13 @@ MANAGER.prototype = { * @method initializer */ initializer: function() { - var regionnames = this.get('regions'), - i = 0, - region, - regionname, - dragdelegation; + var regionnames = this.get('regions'); + var i = 0; + var dragContainer; + var dragdelegation; + var region; + var regionContainer; + var regionname; // Evil required by M.core.dragdrop. this.groups = ['block']; @@ -467,10 +469,11 @@ MANAGER.prototype = { for (i in regionnames) { regionname = regionnames[i]; + regionContainer = Y.one('#block-region-' + regionname); region = new BLOCKREGION({ manager: this, region: regionname, - node: Y.one('#block-region-' + regionname) + node: regionContainer, }); this.regionobjects[regionname] = region; @@ -492,11 +495,24 @@ MANAGER.prototype = { invalid: '.block-hider-hide, .block-hider-show, .moveto, .block_fake', dragConfig: {groups: this.groups} }); + dragdelegation.dd.plug(Y.Plugin.DDProxy, { // Don't move the node at the end of the drag moveOnEnd: false }); - dragdelegation.dd.plug(Y.Plugin.DDWinScroll); + + if (regionContainer === null) { + dragdelegation.dd.plug(Y.Plugin.DDWinScroll); + } else { + dragContainer = regionContainer.ancestor('.drag-container', true); + if (dragContainer) { + dragdelegation.dd.plug(Y.Plugin.DDNodeScroll, { + node: dragContainer, + }); + } else { + dragdelegation.dd.plug(Y.Plugin.DDWinScroll); + } + } // On the DD Manager start operation, we enable all block regions so that they can be drop targets. This // must be done *before* drag:start but after dragging has been initialised. @@ -595,6 +611,23 @@ MANAGER.prototype = { } }, + dragOver: function(e) { + var nearestRegion = e.drop.get('node').ancestor('.drag-container', true); + if (nearestRegion) { + if (e.drag[Y.Plugin.DDNodeScroll]) { + if (e.drag[Y.Plugin.DDNodeScroll].get('node') === nearestRegion) { + // Do not bother resetting the region - it has not changed. + return; + } else { + e.drag.unplug(Y.Plugin.DDNodeScroll); + } + } + e.drag.plug(Y.Plugin.DDNodeScroll, { + node: nearestRegion, + }); + } + }, + /** * Called by M.core.dragdrop.global_drop_over when something is dragged over a drop target. * @method drop_over diff --git a/lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-debug.js b/lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-debug.js index dc7fe32f54a..b945b529cc1 100644 --- a/lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-debug.js +++ b/lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-debug.js @@ -131,6 +131,9 @@ Y.extend(DRAGDROP, Y.Base, { // Listen for all drag:start events. this.listeners.push(Y.DD.DDM.on('drag:start', this.global_drag_start, this)); + // Listen for all drag:over events. + this.listeners.push(Y.DD.DDM.on('drag:over', this.globalDragOver, this)); + // Listen for all drag:end events. this.listeners.push(Y.DD.DDM.on('drag:end', this.global_drag_end, this)); @@ -226,8 +229,8 @@ Y.extend(DRAGDROP, Y.Base, { return ret; }, /* - * Drag-dropping related functions - */ + * Drag-dropping related functions + */ global_drag_start: function(e) { // Get our drag object var drag = e.target; @@ -248,6 +251,15 @@ Y.extend(DRAGDROP, Y.Base, { this.drag_start(e); }, + /** + * Drag-dropping related functions + * + * @param {EventFacade} e + */ + globalDragOver: function(e) { + this.dragOver(e); + }, + global_drag_end: function(e) { var drag = e.target; // Check that drag object belongs to correct group @@ -689,6 +701,14 @@ Y.extend(DRAGDROP, Y.Base, { */ drag_start: function() {}, + /** + * Callback to use for the drag:over event. + * + * @method dragOver + * @param {EventFacade} e + */ + dragOver: function() {}, + /** * Callback to use when dragging ends. * diff --git a/lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-min.js b/lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-min.js index 4233ca749f6..d4808669052 100644 --- a/lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-min.js +++ b/lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-min.js @@ -1,2 +1,2 @@ -YUI.add("moodle-core-dragdrop",function(h,t){var i="moodle-core-dragdrop-draghandle",e=function(){e.superclass.constructor.apply(this,arguments)};h.extend(e,h.Base,{goingup:null,absgoingup:null,samenodeclass:null,parentnodeclass:null,samenodelabel:null,parentnodelabel:null,groups:[],lastdroptarget:null,detectkeyboarddirection:!1,listeners:null,initializer:function(){this.listeners=[],this.listeners.push(h.DD.DDM.on("drag:start",this.global_drag_start,this)),this.listeners.push(h.DD.DDM.on("drag:end",this.global_drag_end,this)),this.listeners.push(h.DD.DDM.on("drag:drag",this.global_drag_drag,this)),this.listeners.push(h.DD.DDM.on("drop:over",this.global_drop_over,this)),this.listeners.push(h.DD.DDM.on("drop:hit",this.global_drop_hit,this)),this.listeners.push(h.DD.DDM.on("drag:dropmiss",this.global_drag_dropmiss,this)),this.listeners.push(h.one(h.config.doc.body).delegate("key",this.global_keydown,"down:32, enter, esc","."+i,this)),this.listeners.push(h.one(h.config.doc.body).delegate("click",this.global_keydown,"."+i,this))},destructor:function(){new h.EventHandle(this.listeners).detach()},get_drag_handle:function(t,e,o){var r=h.Node.create("").addClass(e).setAttribute("title",t).setAttribute("tabIndex",0).setAttribute("data-draggroups",this.groups).setAttribute("role","button");return r.addClass(i),window.require(["core/templates"],function(t){t.renderPix("i/move_2d","core").then(function(t){t=h.Node.create(t);t.setStyle("cursor","move"),void 0!==o&&t.addClass(o),r.appendChild(t)})}),r},lock_drag_handle:function(t,e){t.removeHandle("."+e)},unlock_drag_handle:function(t,e){t.addHandle("."+e),t.get("activeHandle").focus()},ajax_failure:function(t){t={name:t.status+" "+t.statusText,message:t.responseText};return new M.core.exception(t)},in_group:function(e){var o=!1;return h.each(this.groups,function(t){e._groups[t]&&(o=!0)},this),o},global_drag_start:function(t){var e=t.target;this.in_group(e)&&(this.originalstyle=e.get("node").getAttribute("style"),e.get("node").setStyle("opacity",".25"),e.get("dragNode").setStyles({opacity:".75",borderColor:e.get("node").getStyle("borderColor"),backgroundColor:e.get("node").getStyle("backgroundColor")}),e.get("dragNode").empty(),this.drag_start(t))},global_drag_end:function(t){var e=t.target;this.in_group(e)&&(e.get("node").setAttribute("style",this.originalstyle),this.drag_end(t))},global_drag_drag:function(t){var e=t.target,o=t.info;this.in_group(e)&&(o.start[1]o.xy[1]&&(this.absgoingup=!1),o.delta[1]<0?this.goingup=!0:0")).addClass("dragdrop-keyboard-drag"),h.all("."+this.samenodeclass+", ."+this.parentnodeclass).each(function(t){var e,o,r,a=!1,n=t,d=t.getAttribute("class").split(" ").join(", .");if(t.drop&&t.drop.inGroup(this.groups)&&t.drop.get("node")!==i&&(t.next(d)!==i||this.detectkeyboarddirection))a=!0;else for(e=t.getAttribute("data-draggroups").split(" "),o=0;o"),p=h.Node.create(""),s=this.find_element_text(n),u=this.samenodelabel&&t.hasClass(this.samenodeclass)?M.util.get_string(this.samenodelabel.identifier,this.samenodelabel.component,s):this.parentnodelabel&&t.hasClass(this.parentnodeclass)?M.util.get_string(this.parentnodelabel.identifier,this.parentnodelabel.component,s):M.util.get_string("tocontent","moodle",s),p.setContent(u),p.setAttribute("data-drop-target",t.get("id")),p.setAttribute("tabindex","0"),p.on("click",this.global_keyboard_drop,this),p.on("key",this.global_keyboard_drop,"down:enter,32",this),g.append(p),l.append(g))},this),M.core.dragdrop.dropui=new M.core.dialogue({headerContent:e,bodyContent:l,draggable:!0,visible:!0,center:!0,modal:!0}),M.core.dragdrop.dropui.after("visibleChange",function(t){t.prevVal&&!t.newVal&&this.global_cancel_keyboard_drag()},this),l.one("a")&&l.one("a").focus()},simulated_drag_drop_event:function(t,e){var o=function(t){this.node=t};o.prototype.get=function(t){return"node"===t||"dragNode"===t||"dropNode"===t?this.node:"activeHandle"===t?this.node.one(".editing_move"):null},o.prototype.inGroup=function(){return!0},o.prototype.addHandle=function(){},o.prototype.removeHandle=function(){},this.drop=new o(e),this.drag=new o(t),this.target=this.drop},global_keyboard_drop:function(t){var e,o=M.core.dragdrop.keydragcontainer,r=h.one("#"+t.target.getAttribute("data-drop-target"));M.core.dragdrop.dropui.hide(),t.preventDefault(),this.detectkeyboarddirection&&o.getY()>r.getY()?(this.absgoingup=!0,this.goingup=!0):(this.absgoingup=!1, -this.goingup=!1),t=new this.simulated_drag_drop_event(o,o),e=new this.simulated_drag_drop_event(o,r),this.drag_start(t),this.global_drop_over(e),r.hasClass(this.parentnodeclass)&&r.contains(o)&&r.prepend(o),this.global_drop_hit(e)},global_cancel_keyboard_drag:function(){M.core.dragdrop.keydragcontainer&&(M.core.dragdrop.keydraghandle.focus(),M.core.dragdrop.keydragcontainer=null),M.core.dragdrop.dropui&&M.core.dragdrop.dropui.destroy()},global_keydown:function(t){var e,o,r,a,n,d=t.target.ancestor("."+i,!0);if(null!==d){if(27===t.keyCode)return this.global_cancel_keyboard_drag(),void t.preventDefault();if(d.hasClass(i)&&(13===t.keyCode||32===t.keyCode||"click"===t.type)){for(o=d.getAttribute("data-draggroups").split(" "),n=!1,r=0;r").addClass(e).setAttribute("title",t).setAttribute("tabIndex",0).setAttribute("data-draggroups",this.groups).setAttribute("role","button");return r.addClass(d),window.require(["core/templates"],function(t){t.renderPix("i/move_2d","core").then(function(t){t=h.Node.create(t);t.setStyle("cursor","move"),void 0!==o&&t.addClass(o),r.appendChild(t)})}),r},lock_drag_handle:function(t,e){t.removeHandle("."+e)},unlock_drag_handle:function(t,e){t.addHandle("."+e),t.get("activeHandle").focus()},ajax_failure:function(t){t={name:t.status+" "+t.statusText,message:t.responseText};return new M.core.exception(t)},in_group:function(e){var o=!1;return h.each(this.groups,function(t){e._groups[t]&&(o=!0)},this),o},global_drag_start:function(t){var e=t.target;this.in_group(e)&&(this.originalstyle=e.get("node").getAttribute("style"),e.get("node").setStyle("opacity",".25"),e.get("dragNode").setStyles({opacity:".75",borderColor:e.get("node").getStyle("borderColor"),backgroundColor:e.get("node").getStyle("backgroundColor")}),e.get("dragNode").empty(),this.drag_start(t))},globalDragOver:function(t){this.dragOver(t)},global_drag_end:function(t){var e=t.target;this.in_group(e)&&(e.get("node").setAttribute("style",this.originalstyle),this.drag_end(t))},global_drag_drag:function(t){var e=t.target,o=t.info;this.in_group(e)&&(o.start[1]o.xy[1]&&(this.absgoingup=!1),o.delta[1]<0?this.goingup=!0:0")).addClass("dragdrop-keyboard-drag"),h.all("."+this.samenodeclass+", ."+this.parentnodeclass).each(function(t){var e,o,r,a=!1,n=t,i=t.getAttribute("class").split(" ").join(", .");if(t.drop&&t.drop.inGroup(this.groups)&&t.drop.get("node")!==d&&(t.next(i)!==d||this.detectkeyboarddirection))a=!0;else for(e=t.getAttribute("data-draggroups").split(" "),o=0;o"),p=h.Node.create(""),s=this.find_element_text(n),u=this.samenodelabel&&t.hasClass(this.samenodeclass)?M.util.get_string(this.samenodelabel.identifier,this.samenodelabel.component,s):this.parentnodelabel&&t.hasClass(this.parentnodeclass)?M.util.get_string(this.parentnodelabel.identifier,this.parentnodelabel.component,s):M.util.get_string("tocontent","moodle",s),p.setContent(u),p.setAttribute("data-drop-target",t.get("id")),p.setAttribute("tabindex","0"),p.on("click",this.global_keyboard_drop,this),p.on("key",this.global_keyboard_drop,"down:enter,32",this),g.append(p),l.append(g))},this),M.core.dragdrop.dropui=new M.core.dialogue({headerContent:e,bodyContent:l,draggable:!0,visible:!0,center:!0,modal:!0}),M.core.dragdrop.dropui.after("visibleChange",function(t){t.prevVal&&!t.newVal&&this.global_cancel_keyboard_drag()},this),l.one("a")&&l.one("a").focus()},simulated_drag_drop_event:function(t,e){var o=function(t){this.node=t};o.prototype.get=function(t){return"node"===t||"dragNode"===t||"dropNode"===t?this.node:"activeHandle"===t?this.node.one(".editing_move"):null},o.prototype.inGroup=function(){return!0},o.prototype.addHandle=function(){},o.prototype.removeHandle=function(){},this.drop=new o(e),this.drag=new o(t),this.target=this.drop},global_keyboard_drop:function(t){var e,o=M.core.dragdrop.keydragcontainer,r=h.one("#"+t.target.getAttribute("data-drop-target"));M.core.dragdrop.dropui.hide(), +t.preventDefault(),this.detectkeyboarddirection&&o.getY()>r.getY()?(this.absgoingup=!0,this.goingup=!0):(this.absgoingup=!1,this.goingup=!1),t=new this.simulated_drag_drop_event(o,o),e=new this.simulated_drag_drop_event(o,r),this.drag_start(t),this.global_drop_over(e),r.hasClass(this.parentnodeclass)&&r.contains(o)&&r.prepend(o),this.global_drop_hit(e)},global_cancel_keyboard_drag:function(){M.core.dragdrop.keydragcontainer&&(M.core.dragdrop.keydraghandle.focus(),M.core.dragdrop.keydragcontainer=null),M.core.dragdrop.dropui&&M.core.dragdrop.dropui.destroy()},global_keydown:function(t){var e,o,r,a,n,i=t.target.ancestor("."+d,!0);if(null!==i){if(27===t.keyCode)return this.global_cancel_keyboard_drag(),void t.preventDefault();if(i.hasClass(d)&&(13===t.keyCode||32===t.keyCode||"click"===t.type)){for(o=i.getAttribute("data-draggroups").split(" "),n=!1,r=0;r -
+
{{$drawercontent}}{{/drawercontent}}
diff --git a/theme/boost/templates/drawers.mustache b/theme/boost/templates/drawers.mustache index 8d46dbf9e40..3f1c7b185be 100644 --- a/theme/boost/templates/drawers.mustache +++ b/theme/boost/templates/drawers.mustache @@ -89,7 +89,7 @@ {{$closebuttontext}}{{#str}}closeblockdrawer, core{{/str}}{{/closebuttontext}} {{/ theme_boost/drawer}} {{/hasblocks}} -
+
{{#courseindex}}