From bbb483b25935f97ea1da13f8b05d45f49f0badd2 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Thu, 15 Aug 2013 16:03:44 +0800 Subject: [PATCH] MDL-36002 Drag and Drop: Improvements to keyboard drag and drop List of fixes: * Add a simulated drag start event to fix problems with block drag and drop that were expecting it. * Add an access-hidden title for the General section in a course format. This is used to provide the text for the drop region (better than the first activity in the section) * Changed the text in the list to 'Move to "General"' instead of 'Move after General'. This makes more sense for activities when you have a list of activities and sections together. --- course/format/renderer.php | 4 +++- course/lib.php | 2 +- lang/en/moodle.php | 2 +- lib/outputrequirementslib.php | 2 +- lib/yui/dragdrop/dragdrop.js | 9 ++++++--- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/course/format/renderer.php b/course/format/renderer.php index fe693152222..bfc5641b364 100644 --- a/course/format/renderer.php +++ b/course/format/renderer.php @@ -172,9 +172,11 @@ abstract class format_section_renderer_base extends plugin_renderer_base { // When on a section page, we only display the general section title, if title is not the default one $hasnamesecpg = ($onsectionpage && ($section->section == 0 && !is_null($section->name))); + $classes = ' accesshide'; if ($hasnamenotsecpg || $hasnamesecpg) { - $o.= $this->output->heading($this->section_title($section, $course), 3, 'sectionname'); + $classes = ''; } + $o.= $this->output->heading($this->section_title($section, $course), 3, 'sectionname' . $classes); $o.= html_writer::start_tag('div', array('class' => 'summary')); $o.= $this->format_summary_text($section); diff --git a/course/lib.php b/course/lib.php index 3aa7bd61753..aec879b819a 100644 --- a/course/lib.php +++ b/course/lib.php @@ -2978,7 +2978,7 @@ function include_course_ajax($course, $usedmodules = array(), $enabledmodules = 'move', 'movesection', 'movecontent', - 'aftercontent', + 'tocontent', 'emptydragdropregion' ), 'moodle'); diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 7361225dd43..8d7be67bc07 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -115,7 +115,6 @@ $string['administratorsandteachers'] = 'Administrators and teachers'; $string['advanced'] = 'Advanced'; $string['advancedfilter'] = 'Advanced search'; $string['advancedsettings'] = 'Advanced settings'; -$string['aftercontent'] = 'After {$a}'; $string['again'] = 'again'; $string['aimid'] = 'AIM ID'; $string['ajaxuse'] = 'AJAX and Javascript'; @@ -1676,6 +1675,7 @@ $string['time'] = 'Time'; $string['timezone'] = 'Timezone'; $string['to'] = 'To'; $string['tocreatenewaccount'] = 'Skip to create new account'; +$string['tocontent'] = 'To item "{$a}"'; $string['today'] = 'Today'; $string['todaylogs'] = 'Today\'s logs'; $string['toeveryone'] = 'to everyone'; diff --git a/lib/outputrequirementslib.php b/lib/outputrequirementslib.php index a978401030a..f6c6b4b2857 100644 --- a/lib/outputrequirementslib.php +++ b/lib/outputrequirementslib.php @@ -302,7 +302,7 @@ class page_requirements_manager { } // Strings for drag and drop. $this->strings_for_js(array('movecontent', - 'aftercontent', + 'tocontent', 'emptydragdropregion'), 'moodle'); $page->requires->yui_module('moodle-core-blocks', 'M.core_blocks.init_dragdrop', array($params), null, true); diff --git a/lib/yui/dragdrop/dragdrop.js b/lib/yui/dragdrop/dragdrop.js index 8dc4ba05ab2..6448bb0a350 100644 --- a/lib/yui/dragdrop/dragdrop.js +++ b/lib/yui/dragdrop/dragdrop.js @@ -283,7 +283,7 @@ YUI.add('moodle-core-dragdrop', function(Y) { listlink = Y.Node.create(''); nodetitle = this.find_element_text(labelroot); - listitemtext = M.util.get_string('aftercontent', 'moodle', nodetitle); + listitemtext = M.util.get_string('tocontent', 'moodle', nodetitle); listlink.setContent(listitemtext); // Add a data attribute so we can get the real drop target. @@ -339,7 +339,6 @@ YUI.add('moodle-core-dragdrop', function(Y) { * @param {Node} dropnode The node to initiate the drop on */ simulated_drag_drop_event : function(dragnode, dropnode) { - this.target = dropnode; // Subclass for wrapping both drag and drop. var dragdropwrapper = function(node) { @@ -367,6 +366,7 @@ YUI.add('moodle-core-dragdrop', function(Y) { // Create instances of the dragdropwrapper. this.drop = new dragdropwrapper(dropnode); this.drag = new dragdropwrapper(dragnode); + this.target = this.drop; }, /** @@ -386,8 +386,11 @@ YUI.add('moodle-core-dragdrop', function(Y) { M.core.dragdrop.dropui.hide(); // Cancel the event. e.preventDefault(); - // Convert to a drag drop event. + // Convert to drag drop events. + var dragevent = new this.simulated_drag_drop_event(dragcontainer, dragcontainer); var dropevent = new this.simulated_drag_drop_event(dragcontainer, droptarget); + // Simulate the full sequence. + this.drag_start(dragevent); this.global_drop_over(dropevent); this.global_drop_hit(dropevent); M.core.dragdrop.keydraghandle.focus();