From fbd99bbb00107d34e957a818422e7da11e8937f8 Mon Sep 17 00:00:00 2001 From: Bas Brands Date: Thu, 27 Jun 2019 12:27:03 +0200 Subject: [PATCH] MDL-59639 theme_boost: remember last visited tab --- theme/boost/amd/build/loader.min.js | 2 +- theme/boost/amd/build/loader.min.js.map | 2 +- theme/boost/amd/src/loader.js | 14 ++++++++++++++ theme/boost/tests/behat/settingstabs.feature | 13 +++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 theme/boost/tests/behat/settingstabs.feature diff --git a/theme/boost/amd/build/loader.min.js b/theme/boost/amd/build/loader.min.js index bba42534a6b..33e09e43262 100644 --- a/theme/boost/amd/build/loader.min.js +++ b/theme/boost/amd/build/loader.min.js @@ -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;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;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{}}); //# sourceMappingURL=loader.min.js.map diff --git a/theme/boost/amd/build/loader.min.js.map b/theme/boost/amd/build/loader.min.js.map index 2a85064cff7..b090f5bb5d6 100644 --- a/theme/boost/amd/build/loader.min.js.map +++ b/theme/boost/amd/build/loader.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/loader.js"],"names":["define","jQuery","Tether","Event","window","require","Aria","popover","trigger","selector","container","delay","hide","fn","dropdown","Constructor","Default","flip","getLegacyEvents","done","events","document","on","FILTER_CONTENT_UPDATED","init"],"mappings":"AAyBAA,OAAM,sBAAC,CAAC,QAAD,CAAW,UAAX,CAAuB,YAAvB,CAAD,CAAuC,SAASC,CAAT,CAAiBC,CAAjB,CAAyBC,CAAzB,CAAgC,CAEzEC,MAAM,CAACH,MAAP,CAAgBA,CAAhB,CACAG,MAAM,CAACF,MAAP,CAAgBA,CAAhB,CAEAG,OAAO,CAAC,CAAC,kBAAD,CACA,qBADA,CAEA,kBAFA,CAGA,mBAHA,CAIA,oBAJA,CAKA,sBALA,CAMA,sBANA,CAOA,sBAPA,CAQA,mBARA,CASA,uBATA,CAUA,iBAVA,CAWA,qBAXA,CAYA,qBAZA,CAAD,CAaC,SAASC,CAAT,CAAe,CAGnBL,CAAM,CAAC,MAAD,CAAN,CAAeM,OAAf,CAAuB,CACnBC,OAAO,CAAE,OADU,CAEnBC,QAAQ,CAAE,4CAFS,CAAvB,EAKAR,CAAM,CAAC,MAAD,CAAN,CAAeM,OAAf,CAAuB,CACnBG,SAAS,CAAE,MADQ,CAEnBD,QAAQ,CAAE,2CAFS,CAGnBD,OAAO,CAAE,OAHU,CAInBG,KAAK,CAAE,CACHC,IAAI,CAAE,GADH,CAJY,CAAvB,EAUAX,CAAM,CAACY,EAAP,CAAUC,QAAV,CAAmBC,WAAnB,CAA+BC,OAA/B,CAAuCC,IAAvC,IAGAd,CAAK,CAACe,eAAN,GAAwBC,IAAxB,CAA6B,SAASC,CAAT,CAAiB,CAC1CnB,CAAM,CAACoB,QAAD,CAAN,CAAiBC,EAAjB,CAAoBF,CAAM,CAACG,sBAA3B,CAAmD,UAAW,CAC1DtB,CAAM,CAAC,MAAD,CAAN,CAAeM,OAAf,CAAuB,CACnBE,QAAQ,CAAE,2BADS,CAEnBD,OAAO,CAAE,OAFU,CAAvB,CAKH,CAND,CAOH,CARD,EAUAF,CAAI,CAACkB,IAAL,EACH,CA7CM,CAAP,CAgDA,MAAO,EACV,CAtDK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Template renderer for Moodle. Load and render Moodle templates with Mustache.\n *\n * @module core/templates\n * @package core\n * @class templates\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 2.9\n */\ndefine(['jquery', './tether', 'core/event'], function(jQuery, Tether, Event) {\n\n window.jQuery = jQuery;\n window.Tether = Tether;\n\n require(['theme_boost/aria',\n 'theme_boost/pending',\n 'theme_boost/util',\n 'theme_boost/alert',\n 'theme_boost/button',\n 'theme_boost/carousel',\n 'theme_boost/collapse',\n 'theme_boost/dropdown',\n 'theme_boost/modal',\n 'theme_boost/scrollspy',\n 'theme_boost/tab',\n 'theme_boost/tooltip',\n 'theme_boost/popover'],\n function(Aria) {\n\n // We do twice because: https://github.com/twbs/bootstrap/issues/10547\n jQuery('body').popover({\n trigger: 'focus',\n selector: \"[data-toggle=popover][data-trigger!=hover]\"\n });\n\n jQuery(\"html\").popover({\n container: \"body\",\n selector: \"[data-toggle=popover][data-trigger=hover]\",\n trigger: \"hover\",\n delay: {\n hide: 500\n }\n });\n\n // Disables flipping the dropdowns up and getting hidden behind the navbar.\n jQuery.fn.dropdown.Constructor.Default.flip = false;\n\n // We need to call popover automatically if nodes are added to the page later.\n Event.getLegacyEvents().done(function(events) {\n jQuery(document).on(events.FILTER_CONTENT_UPDATED, function() {\n jQuery('body').popover({\n selector: '[data-toggle=\"popover\"]',\n trigger: 'focus'\n });\n\n });\n });\n\n Aria.init();\n });\n\n\n return {};\n});\n"],"file":"loader.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/loader.js"],"names":["define","jQuery","Tether","Event","window","require","Aria","popover","trigger","selector","container","delay","hide","fn","dropdown","Constructor","Default","flip","on","e","hash","target","attr","history","replaceState","location","tab","getLegacyEvents","done","events","document","FILTER_CONTENT_UPDATED","init"],"mappings":"AAyBAA,OAAM,sBAAC,CAAC,QAAD,CAAW,UAAX,CAAuB,YAAvB,CAAD,CAAuC,SAASC,CAAT,CAAiBC,CAAjB,CAAyBC,CAAzB,CAAgC,CAEzEC,MAAM,CAACH,MAAP,CAAgBA,CAAhB,CACAG,MAAM,CAACF,MAAP,CAAgBA,CAAhB,CAEAG,OAAO,CAAC,CAAC,kBAAD,CACA,qBADA,CAEA,kBAFA,CAGA,mBAHA,CAIA,oBAJA,CAKA,sBALA,CAMA,sBANA,CAOA,sBAPA,CAQA,mBARA,CASA,uBATA,CAUA,iBAVA,CAWA,qBAXA,CAYA,qBAZA,CAAD,CAaC,SAASC,CAAT,C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CAKH,CAND,CAOH,CARD,EAUAF,CAAI,CAAC0B,IAAL,EACH,CA3DM,CAAP,CA8DA,MAAO,EACV,CApEK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Template renderer for Moodle. Load and render Moodle templates with Mustache.\n *\n * @module core/templates\n * @package core\n * @class templates\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 2.9\n */\ndefine(['jquery', './tether', 'core/event'], function(jQuery, Tether, Event) {\n\n window.jQuery = jQuery;\n window.Tether = Tether;\n\n require(['theme_boost/aria',\n 'theme_boost/pending',\n 'theme_boost/util',\n 'theme_boost/alert',\n 'theme_boost/button',\n 'theme_boost/carousel',\n 'theme_boost/collapse',\n 'theme_boost/dropdown',\n 'theme_boost/modal',\n 'theme_boost/scrollspy',\n 'theme_boost/tab',\n 'theme_boost/tooltip',\n 'theme_boost/popover'],\n function(Aria) {\n\n // We do twice because: https://github.com/twbs/bootstrap/issues/10547\n jQuery('body').popover({\n trigger: 'focus',\n selector: \"[data-toggle=popover][data-trigger!=hover]\"\n });\n\n jQuery(\"html\").popover({\n container: \"body\",\n selector: \"[data-toggle=popover][data-trigger=hover]\",\n trigger: \"hover\",\n delay: {\n hide: 500\n }\n });\n\n // Disables flipping the dropdowns up and getting hidden behind the navbar.\n jQuery.fn.dropdown.Constructor.Default.flip = false;\n\n jQuery('a[data-toggle=\"tab\"]').on('shown.bs.tab', function(e) {\n var hash = jQuery(e.target).attr('href');\n if (history.replaceState) {\n history.replaceState(null, null, hash);\n } else {\n location.hash = hash;\n }\n });\n\n var hash = window.location.hash;\n if (hash) {\n jQuery('.nav-link[href=\"' + hash + '\"]').tab('show');\n }\n\n // We need to call popover automatically if nodes are added to the page later.\n Event.getLegacyEvents().done(function(events) {\n jQuery(document).on(events.FILTER_CONTENT_UPDATED, function() {\n jQuery('body').popover({\n selector: '[data-toggle=\"popover\"]',\n trigger: 'focus'\n });\n\n });\n });\n\n Aria.init();\n });\n\n\n return {};\n});\n"],"file":"loader.min.js"} \ No newline at end of file diff --git a/theme/boost/amd/src/loader.js b/theme/boost/amd/src/loader.js index 88630efc72d..bb29acb0c60 100644 --- a/theme/boost/amd/src/loader.js +++ b/theme/boost/amd/src/loader.js @@ -61,6 +61,20 @@ define(['jquery', './tether', 'core/event'], function(jQuery, Tether, Event) { // Disables flipping the dropdowns up and getting hidden behind the navbar. jQuery.fn.dropdown.Constructor.Default.flip = false; + jQuery('a[data-toggle="tab"]').on('shown.bs.tab', function(e) { + var hash = jQuery(e.target).attr('href'); + if (history.replaceState) { + history.replaceState(null, null, hash); + } else { + location.hash = hash; + } + }); + + var hash = window.location.hash; + if (hash) { + jQuery('.nav-link[href="' + hash + '"]').tab('show'); + } + // We need to call popover automatically if nodes are added to the page later. Event.getLegacyEvents().done(function(events) { jQuery(document).on(events.FILTER_CONTENT_UPDATED, function() { diff --git a/theme/boost/tests/behat/settingstabs.feature b/theme/boost/tests/behat/settingstabs.feature new file mode 100644 index 00000000000..33cdacd442c --- /dev/null +++ b/theme/boost/tests/behat/settingstabs.feature @@ -0,0 +1,13 @@ +@javascript @theme_boost +Feature: Administration nav tabs back + When returning to the Administration page I want to see my last opened tab + + Scenario: See last opened tab in site admin + Given I log in as "admin" + And I am on site homepage + And I click on "Site administration" "link" + And I click on "Users" "link" + And I click on "Browse list of users" "link" + And I should see "New filter" + When I press the "back" button in the browser + Then I should see "Cohorts" \ No newline at end of file