Merge branch 'MDL-66550-master' of git://github.com/andrewnicols/moodle
This commit is contained in:
@@ -48,13 +48,11 @@ class behat_admin extends behat_base {
|
||||
* @param TableNode $table
|
||||
*/
|
||||
public function i_set_the_following_administration_settings_values(TableNode $table) {
|
||||
|
||||
if (!$data = $table->getRowsHash()) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($data as $label => $value) {
|
||||
|
||||
$this->execute('behat_navigation::i_select_from_flat_navigation_drawer', [get_string('administrationsite')]);
|
||||
|
||||
// Search by label.
|
||||
@@ -76,38 +74,17 @@ class behat_admin extends behat_base {
|
||||
"@id=//span[contains(normalize-space(.), $label)]/preceding-sibling::label[1]/@for]";
|
||||
$fieldnode = $this->find('xpath', $fieldxpath, $exception);
|
||||
|
||||
$formfieldtypenode = $this->find('xpath', $fieldxpath .
|
||||
"/ancestor::div[contains(concat(' ', @class, ' '), ' form-setting ')]" .
|
||||
"/child::div[contains(concat(' ', @class, ' '), ' form-')]/child::*/parent::div");
|
||||
|
||||
} catch (ElementNotFoundException $e) {
|
||||
|
||||
// Multi element settings, interacting only the first one.
|
||||
$fieldxpath = "//*[label[contains(., $label)]|span[contains(., $label)]]" .
|
||||
"/ancestor::div[contains(concat(' ', normalize-space(@class), ' '), ' form-item ')]" .
|
||||
"/descendant::div[contains(concat(' ', @class, ' '), ' form-group ')]" .
|
||||
"/descendant::*[self::input | self::textarea | self::select]" .
|
||||
"[not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')]";
|
||||
$fieldnode = $this->find('xpath', $fieldxpath);
|
||||
|
||||
// It is the same one that contains the type.
|
||||
$formfieldtypenode = $fieldnode;
|
||||
}
|
||||
|
||||
// Getting the class which contains the field type.
|
||||
$classes = explode(' ', $formfieldtypenode->getAttribute('class'));
|
||||
$type = false;
|
||||
foreach ($classes as $class) {
|
||||
if (substr($class, 0, 5) == 'form-') {
|
||||
$type = substr($class, 5);
|
||||
}
|
||||
}
|
||||
|
||||
// Instantiating the appropiate field type.
|
||||
$field = behat_field_manager::get_field_instance($type, $fieldnode, $this->getSession());
|
||||
$field->set_value($value);
|
||||
|
||||
$this->find_button(get_string('savechanges'))->press();
|
||||
$this->execute('behat_forms::i_set_the_field_with_xpath_to', [$fieldxpath, $value]);
|
||||
$this->execute("behat_general::i_click_on", [get_string('savechanges'), 'button']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,10 @@ class fragment_requirements_manager extends page_requirements_manager {
|
||||
$output = '';
|
||||
|
||||
// First include must be to a module with no dependencies, this prevents multiple requests.
|
||||
$prefix = "require(['core/first'], function() {\n";
|
||||
$prefix = 'M.util.js_pending("core/first");';
|
||||
$prefix .= "require(['core/first'], function() {\n";
|
||||
$suffix = "\n});";
|
||||
$suffix .= 'M.util.js_complete("core/first");';
|
||||
$output .= html_writer::script($prefix . implode(";\n", $this->amdjscode) . $suffix);
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -1038,7 +1038,9 @@ class page_requirements_manager {
|
||||
|
||||
$component = clean_param($component, PARAM_COMPONENT);
|
||||
$module = clean_param($module, PARAM_ALPHANUMEXT);
|
||||
$modname = "{$component}/{$module}";
|
||||
|
||||
$functioncode = [];
|
||||
if ($func !== null) {
|
||||
$func = clean_param($func, PARAM_ALPHANUMEXT);
|
||||
|
||||
@@ -1057,12 +1059,14 @@ class page_requirements_manager {
|
||||
}
|
||||
}
|
||||
|
||||
$js = 'require(["' . $component . '/' . $module . '"], function(amd) { amd.' . $func . '(' . $strparams . '); });';
|
||||
|
||||
} else {
|
||||
$js = 'require(["' . $component . '/' . $module . '"]);';
|
||||
$functioncode[] = "amd.{$func}({$strparams});";
|
||||
}
|
||||
|
||||
$functioncode[] = "M.util.js_complete('{$modname}');";
|
||||
|
||||
$initcode = implode(' ', $functioncode);
|
||||
$js = "M.util.js_pending('{$modname}'); require(['{$modname}'], function(amd) {{$initcode}});";
|
||||
|
||||
$this->js_amd_inline($js);
|
||||
}
|
||||
|
||||
@@ -1384,8 +1388,10 @@ class page_requirements_manager {
|
||||
}
|
||||
|
||||
// First include must be to a module with no dependencies, this prevents multiple requests.
|
||||
$prefix = "require(['core/first'], function() {\n";
|
||||
$suffix = "\n});";
|
||||
$prefix = 'M.util.js_pending("core/first");';
|
||||
$prefix .= "require(['core/first'], function() {\n";
|
||||
$suffix = 'M.util.js_complete("core/first");';
|
||||
$suffix .= "\n});";
|
||||
$output .= html_writer::script($prefix . implode(";\n", $this->amdjscode) . $suffix);
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -125,8 +125,13 @@ class core_outputrequirementslib_testcase extends advanced_testcase {
|
||||
|
||||
$html = $page->requires->get_end_code();
|
||||
|
||||
$this->assertContains('require(["theme_foobar/lightbox"]);', $html);
|
||||
$this->assertContains('require(["theme_foobar/demo_one"], function(amd) { amd.init(); });', $html);
|
||||
$this->assertContains('require(["theme_foobar/demo_two"], function(amd) { amd.init("foo", "baz", [42,"xyz"]); });', $html);
|
||||
$modname = 'theme_foobar/lightbox';
|
||||
$this->assertContains("M.util.js_pending('{$modname}'); require(['{$modname}'], function(amd) {M.util.js_complete('{$modname}');});", $html);
|
||||
|
||||
$modname = 'theme_foobar/demo_one';
|
||||
$this->assertContains("M.util.js_pending('{$modname}'); require(['{$modname}'], function(amd) {amd.init(); M.util.js_complete('{$modname}');});", $html);
|
||||
|
||||
$modname = 'theme_foobar/demo_two';
|
||||
$this->assertContains("M.util.js_pending('{$modname}'); require(['{$modname}'], function(amd) {amd.init(\"foo\", \"baz\", [42,\"xyz\"]); M.util.js_complete('{$modname}');});", $html);
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
define ("theme_boost/aria",["jquery","core/pending"],function(a,b){return{init:function init(){var c=!1,d=function(){c=!0},e=function(){var a=c;c=!1;return a};a("[data-toggle=\"dropdown\"]").keydown(function(b){var c=b.which||b.keyCode,e;if(38==c){d()}if(27==c){e=a(b.target).attr("aria-expanded");b.preventDefault();if("false"==e){a(b.target).click()}}if(32==c||13==c){b.preventDefault();a(b.target).click()}});var f=function(c){var d=function(b){a(this).focus();b.resolve()}.bind(c);setTimeout(d,50,new b("core/aria:delayed-focus"))};a(".dropdown").on("shown.bs.dropdown",function(b){var c=a(b.target).find("[role=\"menu\"]"),d=!1,g=!1;if(c){d=a(c).find("[role=\"menuitem\"]")}if(d&&0<d.length){if(e()){g=d[d.length-1]}else{g=d[0]}}if(g){f(g)}});a(".dropdown [role=\"menu\"] [role=\"menuitem\"]").keypress(function(b){var c=String.fromCharCode(b.which||b.keyCode),d=a(b.target).closest("[role=\"menu\"]"),e=0,g=!1,h,j;if(!d){return}g=a(d).find("[role=\"menuitem\"]");if(!g){return}c=c.toLowerCase();for(e=0;e<g.length;e++){h=a(g[e]);j=h.text().trim().toLowerCase();if(0==j.indexOf(c)){f(h);break}}});a(".dropdown [role=\"menu\"] [role=\"menuitem\"]").keydown(function(b){var c=b.which||b.keyCode,d=!1,e=a(b.target).closest("[role=\"menu\"]"),g=0,h=!1;if(!e){return}h=a(e).find("[role=\"menuitem\"]");if(!h){return}if(40==c){for(g=0;g<h.length-1;g++){if(h[g]==b.target){d=h[g+1];break}}if(!d){d=h[0]}}else if(38==c){for(g=1;g<h.length;g++){if(h[g]==b.target){d=h[g-1];break}}if(!d){d=h[h.length-1]}}else if(36==c){d=h[0]}else if(35==c){d=h[h.length-1]}if(d){b.preventDefault();f(d)}});a(".dropdown").on("hidden.bs.dropdown",function(b){var c=a(b.target).find("[data-toggle=\"dropdown\"]");if(c){f(c)}});a(function(){window.setTimeout(function(b){var c=a("[role=\"alert\"][data-aria-autofocus=\"true\"]");if(0<c.length){a(c[0]).attr("tabindex","0");a(c[0]).focus()}b.resolve()},300,new b("core/aria:delayed-focus"))})}}});
|
||||
define ("theme_boost/aria",["jquery","core/pending"],function(a,b){return{init:function init(){var c=!1,d=function(){c=!0},e=function(){var a=c;c=!1;return a};a("[data-toggle=\"dropdown\"]").keydown(function(b){var c=b.which||b.keyCode,e;if(38==c){d()}if(27==c){e=a(b.target).attr("aria-expanded");b.preventDefault();if("false"==e){a(b.target).click()}}if(32==c||13==c){b.preventDefault();a(b.target).click()}});var f=function(c){var d=function(b){a(this).focus();b.resolve()}.bind(c);setTimeout(d,50,new b("core/aria:delayed-focus"))};a(".dropdown").on("shown.bs.dropdown",function(b){var c=a(b.target).find("[role=\"menu\"]"),d=!1,g=!1;if(c){d=a(c).find("[role=\"menuitem\"]")}if(d&&0<d.length){if(e()){g=d[d.length-1]}else{g=d[0]}}if(g){f(g)}});a(".dropdown [role=\"menu\"] [role=\"menuitem\"]").keypress(function(b){var c=String.fromCharCode(b.which||b.keyCode),d=a(b.target).closest("[role=\"menu\"]"),e=0,g=!1,h,j;if(!d){return}g=a(d).find("[role=\"menuitem\"]");if(!g){return}c=c.toLowerCase();for(e=0;e<g.length;e++){h=a(g[e]);j=h.text().trim().toLowerCase();if(0==j.indexOf(c)){f(h);break}}});a(".dropdown [role=\"menu\"] [role=\"menuitem\"]").keydown(function(b){var c=b.which||b.keyCode,d=!1,e=a(b.target).closest("[role=\"menu\"]"),g=0,h=!1;if(!e){return}h=a(e).find("[role=\"menuitem\"]");if(!h){return}if(40==c){for(g=0;g<h.length-1;g++){if(h[g]==b.target){d=h[g+1];break}}if(!d){d=h[0]}}else if(38==c){for(g=1;g<h.length;g++){if(h[g]==b.target){d=h[g-1];break}}if(!d){d=h[h.length-1]}}else if(36==c){d=h[0]}else if(35==c){d=h[h.length-1]}if(d){b.preventDefault();f(d)}});a(".dropdown").on("hidden.bs.dropdown",function(b){var c=a(b.target).find("[data-toggle=\"dropdown\"]");if(c){f(c)}});var g=new b("core/aria:delayed-focus");a(function(){window.setTimeout(function(b){var c=a("[role=\"alert\"][data-aria-autofocus=\"true\"]");if(0<c.length){a(c[0]).attr("tabindex","0");a(c[0]).focus()}b.resolve()},300,g)})}}});
|
||||
//# sourceMappingURL=aria.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
define ("theme_boost/loader",["jquery","./tether","core/event"],function(a,b,c){window.jQuery=a;window.Tether=b;require(["theme_boost/aria","theme_boost/pending","theme_boost/util","theme_boost/alert","theme_boost/button","theme_boost/carousel","theme_boost/collapse","theme_boost/dropdown","theme_boost/modal","theme_boost/scrollspy","theme_boost/tab","theme_boost/tooltip","theme_boost/popover"],function(b){a("body").popover({trigger:"focus",selector:"[data-toggle=popover][data-trigger!=hover]"});a("html").popover({container:"body",selector:"[data-toggle=popover][data-trigger=hover]",trigger:"hover",delay:{hide:500}});a.fn.dropdown.Constructor.Default.flip=!1;a("a[data-toggle=\"tab\"]").on("shown.bs.tab",function(b){var c=a(b.target).attr("href");if(history.replaceState){history.replaceState(null,null,c)}else{location.hash=c}});var d=window.location.hash;if(d){a(".nav-link[href=\""+d+"\"]").tab("show")}c.getLegacyEvents().done(function(b){a(document).on(b.FILTER_CONTENT_UPDATED,function(){a("body").popover({selector:"[data-toggle=\"popover\"]",trigger:"focus"})})});b.init()});return{}});
|
||||
define ("theme_boost/loader",["jquery","./tether","core/event"],function(a,b,c){window.jQuery=a;window.Tether=b;M.util.js_pending("theme_boost/loader:children");require(["theme_boost/aria","theme_boost/pending","theme_boost/util","theme_boost/alert","theme_boost/button","theme_boost/carousel","theme_boost/collapse","theme_boost/dropdown","theme_boost/modal","theme_boost/scrollspy","theme_boost/tab","theme_boost/tooltip","theme_boost/popover"],function(b){a("body").popover({trigger:"focus",selector:"[data-toggle=popover][data-trigger!=hover]"});a("html").popover({container:"body",selector:"[data-toggle=popover][data-trigger=hover]",trigger:"hover",delay:{hide:500}});a.fn.dropdown.Constructor.Default.flip=!1;a("a[data-toggle=\"tab\"]").on("shown.bs.tab",function(b){var c=a(b.target).attr("href");if(history.replaceState){history.replaceState(null,null,c)}else{location.hash=c}});var d=window.location.hash;if(d){a(".nav-link[href=\""+d+"\"]").tab("show")}c.getLegacyEvents().done(function(b){a(document).on(b.FILTER_CONTENT_UPDATED,function(){a("body").popover({selector:"[data-toggle=\"popover\"]",trigger:"focus"})})});b.init();M.util.js_complete("theme_boost/loader:children")});return{}});
|
||||
//# sourceMappingURL=loader.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -186,6 +186,7 @@ define(['jquery', 'core/pending'], function($, Pending) {
|
||||
});
|
||||
|
||||
// After page load, focus on any element with special autofocus attribute.
|
||||
var delayedFocusPromise = new Pending('core/aria:delayed-focus');
|
||||
$(function() {
|
||||
window.setTimeout(function(pendingPromise) {
|
||||
var alerts = $('[role="alert"][data-aria-autofocus="true"]');
|
||||
@@ -194,7 +195,7 @@ define(['jquery', 'core/pending'], function($, Pending) {
|
||||
$(alerts[0]).focus();
|
||||
}
|
||||
pendingPromise.resolve();
|
||||
}, 300, new Pending('core/aria:delayed-focus'));
|
||||
}, 300, delayedFocusPromise);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -27,6 +27,7 @@ define(['jquery', './tether', 'core/event'], function(jQuery, Tether, Event) {
|
||||
|
||||
window.jQuery = jQuery;
|
||||
window.Tether = Tether;
|
||||
M.util.js_pending('theme_boost/loader:children');
|
||||
|
||||
require(['theme_boost/aria',
|
||||
'theme_boost/pending',
|
||||
@@ -87,6 +88,7 @@ define(['jquery', './tether', 'core/event'], function(jQuery, Tether, Event) {
|
||||
});
|
||||
|
||||
Aria.init();
|
||||
M.util.js_complete('theme_boost/loader:children');
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -64,5 +64,8 @@
|
||||
</body>
|
||||
</html>
|
||||
{{#js}}
|
||||
require(['theme_boost/loader']);
|
||||
M.util.js_pending('theme_boost/loader');
|
||||
require(['theme_boost/loader'], function() {
|
||||
M.util.js_complete('theme_boost/loader');
|
||||
});
|
||||
{{/js}}
|
||||
|
||||
@@ -95,8 +95,13 @@
|
||||
</body>
|
||||
</html>
|
||||
{{#js}}
|
||||
require(['theme_boost/loader']);
|
||||
M.util.js_pending('theme_boost/loader');
|
||||
require(['theme_boost/loader'], function() {
|
||||
M.util.js_complete('theme_boost/loader');
|
||||
});
|
||||
M.util.js_pending('theme_boost/drawer');
|
||||
require(['theme_boost/drawer'], function(mod) {
|
||||
mod.init();
|
||||
M.util.js_complete('theme_boost/drawer');
|
||||
});
|
||||
{{/js}}
|
||||
|
||||
@@ -53,5 +53,8 @@
|
||||
</body>
|
||||
</html>
|
||||
{{#js}}
|
||||
require(['theme_boost/loader']);
|
||||
M.util.js_pending('theme_boost/loader');
|
||||
require(['theme_boost/loader'], function() {
|
||||
M.util.js_complete('theme_boost/loader');
|
||||
});
|
||||
{{/js}}
|
||||
|
||||
@@ -67,5 +67,8 @@
|
||||
</body>
|
||||
</html>
|
||||
{{#js}}
|
||||
require(['theme_boost/loader']);
|
||||
M.util.js_pending('theme_boost/loader');
|
||||
require(['theme_boost/loader'], function() {
|
||||
M.util.js_complete('theme_boost/loader');
|
||||
});
|
||||
{{/js}}
|
||||
|
||||
@@ -73,5 +73,8 @@
|
||||
</body>
|
||||
</html>
|
||||
{{#js}}
|
||||
require(['theme_boost/loader']);
|
||||
M.util.js_pending('theme_boost/loader');
|
||||
require(['theme_boost/loader'], function() {
|
||||
M.util.js_complete('theme_boost/loader');
|
||||
});
|
||||
{{/js}}
|
||||
|
||||
@@ -87,5 +87,8 @@
|
||||
</body>
|
||||
</html>
|
||||
{{#js}}
|
||||
require(['theme_boost/loader']);
|
||||
M.util.js_pending('theme_boost/loader');
|
||||
require(['theme_boost/loader'], function() {
|
||||
M.util.js_complete('theme_boost/loader');
|
||||
});
|
||||
{{/js}}
|
||||
|
||||
@@ -96,6 +96,8 @@
|
||||
</body>
|
||||
</html>
|
||||
{{#js}}
|
||||
require(['theme_boost/loader']);
|
||||
M.util.js_pending('theme_boost/loader');
|
||||
require(['theme_boost/loader'], function() {
|
||||
M.util.js_complete('theme_boost/loader');
|
||||
});
|
||||
{{/js}}
|
||||
|
||||
|
||||
@@ -68,5 +68,8 @@
|
||||
</body>
|
||||
</html>
|
||||
{{#js}}
|
||||
require(['theme_boost/loader']);
|
||||
M.util.js_pending('theme_boost/loader');
|
||||
require(['theme_boost/loader'], function() {
|
||||
M.util.js_complete('theme_boost/loader');
|
||||
});
|
||||
{{/js}}
|
||||
|
||||
@@ -106,5 +106,8 @@
|
||||
</body>
|
||||
</html>
|
||||
{{#js}}
|
||||
require(['theme_boost/loader']);
|
||||
M.util.js_pending('theme_boost/loader');
|
||||
require(['theme_boost/loader'], function() {
|
||||
M.util.js_complete('theme_boost/loader');
|
||||
});
|
||||
{{/js}}
|
||||
|
||||
@@ -56,17 +56,12 @@ class behat_theme_classic_behat_admin extends behat_admin {
|
||||
|
||||
// We expect admin block to be visible, otherwise go to homepage.
|
||||
if (!$this->getSession()->getPage()->find('css', '.block_settings')) {
|
||||
$this->getSession()->visit($this->locate_path('/'));
|
||||
$this->wait(self::TIMEOUT * 1000, self::PAGE_READY_JS);
|
||||
$this->execute('behat_forms::i_am_on_homepage');
|
||||
}
|
||||
|
||||
// Search by label.
|
||||
$searchbox = $this->find_field(get_string('searchinsettings', 'admin'));
|
||||
$searchbox->setValue($label);
|
||||
$submitsearch = $this->find('css', 'form.adminsearchform input[type=submit]');
|
||||
$submitsearch->press();
|
||||
|
||||
$this->wait(self::TIMEOUT * 1000, self::PAGE_READY_JS);
|
||||
$this->execute('behat_forms::i_set_the_field_to', [get_string('searchinsettings', 'admin'), $label]);
|
||||
$this->execute("behat_general::i_click_on_in_the", [get_string('search', 'admin'), 'button', '.block_settings', 'css_element']);
|
||||
|
||||
// Admin settings does not use the same DOM structure than other moodle forms
|
||||
// but we also need to use lib/behat/form_field/* to deal with the different moodle form elements.
|
||||
@@ -82,11 +77,6 @@ class behat_theme_classic_behat_admin extends behat_admin {
|
||||
"[@id=//label[contains(normalize-space(.), $label)]/@for or " .
|
||||
"@id=//span[contains(normalize-space(.), $label)]/preceding-sibling::label[1]/@for]";
|
||||
$fieldnode = $this->find('xpath', $fieldxpath, $exception);
|
||||
|
||||
$formfieldtypenode = $this->find('xpath', $fieldxpath .
|
||||
"/ancestor::div[contains(concat(' ', @class, ' '), ' form-setting ')]" .
|
||||
"/child::div[contains(concat(' ', @class, ' '), ' form-')]/child::*/parent::div");
|
||||
|
||||
} catch (ElementNotFoundException $e) {
|
||||
|
||||
// Multi element settings, interacting only the first one.
|
||||
@@ -96,25 +86,11 @@ class behat_theme_classic_behat_admin extends behat_admin {
|
||||
"/descendant::*[self::input | self::textarea | self::select]" .
|
||||
"[not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')]";
|
||||
$fieldnode = $this->find('xpath', $fieldxpath);
|
||||
|
||||
// It is the same one that contains the type.
|
||||
$formfieldtypenode = $fieldnode;
|
||||
}
|
||||
|
||||
// Getting the class which contains the field type.
|
||||
$classes = explode(' ', $formfieldtypenode->getAttribute('class'));
|
||||
$type = false;
|
||||
foreach ($classes as $class) {
|
||||
if (substr($class, 0, 5) == 'form-') {
|
||||
$type = substr($class, 5);
|
||||
}
|
||||
}
|
||||
$this->execute('behat_forms::i_set_the_field_with_xpath_to', [$fieldxpath, $value]);
|
||||
|
||||
// Instantiating the appropiate field type.
|
||||
$field = behat_field_manager::get_field_instance($type, $fieldnode, $this->getSession());
|
||||
$field->set_value($value);
|
||||
|
||||
$this->find_button(get_string('savechanges'))->press();
|
||||
$this->execute("behat_general::i_click_on", [get_string('savechanges'), 'button']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user