Skip to content

Commit

Permalink
MDL-54722 navigation: Properly overflow expanded nav trees
Browse files Browse the repository at this point in the history
  • Loading branch information
cameorn1730 committed Jun 1, 2016
1 parent 6a74e76 commit fd5466a
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 26 deletions.
2 changes: 1 addition & 1 deletion blocks/navigation/amd/build/navblock.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions blocks/navigation/amd/src/navblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,20 @@
*/
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
});
};
}
};
});
5 changes: 4 additions & 1 deletion blocks/navigation/block_navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,11 @@ function instance_can_be_docked() {
*/
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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion blocks/settings/amd/build/settingsblock.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions blocks/settings/amd/src/settingsblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,32 @@
/**
* Load the settings block tree javscript
*
* @module block_navigation/navblock
* @module block_settings/settingsblock
* @package core
* @copyright 2015 John Okely <[email protected]>
* @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
});
};
}
};
});
11 changes: 3 additions & 8 deletions blocks/settings/block_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,13 @@ function instance_can_be_docked() {

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);
}

/**
Expand Down
6 changes: 5 additions & 1 deletion lib/yui/build/moodle-core-dock/moodle-core-dock-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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');
};
Expand Down Expand Up @@ -2207,6 +2210,7 @@ Y.augment(DOCKEDITEM, Y.EventTarget);
"event-mouseenter",
"event-resize",
"escape",
"moodle-core-dock-loader"
"moodle-core-dock-loader",
"moodle-core-event"
]
});
8 changes: 4 additions & 4 deletions lib/yui/build/moodle-core-dock/moodle-core-dock-min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion lib/yui/build/moodle-core-dock/moodle-core-dock.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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');
};
Expand Down Expand Up @@ -2186,6 +2189,7 @@ Y.augment(DOCKEDITEM, Y.EventTarget);
"event-mouseenter",
"event-resize",
"escape",
"moodle-core-dock-loader"
"moodle-core-dock-loader",
"moodle-core-event"
]
});
10 changes: 9 additions & 1 deletion lib/yui/build/moodle-core-event/moodle-core-event-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,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"
};


Expand Down
2 changes: 1 addition & 1 deletion lib/yui/build/moodle-core-event/moodle-core-event-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion lib/yui/build/moodle-core-event/moodle-core-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,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"
};


Expand Down
3 changes: 3 additions & 0 deletions lib/yui/src/dock/js/dock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
};
Expand Down
3 changes: 2 additions & 1 deletion lib/yui/src/dock/meta/dock.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"event-mouseenter",
"event-resize",
"escape",
"moodle-core-dock-loader"
"moodle-core-dock-loader",
"moodle-core-event"
]
},
"moodle-core-dock-loader": {
Expand Down
10 changes: 9 additions & 1 deletion lib/yui/src/event/js/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
};


Expand Down

0 comments on commit fd5466a

Please sign in to comment.