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:
committed by
Sam Hemelryk
parent
9d8abffc87
commit
e893c6d442
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Vendored
+11
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user