mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 18:36:42 +02:00
MDL-56586 blocks: allow theme to manage "Add a block" select
This commit is contained in:
parent
692c1bf345
commit
b11916d3e7
8 changed files with 140 additions and 18 deletions
|
@ -152,3 +152,4 @@ $THEME->prescsscallback = 'theme_boost_get_pre_scss';
|
|||
$THEME->yuicssmodules = array();
|
||||
$THEME->rendererfactory = 'theme_overridden_renderer_factory';
|
||||
$THEME->undeletableblocktypes = '';
|
||||
$THEME->addblockposition = BLOCK_ADDBLOCK_POSITION_FLATNAV;
|
||||
|
|
|
@ -38,15 +38,8 @@ require_once(__DIR__ . '/../../../../blocks/tests/behat/behat_blocks.php');
|
|||
class behat_theme_boost_behat_blocks extends behat_blocks {
|
||||
|
||||
public function i_add_the_block($blockname) {
|
||||
$this->execute('behat_forms::i_set_the_field_to',
|
||||
array("bui_addblock", $this->escape($blockname))
|
||||
);
|
||||
|
||||
// If we are running without javascript we need to submit the form.
|
||||
if (!$this->running_javascript()) {
|
||||
$this->execute('behat_general::i_click_on_in_the',
|
||||
array("Go", "button", "Add a block", "block"));
|
||||
}
|
||||
$this->execute('behat_navigation::i_select_from_flat_navigation_drawer', get_string('addblock'));
|
||||
$this->execute('behat_forms::press_button', $blockname);
|
||||
}
|
||||
|
||||
public function i_open_the_blocks_action_menu($blockname) {
|
||||
|
|
|
@ -76,4 +76,56 @@ class behat_theme_boost_behat_navigation extends behat_navigation {
|
|||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the flat navigation drawer if it is not already open
|
||||
*
|
||||
* @When /^I open flat navigation drawer$/
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
*/
|
||||
public function i_open_flat_navigation_drawer() {
|
||||
if (!$this->running_javascript()) {
|
||||
// Navigation drawer is always open without JS.
|
||||
return;
|
||||
}
|
||||
$xpath = "//button[contains(@data-action,'toggle-drawer')]";
|
||||
$node = $this->find('xpath', $xpath);
|
||||
$expanded = $node->getAttribute('aria-expanded');
|
||||
if ($expanded === 'false') {
|
||||
$node->click();
|
||||
$this->wait_for_pending_js();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the flat navigation drawer if it is open (does nothing if JS disabled)
|
||||
*
|
||||
* @When /^I close flat navigation drawer$/
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
*/
|
||||
public function i_close_flat_navigation_drawer() {
|
||||
if (!$this->running_javascript()) {
|
||||
// Navigation drawer can not be closed without JS.
|
||||
return;
|
||||
}
|
||||
$xpath = "//button[contains(@data-action,'toggle-drawer')]";
|
||||
$node = $this->find('xpath', $xpath);
|
||||
$expanded = $node->getAttribute('aria-expanded');
|
||||
if ($expanded === 'true') {
|
||||
$node->click();
|
||||
$this->wait_for_pending_js();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks link with specified id|title|alt|text in the flat navigation drawer.
|
||||
*
|
||||
* @When /^I select "(?P<link_string>(?:[^"]|\\")*)" from flat navigation drawer$/
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
* @param string $link
|
||||
*/
|
||||
public function i_select_from_flat_navigation_drawer($link) {
|
||||
$this->i_open_flat_navigation_drawer();
|
||||
$this->execute('behat_general::i_click_on_in_the', [$link, 'link', '#nav-drawer', 'css_element']);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue