From dc396cf1e23e1e4019492a0479f9536d26afda0e Mon Sep 17 00:00:00 2001 From: Rajeev S Date: Wed, 9 Apr 2014 10:34:14 +0530 Subject: [PATCH 01/22] MDL-43789: coursename disallows spaces in user bulk actions filter coursename filter for user bulk actions.This prevents filtering based upon courserole if the coursename contains spaces or other non alphanumeric characters. --- user/filters/courserole.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user/filters/courserole.php b/user/filters/courserole.php index 09d3d7f0f8a..22dad4e5fcc 100644 --- a/user/filters/courserole.php +++ b/user/filters/courserole.php @@ -46,7 +46,7 @@ class user_filter_courserole extends user_filter_type { $objs[] =& $mform->createElement('select', $this->_name .'_ct', null, $this->get_course_categories()); $objs[] =& $mform->createElement('text', $this->_name, null); $grp =& $mform->addElement('group', $this->_name.'_grp', $this->_label, $objs, '', false); - $mform->setType($this->_name, PARAM_ALPHANUMEXT); + $mform->setType($this->_name, PARAM_TEXT); if ($this->_advanced) { $mform->setAdvanced($this->_name.'_grp'); } From 6e3006e35923325e12cc1fede7126c05778bd7e4 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Wed, 9 Apr 2014 15:10:16 +0800 Subject: [PATCH 02/22] MDL-45010 mod_chat: Use H3 instead of H2 in recent activity info --- mod/chat/lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/chat/lib.php b/mod/chat/lib.php index 39823327e8b..c44b800090a 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -329,7 +329,7 @@ function chat_print_recent_activity($course, $viewfullnames, $timestart) { $strftimerecent = get_string('strftimerecent'); if ($past) { - echo $OUTPUT->heading(get_string("pastchats", 'chat').':'); + echo $OUTPUT->heading(get_string("pastchats", 'chat').':', 3); foreach ($past as $cm) { $link = $CFG->wwwroot.'/mod/chat/view.php?id='.$cm->id; @@ -340,7 +340,7 @@ function chat_print_recent_activity($course, $viewfullnames, $timestart) { } if ($current) { - echo $OUTPUT->heading(get_string("currentchats", 'chat').':'); + echo $OUTPUT->heading(get_string("currentchats", 'chat').':', 3); $oldest = floor((time()-$CFG->chat_old_ping)/10)*10; // better db caching From c6838d107de77769a54f1c1c99d318d9e4d43b30 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Mon, 13 Jan 2014 22:03:55 +0100 Subject: [PATCH 03/22] MDL-43673 wiki: verify page tags work as expected This covers MDL-43109, verifying that saved tags are available on re-edition of a page, without any warning/error. Also official tags are verified to be working ok. With support for multiple options added by MDL-43713 and MDL-43738. --- mod/wiki/tests/behat/edit_tags.feature | 70 ++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 mod/wiki/tests/behat/edit_tags.feature diff --git a/mod/wiki/tests/behat/edit_tags.feature b/mod/wiki/tests/behat/edit_tags.feature new file mode 100644 index 00000000000..a3e3dfd0a73 --- /dev/null +++ b/mod/wiki/tests/behat/edit_tags.feature @@ -0,0 +1,70 @@ +@mod @mod_wiki +Feature: Edited wiki pages handle tags correctly + In order to get wiki pages properly labelled + As a user + I need to introduce the tags while editing + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@asd.com | + | student1 | Student | 1 | student1@asd.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + And I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + And I add a "Wiki" to section "1" and I fill the form with: + | Wiki name | Test wiki name | + | Description | Test wiki description | + | First page name | First page | + | Wiki mode | Collaborative wiki | + And I log out + + Scenario: Wiki page edition of custom tags works as expected + Given I log in as "student1" + And I follow "Course 1" + And I follow "Test wiki name" + And I press "Create page" + When I set the following fields to these values: + | HTML format | Student page contents to be tagged | + | Other tags (enter tags separated by commas) | Example, Page, Cool | + And I press "Save" + Then I should see "Example" in the ".wiki-tags" "css_element" + And I should see "Page" in the ".wiki-tags" "css_element" + And I should see "Cool" in the ".wiki-tags" "css_element" + And I follow "Edit" + And the field "Other tags (enter tags separated by commas)" matches value "Example, Page, Cool" + And I press "Cancel" + + Scenario: Wiki page edition of official tags works as expected + Given I log in as "admin" + And I expand "Site administration" node + And I expand "Appearance" node + And I follow "Manage tags" + And I set the field "otagsadd" to "OT1, OT2, OT3" + And I press "Add official tags" + And I log out + And I log in as "student1" + And I follow "Course 1" + And I follow "Test wiki name" + And I press "Create page" + And the "tags[officialtags][]" select box should contain "OT1" + And the "tags[officialtags][]" select box should contain "OT2" + And the "tags[officialtags][]" select box should contain "OT3" + When I set the following fields to these values: + | HTML format | Student page contents to be tagged | + | tags[officialtags][] | OT1, OT3 | + And I press "Save" + Then I should see "OT1" in the ".wiki-tags" "css_element" + And I should see "OT3" in the ".wiki-tags" "css_element" + And I should not see "OT2" in the ".wiki-tags" "css_element" + And I follow "Edit" + And the field "tags[officialtags][]" matches value "OT1, OT3" + And the field "tags[officialtags][]" does not match value "OT2" + And I press "Cancel" From a95e278050890f48b82367c61088f4831c60ec52 Mon Sep 17 00:00:00 2001 From: Gareth J Barnard Date: Fri, 11 Apr 2014 13:29:01 +0100 Subject: [PATCH 04/22] MDL-45045 block theme: Fake blocks show empty region when editing and clicked. --- lib/blocklib.php | 1 + lib/yui/build/moodle-core-blocks/moodle-core-blocks-debug.js | 2 +- lib/yui/build/moodle-core-blocks/moodle-core-blocks-min.js | 2 +- lib/yui/build/moodle-core-blocks/moodle-core-blocks.js | 2 +- lib/yui/src/blocks/js/manager.js | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/blocklib.php b/lib/blocklib.php index 32d4c516694..91501cd0974 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -478,6 +478,7 @@ class block_manager { throw new coding_exception('block_manager has already prepared the blocks in region ' . $region . 'for output. It is too late to add a fake block.'); } + $bc->attributes['class'] .= ' block_fake'; $this->extracontent[$region][] = $bc; } 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 0da15b501b6..af2f2d56486 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 @@ -492,7 +492,7 @@ MANAGER.prototype = { nodes: '.'+CSS.BLOCK, target: true, handles: ['.'+CSS.HEADER], - invalid: '.block-hider-hide, .block-hider-show, .moveto', + invalid: '.block-hider-hide, .block-hider-show, .moveto, .block_fake', dragConfig: {groups: this.groups} }); dragdelegation.dd.plug(Y.Plugin.DDProxy, { 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 9abcb15503f..0488a13cab7 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(e,t){var n="/lib/ajax/blocks.php",r={BLOCK:"block",BLOCKREGION:"block-region",BLOCKADMINBLOCK:"block_adminblock",EDITINGMOVE:"editing_move",HEADER:"header",LIGHTBOX:"lightbox",REGIONCONTENT:"region-content",SKIPBLOCK:"skip-block",SKIPBLOCKTO:"skip-block-to",MYINDEX:"page-my-index",REGIONMAIN:"region-main",BLOCKSMOVING:"blocks-moving"},i=function(){i.superclass.constructor.apply(this,arguments)};e.extend(i,M.core.dragdrop,{skipnodetop:null,skipnodebottom:null,dragsourceregion:null,initializer:function(){this.groups=["block"],this.samenodeclass=r.BLOCK,this.parentnodeclass=r.REGIONCONTENT;var t=e.Node.all("body#"+r.MYINDEX+" #"+r.REGIONMAIN+" > ."+r.REGIONCONTENT);if(t.size()>0){var n=t.item(0);n.addClass(r.BLOCKREGION),n.set("id",r.REGIONCONTENT),n.one("div").addClass(r.REGIONCONTENT)}var i=e.Node.all("div."+r.BLOCKREGION);if(i.size()===0)return!1;if(i.size()!==this.get("regions").length){var s=e.Node.create("
").addClass(r.BLOCKREGION),o=e.Node.create("
").addClass(r.REGIONCONTENT);s.appendChild(o);var u=i.filter("#region-pre"),a=i.filter("#region-post");u.size()===0&&a.size()===1?(s.setAttrs({id:"region-pre"}),a.item(0).insert(s,"before"),i.unshift(s)):a.size()===0&&u.size()===1&&(s.setAttrs({id:"region-post"}),u.item(0).insert(s,"after"),i.push(s))}i.each(function(t){new e.DD.Drop({node:t.one("div."+r.REGIONCONTENT),groups:this.groups,padding:"40 240 40 240"});var n=new e.DD.Delegate({container:t,nodes:"."+r.BLOCK,target:!0,handles:["."+r.HEADER],invalid:".block-hider-hide, .block-hider-show, .moveto",dragConfig:{groups:this.groups}});n.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),n.dd.plug(e.Plugin.DDWinScroll);var i=t.all("."+r.BLOCK);i.each(function(e){var t=e.one("a."+r.EDITINGMOVE);t&&(t.remove(),e.one("."+r.HEADER).setStyle("cursor","move"))},this)},this)},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(t){var n=t.ancestor("div."+r.BLOCKREGION).get("id").replace(/region-/i,"");return e.Array.indexOf(this.get("regions"),n)===-1?(right_to_left()&&(n==="post"?n="pre":n==="pre"&&(n="post")),"side-"+n):n},get_region_id:function(e){return e.get("id").replace(/region-/i,"")},drag_start:function(t){var n=t.target;this.dragsourceregion=n.get("node").ancestor("div."+r.BLOCKREGION),n.get("node").previous()&&n.get("node").previous().hasClass(r.SKIPBLOCK)&&(this.skipnodetop=n.get("node").previous()),n.get("node").next()&&n.get("node").next().hasClass(r.SKIPBLOCKTO)&&(this.skipnodebottom=n.get("node").next()),e.one("body").addClass(r.BLOCKSMOVING)},drop_over:function(t){var n=t.drag.get("node"),i=t.drop.get("node");i.hasClass(this.parentnodeclass)&&i.one("."+r.BLOCKADMINBLOCK)&&i.one("."+r.BLOCKADMINBLOCK).next("."+r.BLOCK)&&i.prepend(n);if(this.dragsourceregion.contains(i))return!1;var s=e.one("body"),o=this.get_region_id(this.dragsourceregion);s.hasClass("side-"+o+"-only")&&s.removeClass("side-"+o+"-only"),o=this.get_region_id(i.ancestor("div."+r.BLOCKREGION)),this.dragsourceregion.all("."+r.BLOCK).size()===0&&this.dragsourceregion.get("id").match(/(region-pre|region-post)/i)&&(s.hasClass("side-"+o+"-only")||s.addClass("side-"+o+"-only"))},drag_end:function(){this.skipnodetop=null,this.skipnodebottom=null,this.dragsourceregion=null,e.one("body").removeClass(r.BLOCKSMOVING)},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(t){var i=t.drag,s=i.get("node"),o=t.drop.get("node");s.previous()&&s.previous().hasClass(r.SKIPBLOCK)&&s.insert(s.previous(),"after"),this.skipnodetop&&s.insert(this.skipnodetop,"before"),this.skipnodebottom&&s.insert(this.skipnodebottom,"after");var u=M.util.add_lightbox(e,s),a={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(s),bui_newregion:this.get_block_region(o)};this.get("cmid")&&(a.cmid=this.get("cmid")),s.next("."+this.samenodeclass)&&!s.next("."+this.samenodeclass).hasClass(r.BLOCKADMINBLOCK)&&(a.bui_beforeid=this.get_block_id(s.next("."+this.samenodeclass))),e.io(M.cfg.wwwroot+n,{method:"POST",data:a,on:{start:function(){u.show()},success:function(t,n){window.setTimeout(function(){u.hide()},250);try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r)}catch(i){}},failure:function(e,t){this.ajax_failure(t),u.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(){if(this._isusingnewblocksmethod===null){var t=e.all(".block-region[data-blockregion]").size(),n=e.all(".block-region").size();this._isusingnewblocksmethod=n===t,t>0&&n>0}return this._isusingnewblocksmethod},M.core.blockdraganddrop.init=function(e){this.is_using_blocks_render_method()?new s(e):new i(e)},M.core_blocks=M.core_blocks||{},M.core_blocks.init_dragdrop=function(e){M.core.blockdraganddrop.init(e)};var s=function(){s.superclass.constructor.apply(this,arguments)};s.prototype={skipnodetop:null,skipnodebottom:null,regionobjects:{},initializer:function(){var t=this.get("regions"),n=0,i,s,u,a;this.groups=["block"],this.samenodeclass=r.BLOCK,this.parentnodeclass=r.BLOCKREGION;var f=e.Node.all("body#"+r.MYINDEX+" #"+r.REGIONMAIN+" > ."+r.REGIONCONTENT);if(f.size()>0){var l=f.item(0);l.addClass(r.BLOCKREGION),l.set("id",r.REGIONCONTENT),l.one("div").addClass(r.REGIONCONTENT)}for(n in t)s=t[n],i=new o({manager:this,region:s,node:e.one("#block-region-"+s)}),this.regionobjects[s]=i,u=new e.DD.Drop({node:i.get_droptarget(),groups:this.groups,padding:"40 240 40 240"}),a=new e.DD.Delegate({container:i.get_droptarget(),nodes:"."+r.BLOCK,target:!0,handles:["."+r.HEADER],invalid -:".block-hider-hide, .block-hider-show, .moveto",dragConfig:{groups:this.groups}}),a.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),a.dd.plug(e.Plugin.DDWinScroll),a.on("drag:mouseDown",this.enable_all_regions,this),i.remove_block_move_icons()},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(e){return e.test("[data-blockregion]")||(e=e.ancestor("[data-blockregion]")),e.getData("blockregion")},get_region_object:function(e){return this.regionobjects[this.get_block_region(e)]},enable_all_regions:function(){var e=0;for(e in this.regionobjects)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){var t=e.target;t.get("node").previous()&&t.get("node").previous().hasClass(r.SKIPBLOCK)&&(this.skipnodetop=t.get("node").previous()),t.get("node").next()&&t.get("node").next().hasClass(r.SKIPBLOCKTO)&&(this.skipnodebottom=t.get("node").next())},drop_over:function(e){var t=e.drag.get("node"),n=e.drop.get("node");n.hasClass(r.REGIONCONTENT)&&n.one("."+r.BLOCKADMINBLOCK)&&n.one("."+r.BLOCKADMINBLOCK).next("."+r.BLOCK)&&n.prepend(t)},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(t){var i=t.drag.get("node"),s=t.drop.get("node");i.previous()&&i.previous().hasClass(r.SKIPBLOCK)&&i.insert(i.previous(),"after"),this.skipnodetop&&i.insert(this.skipnodetop,"before"),this.skipnodebottom&&i.insert(this.skipnodebottom,"after");var o=M.util.add_lightbox(e,i),u={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(i),bui_newregion:this.get_block_region(s)};this.get("cmid")&&(u.cmid=this.get("cmid")),i.next("."+r.BLOCK)&&!i.next("."+r.BLOCK).hasClass(r.BLOCKADMINBLOCK)&&(u.bui_beforeid=this.get_block_id(i.next("."+r.BLOCK))),e.io(M.cfg.wwwroot+n,{method:"POST",data:u,on:{start:function(){o.show()},success:function(t,n){window.setTimeout(function(){o.hide()},250);try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r)}catch(i){}},failure:function(e,t){this.ajax_failure(t),o.hide()},complete:function(){this.disable_regions_if_required()}},context:this})}},e.extend(s,M.core.dragdrop,s.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:[]}}});var o=function(){o.superclass.constructor.apply(this,arguments)};o.prototype={initializer:function(){var t=this.get("node");t||(t=this.create_and_add_node());var n=e.one("body"),i=t.all("."+r.BLOCK).size()>0,s=this.get_has_region_class();this.set("hasblocks",i),n.hasClass(s)||n.addClass(s),n.addClass(i?this.get_used_region_class():this.get_empty_region_class()),n.removeClass(i?this.get_empty_region_class():this.get_used_region_class())},create_and_add_node:function(){var t=e.Node.create,n=this.get("region"),i=t('
').addClass(r.BLOCKREGION).setData("blockregion",n),s=this.get("manager").get("regions"),o,u=!1,a=!1,f=!1,l,c;for(o in s)s[o].match(/(pre|left)/)?u=s[o]:s[o].match(/(post|right)/)&&(a=s[o]);return u!==!1&&a!==!1&&(n===u?(c=e.one("#block-region-"+a),c&&(c.insert(i,"before"),f=!0)):(l=e.one("#block-region-"+u),l&&(l.insert(i,"after"),f=!0))),f===!1&&e.one("body").append(i),this.set("node",i),i},remove_block_move_icons:function(){this.get("node").all("."+r.BLOCK+" a."+r.EDITINGMOVE).each(function(e){e.ancestor("."+r.BLOCK).one("."+r.HEADER).setStyle("cursor","move"),e.remove()})},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(){e.one("body").addClass(this.get_used_region_class()).removeClass(this.get_empty_region_class())},disable_if_required:function(){this.get("node").all("."+r.BLOCK).size()===0&&e.one("body").addClass(this.get_empty_region_class()).removeClass(this.get_used_region_class())}},e.extend(o,e.Base,o.prototype,{NAME:"core-blocks-dragdrop-blockregion",ATTRS:{manager:{writeOnce:"initOnly",validator:function(t){return e.Lang.isObject(t)&&t instanceof s}},region:{writeOnce:"initOnly",validator:function(t){return e.Lang.isString(t)}},node:{validator:function(t){return e.Lang.isObject(t)||e.Lang.isNull(t)}},hasblocks:{value:!1,validator:function(t){return e.Lang.isBoolean(t)}}}})},"@VERSION@",{requires:["base","node","io","dom","dd","dd-scroll","moodle-core-dragdrop","moodle-core-notification"]}); +:".block-hider-hide, .block-hider-show, .moveto, .block_fake",dragConfig:{groups:this.groups}}),a.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),a.dd.plug(e.Plugin.DDWinScroll),a.on("drag:mouseDown",this.enable_all_regions,this),i.remove_block_move_icons()},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(e){return e.test("[data-blockregion]")||(e=e.ancestor("[data-blockregion]")),e.getData("blockregion")},get_region_object:function(e){return this.regionobjects[this.get_block_region(e)]},enable_all_regions:function(){var e=0;for(e in this.regionobjects)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){var t=e.target;t.get("node").previous()&&t.get("node").previous().hasClass(r.SKIPBLOCK)&&(this.skipnodetop=t.get("node").previous()),t.get("node").next()&&t.get("node").next().hasClass(r.SKIPBLOCKTO)&&(this.skipnodebottom=t.get("node").next())},drop_over:function(e){var t=e.drag.get("node"),n=e.drop.get("node");n.hasClass(r.REGIONCONTENT)&&n.one("."+r.BLOCKADMINBLOCK)&&n.one("."+r.BLOCKADMINBLOCK).next("."+r.BLOCK)&&n.prepend(t)},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(t){var i=t.drag.get("node"),s=t.drop.get("node");i.previous()&&i.previous().hasClass(r.SKIPBLOCK)&&i.insert(i.previous(),"after"),this.skipnodetop&&i.insert(this.skipnodetop,"before"),this.skipnodebottom&&i.insert(this.skipnodebottom,"after");var o=M.util.add_lightbox(e,i),u={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(i),bui_newregion:this.get_block_region(s)};this.get("cmid")&&(u.cmid=this.get("cmid")),i.next("."+r.BLOCK)&&!i.next("."+r.BLOCK).hasClass(r.BLOCKADMINBLOCK)&&(u.bui_beforeid=this.get_block_id(i.next("."+r.BLOCK))),e.io(M.cfg.wwwroot+n,{method:"POST",data:u,on:{start:function(){o.show()},success:function(t,n){window.setTimeout(function(){o.hide()},250);try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r)}catch(i){}},failure:function(e,t){this.ajax_failure(t),o.hide()},complete:function(){this.disable_regions_if_required()}},context:this})}},e.extend(s,M.core.dragdrop,s.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:[]}}});var o=function(){o.superclass.constructor.apply(this,arguments)};o.prototype={initializer:function(){var t=this.get("node");t||(t=this.create_and_add_node());var n=e.one("body"),i=t.all("."+r.BLOCK).size()>0,s=this.get_has_region_class();this.set("hasblocks",i),n.hasClass(s)||n.addClass(s),n.addClass(i?this.get_used_region_class():this.get_empty_region_class()),n.removeClass(i?this.get_empty_region_class():this.get_used_region_class())},create_and_add_node:function(){var t=e.Node.create,n=this.get("region"),i=t('
').addClass(r.BLOCKREGION).setData("blockregion",n),s=this.get("manager").get("regions"),o,u=!1,a=!1,f=!1,l,c;for(o in s)s[o].match(/(pre|left)/)?u=s[o]:s[o].match(/(post|right)/)&&(a=s[o]);return u!==!1&&a!==!1&&(n===u?(c=e.one("#block-region-"+a),c&&(c.insert(i,"before"),f=!0)):(l=e.one("#block-region-"+u),l&&(l.insert(i,"after"),f=!0))),f===!1&&e.one("body").append(i),this.set("node",i),i},remove_block_move_icons:function(){this.get("node").all("."+r.BLOCK+" a."+r.EDITINGMOVE).each(function(e){e.ancestor("."+r.BLOCK).one("."+r.HEADER).setStyle("cursor","move"),e.remove()})},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(){e.one("body").addClass(this.get_used_region_class()).removeClass(this.get_empty_region_class())},disable_if_required:function(){this.get("node").all("."+r.BLOCK).size()===0&&e.one("body").addClass(this.get_empty_region_class()).removeClass(this.get_used_region_class())}},e.extend(o,e.Base,o.prototype,{NAME:"core-blocks-dragdrop-blockregion",ATTRS:{manager:{writeOnce:"initOnly",validator:function(t){return e.Lang.isObject(t)&&t instanceof s}},region:{writeOnce:"initOnly",validator:function(t){return e.Lang.isString(t)}},node:{validator:function(t){return e.Lang.isObject(t)||e.Lang.isNull(t)}},hasblocks:{value:!1,validator:function(t){return e.Lang.isBoolean(t)}}}})},"@VERSION@",{requires:["base","node","io","dom","dd","dd-scroll","moodle-core-dragdrop","moodle-core-notification"]}); 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 bc8daf48623..445701426c1 100644 --- a/lib/yui/build/moodle-core-blocks/moodle-core-blocks.js +++ b/lib/yui/build/moodle-core-blocks/moodle-core-blocks.js @@ -488,7 +488,7 @@ MANAGER.prototype = { nodes: '.'+CSS.BLOCK, target: true, handles: ['.'+CSS.HEADER], - invalid: '.block-hider-hide, .block-hider-show, .moveto', + invalid: '.block-hider-hide, .block-hider-show, .moveto, .block_fake', dragConfig: {groups: this.groups} }); dragdelegation.dd.plug(Y.Plugin.DDProxy, { diff --git a/lib/yui/src/blocks/js/manager.js b/lib/yui/src/blocks/js/manager.js index 40490af9ab7..ad2b2ee39e5 100644 --- a/lib/yui/src/blocks/js/manager.js +++ b/lib/yui/src/blocks/js/manager.js @@ -99,7 +99,7 @@ MANAGER.prototype = { nodes: '.'+CSS.BLOCK, target: true, handles: ['.'+CSS.HEADER], - invalid: '.block-hider-hide, .block-hider-show, .moveto', + invalid: '.block-hider-hide, .block-hider-show, .moveto, .block_fake', dragConfig: {groups: this.groups} }); dragdelegation.dd.plug(Y.Plugin.DDProxy, { From 9d399ce4da938572d58bb0460aec9f6fe14aa1f6 Mon Sep 17 00:00:00 2001 From: Tim Lock Date: Wed, 9 Apr 2014 13:13:24 +0930 Subject: [PATCH 05/22] MDL-45012: Enable support for wma files within tinymce Moodle Media plugin --- lib/filelib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/filelib.php b/lib/filelib.php index e54530fa051..2d5946c5472 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -1603,6 +1603,7 @@ function &get_mimetypes_array() { 'webm' => array ('type'=>'video/webm', 'icon'=>'video', 'groups'=>array('video'), 'string'=>'video'), 'wmv' => array ('type'=>'video/x-ms-wmv', 'icon'=>'wmv', 'groups'=>array('video'), 'string'=>'video'), 'asf' => array ('type'=>'video/x-ms-asf', 'icon'=>'wmv', 'groups'=>array('video'), 'string'=>'video'), + 'wma' => array ('type'=>'audio/x-ms-wma', 'icon'=>'audio', 'groups'=>array('audio'), 'string'=>'audio'), 'xbk' => array ('type'=>'application/x-smarttech-notebook', 'icon'=>'archive'), 'xdp' => array ('type'=>'application/pdf', 'icon'=>'pdf'), From aa1f42288eda2dd2f34810b928985c52ab26707f Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Fri, 11 Apr 2014 13:38:03 +1200 Subject: [PATCH 06/22] MDL-43145 dock: fixed up region_completely_docked code to ignore empty regions --- lib/blocklib.php | 6 +++++- .../build/moodle-core-blocks/moodle-core-blocks-debug.js | 7 ++++--- lib/yui/build/moodle-core-blocks/moodle-core-blocks-min.js | 4 ++-- lib/yui/build/moodle-core-blocks/moodle-core-blocks.js | 7 ++++--- lib/yui/src/blocks/js/blocks.js | 2 +- lib/yui/src/blocks/js/manager.js | 4 ++-- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/blocklib.php b/lib/blocklib.php index 32d4c516694..c89b41aabc1 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -515,7 +515,11 @@ class block_manager { $this->check_is_loaded(); $this->ensure_content_created($region, $output); - foreach($this->visibleblockcontent[$region] as $instance) { + if (!$this->region_has_content($region, $output)) { + // If the region has no content then nothing is docked at all of course. + return false; + } + foreach ($this->visibleblockcontent[$region] as $instance) { if (!empty($instance->content) && !get_user_preferences('docked_block_instance_'.$instance->blockinstanceid, 0)) { return false; } 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 0da15b501b6..dfdab014a74 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 @@ -359,7 +359,7 @@ M.core.blockdraganddrop.is_using_blocks_render_method = function() { var goodregions = Y.all('.block-region[data-blockregion]').size(); var allregions = Y.all('.block-region').size(); this._isusingnewblocksmethod = (allregions === goodregions); - if (goodregions > 0 && allregions > 0) { + if (goodregions > 0 && allregions > 0 && goodregions !== allregions) { Y.log('Both core_renderer::blocks and core_renderer::blocks_for_region have been used.', 'warn', 'moodle-core_blocks'); } } @@ -502,7 +502,7 @@ MANAGER.prototype = { dragdelegation.dd.plug(Y.Plugin.DDWinScroll); // On the mouse down event we will enable all block regions so that they can be dragged to. // This is VERY important as without it dnd won't work for empty block regions. - dragdelegation.on('drag:mouseDown', this.enable_all_regions, this); + dragdelegation.on('drag:start', this.enable_all_regions, this); region.remove_block_move_icons(); } @@ -783,7 +783,8 @@ Y.extend(MANAGER, M.core.dragdrop, MANAGER.prototype, { value : [] } } -});/** +}); +/** * This file contains the Block Region class used by the drag and drop manager. * * Provides drag and drop functionality for blocks. 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 9abcb15503f..dc483286651 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(e,t){var n="/lib/ajax/blocks.php",r={BLOCK:"block",BLOCKREGION:"block-region",BLOCKADMINBLOCK:"block_adminblock",EDITINGMOVE:"editing_move",HEADER:"header",LIGHTBOX:"lightbox",REGIONCONTENT:"region-content",SKIPBLOCK:"skip-block",SKIPBLOCKTO:"skip-block-to",MYINDEX:"page-my-index",REGIONMAIN:"region-main",BLOCKSMOVING:"blocks-moving"},i=function(){i.superclass.constructor.apply(this,arguments)};e.extend(i,M.core.dragdrop,{skipnodetop:null,skipnodebottom:null,dragsourceregion:null,initializer:function(){this.groups=["block"],this.samenodeclass=r.BLOCK,this.parentnodeclass=r.REGIONCONTENT;var t=e.Node.all("body#"+r.MYINDEX+" #"+r.REGIONMAIN+" > ."+r.REGIONCONTENT);if(t.size()>0){var n=t.item(0);n.addClass(r.BLOCKREGION),n.set("id",r.REGIONCONTENT),n.one("div").addClass(r.REGIONCONTENT)}var i=e.Node.all("div."+r.BLOCKREGION);if(i.size()===0)return!1;if(i.size()!==this.get("regions").length){var s=e.Node.create("
").addClass(r.BLOCKREGION),o=e.Node.create("
").addClass(r.REGIONCONTENT);s.appendChild(o);var u=i.filter("#region-pre"),a=i.filter("#region-post");u.size()===0&&a.size()===1?(s.setAttrs({id:"region-pre"}),a.item(0).insert(s,"before"),i.unshift(s)):a.size()===0&&u.size()===1&&(s.setAttrs({id:"region-post"}),u.item(0).insert(s,"after"),i.push(s))}i.each(function(t){new e.DD.Drop({node:t.one("div."+r.REGIONCONTENT),groups:this.groups,padding:"40 240 40 240"});var n=new e.DD.Delegate({container:t,nodes:"."+r.BLOCK,target:!0,handles:["."+r.HEADER],invalid:".block-hider-hide, .block-hider-show, .moveto",dragConfig:{groups:this.groups}});n.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),n.dd.plug(e.Plugin.DDWinScroll);var i=t.all("."+r.BLOCK);i.each(function(e){var t=e.one("a."+r.EDITINGMOVE);t&&(t.remove(),e.one("."+r.HEADER).setStyle("cursor","move"))},this)},this)},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(t){var n=t.ancestor("div."+r.BLOCKREGION).get("id").replace(/region-/i,"");return e.Array.indexOf(this.get("regions"),n)===-1?(right_to_left()&&(n==="post"?n="pre":n==="pre"&&(n="post")),"side-"+n):n},get_region_id:function(e){return e.get("id").replace(/region-/i,"")},drag_start:function(t){var n=t.target;this.dragsourceregion=n.get("node").ancestor("div."+r.BLOCKREGION),n.get("node").previous()&&n.get("node").previous().hasClass(r.SKIPBLOCK)&&(this.skipnodetop=n.get("node").previous()),n.get("node").next()&&n.get("node").next().hasClass(r.SKIPBLOCKTO)&&(this.skipnodebottom=n.get("node").next()),e.one("body").addClass(r.BLOCKSMOVING)},drop_over:function(t){var n=t.drag.get("node"),i=t.drop.get("node");i.hasClass(this.parentnodeclass)&&i.one("."+r.BLOCKADMINBLOCK)&&i.one("."+r.BLOCKADMINBLOCK).next("."+r.BLOCK)&&i.prepend(n);if(this.dragsourceregion.contains(i))return!1;var s=e.one("body"),o=this.get_region_id(this.dragsourceregion);s.hasClass("side-"+o+"-only")&&s.removeClass("side-"+o+"-only"),o=this.get_region_id(i.ancestor("div."+r.BLOCKREGION)),this.dragsourceregion.all("."+r.BLOCK).size()===0&&this.dragsourceregion.get("id").match(/(region-pre|region-post)/i)&&(s.hasClass("side-"+o+"-only")||s.addClass("side-"+o+"-only"))},drag_end:function(){this.skipnodetop=null,this.skipnodebottom=null,this.dragsourceregion=null,e.one("body").removeClass(r.BLOCKSMOVING)},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(t){var i=t.drag,s=i.get("node"),o=t.drop.get("node");s.previous()&&s.previous().hasClass(r.SKIPBLOCK)&&s.insert(s.previous(),"after"),this.skipnodetop&&s.insert(this.skipnodetop,"before"),this.skipnodebottom&&s.insert(this.skipnodebottom,"after");var u=M.util.add_lightbox(e,s),a={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(s),bui_newregion:this.get_block_region(o)};this.get("cmid")&&(a.cmid=this.get("cmid")),s.next("."+this.samenodeclass)&&!s.next("."+this.samenodeclass).hasClass(r.BLOCKADMINBLOCK)&&(a.bui_beforeid=this.get_block_id(s.next("."+this.samenodeclass))),e.io(M.cfg.wwwroot+n,{method:"POST",data:a,on:{start:function(){u.show()},success:function(t,n){window.setTimeout(function(){u.hide()},250);try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r)}catch(i){}},failure:function(e,t){this.ajax_failure(t),u.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(){if(this._isusingnewblocksmethod===null){var t=e.all(".block-region[data-blockregion]").size(),n=e.all(".block-region").size();this._isusingnewblocksmethod=n===t,t>0&&n>0}return this._isusingnewblocksmethod},M.core.blockdraganddrop.init=function(e){this.is_using_blocks_render_method()?new s(e):new i(e)},M.core_blocks=M.core_blocks||{},M.core_blocks.init_dragdrop=function(e){M.core.blockdraganddrop.init(e)};var s=function(){s.superclass.constructor.apply(this,arguments)};s.prototype={skipnodetop:null,skipnodebottom:null,regionobjects:{},initializer:function(){var t=this.get("regions"),n=0,i,s,u,a;this.groups=["block"],this.samenodeclass=r.BLOCK,this.parentnodeclass=r.BLOCKREGION;var f=e.Node.all("body#"+r.MYINDEX+" #"+r.REGIONMAIN+" > ."+r.REGIONCONTENT);if(f.size()>0){var l=f.item(0);l.addClass(r.BLOCKREGION),l.set("id",r.REGIONCONTENT),l.one("div").addClass(r.REGIONCONTENT)}for(n in t)s=t[n],i=new o({manager:this,region:s,node:e.one("#block-region-"+s)}),this.regionobjects[s]=i,u=new e.DD.Drop({node:i.get_droptarget(),groups:this.groups,padding:"40 240 40 240"}),a=new e.DD.Delegate({container:i.get_droptarget(),nodes:"."+r.BLOCK,target:!0,handles:["."+r.HEADER],invalid -:".block-hider-hide, .block-hider-show, .moveto",dragConfig:{groups:this.groups}}),a.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),a.dd.plug(e.Plugin.DDWinScroll),a.on("drag:mouseDown",this.enable_all_regions,this),i.remove_block_move_icons()},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(e){return e.test("[data-blockregion]")||(e=e.ancestor("[data-blockregion]")),e.getData("blockregion")},get_region_object:function(e){return this.regionobjects[this.get_block_region(e)]},enable_all_regions:function(){var e=0;for(e in this.regionobjects)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){var t=e.target;t.get("node").previous()&&t.get("node").previous().hasClass(r.SKIPBLOCK)&&(this.skipnodetop=t.get("node").previous()),t.get("node").next()&&t.get("node").next().hasClass(r.SKIPBLOCKTO)&&(this.skipnodebottom=t.get("node").next())},drop_over:function(e){var t=e.drag.get("node"),n=e.drop.get("node");n.hasClass(r.REGIONCONTENT)&&n.one("."+r.BLOCKADMINBLOCK)&&n.one("."+r.BLOCKADMINBLOCK).next("."+r.BLOCK)&&n.prepend(t)},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(t){var i=t.drag.get("node"),s=t.drop.get("node");i.previous()&&i.previous().hasClass(r.SKIPBLOCK)&&i.insert(i.previous(),"after"),this.skipnodetop&&i.insert(this.skipnodetop,"before"),this.skipnodebottom&&i.insert(this.skipnodebottom,"after");var o=M.util.add_lightbox(e,i),u={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(i),bui_newregion:this.get_block_region(s)};this.get("cmid")&&(u.cmid=this.get("cmid")),i.next("."+r.BLOCK)&&!i.next("."+r.BLOCK).hasClass(r.BLOCKADMINBLOCK)&&(u.bui_beforeid=this.get_block_id(i.next("."+r.BLOCK))),e.io(M.cfg.wwwroot+n,{method:"POST",data:u,on:{start:function(){o.show()},success:function(t,n){window.setTimeout(function(){o.hide()},250);try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r)}catch(i){}},failure:function(e,t){this.ajax_failure(t),o.hide()},complete:function(){this.disable_regions_if_required()}},context:this})}},e.extend(s,M.core.dragdrop,s.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:[]}}});var o=function(){o.superclass.constructor.apply(this,arguments)};o.prototype={initializer:function(){var t=this.get("node");t||(t=this.create_and_add_node());var n=e.one("body"),i=t.all("."+r.BLOCK).size()>0,s=this.get_has_region_class();this.set("hasblocks",i),n.hasClass(s)||n.addClass(s),n.addClass(i?this.get_used_region_class():this.get_empty_region_class()),n.removeClass(i?this.get_empty_region_class():this.get_used_region_class())},create_and_add_node:function(){var t=e.Node.create,n=this.get("region"),i=t('
').addClass(r.BLOCKREGION).setData("blockregion",n),s=this.get("manager").get("regions"),o,u=!1,a=!1,f=!1,l,c;for(o in s)s[o].match(/(pre|left)/)?u=s[o]:s[o].match(/(post|right)/)&&(a=s[o]);return u!==!1&&a!==!1&&(n===u?(c=e.one("#block-region-"+a),c&&(c.insert(i,"before"),f=!0)):(l=e.one("#block-region-"+u),l&&(l.insert(i,"after"),f=!0))),f===!1&&e.one("body").append(i),this.set("node",i),i},remove_block_move_icons:function(){this.get("node").all("."+r.BLOCK+" a."+r.EDITINGMOVE).each(function(e){e.ancestor("."+r.BLOCK).one("."+r.HEADER).setStyle("cursor","move"),e.remove()})},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(){e.one("body").addClass(this.get_used_region_class()).removeClass(this.get_empty_region_class())},disable_if_required:function(){this.get("node").all("."+r.BLOCK).size()===0&&e.one("body").addClass(this.get_empty_region_class()).removeClass(this.get_used_region_class())}},e.extend(o,e.Base,o.prototype,{NAME:"core-blocks-dragdrop-blockregion",ATTRS:{manager:{writeOnce:"initOnly",validator:function(t){return e.Lang.isObject(t)&&t instanceof s}},region:{writeOnce:"initOnly",validator:function(t){return e.Lang.isString(t)}},node:{validator:function(t){return e.Lang.isObject(t)||e.Lang.isNull(t)}},hasblocks:{value:!1,validator:function(t){return e.Lang.isBoolean(t)}}}})},"@VERSION@",{requires:["base","node","io","dom","dd","dd-scroll","moodle-core-dragdrop","moodle-core-notification"]}); +YUI.add("moodle-core-blocks",function(e,t){var n="/lib/ajax/blocks.php",r={BLOCK:"block",BLOCKREGION:"block-region",BLOCKADMINBLOCK:"block_adminblock",EDITINGMOVE:"editing_move",HEADER:"header",LIGHTBOX:"lightbox",REGIONCONTENT:"region-content",SKIPBLOCK:"skip-block",SKIPBLOCKTO:"skip-block-to",MYINDEX:"page-my-index",REGIONMAIN:"region-main",BLOCKSMOVING:"blocks-moving"},i=function(){i.superclass.constructor.apply(this,arguments)};e.extend(i,M.core.dragdrop,{skipnodetop:null,skipnodebottom:null,dragsourceregion:null,initializer:function(){this.groups=["block"],this.samenodeclass=r.BLOCK,this.parentnodeclass=r.REGIONCONTENT;var t=e.Node.all("body#"+r.MYINDEX+" #"+r.REGIONMAIN+" > ."+r.REGIONCONTENT);if(t.size()>0){var n=t.item(0);n.addClass(r.BLOCKREGION),n.set("id",r.REGIONCONTENT),n.one("div").addClass(r.REGIONCONTENT)}var i=e.Node.all("div."+r.BLOCKREGION);if(i.size()===0)return!1;if(i.size()!==this.get("regions").length){var s=e.Node.create("
").addClass(r.BLOCKREGION),o=e.Node.create("
").addClass(r.REGIONCONTENT);s.appendChild(o);var u=i.filter("#region-pre"),a=i.filter("#region-post");u.size()===0&&a.size()===1?(s.setAttrs({id:"region-pre"}),a.item(0).insert(s,"before"),i.unshift(s)):a.size()===0&&u.size()===1&&(s.setAttrs({id:"region-post"}),u.item(0).insert(s,"after"),i.push(s))}i.each(function(t){new e.DD.Drop({node:t.one("div."+r.REGIONCONTENT),groups:this.groups,padding:"40 240 40 240"});var n=new e.DD.Delegate({container:t,nodes:"."+r.BLOCK,target:!0,handles:["."+r.HEADER],invalid:".block-hider-hide, .block-hider-show, .moveto",dragConfig:{groups:this.groups}});n.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),n.dd.plug(e.Plugin.DDWinScroll);var i=t.all("."+r.BLOCK);i.each(function(e){var t=e.one("a."+r.EDITINGMOVE);t&&(t.remove(),e.one("."+r.HEADER).setStyle("cursor","move"))},this)},this)},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(t){var n=t.ancestor("div."+r.BLOCKREGION).get("id").replace(/region-/i,"");return e.Array.indexOf(this.get("regions"),n)===-1?(right_to_left()&&(n==="post"?n="pre":n==="pre"&&(n="post")),"side-"+n):n},get_region_id:function(e){return e.get("id").replace(/region-/i,"")},drag_start:function(t){var n=t.target;this.dragsourceregion=n.get("node").ancestor("div."+r.BLOCKREGION),n.get("node").previous()&&n.get("node").previous().hasClass(r.SKIPBLOCK)&&(this.skipnodetop=n.get("node").previous()),n.get("node").next()&&n.get("node").next().hasClass(r.SKIPBLOCKTO)&&(this.skipnodebottom=n.get("node").next()),e.one("body").addClass(r.BLOCKSMOVING)},drop_over:function(t){var n=t.drag.get("node"),i=t.drop.get("node");i.hasClass(this.parentnodeclass)&&i.one("."+r.BLOCKADMINBLOCK)&&i.one("."+r.BLOCKADMINBLOCK).next("."+r.BLOCK)&&i.prepend(n);if(this.dragsourceregion.contains(i))return!1;var s=e.one("body"),o=this.get_region_id(this.dragsourceregion);s.hasClass("side-"+o+"-only")&&s.removeClass("side-"+o+"-only"),o=this.get_region_id(i.ancestor("div."+r.BLOCKREGION)),this.dragsourceregion.all("."+r.BLOCK).size()===0&&this.dragsourceregion.get("id").match(/(region-pre|region-post)/i)&&(s.hasClass("side-"+o+"-only")||s.addClass("side-"+o+"-only"))},drag_end:function(){this.skipnodetop=null,this.skipnodebottom=null,this.dragsourceregion=null,e.one("body").removeClass(r.BLOCKSMOVING)},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(t){var i=t.drag,s=i.get("node"),o=t.drop.get("node");s.previous()&&s.previous().hasClass(r.SKIPBLOCK)&&s.insert(s.previous(),"after"),this.skipnodetop&&s.insert(this.skipnodetop,"before"),this.skipnodebottom&&s.insert(this.skipnodebottom,"after");var u=M.util.add_lightbox(e,s),a={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(s),bui_newregion:this.get_block_region(o)};this.get("cmid")&&(a.cmid=this.get("cmid")),s.next("."+this.samenodeclass)&&!s.next("."+this.samenodeclass).hasClass(r.BLOCKADMINBLOCK)&&(a.bui_beforeid=this.get_block_id(s.next("."+this.samenodeclass))),e.io(M.cfg.wwwroot+n,{method:"POST",data:a,on:{start:function(){u.show()},success:function(t,n){window.setTimeout(function(){u.hide()},250);try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r)}catch(i){}},failure:function(e,t){this.ajax_failure(t),u.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(){if(this._isusingnewblocksmethod===null){var t=e.all(".block-region[data-blockregion]").size(),n=e.all(".block-region").size();this._isusingnewblocksmethod=n===t,t>0&&n>0&&t!==n}return this._isusingnewblocksmethod},M.core.blockdraganddrop.init=function(e){this.is_using_blocks_render_method()?new s(e):new i(e)},M.core_blocks=M.core_blocks||{},M.core_blocks.init_dragdrop=function(e){M.core.blockdraganddrop.init(e)};var s=function(){s.superclass.constructor.apply(this,arguments)};s.prototype={skipnodetop:null,skipnodebottom:null,regionobjects:{},initializer:function(){var t=this.get("regions"),n=0,i,s,u,a;this.groups=["block"],this.samenodeclass=r.BLOCK,this.parentnodeclass=r.BLOCKREGION;var f=e.Node.all("body#"+r.MYINDEX+" #"+r.REGIONMAIN+" > ."+r.REGIONCONTENT);if(f.size()>0){var l=f.item(0);l.addClass(r.BLOCKREGION),l.set("id",r.REGIONCONTENT),l.one("div").addClass(r.REGIONCONTENT)}for(n in t)s=t[n],i=new o({manager:this,region:s,node:e.one("#block-region-"+s)}),this.regionobjects[s]=i,u=new e.DD.Drop({node:i.get_droptarget(),groups:this.groups,padding:"40 240 40 240"}),a=new e.DD.Delegate({container:i.get_droptarget(),nodes:"."+r.BLOCK,target:!0,handles:["."+r.HEADER +],invalid:".block-hider-hide, .block-hider-show, .moveto",dragConfig:{groups:this.groups}}),a.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),a.dd.plug(e.Plugin.DDWinScroll),a.on("drag:start",this.enable_all_regions,this),i.remove_block_move_icons()},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(e){return e.test("[data-blockregion]")||(e=e.ancestor("[data-blockregion]")),e.getData("blockregion")},get_region_object:function(e){return this.regionobjects[this.get_block_region(e)]},enable_all_regions:function(){var e=0;for(e in this.regionobjects)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){var t=e.target;t.get("node").previous()&&t.get("node").previous().hasClass(r.SKIPBLOCK)&&(this.skipnodetop=t.get("node").previous()),t.get("node").next()&&t.get("node").next().hasClass(r.SKIPBLOCKTO)&&(this.skipnodebottom=t.get("node").next())},drop_over:function(e){var t=e.drag.get("node"),n=e.drop.get("node");n.hasClass(r.REGIONCONTENT)&&n.one("."+r.BLOCKADMINBLOCK)&&n.one("."+r.BLOCKADMINBLOCK).next("."+r.BLOCK)&&n.prepend(t)},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(t){var i=t.drag.get("node"),s=t.drop.get("node");i.previous()&&i.previous().hasClass(r.SKIPBLOCK)&&i.insert(i.previous(),"after"),this.skipnodetop&&i.insert(this.skipnodetop,"before"),this.skipnodebottom&&i.insert(this.skipnodebottom,"after");var o=M.util.add_lightbox(e,i),u={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(i),bui_newregion:this.get_block_region(s)};this.get("cmid")&&(u.cmid=this.get("cmid")),i.next("."+r.BLOCK)&&!i.next("."+r.BLOCK).hasClass(r.BLOCKADMINBLOCK)&&(u.bui_beforeid=this.get_block_id(i.next("."+r.BLOCK))),e.io(M.cfg.wwwroot+n,{method:"POST",data:u,on:{start:function(){o.show()},success:function(t,n){window.setTimeout(function(){o.hide()},250);try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r)}catch(i){}},failure:function(e,t){this.ajax_failure(t),o.hide()},complete:function(){this.disable_regions_if_required()}},context:this})}},e.extend(s,M.core.dragdrop,s.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:[]}}});var o=function(){o.superclass.constructor.apply(this,arguments)};o.prototype={initializer:function(){var t=this.get("node");t||(t=this.create_and_add_node());var n=e.one("body"),i=t.all("."+r.BLOCK).size()>0,s=this.get_has_region_class();this.set("hasblocks",i),n.hasClass(s)||n.addClass(s),n.addClass(i?this.get_used_region_class():this.get_empty_region_class()),n.removeClass(i?this.get_empty_region_class():this.get_used_region_class())},create_and_add_node:function(){var t=e.Node.create,n=this.get("region"),i=t('
').addClass(r.BLOCKREGION).setData("blockregion",n),s=this.get("manager").get("regions"),o,u=!1,a=!1,f=!1,l,c;for(o in s)s[o].match(/(pre|left)/)?u=s[o]:s[o].match(/(post|right)/)&&(a=s[o]);return u!==!1&&a!==!1&&(n===u?(c=e.one("#block-region-"+a),c&&(c.insert(i,"before"),f=!0)):(l=e.one("#block-region-"+u),l&&(l.insert(i,"after"),f=!0))),f===!1&&e.one("body").append(i),this.set("node",i),i},remove_block_move_icons:function(){this.get("node").all("."+r.BLOCK+" a."+r.EDITINGMOVE).each(function(e){e.ancestor("."+r.BLOCK).one("."+r.HEADER).setStyle("cursor","move"),e.remove()})},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(){e.one("body").addClass(this.get_used_region_class()).removeClass(this.get_empty_region_class())},disable_if_required:function(){this.get("node").all("."+r.BLOCK).size()===0&&e.one("body").addClass(this.get_empty_region_class()).removeClass(this.get_used_region_class())}},e.extend(o,e.Base,o.prototype,{NAME:"core-blocks-dragdrop-blockregion",ATTRS:{manager:{writeOnce:"initOnly",validator:function(t){return e.Lang.isObject(t)&&t instanceof s}},region:{writeOnce:"initOnly",validator:function(t){return e.Lang.isString(t)}},node:{validator:function(t){return e.Lang.isObject(t)||e.Lang.isNull(t)}},hasblocks:{value:!1,validator:function(t){return e.Lang.isBoolean(t)}}}})},"@VERSION@",{requires:["base","node","io","dom","dd","dd-scroll","moodle-core-dragdrop","moodle-core-notification"]}); 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 bc8daf48623..0ae8850ad56 100644 --- a/lib/yui/build/moodle-core-blocks/moodle-core-blocks.js +++ b/lib/yui/build/moodle-core-blocks/moodle-core-blocks.js @@ -359,7 +359,7 @@ M.core.blockdraganddrop.is_using_blocks_render_method = function() { var goodregions = Y.all('.block-region[data-blockregion]').size(); var allregions = Y.all('.block-region').size(); this._isusingnewblocksmethod = (allregions === goodregions); - if (goodregions > 0 && allregions > 0) { + if (goodregions > 0 && allregions > 0 && goodregions !== allregions) { } } return this._isusingnewblocksmethod; @@ -498,7 +498,7 @@ MANAGER.prototype = { dragdelegation.dd.plug(Y.Plugin.DDWinScroll); // On the mouse down event we will enable all block regions so that they can be dragged to. // This is VERY important as without it dnd won't work for empty block regions. - dragdelegation.on('drag:mouseDown', this.enable_all_regions, this); + dragdelegation.on('drag:start', this.enable_all_regions, this); region.remove_block_move_icons(); } @@ -778,7 +778,8 @@ Y.extend(MANAGER, M.core.dragdrop, MANAGER.prototype, { value : [] } } -});/** +}); +/** * This file contains the Block Region class used by the drag and drop manager. * * Provides drag and drop functionality for blocks. diff --git a/lib/yui/src/blocks/js/blocks.js b/lib/yui/src/blocks/js/blocks.js index 2846a98ed5f..cf9d57ff799 100644 --- a/lib/yui/src/blocks/js/blocks.js +++ b/lib/yui/src/blocks/js/blocks.js @@ -357,7 +357,7 @@ M.core.blockdraganddrop.is_using_blocks_render_method = function() { var goodregions = Y.all('.block-region[data-blockregion]').size(); var allregions = Y.all('.block-region').size(); this._isusingnewblocksmethod = (allregions === goodregions); - if (goodregions > 0 && allregions > 0) { + if (goodregions > 0 && allregions > 0 && goodregions !== allregions) { Y.log('Both core_renderer::blocks and core_renderer::blocks_for_region have been used.', 'warn', 'moodle-core_blocks'); } } diff --git a/lib/yui/src/blocks/js/manager.js b/lib/yui/src/blocks/js/manager.js index 40490af9ab7..a3d906b7ca1 100644 --- a/lib/yui/src/blocks/js/manager.js +++ b/lib/yui/src/blocks/js/manager.js @@ -109,7 +109,7 @@ MANAGER.prototype = { dragdelegation.dd.plug(Y.Plugin.DDWinScroll); // On the mouse down event we will enable all block regions so that they can be dragged to. // This is VERY important as without it dnd won't work for empty block regions. - dragdelegation.on('drag:mouseDown', this.enable_all_regions, this); + dragdelegation.on('drag:start', this.enable_all_regions, this); region.remove_block_move_icons(); } @@ -390,4 +390,4 @@ Y.extend(MANAGER, M.core.dragdrop, MANAGER.prototype, { value : [] } } -}); \ No newline at end of file +}); From da7f707de70a52205ebcc032caaa6d90573db90c Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 11 Apr 2014 10:40:09 +0800 Subject: [PATCH 07/22] MDL-43145 dock: Enable regions before the drag operation starts --- .../moodle-core-blocks-debug.js | 25 ++++++++++++++----- .../moodle-core-blocks-min.js | 4 +-- .../moodle-core-blocks/moodle-core-blocks.js | 25 ++++++++++++++----- lib/yui/src/blocks/js/manager.js | 25 ++++++++++++++----- 4 files changed, 59 insertions(+), 20 deletions(-) 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 dfdab014a74..250c8a7a599 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 @@ -451,7 +451,6 @@ MANAGER.prototype = { i = 0, region, regionname, - droptarget, dragdelegation; // Evil required by M.core.dragdrop. @@ -480,7 +479,7 @@ MANAGER.prototype = { // Setting blockregion as droptarget (the case when it is empty) // The region-post (the right one) // is very narrow, so add extra padding on the left to drop block on it. - droptarget = new Y.DD.Drop({ + new Y.DD.Drop({ node: region.get_droptarget(), groups: this.groups, padding: '40 240 40 240' @@ -500,9 +499,10 @@ MANAGER.prototype = { moveOnEnd: false }); dragdelegation.dd.plug(Y.Plugin.DDWinScroll); - // On the mouse down event we will enable all block regions so that they can be dragged to. - // This is VERY important as without it dnd won't work for empty block regions. - dragdelegation.on('drag:start', this.enable_all_regions, this); + + // 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. + Y.DD.DDM.on('ddm:start', this.enable_all_regions, this); region.remove_block_move_icons(); } @@ -544,12 +544,25 @@ MANAGER.prototype = { /** * Enables all fo the regions so that they are all visible while dragging is occuring. + * * @method enable_all_regions * @returns {undefined} */ enable_all_regions : function() { - var i = 0; + var groups = Y.DD.DDM.activeDrag.get('groups'); + + // As we're called by Y.DD.DDM, we can't be certain that the call + // relates specifically to a block drag/drop operation. Test + // whether the relevant group applies here. + if (!groups || Y.Array.indexOf(groups, 'block') === -1) { + return; + } + + var i; for (i in this.regionobjects) { + if (!this.regionobjects.hasOwnProperty(i)) { + continue; + } this.regionobjects[i].enable(); } }, 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 dc483286651..12a872f8c7d 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(e,t){var n="/lib/ajax/blocks.php",r={BLOCK:"block",BLOCKREGION:"block-region",BLOCKADMINBLOCK:"block_adminblock",EDITINGMOVE:"editing_move",HEADER:"header",LIGHTBOX:"lightbox",REGIONCONTENT:"region-content",SKIPBLOCK:"skip-block",SKIPBLOCKTO:"skip-block-to",MYINDEX:"page-my-index",REGIONMAIN:"region-main",BLOCKSMOVING:"blocks-moving"},i=function(){i.superclass.constructor.apply(this,arguments)};e.extend(i,M.core.dragdrop,{skipnodetop:null,skipnodebottom:null,dragsourceregion:null,initializer:function(){this.groups=["block"],this.samenodeclass=r.BLOCK,this.parentnodeclass=r.REGIONCONTENT;var t=e.Node.all("body#"+r.MYINDEX+" #"+r.REGIONMAIN+" > ."+r.REGIONCONTENT);if(t.size()>0){var n=t.item(0);n.addClass(r.BLOCKREGION),n.set("id",r.REGIONCONTENT),n.one("div").addClass(r.REGIONCONTENT)}var i=e.Node.all("div."+r.BLOCKREGION);if(i.size()===0)return!1;if(i.size()!==this.get("regions").length){var s=e.Node.create("
").addClass(r.BLOCKREGION),o=e.Node.create("
").addClass(r.REGIONCONTENT);s.appendChild(o);var u=i.filter("#region-pre"),a=i.filter("#region-post");u.size()===0&&a.size()===1?(s.setAttrs({id:"region-pre"}),a.item(0).insert(s,"before"),i.unshift(s)):a.size()===0&&u.size()===1&&(s.setAttrs({id:"region-post"}),u.item(0).insert(s,"after"),i.push(s))}i.each(function(t){new e.DD.Drop({node:t.one("div."+r.REGIONCONTENT),groups:this.groups,padding:"40 240 40 240"});var n=new e.DD.Delegate({container:t,nodes:"."+r.BLOCK,target:!0,handles:["."+r.HEADER],invalid:".block-hider-hide, .block-hider-show, .moveto",dragConfig:{groups:this.groups}});n.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),n.dd.plug(e.Plugin.DDWinScroll);var i=t.all("."+r.BLOCK);i.each(function(e){var t=e.one("a."+r.EDITINGMOVE);t&&(t.remove(),e.one("."+r.HEADER).setStyle("cursor","move"))},this)},this)},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(t){var n=t.ancestor("div."+r.BLOCKREGION).get("id").replace(/region-/i,"");return e.Array.indexOf(this.get("regions"),n)===-1?(right_to_left()&&(n==="post"?n="pre":n==="pre"&&(n="post")),"side-"+n):n},get_region_id:function(e){return e.get("id").replace(/region-/i,"")},drag_start:function(t){var n=t.target;this.dragsourceregion=n.get("node").ancestor("div."+r.BLOCKREGION),n.get("node").previous()&&n.get("node").previous().hasClass(r.SKIPBLOCK)&&(this.skipnodetop=n.get("node").previous()),n.get("node").next()&&n.get("node").next().hasClass(r.SKIPBLOCKTO)&&(this.skipnodebottom=n.get("node").next()),e.one("body").addClass(r.BLOCKSMOVING)},drop_over:function(t){var n=t.drag.get("node"),i=t.drop.get("node");i.hasClass(this.parentnodeclass)&&i.one("."+r.BLOCKADMINBLOCK)&&i.one("."+r.BLOCKADMINBLOCK).next("."+r.BLOCK)&&i.prepend(n);if(this.dragsourceregion.contains(i))return!1;var s=e.one("body"),o=this.get_region_id(this.dragsourceregion);s.hasClass("side-"+o+"-only")&&s.removeClass("side-"+o+"-only"),o=this.get_region_id(i.ancestor("div."+r.BLOCKREGION)),this.dragsourceregion.all("."+r.BLOCK).size()===0&&this.dragsourceregion.get("id").match(/(region-pre|region-post)/i)&&(s.hasClass("side-"+o+"-only")||s.addClass("side-"+o+"-only"))},drag_end:function(){this.skipnodetop=null,this.skipnodebottom=null,this.dragsourceregion=null,e.one("body").removeClass(r.BLOCKSMOVING)},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(t){var i=t.drag,s=i.get("node"),o=t.drop.get("node");s.previous()&&s.previous().hasClass(r.SKIPBLOCK)&&s.insert(s.previous(),"after"),this.skipnodetop&&s.insert(this.skipnodetop,"before"),this.skipnodebottom&&s.insert(this.skipnodebottom,"after");var u=M.util.add_lightbox(e,s),a={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(s),bui_newregion:this.get_block_region(o)};this.get("cmid")&&(a.cmid=this.get("cmid")),s.next("."+this.samenodeclass)&&!s.next("."+this.samenodeclass).hasClass(r.BLOCKADMINBLOCK)&&(a.bui_beforeid=this.get_block_id(s.next("."+this.samenodeclass))),e.io(M.cfg.wwwroot+n,{method:"POST",data:a,on:{start:function(){u.show()},success:function(t,n){window.setTimeout(function(){u.hide()},250);try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r)}catch(i){}},failure:function(e,t){this.ajax_failure(t),u.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(){if(this._isusingnewblocksmethod===null){var t=e.all(".block-region[data-blockregion]").size(),n=e.all(".block-region").size();this._isusingnewblocksmethod=n===t,t>0&&n>0&&t!==n}return this._isusingnewblocksmethod},M.core.blockdraganddrop.init=function(e){this.is_using_blocks_render_method()?new s(e):new i(e)},M.core_blocks=M.core_blocks||{},M.core_blocks.init_dragdrop=function(e){M.core.blockdraganddrop.init(e)};var s=function(){s.superclass.constructor.apply(this,arguments)};s.prototype={skipnodetop:null,skipnodebottom:null,regionobjects:{},initializer:function(){var t=this.get("regions"),n=0,i,s,u,a;this.groups=["block"],this.samenodeclass=r.BLOCK,this.parentnodeclass=r.BLOCKREGION;var f=e.Node.all("body#"+r.MYINDEX+" #"+r.REGIONMAIN+" > ."+r.REGIONCONTENT);if(f.size()>0){var l=f.item(0);l.addClass(r.BLOCKREGION),l.set("id",r.REGIONCONTENT),l.one("div").addClass(r.REGIONCONTENT)}for(n in t)s=t[n],i=new o({manager:this,region:s,node:e.one("#block-region-"+s)}),this.regionobjects[s]=i,u=new e.DD.Drop({node:i.get_droptarget(),groups:this.groups,padding:"40 240 40 240"}),a=new e.DD.Delegate({container:i.get_droptarget(),nodes:"."+r.BLOCK,target:!0,handles:["."+r.HEADER -],invalid:".block-hider-hide, .block-hider-show, .moveto",dragConfig:{groups:this.groups}}),a.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),a.dd.plug(e.Plugin.DDWinScroll),a.on("drag:start",this.enable_all_regions,this),i.remove_block_move_icons()},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(e){return e.test("[data-blockregion]")||(e=e.ancestor("[data-blockregion]")),e.getData("blockregion")},get_region_object:function(e){return this.regionobjects[this.get_block_region(e)]},enable_all_regions:function(){var e=0;for(e in this.regionobjects)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){var t=e.target;t.get("node").previous()&&t.get("node").previous().hasClass(r.SKIPBLOCK)&&(this.skipnodetop=t.get("node").previous()),t.get("node").next()&&t.get("node").next().hasClass(r.SKIPBLOCKTO)&&(this.skipnodebottom=t.get("node").next())},drop_over:function(e){var t=e.drag.get("node"),n=e.drop.get("node");n.hasClass(r.REGIONCONTENT)&&n.one("."+r.BLOCKADMINBLOCK)&&n.one("."+r.BLOCKADMINBLOCK).next("."+r.BLOCK)&&n.prepend(t)},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(t){var i=t.drag.get("node"),s=t.drop.get("node");i.previous()&&i.previous().hasClass(r.SKIPBLOCK)&&i.insert(i.previous(),"after"),this.skipnodetop&&i.insert(this.skipnodetop,"before"),this.skipnodebottom&&i.insert(this.skipnodebottom,"after");var o=M.util.add_lightbox(e,i),u={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(i),bui_newregion:this.get_block_region(s)};this.get("cmid")&&(u.cmid=this.get("cmid")),i.next("."+r.BLOCK)&&!i.next("."+r.BLOCK).hasClass(r.BLOCKADMINBLOCK)&&(u.bui_beforeid=this.get_block_id(i.next("."+r.BLOCK))),e.io(M.cfg.wwwroot+n,{method:"POST",data:u,on:{start:function(){o.show()},success:function(t,n){window.setTimeout(function(){o.hide()},250);try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r)}catch(i){}},failure:function(e,t){this.ajax_failure(t),o.hide()},complete:function(){this.disable_regions_if_required()}},context:this})}},e.extend(s,M.core.dragdrop,s.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:[]}}});var o=function(){o.superclass.constructor.apply(this,arguments)};o.prototype={initializer:function(){var t=this.get("node");t||(t=this.create_and_add_node());var n=e.one("body"),i=t.all("."+r.BLOCK).size()>0,s=this.get_has_region_class();this.set("hasblocks",i),n.hasClass(s)||n.addClass(s),n.addClass(i?this.get_used_region_class():this.get_empty_region_class()),n.removeClass(i?this.get_empty_region_class():this.get_used_region_class())},create_and_add_node:function(){var t=e.Node.create,n=this.get("region"),i=t('
').addClass(r.BLOCKREGION).setData("blockregion",n),s=this.get("manager").get("regions"),o,u=!1,a=!1,f=!1,l,c;for(o in s)s[o].match(/(pre|left)/)?u=s[o]:s[o].match(/(post|right)/)&&(a=s[o]);return u!==!1&&a!==!1&&(n===u?(c=e.one("#block-region-"+a),c&&(c.insert(i,"before"),f=!0)):(l=e.one("#block-region-"+u),l&&(l.insert(i,"after"),f=!0))),f===!1&&e.one("body").append(i),this.set("node",i),i},remove_block_move_icons:function(){this.get("node").all("."+r.BLOCK+" a."+r.EDITINGMOVE).each(function(e){e.ancestor("."+r.BLOCK).one("."+r.HEADER).setStyle("cursor","move"),e.remove()})},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(){e.one("body").addClass(this.get_used_region_class()).removeClass(this.get_empty_region_class())},disable_if_required:function(){this.get("node").all("."+r.BLOCK).size()===0&&e.one("body").addClass(this.get_empty_region_class()).removeClass(this.get_used_region_class())}},e.extend(o,e.Base,o.prototype,{NAME:"core-blocks-dragdrop-blockregion",ATTRS:{manager:{writeOnce:"initOnly",validator:function(t){return e.Lang.isObject(t)&&t instanceof s}},region:{writeOnce:"initOnly",validator:function(t){return e.Lang.isString(t)}},node:{validator:function(t){return e.Lang.isObject(t)||e.Lang.isNull(t)}},hasblocks:{value:!1,validator:function(t){return e.Lang.isBoolean(t)}}}})},"@VERSION@",{requires:["base","node","io","dom","dd","dd-scroll","moodle-core-dragdrop","moodle-core-notification"]}); +YUI.add("moodle-core-blocks",function(e,t){var n="/lib/ajax/blocks.php",r={BLOCK:"block",BLOCKREGION:"block-region",BLOCKADMINBLOCK:"block_adminblock",EDITINGMOVE:"editing_move",HEADER:"header",LIGHTBOX:"lightbox",REGIONCONTENT:"region-content",SKIPBLOCK:"skip-block",SKIPBLOCKTO:"skip-block-to",MYINDEX:"page-my-index",REGIONMAIN:"region-main",BLOCKSMOVING:"blocks-moving"},i=function(){i.superclass.constructor.apply(this,arguments)};e.extend(i,M.core.dragdrop,{skipnodetop:null,skipnodebottom:null,dragsourceregion:null,initializer:function(){this.groups=["block"],this.samenodeclass=r.BLOCK,this.parentnodeclass=r.REGIONCONTENT;var t=e.Node.all("body#"+r.MYINDEX+" #"+r.REGIONMAIN+" > ."+r.REGIONCONTENT);if(t.size()>0){var n=t.item(0);n.addClass(r.BLOCKREGION),n.set("id",r.REGIONCONTENT),n.one("div").addClass(r.REGIONCONTENT)}var i=e.Node.all("div."+r.BLOCKREGION);if(i.size()===0)return!1;if(i.size()!==this.get("regions").length){var s=e.Node.create("
").addClass(r.BLOCKREGION),o=e.Node.create("
").addClass(r.REGIONCONTENT);s.appendChild(o);var u=i.filter("#region-pre"),a=i.filter("#region-post");u.size()===0&&a.size()===1?(s.setAttrs({id:"region-pre"}),a.item(0).insert(s,"before"),i.unshift(s)):a.size()===0&&u.size()===1&&(s.setAttrs({id:"region-post"}),u.item(0).insert(s,"after"),i.push(s))}i.each(function(t){new e.DD.Drop({node:t.one("div."+r.REGIONCONTENT),groups:this.groups,padding:"40 240 40 240"});var n=new e.DD.Delegate({container:t,nodes:"."+r.BLOCK,target:!0,handles:["."+r.HEADER],invalid:".block-hider-hide, .block-hider-show, .moveto",dragConfig:{groups:this.groups}});n.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),n.dd.plug(e.Plugin.DDWinScroll);var i=t.all("."+r.BLOCK);i.each(function(e){var t=e.one("a."+r.EDITINGMOVE);t&&(t.remove(),e.one("."+r.HEADER).setStyle("cursor","move"))},this)},this)},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(t){var n=t.ancestor("div."+r.BLOCKREGION).get("id").replace(/region-/i,"");return e.Array.indexOf(this.get("regions"),n)===-1?(right_to_left()&&(n==="post"?n="pre":n==="pre"&&(n="post")),"side-"+n):n},get_region_id:function(e){return e.get("id").replace(/region-/i,"")},drag_start:function(t){var n=t.target;this.dragsourceregion=n.get("node").ancestor("div."+r.BLOCKREGION),n.get("node").previous()&&n.get("node").previous().hasClass(r.SKIPBLOCK)&&(this.skipnodetop=n.get("node").previous()),n.get("node").next()&&n.get("node").next().hasClass(r.SKIPBLOCKTO)&&(this.skipnodebottom=n.get("node").next()),e.one("body").addClass(r.BLOCKSMOVING)},drop_over:function(t){var n=t.drag.get("node"),i=t.drop.get("node");i.hasClass(this.parentnodeclass)&&i.one("."+r.BLOCKADMINBLOCK)&&i.one("."+r.BLOCKADMINBLOCK).next("."+r.BLOCK)&&i.prepend(n);if(this.dragsourceregion.contains(i))return!1;var s=e.one("body"),o=this.get_region_id(this.dragsourceregion);s.hasClass("side-"+o+"-only")&&s.removeClass("side-"+o+"-only"),o=this.get_region_id(i.ancestor("div."+r.BLOCKREGION)),this.dragsourceregion.all("."+r.BLOCK).size()===0&&this.dragsourceregion.get("id").match(/(region-pre|region-post)/i)&&(s.hasClass("side-"+o+"-only")||s.addClass("side-"+o+"-only"))},drag_end:function(){this.skipnodetop=null,this.skipnodebottom=null,this.dragsourceregion=null,e.one("body").removeClass(r.BLOCKSMOVING)},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(t){var i=t.drag,s=i.get("node"),o=t.drop.get("node");s.previous()&&s.previous().hasClass(r.SKIPBLOCK)&&s.insert(s.previous(),"after"),this.skipnodetop&&s.insert(this.skipnodetop,"before"),this.skipnodebottom&&s.insert(this.skipnodebottom,"after");var u=M.util.add_lightbox(e,s),a={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(s),bui_newregion:this.get_block_region(o)};this.get("cmid")&&(a.cmid=this.get("cmid")),s.next("."+this.samenodeclass)&&!s.next("."+this.samenodeclass).hasClass(r.BLOCKADMINBLOCK)&&(a.bui_beforeid=this.get_block_id(s.next("."+this.samenodeclass))),e.io(M.cfg.wwwroot+n,{method:"POST",data:a,on:{start:function(){u.show()},success:function(t,n){window.setTimeout(function(){u.hide()},250);try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r)}catch(i){}},failure:function(e,t){this.ajax_failure(t),u.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(){if(this._isusingnewblocksmethod===null){var t=e.all(".block-region[data-blockregion]").size(),n=e.all(".block-region").size();this._isusingnewblocksmethod=n===t,t>0&&n>0&&t!==n}return this._isusingnewblocksmethod},M.core.blockdraganddrop.init=function(e){this.is_using_blocks_render_method()?new s(e):new i(e)},M.core_blocks=M.core_blocks||{},M.core_blocks.init_dragdrop=function(e){M.core.blockdraganddrop.init(e)};var s=function(){s.superclass.constructor.apply(this,arguments)};s.prototype={skipnodetop:null,skipnodebottom:null,regionobjects:{},initializer:function(){var t=this.get("regions"),n=0,i,s,u;this.groups=["block"],this.samenodeclass=r.BLOCK,this.parentnodeclass=r.BLOCKREGION;var a=e.Node.all("body#"+r.MYINDEX+" #"+r.REGIONMAIN+" > ."+r.REGIONCONTENT);if(a.size()>0){var f=a.item(0);f.addClass(r.BLOCKREGION),f.set("id",r.REGIONCONTENT),f.one("div").addClass(r.REGIONCONTENT)}for(n in t)s=t[n],i=new o({manager:this,region:s,node:e.one("#block-region-"+s)}),this.regionobjects[s]=i,new e.DD.Drop({node:i.get_droptarget(),groups:this.groups,padding:"40 240 40 240"}),u=new e.DD.Delegate({container:i.get_droptarget(),nodes:"."+r.BLOCK,target:!0,handles:["."+r.HEADER +],invalid:".block-hider-hide, .block-hider-show, .moveto",dragConfig:{groups:this.groups}}),u.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),u.dd.plug(e.Plugin.DDWinScroll),e.DD.DDM.on("ddm:start",this.enable_all_regions,this),i.remove_block_move_icons()},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(e){return e.test("[data-blockregion]")||(e=e.ancestor("[data-blockregion]")),e.getData("blockregion")},get_region_object:function(e){return this.regionobjects[this.get_block_region(e)]},enable_all_regions:function(){var t=e.DD.DDM.activeDrag.get("groups");if(!t||e.Array.indexOf(t,"block")===-1)return;var n;for(n in this.regionobjects){if(!this.regionobjects.hasOwnProperty(n))continue;this.regionobjects[n].enable()}},disable_regions_if_required:function(){var e=0;for(e in this.regionobjects)this.regionobjects[e].disable_if_required()},drag_start:function(e){var t=e.target;t.get("node").previous()&&t.get("node").previous().hasClass(r.SKIPBLOCK)&&(this.skipnodetop=t.get("node").previous()),t.get("node").next()&&t.get("node").next().hasClass(r.SKIPBLOCKTO)&&(this.skipnodebottom=t.get("node").next())},drop_over:function(e){var t=e.drag.get("node"),n=e.drop.get("node");n.hasClass(r.REGIONCONTENT)&&n.one("."+r.BLOCKADMINBLOCK)&&n.one("."+r.BLOCKADMINBLOCK).next("."+r.BLOCK)&&n.prepend(t)},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(t){var i=t.drag.get("node"),s=t.drop.get("node");i.previous()&&i.previous().hasClass(r.SKIPBLOCK)&&i.insert(i.previous(),"after"),this.skipnodetop&&i.insert(this.skipnodetop,"before"),this.skipnodebottom&&i.insert(this.skipnodebottom,"after");var o=M.util.add_lightbox(e,i),u={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(i),bui_newregion:this.get_block_region(s)};this.get("cmid")&&(u.cmid=this.get("cmid")),i.next("."+r.BLOCK)&&!i.next("."+r.BLOCK).hasClass(r.BLOCKADMINBLOCK)&&(u.bui_beforeid=this.get_block_id(i.next("."+r.BLOCK))),e.io(M.cfg.wwwroot+n,{method:"POST",data:u,on:{start:function(){o.show()},success:function(t,n){window.setTimeout(function(){o.hide()},250);try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r)}catch(i){}},failure:function(e,t){this.ajax_failure(t),o.hide()},complete:function(){this.disable_regions_if_required()}},context:this})}},e.extend(s,M.core.dragdrop,s.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:[]}}});var o=function(){o.superclass.constructor.apply(this,arguments)};o.prototype={initializer:function(){var t=this.get("node");t||(t=this.create_and_add_node());var n=e.one("body"),i=t.all("."+r.BLOCK).size()>0,s=this.get_has_region_class();this.set("hasblocks",i),n.hasClass(s)||n.addClass(s),n.addClass(i?this.get_used_region_class():this.get_empty_region_class()),n.removeClass(i?this.get_empty_region_class():this.get_used_region_class())},create_and_add_node:function(){var t=e.Node.create,n=this.get("region"),i=t('
').addClass(r.BLOCKREGION).setData("blockregion",n),s=this.get("manager").get("regions"),o,u=!1,a=!1,f=!1,l,c;for(o in s)s[o].match(/(pre|left)/)?u=s[o]:s[o].match(/(post|right)/)&&(a=s[o]);return u!==!1&&a!==!1&&(n===u?(c=e.one("#block-region-"+a),c&&(c.insert(i,"before"),f=!0)):(l=e.one("#block-region-"+u),l&&(l.insert(i,"after"),f=!0))),f===!1&&e.one("body").append(i),this.set("node",i),i},remove_block_move_icons:function(){this.get("node").all("."+r.BLOCK+" a."+r.EDITINGMOVE).each(function(e){e.ancestor("."+r.BLOCK).one("."+r.HEADER).setStyle("cursor","move"),e.remove()})},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(){e.one("body").addClass(this.get_used_region_class()).removeClass(this.get_empty_region_class())},disable_if_required:function(){this.get("node").all("."+r.BLOCK).size()===0&&e.one("body").addClass(this.get_empty_region_class()).removeClass(this.get_used_region_class())}},e.extend(o,e.Base,o.prototype,{NAME:"core-blocks-dragdrop-blockregion",ATTRS:{manager:{writeOnce:"initOnly",validator:function(t){return e.Lang.isObject(t)&&t instanceof s}},region:{writeOnce:"initOnly",validator:function(t){return e.Lang.isString(t)}},node:{validator:function(t){return e.Lang.isObject(t)||e.Lang.isNull(t)}},hasblocks:{value:!1,validator:function(t){return e.Lang.isBoolean(t)}}}})},"@VERSION@",{requires:["base","node","io","dom","dd","dd-scroll","moodle-core-dragdrop","moodle-core-notification"]}); 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 0ae8850ad56..b664cc8c4e5 100644 --- a/lib/yui/build/moodle-core-blocks/moodle-core-blocks.js +++ b/lib/yui/build/moodle-core-blocks/moodle-core-blocks.js @@ -447,7 +447,6 @@ MANAGER.prototype = { i = 0, region, regionname, - droptarget, dragdelegation; // Evil required by M.core.dragdrop. @@ -476,7 +475,7 @@ MANAGER.prototype = { // Setting blockregion as droptarget (the case when it is empty) // The region-post (the right one) // is very narrow, so add extra padding on the left to drop block on it. - droptarget = new Y.DD.Drop({ + new Y.DD.Drop({ node: region.get_droptarget(), groups: this.groups, padding: '40 240 40 240' @@ -496,9 +495,10 @@ MANAGER.prototype = { moveOnEnd: false }); dragdelegation.dd.plug(Y.Plugin.DDWinScroll); - // On the mouse down event we will enable all block regions so that they can be dragged to. - // This is VERY important as without it dnd won't work for empty block regions. - dragdelegation.on('drag:start', this.enable_all_regions, this); + + // 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. + Y.DD.DDM.on('ddm:start', this.enable_all_regions, this); region.remove_block_move_icons(); } @@ -539,12 +539,25 @@ MANAGER.prototype = { /** * Enables all fo the regions so that they are all visible while dragging is occuring. + * * @method enable_all_regions * @returns {undefined} */ enable_all_regions : function() { - var i = 0; + var groups = Y.DD.DDM.activeDrag.get('groups'); + + // As we're called by Y.DD.DDM, we can't be certain that the call + // relates specifically to a block drag/drop operation. Test + // whether the relevant group applies here. + if (!groups || Y.Array.indexOf(groups, 'block') === -1) { + return; + } + + var i; for (i in this.regionobjects) { + if (!this.regionobjects.hasOwnProperty(i)) { + continue; + } this.regionobjects[i].enable(); } }, diff --git a/lib/yui/src/blocks/js/manager.js b/lib/yui/src/blocks/js/manager.js index a3d906b7ca1..92d484348cc 100644 --- a/lib/yui/src/blocks/js/manager.js +++ b/lib/yui/src/blocks/js/manager.js @@ -58,7 +58,6 @@ MANAGER.prototype = { i = 0, region, regionname, - droptarget, dragdelegation; // Evil required by M.core.dragdrop. @@ -87,7 +86,7 @@ MANAGER.prototype = { // Setting blockregion as droptarget (the case when it is empty) // The region-post (the right one) // is very narrow, so add extra padding on the left to drop block on it. - droptarget = new Y.DD.Drop({ + new Y.DD.Drop({ node: region.get_droptarget(), groups: this.groups, padding: '40 240 40 240' @@ -107,9 +106,10 @@ MANAGER.prototype = { moveOnEnd: false }); dragdelegation.dd.plug(Y.Plugin.DDWinScroll); - // On the mouse down event we will enable all block regions so that they can be dragged to. - // This is VERY important as without it dnd won't work for empty block regions. - dragdelegation.on('drag:start', this.enable_all_regions, this); + + // 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. + Y.DD.DDM.on('ddm:start', this.enable_all_regions, this); region.remove_block_move_icons(); } @@ -151,12 +151,25 @@ MANAGER.prototype = { /** * Enables all fo the regions so that they are all visible while dragging is occuring. + * * @method enable_all_regions * @returns {undefined} */ enable_all_regions : function() { - var i = 0; + var groups = Y.DD.DDM.activeDrag.get('groups'); + + // As we're called by Y.DD.DDM, we can't be certain that the call + // relates specifically to a block drag/drop operation. Test + // whether the relevant group applies here. + if (!groups || Y.Array.indexOf(groups, 'block') === -1) { + return; + } + + var i; for (i in this.regionobjects) { + if (!this.regionobjects.hasOwnProperty(i)) { + continue; + } this.regionobjects[i].enable(); } }, From 1c5d239f2d9c7858882cfbc6175320b7351b47a7 Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Thu, 10 Apr 2014 17:32:03 +0800 Subject: [PATCH 08/22] MDL-45037 gradebook: Allow dashes in xml grade values to be ignored. This was delivering an error message when trying to import an exported xml file (from Moodle). --- grade/import/xml/lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grade/import/xml/lib.php b/grade/import/xml/lib.php index 3e059f83c4a..3984cca059f 100644 --- a/grade/import/xml/lib.php +++ b/grade/import/xml/lib.php @@ -82,7 +82,7 @@ function import_xml_grades($text, $course, &$error) { $newgrade->importer = $USER->id; // check grade value exists and is a numeric grade - if (isset($result['#']['score'][0]['#'])) { + if (isset($result['#']['score'][0]['#']) && $result['#']['score'][0]['#'] !== '-') { if (is_numeric($result['#']['score'][0]['#'])) { $newgrade->finalgrade = $result['#']['score'][0]['#']; } else { From 2620fcc116484f9f5c3afc99eb23df742e081aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Mon, 14 Apr 2014 13:16:41 +0800 Subject: [PATCH 09/22] MDL-45049 improve debugging output in error log for NO_DEBUG_DISPLAY scripts --- lib/weblib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index b61725a2c6f..8675d8b2596 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2810,7 +2810,7 @@ function debugging($message = '', $level = DEBUG_NORMAL, $backtrace = null) { if (!$backtrace) { $backtrace = debug_backtrace(); } - $from = format_backtrace($backtrace, CLI_SCRIPT); + $from = format_backtrace($backtrace, CLI_SCRIPT || NO_DEBUG_DISPLAY); if (PHPUNIT_TEST) { if (phpunit_util::debugging_triggered($message, $level, $from)) { // We are inside test, the debug message was logged. @@ -2821,7 +2821,7 @@ function debugging($message = '', $level = DEBUG_NORMAL, $backtrace = null) { if (NO_DEBUG_DISPLAY) { // script does not want any errors or debugging in output, // we send the info to error log instead - error_log('Debugging: ' . $message . $from); + error_log('Debugging: ' . $message . ' in '. PHP_EOL . $from); } else if ($forcedebug or $CFG->debugdisplay) { if (!defined('DEBUGGING_PRINTED')) { From 0859a464cb1a64a745e1b8ec82aec01dbf3a2107 Mon Sep 17 00:00:00 2001 From: Jonathon Fowler Date: Tue, 15 Apr 2014 14:18:55 +1000 Subject: [PATCH 10/22] MDL-44270 files: handle drag-drop js error when event has null types This can happen when the 'dragover' event fires as has been observed in Safari. When the dataTransfer.types property of the event is null, accessing types.length throws a JavaScript error. --- lib/form/dndupload.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/form/dndupload.js b/lib/form/dndupload.js index 4be065040c7..f93f261c000 100644 --- a/lib/form/dndupload.js +++ b/lib/form/dndupload.js @@ -355,7 +355,10 @@ M.form_dndupload.init = function(Y, options) { * @return boolean true if event has files */ has_files: function(e) { - var types = e._event.dataTransfer.types; + // In some browsers, dataTransfer.types may be null for a + // 'dragover' event, so ensure a valid Array is always + // inspected. + var types = e._event.dataTransfer.types || []; for (var i=0; i Date: Wed, 16 Apr 2014 13:32:54 +0800 Subject: [PATCH 11/22] MDL-41975 repository_alfresco: Ensure Moodle sends GMT time to Alfresco --- lib/alfresco/Service/WebService/AlfrescoWebService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/alfresco/Service/WebService/AlfrescoWebService.php b/lib/alfresco/Service/WebService/AlfrescoWebService.php index b549755b467..898dcdf73db 100644 --- a/lib/alfresco/Service/WebService/AlfrescoWebService.php +++ b/lib/alfresco/Service/WebService/AlfrescoWebService.php @@ -79,8 +79,8 @@ class AlfrescoWebService extends SoapClient // Construct Timestamp Header $timeStamp = $dom->createElementNS($this->wsUtilityNS, "Timestamp"); - $createdDate = date("Y-m-d\TH:i:s\Z", mktime(date("H")+24, date("i"), date("s"), date("m"), date("d"), date("Y"))); - $expiresDate = date("Y-m-d\TH:i:s\Z", mktime(date("H")+25, date("i"), date("s"), date("m"), date("d"), date("Y"))); + $createdDate = gmdate("Y-m-d\TH:i:s\Z", gmmktime(gmdate("H"), gmdate("i"), gmdate("s"), gmdate("m"), gmdate("d"), gmdate("Y"))); + $expiresDate = gmdate("Y-m-d\TH:i:s\Z", gmmktime(gmdate("H")+1, gmdate("i"), gmdate("s"), gmdate("m"), gmdate("d"), gmdate("Y"))); $created = new DOMElement("Created", $createdDate, $this->wsUtilityNS); $expires = new DOMElement("Expires", $expiresDate, $this->wsUtilityNS); $timeStamp->appendChild($created); From ec0efc18e177ab81167cc9e6f2dbd384df35293d Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Wed, 16 Apr 2014 13:38:27 +0800 Subject: [PATCH 12/22] MDL-41975 repository_alfresco: Updating details about Alfresco URL and timestamps --- lib/alfresco/README_MOODLE.txt | 2 ++ repository/alfresco/lang/en/repository_alfresco.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/alfresco/README_MOODLE.txt b/lib/alfresco/README_MOODLE.txt index 83179f07fdb..aaf6400c32c 100644 --- a/lib/alfresco/README_MOODLE.txt +++ b/lib/alfresco/README_MOODLE.txt @@ -34,6 +34,8 @@ - AlfrescoWebService::__soapCall() arguments do not match SoapClient::__soapCall() - AlfrescoWebService::__doRequest() arguments do not match SoapClient::__soapCall() +6. Apply the changes from MDL-41975 in regard with the timestamp + == Alfresco PHP Library == Installation and developer documentation for the Alfresco PHP Library can be found on the Alfresco Wiki. diff --git a/repository/alfresco/lang/en/repository_alfresco.php b/repository/alfresco/lang/en/repository_alfresco.php index fe75bd5beb7..1bcc0e0c981 100644 --- a/repository/alfresco/lang/en/repository_alfresco.php +++ b/repository/alfresco/lang/en/repository_alfresco.php @@ -24,7 +24,7 @@ */ $string['alfresco_url'] = 'Alfresco URL'; -$string['alfrescourltext'] = 'Afresco API url should be: http://yoursite.com/alfresco/api'; +$string['alfrescourltext'] = 'Afresco API URL should be: http://yoursite.com/alfresco/api or http://yoursite.com/alfresco/soapapi for Alfresco 4.2.d or greater.'; $string['alfresco:view'] = 'View alfresco repository'; $string['configplugin'] = 'Alfresco configuration'; $string['notitle'] = 'notitle'; From 5727b32b3fe48c2bc8fec45735a8e9aca05ed9a8 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Thu, 17 Apr 2014 12:46:07 +0800 Subject: [PATCH 13/22] MDL-42761 badges: Remove H2s from help popup --- lang/en/badges.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lang/en/badges.php b/lang/en/badges.php index 62aba784012..f8c701bc8a9 100644 --- a/lang/en/badges.php +++ b/lang/en/badges.php @@ -64,15 +64,15 @@ $string['awards'] = 'Recipients'; $string['backpackavailability'] = 'External badge verification'; $string['backpackavailability_help'] = 'For badge recipients to be able to prove they earned their badges from you, an external backpack service should be able to access your site and verify badges issued from it. Your site does not currently appear to be accessible, which means that badges you have already issued or will issue in the future cannot be verified. -##Why am I seeing this message? +**Why am I seeing this message?** It may be that your firewall prevents access from users outside your network, your site is password protected, or you are running the site on a computer that is not available from the Internet (such as a local development machine). -##Is this a problem? +**Is this a problem?** You should fix this issue on any production site where you are planning to issue badges, otherwise the recipients will not be able to prove they earned their badges from you. If your site is not yet live you can create and issue test badges, as long as the site is accessible before you go live. -##What if I can\'t make my whole site publicly accessible? +**What if I can\'t make my whole site publicly accessible?** The only URL required for verification is [your-site-url]/badges/assertion.php so if you are able to modify your firewall to allow external access to that file, badge verification will still work.'; $string['backpackbadges'] = 'You have {$a->totalbadges} badge(s) displayed from {$a->totalcollections} collection(s). Change backpack settings.'; From 93815e49d27046681e0af888482e3d4cef44609e Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Thu, 17 Apr 2014 14:24:58 +0800 Subject: [PATCH 14/22] MDL-45154 user profiles: avoid redirection warnings --- user/profile/definelib.php | 4 ++-- user/profile/index.php | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/user/profile/definelib.php b/user/profile/definelib.php index c73baf32486..eae98b3ea4e 100644 --- a/user/profile/definelib.php +++ b/user/profile/definelib.php @@ -418,7 +418,7 @@ function profile_list_categories() { function profile_edit_category($id, $redirect) { global $CFG, $DB, $OUTPUT; - require_once('index_category_form.php'); + require_once($CFG->dirroot.'/user/profile/index_category_form.php'); $categoryform = new category_form(); if ($category = $DB->get_record('user_info_category', array('id'=>$id))) { @@ -474,7 +474,7 @@ function profile_edit_field($id, $datatype, $redirect) { $field->description = clean_text($field->description, $field->descriptionformat); $field->description = array('text'=>$field->description, 'format'=>$field->descriptionformat, 'itemid'=>0); - require_once('index_field_form.php'); + require_once($CFG->dirroot.'/user/profile/index_field_form.php'); $fieldform = new field_form(null, $field->datatype); // Convert the data format for diff --git a/user/profile/index.php b/user/profile/index.php index 17ab381403f..4c6fe664b01 100644 --- a/user/profile/index.php +++ b/user/profile/index.php @@ -87,12 +87,11 @@ switch ($action) { //normal form } -/// Print the header -echo $OUTPUT->header(); -echo $OUTPUT->heading(get_string('profilefields', 'admin')); +// Show all categories. +$categories = $DB->get_records('user_info_category', null, 'sortorder ASC'); -/// Check that we have at least one category defined -if ($DB->count_records('user_info_category') == 0) { +// Check that we have at least one category defined. +if (empty($categories)) { $defaultcategory = new stdClass(); $defaultcategory->name = $strdefaultcategory; $defaultcategory->sortorder = 1; @@ -100,8 +99,9 @@ if ($DB->count_records('user_info_category') == 0) { redirect($redirect); } -/// Show all categories -$categories = $DB->get_records('user_info_category', null, 'sortorder ASC'); +// Print the header. +echo $OUTPUT->header(); +echo $OUTPUT->heading(get_string('profilefields', 'admin')); foreach ($categories as $category) { $table = new html_table(); From 13a554a52e965a9448c2eab3027c1aaf2f685467 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Thu, 17 Apr 2014 15:16:06 +1200 Subject: [PATCH 15/22] MDL-45147 my: automate testing of block restriction --- .../behat/restrict_available_blocks.feature | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 my/tests/behat/restrict_available_blocks.feature diff --git a/my/tests/behat/restrict_available_blocks.feature b/my/tests/behat/restrict_available_blocks.feature new file mode 100644 index 00000000000..abcd337c55b --- /dev/null +++ b/my/tests/behat/restrict_available_blocks.feature @@ -0,0 +1,42 @@ +@core @core_my +Feature: Restrict which blocks can be added to My home + In order to restrict which blocks can be added + As a student I need to ensure I can add the blocks + As an admin I need to remove the capability to add a blocks + As a student I need to ensure I can't add the blocks any more + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Student | 1 | student1@asd.com | + And the following "courses" exist: + | fullname | shortname | format | + | Course 1 | C1 | topics | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + + Scenario: The comments block can be added to My home by default + And I log in as "student1" + And I follow "My home" + And I press "Customise this page" + Then the "Add a block" select box should contain "Comments" + And the "Add a block" select box should contain "Courses" + And the "Add a block" select box should contain "HTML" + And the "Add a block" select box should contain "Tags" + + @javascript + Scenario: Remove the ability to add the comments block to My home + When I log in as "admin" + And I set the following system permissions of "Authenticated user" role: + | block/comments:myaddinstance | Prohibit | + | block/course_list:myaddinstance | Prohibit | + | block/html:myaddinstance | Prohibit | + And I log out + And I log in as "student1" + And I follow "My home" + And I press "Customise this page" + Then the "Add a block" select box should not contain "Comments" + And the "Add a block" select box should not contain "Courses" + And the "Add a block" select box should not contain "HTML" + And the "Add a block" select box should contain "Tags" \ No newline at end of file From caebab92973d30293cb9500dce5fb3a585ff87a1 Mon Sep 17 00:00:00 2001 From: Nadav Kavalerchik Date: Thu, 18 Jul 2013 12:24:41 +0300 Subject: [PATCH 16/22] MDL-40716 - Activity labels are not visible in course completion report, when in RTL mode (theme/clean , bootstrap) --- report/progress/styles.css | 1 + 1 file changed, 1 insertion(+) diff --git a/report/progress/styles.css b/report/progress/styles.css index 2c0350c9134..902dbf8a39b 100644 --- a/report/progress/styles.css +++ b/report/progress/styles.css @@ -5,3 +5,4 @@ #page-report-progress-index .completion_prev {display:inline;margin-right:2em;} #page-report-progress-index .completion_pagingbar p {display:inline;margin:0;} #page-report-progress-index .completion_next {display:inline;margin-left:2em;} +#page-report-progress-index.dir-rtl #completion-progress th svg {direction:ltr;} From 10281644a36cfc10fdb31e03b26895e9ff5cbbe8 Mon Sep 17 00:00:00 2001 From: David Scotson Date: Thu, 6 Mar 2014 12:03:40 +0000 Subject: [PATCH 17/22] MDL-44468 backup: use notification API Replace a hardcoded div.notifyproblem with a API call that, in Standard theme, outputs the same HTML. Also removes the .notifyproblem class from the heading, as that might cause problems for themers who expect it to be used consistently with the API. --- backup/util/ui/renderer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backup/util/ui/renderer.php b/backup/util/ui/renderer.php index 57e71cb84ec..d79eb011e34 100644 --- a/backup/util/ui/renderer.php +++ b/backup/util/ui/renderer.php @@ -204,8 +204,8 @@ class core_backup_renderer extends plugin_renderer_base { public function backup_details_unknown(moodle_url $nextstageurl) { $html = html_writer::start_tag('div', array('class' => 'unknownformat')); - $html .= $this->output->heading(get_string('errorinvalidformat', 'backup'), 2, 'notifyproblem'); - $html .= html_writer::tag('div', get_string('errorinvalidformatinfo', 'backup'), array('class' => 'notifyproblem')); + $html .= $this->output->heading(get_string('errorinvalidformat', 'backup'), 2); + $html .= $this->output->notification(get_string('errorinvalidformatinfo', 'backup'), 'notifyproblem'); $html .= $this->output->single_button($nextstageurl, get_string('continue'), 'post'); $html .= html_writer::end_tag('div'); From a9d31ba04878b4648ebc494abc90acb04fde820f Mon Sep 17 00:00:00 2001 From: David Scotson Date: Thu, 6 Mar 2014 12:11:42 +0000 Subject: [PATCH 18/22] MDL-44468 backup: use html_writer::div call Simplify the renderer code with the new html_writer div function. --- backup/util/ui/renderer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backup/util/ui/renderer.php b/backup/util/ui/renderer.php index d79eb011e34..a3cdbf3d772 100644 --- a/backup/util/ui/renderer.php +++ b/backup/util/ui/renderer.php @@ -203,11 +203,11 @@ class core_backup_renderer extends plugin_renderer_base { */ public function backup_details_unknown(moodle_url $nextstageurl) { - $html = html_writer::start_tag('div', array('class' => 'unknownformat')); + $html = html_writer::start_div('unknownformat'); $html .= $this->output->heading(get_string('errorinvalidformat', 'backup'), 2); $html .= $this->output->notification(get_string('errorinvalidformatinfo', 'backup'), 'notifyproblem'); $html .= $this->output->single_button($nextstageurl, get_string('continue'), 'post'); - $html .= html_writer::end_tag('div'); + $html .= html_writer::end_div(); return $html; } From 067d7ee92d28e68e9741c1c9711385fc447e2af4 Mon Sep 17 00:00:00 2001 From: Matt Petro Date: Tue, 15 Apr 2014 23:11:32 -0400 Subject: [PATCH 19/22] MDL-45118 shibboleth: set context on index page --- auth/shibboleth/index.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/auth/shibboleth/index.php b/auth/shibboleth/index.php index 61f6ba877f8..cf9695899ad 100644 --- a/auth/shibboleth/index.php +++ b/auth/shibboleth/index.php @@ -4,7 +4,9 @@ require('../../config.php'); + $context = context_system::instance(); $PAGE->set_url('/auth/shibboleth/index.php'); + $PAGE->set_context($context); // Support for WAYFless URLs. $target = optional_param('target', '', PARAM_LOCALURL); From 4a41887292cac12b1ca719d0f5d33c2ecc303e7c Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Tue, 22 Apr 2014 10:37:27 +0800 Subject: [PATCH 20/22] MDL-45154 user profiles: category name duplication error --- user/profile/index_category_form.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user/profile/index_category_form.php b/user/profile/index_category_form.php index d835db12d58..20bb5354789 100644 --- a/user/profile/index_category_form.php +++ b/user/profile/index_category_form.php @@ -37,13 +37,13 @@ class category_form extends moodleform { $data = (object)$data; - $duplicate = $DB->record_exists('user_info_category', array('name'=>$data->name)); + $duplicate = $DB->get_field('user_info_category', 'id', array('name' => $data->name)); /// Check the name is unique if (!empty($data->id)) { // we are editing an existing record $olddata = $DB->get_record('user_info_category', array('id'=>$data->id)); // name has changed, new name in use, new name in use by another record - $dupfound = (($olddata->name !== $data->name) && $duplicate && ($data->id != $duplicate->id)); + $dupfound = (($olddata->name !== $data->name) && $duplicate && ($data->id != $duplicate)); } else { // new profile category $dupfound = $duplicate; From dbc3519e208be0070d94428fe8502595b28b10c4 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Tue, 22 Apr 2014 15:06:23 +0800 Subject: [PATCH 21/22] MDL-40716 report_completion: Set RTL --- report/completion/styles.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/report/completion/styles.css b/report/completion/styles.css index ed84511eb9a..fa601eb4e02 100644 --- a/report/completion/styles.css +++ b/report/completion/styles.css @@ -6,3 +6,6 @@ #page-report-completion-index .export-actions { text-align: center; } +#page-report-completion-index.dir-rtl #completion-progress th svg { + direction: ltr; +} From 689f9aa1f52db2f5eac75251b8a57161b24a0eeb Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Tue, 22 Apr 2014 12:26:39 +0200 Subject: [PATCH 22/22] weekly release 2.5.5+ --- version.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.php b/version.php index e2b04896feb..e780776724d 100644 --- a/version.php +++ b/version.php @@ -29,11 +29,11 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2013051405.07; // 20130514 = branching date YYYYMMDD - do not modify! +$version = 2013051405.08; // 20130514 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches // .XX = incremental changes -$release = '2.5.5+ (Build: 20140417)'; // Human-friendly version name +$release = '2.5.5+ (Build: 20140422)'; // Human-friendly version name $branch = '25'; // this version's branch $maturity = MATURITY_STABLE; // this version's maturity level