Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-36607: Improve block drag and drop

* Adding support for subpage
* Adding support for regions that do not start with "side-"
  • Loading branch information...
commit 4d5970ea638b347aa8e7702b7f1d72bb48ae4253 1 parent 656cea2
@mrmark mrmark authored samhemelryk committed
View
1  course/lib.php
@@ -4493,6 +4493,7 @@ function include_course_ajax($course, $usedmodules = array(), $enabledmodules =
'courseid' => $course->id,
'pagetype' => $PAGE->pagetype,
'pagelayout' => $PAGE->pagelayout,
+ 'subpage' => $PAGE->subpage,
'regions' => $PAGE->blocks->get_regions(),
);
$PAGE->requires->yui_module('moodle-core-blocks', 'M.core_blocks.init_dragdrop', array($params), null, true);
View
2  lib/ajax/blocks.php
@@ -30,6 +30,7 @@
$courseid = required_param('courseid', PARAM_INT);
$pagelayout = required_param('pagelayout', PARAM_ALPHAEXT);
$pagetype = required_param('pagetype', PARAM_ALPHAEXT);
+$subpage = optional_param('subpage', '', PARAM_ALPHANUMEXT);
$cmid = optional_param('cmid', null, PARAM_INT);
$action = optional_param('action', '', PARAM_ALPHA);
// Params for blocks-move actions
@@ -51,6 +52,7 @@
// Setting layout to replicate blocks configuration for the page we edit
$PAGE->set_pagelayout($pagelayout);
+$PAGE->set_subpage($subpage);
echo $OUTPUT->header(); // send headers
switch ($action) {
View
12 lib/yui/blocks/blocks.js
@@ -99,7 +99,13 @@ YUI.add('moodle-core-blocks', function(Y) {
},
get_block_region : function(node) {
- return node.ancestor('div.'+CSS.BLOCKREGION).get('id').replace(/region/i, 'side');
+ var region = node.ancestor('div.'+CSS.BLOCKREGION).get('id').replace(/region-/i, '');
+ if (Y.Array.indexOf(this.get('regions'), region) === -1) {
+ // Must be standard side-X
+ return 'side-' + region;
+ }
+ // Perhaps custom region
+ return region;
},
get_region_id : function(node) {
@@ -207,6 +213,7 @@ YUI.add('moodle-core-blocks', function(Y) {
courseid : this.get('courseid'),
pagelayout : this.get('pagelayout'),
pagetype : this.get('pagetype'),
+ subpage : this.get('subpage'),
action : 'move',
bui_moveid : this.get_block_id(dragnode),
bui_newregion : this.get_block_region(dropnode)
@@ -262,6 +269,9 @@ YUI.add('moodle-core-blocks', function(Y) {
pagetype : {
value : null
},
+ subpage : {
+ value : null
+ },
regions : {
value : null
}
Please sign in to comment.
Something went wrong with that request. Please try again.