MDL-54722 navigation: Properly overflow expanded nav trees
authorCameron Ball <cameron@moodle.com>
Tue, 31 May 2016 08:56:09 +0000 (16:56 +0800)
committerCameron Ball <cameron@moodle.com>
Wed, 1 Jun 2016 02:15:22 +0000 (10:15 +0800)
15 files changed:
blocks/navigation/amd/build/navblock.min.js
blocks/navigation/amd/src/navblock.js
blocks/navigation/block_navigation.php
blocks/settings/amd/build/settingsblock.min.js
blocks/settings/amd/src/settingsblock.js
blocks/settings/block_settings.php
lib/yui/build/moodle-core-dock/moodle-core-dock-debug.js
lib/yui/build/moodle-core-dock/moodle-core-dock-min.js
lib/yui/build/moodle-core-dock/moodle-core-dock.js
lib/yui/build/moodle-core-event/moodle-core-event-debug.js
lib/yui/build/moodle-core-event/moodle-core-event-min.js
lib/yui/build/moodle-core-event/moodle-core-event.js
lib/yui/src/dock/js/dock.js
lib/yui/src/dock/meta/dock.json
lib/yui/src/event/js/event.js

index 5a5d7b9..60df49e 100644 (file)
Binary files a/blocks/navigation/amd/build/navblock.min.js and b/blocks/navigation/amd/build/navblock.min.js differ
index 14b14bb..cd44db3 100644 (file)
  */
 define(['jquery', 'core/tree'], function($, Tree) {
     return {
-        init: function() {
-            new Tree(".block_navigation .block_tree");
+        init: function(instanceid) {
+            var navTree = new Tree(".block_navigation .block_tree");
+            navTree.finishExpandingGroup = function(item) {
+                Tree.prototype.finishExpandingGroup.call(this, item);
+                Y.Global.fire(M.core.globalEvents.BLOCK_CONTENT_UPDATED, {
+                    instanceid: instanceid
+                });
+            };
+            navTree.collapseGroup = function(item) {
+                Tree.prototype.collapseGroup.call(this, item);
+                Y.Global.fire(M.core.globalEvents.BLOCK_CONTENT_UPDATED, {
+                    instanceid: instanceid
+                });
+            };
         }
     };
 });
index 31a3fc8..e7a5c11 100644 (file)
@@ -108,8 +108,11 @@ class block_navigation extends block_base {
      */
     function get_required_javascript() {
         parent::get_required_javascript();
+        $arguments = array(
+            'instanceid' => $this->instance->id
+        );
         $this->page->requires->string_for_js('viewallcourses', 'moodle');
-        $this->page->requires->js_call_amd('block_navigation/navblock', 'init', array());
+        $this->page->requires->js_call_amd('block_navigation/navblock', 'init', $arguments);
     }
 
     /**
index 91aa6a5..de0b9b9 100644 (file)
Binary files a/blocks/settings/amd/build/settingsblock.min.js and b/blocks/settings/amd/build/settingsblock.min.js differ
index 965aec5..01187fd 100644 (file)
 /**
  * Load the settings block tree javscript
  *
- * @module     block_navigation/navblock
+ * @module     block_settings/settingsblock
  * @package    core
  * @copyright  2015 John Okely <john@moodle.com>
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 define(['jquery', 'core/tree'], function($, Tree) {
     return {
-        init: function(siteAdminNodeId) {
+        init: function(instanceid, siteAdminNodeId) {
             var adminTree = new Tree(".block_settings .block_tree");
             if (siteAdminNodeId) {
                 var siteAdminNode = adminTree.treeRoot.find('#' + siteAdminNodeId);
                 var siteAdminLink = siteAdminNode.children('a').first();
                 siteAdminLink.replaceWith('<span tabindex="0">' + siteAdminLink.html() + '</span>');
             }
+            adminTree.finishExpandingGroup = function(item) {
+                Tree.prototype.finishExpandingGroup.call(this, item);
+                Y.Global.fire(M.core.globalEvents.BLOCK_CONTENT_UPDATED, {
+                    instanceid: instanceid
+                });
+            };
+            adminTree.collapseGroup = function(item) {
+                Tree.prototype.collapseGroup.call(this, item);
+                Y.Global.fire(M.core.globalEvents.BLOCK_CONTENT_UPDATED, {
+                    instanceid: instanceid
+                });
+            };
         }
     };
 });
index beaa87f..1ed9409 100644 (file)
@@ -91,18 +91,13 @@ class block_settings extends block_base {
 
     function get_required_javascript() {
         global $PAGE;
-        $adminnodeid = null;
         $adminnode = $PAGE->settingsnav->find('siteadministration', navigation_node::TYPE_SITE_ADMIN);
-        if (!empty($adminnode)) {
-            $adminnodeid = $adminnode->id;
-        }
         parent::get_required_javascript();
         $arguments = array(
-            'id' => $this->instance->id,
-            'instance' => $this->instance->id,
-            'candock' => $this->instance_can_be_docked()
+            'instanceid' => $this->instance->id,
+            'adminnodeid' => $adminnode ? $adminnode->id : null
         );
-        $this->page->requires->js_call_amd('block_settings/settingsblock', 'init', array($adminnodeid));
+        $this->page->requires->js_call_amd('block_settings/settingsblock', 'init', $arguments);
     }
 
     /**
index bd12367..6d060fb 100644 (file)
Binary files a/lib/yui/build/moodle-core-dock/moodle-core-dock-debug.js and b/lib/yui/build/moodle-core-dock/moodle-core-dock-debug.js differ
index 293b9c1..a6e9b29 100644 (file)
Binary files a/lib/yui/build/moodle-core-dock/moodle-core-dock-min.js and b/lib/yui/build/moodle-core-dock/moodle-core-dock-min.js differ
index 7e6f8cd..35bb1e3 100644 (file)
Binary files a/lib/yui/build/moodle-core-dock/moodle-core-dock.js and b/lib/yui/build/moodle-core-dock/moodle-core-dock.js differ
index ca46f73..75d33c1 100644 (file)
Binary files a/lib/yui/build/moodle-core-event/moodle-core-event-debug.js and b/lib/yui/build/moodle-core-event/moodle-core-event-debug.js differ
index ced026e..7a13d0d 100644 (file)
Binary files a/lib/yui/build/moodle-core-event/moodle-core-event-min.js and b/lib/yui/build/moodle-core-event/moodle-core-event-min.js differ
index 6a18fe6..a54d395 100644 (file)
Binary files a/lib/yui/build/moodle-core-event/moodle-core-event.js and b/lib/yui/build/moodle-core-event/moodle-core-event.js differ
index 8e03abc..e16d3e4 100644 (file)
@@ -62,6 +62,9 @@ M.core.dock._dockableblocks = {};
  */
 M.core.dock.init = function() {
     Y.all(SELECTOR.dockableblock).each(M.core.dock.registerDockableBlock);
+    Y.Global.on(M.core.globalEvents.BLOCK_CONTENT_UPDATED, function(e) {
+        M.core.dock.notifyBlockChange(e.instanceid);
+    }, this);
     BODY.delegate('click', M.core.dock.dockBlock, SELECTOR.blockmoveto);
     BODY.delegate('key', M.core.dock.dockBlock, SELECTOR.blockmoveto, 'enter');
 };
index 9f88e2a..7616fbd 100644 (file)
@@ -7,7 +7,8 @@
         "event-mouseenter",
         "event-resize",
         "escape",
-        "moodle-core-dock-loader"
+        "moodle-core-dock-loader",
+        "moodle-core-event"
     ]
   },
   "moodle-core-dock-loader": {
index 5a51c2a..f30f900 100644 (file)
@@ -50,7 +50,15 @@ M.core.globalEvents = M.core.globalEvents || {
      * @param formid {string} Id of form with error.
      * @param elementid {string} Id of element with error.
      */
-    FORM_ERROR: "form_error"
+    FORM_ERROR: "form_error",
+
+    /**
+     * This event is triggered when the content of a block has changed
+     *
+     * @event "block_content_updated"
+     * @param instanceid ID of the block instance that was updated
+     */
+    BLOCK_CONTENT_UPDATED: "block_content_updated"
 };