mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-35590 navigation: Remove link from admin node if you have javascript
Also: * In behat, ensure nav node exists before checking attribute (Credit to Rajesh Taneja) * Remove some unused JS constants * Fix debugging notice for users without settings block
This commit is contained in:
parent
846cd414bf
commit
a057ba5924
@ -27,32 +27,10 @@ define(['jquery'], function($) {
|
||||
// Mappings for the different types of nodes coming from the navigation.
|
||||
// Copied from lib/navigationlib.php navigation_node constants.
|
||||
var NODETYPE = {
|
||||
// @type int Root node = 0.
|
||||
ROOTNODE : 0,
|
||||
// @type int System context = 1.
|
||||
SYSTEM : 1,
|
||||
// @type int Course category = 10.
|
||||
CATEGORY : 10,
|
||||
// @type int MYCATEGORY = 11.
|
||||
MYCATEGORY : 11,
|
||||
// @type int Course = 20.
|
||||
COURSE : 20,
|
||||
// @type int Course section = 30.
|
||||
SECTION : 30,
|
||||
// @type int Activity (course module) = 40.
|
||||
ACTIVITY : 40,
|
||||
// @type int Resource (course module = 50.
|
||||
RESOURCE : 50,
|
||||
// @type int Custom node (could be anything) = 60.
|
||||
CUSTOM : 60,
|
||||
// @type int Setting = 70.
|
||||
SETTING : 70,
|
||||
// @type int site administration = 71.
|
||||
SITEADMIN : 71,
|
||||
// @type int User context = 80.
|
||||
USER : 80,
|
||||
// @type int Container = 90.
|
||||
CONTAINER : 90
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -23,8 +23,13 @@
|
||||
*/
|
||||
define(['jquery', 'core/tree'], function($, Tree) {
|
||||
return {
|
||||
init: function() {
|
||||
new Tree(".block_settings .block_tree");
|
||||
init: function(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>');
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -90,13 +90,19 @@ 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()
|
||||
);
|
||||
$this->page->requires->js_call_amd('block_settings/settingsblock', 'init', array());
|
||||
$this->page->requires->js_call_amd('block_settings/settingsblock', 'init', array($adminnodeid));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,7 +101,7 @@ define(['jquery'], function($) {
|
||||
}
|
||||
|
||||
// Remove previous active from tab order.
|
||||
if (currentActive !== null) {
|
||||
if (currentActive) {
|
||||
currentActive.attr('tabindex', '-1');
|
||||
currentActive.attr('aria-selected', 'false');
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ class behat_navigation extends behat_base {
|
||||
|
||||
// Wait for node to load, if not loaded before.
|
||||
$linode = $nodetoexpand->getParent();
|
||||
if ($linode->hasAttribute('data-loaded') && $linode->getAttribute('data-loaded') == "false") {
|
||||
if ($linode && $linode->hasAttribute('data-loaded') && $linode->getAttribute('data-loaded') == "false") {
|
||||
$jscondition = '(document.evaluate("' . $linode->getXpath() . '", document, null, '.
|
||||
'XPathResult.ANY_TYPE, null).iterateNext().getAttribute(\'data-loaded\') == "true")';
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user