MDL-36607: Improve block drag and drop

* Adding support for subpage
* Adding support for regions that do not start with "side-"
This commit is contained in:
Mark Nielsen
2012-11-14 15:35:14 -08:00
committed by Sam Hemelryk
parent 9d8abffc87
commit e893c6d442
3 changed files with 14 additions and 1 deletions
+1
View File
@@ -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);
+2
View File
@@ -30,6 +30,7 @@ require_once(dirname(__FILE__) . '/../../config.php');
$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 @@ require_sesskey();
// 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) {
+11 -1
View File
@@ -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
}