diff --git a/CHANGES.md b/CHANGES.md index ca0d808..5e33851 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,10 @@ moodle-format_collapsibletopics Changes ------- +### v3.8 +* 2019-11-17 - Rebuild amd module with new transpiler +* 2019-11-17 - Fix wrong behaviour of section collapsing with bootstrap in moodle 3.8. + ### v3.7.2 * 2019-10-09 - Transfer toggle state persistance from db to browser storage. @@ -12,7 +16,6 @@ Changes * 2019-08-23 - Fix display of section 0 title to be consistent with core topics format (issue #1) ### v3.7 - * 2019-05-20 - Remove support for legacy themes. * 2019-08-20 - Add toggle icon for rtl languages. * 2019-08-20 - Fix issue #12 Wrong item labels in drop targets list. \ No newline at end of file diff --git a/amd/build/collapsibletopics.min.js b/amd/build/collapsibletopics.min.js index 7585410..e43e24d 100644 --- a/amd/build/collapsibletopics.min.js +++ b/amd/build/collapsibletopics.min.js @@ -1 +1,2 @@ -define(["jquery","core/log","core/str"],function(a,b,c){"use strict";var d=function(a,b,c){"local"==c?window.localStorage.setItem("sections-toggle-"+a,JSON.stringify(b)):"session"==c&&window.sessionStorage.setItem("sections-toggle-"+a,JSON.stringify(b))},e=function(a,b){var c;return"local"==b?c=window.localStorage.getItem("sections-toggle-"+a):"session"==b&&(c=window.sessionStorage.getItem("sections-toggle-"+a)),null===c?{}:JSON.parse(c)};return{init:function(f){b.debug("Format collapsibletopics AMD module initialized"),a(document).ready(function(a){var b,g,h=f.keepstateoversession;g=1==h?"local":"session",b=e(f.course,g),setTimeout(function(){a(".sectiontoggle").each(function(c){var d="#collapse-"+(c+1);a(d).parent().parent().hasClass("current")||c+1 in b?a(d).collapse("show"):a(d).collapse("hide")})},50),a("body").on("click",".expandall",function(c){c.preventDefault();var e=c.target;a(e).removeClass("expandall").addClass("collapseall").html(M.util.get_string("collapseall","moodle")),a(".sectiontoggle").each(function(c){var e="#collapse-"+(c+1);a(e).collapse("show"),b.hasOwnProperty(c+1)||(b[c+1]="true",d(f.course,b,g))})}),a("body").on("click",".collapseall",function(c){c.preventDefault();var e=c.target;a(e).removeClass("collapseall").addClass("expandall").html(M.util.get_string("expandall","moodle")),a(".sectiontoggle").each(function(c){var e="#collapse-"+(c+1);a(e).collapse("hide"),b.hasOwnProperty(c+1)&&(delete b[c+1],d(f.course,b,g))})}),a("#nav-drawer div.media").on("click",function(b){var c=a(b.target).parent().parent().parent().attr("href");if(c.lastIndexOf("#section-")!=-1){var d=c.substring(c.lastIndexOf("-")+1),e="#collapse-"+d;a(e).collapse("show")}}),a(".collapse").on("show.bs.collapse",function(c){var e=a(c.target).attr("id"),h=e.substring(e.lastIndexOf("-")+1);b.hasOwnProperty(h)||(b[h]="true",d(f.course,b,g))}),a(".collapse").on("hide.bs.collapse",function(c){var e=a(c.target).attr("id"),h=e.substring(e.lastIndexOf("-")+1);b.hasOwnProperty(h)&&(delete b[h],d(f.course,b,g))}),a("body").on("click",".togglecompletion button",function(b){var d=b.target,e=a(d).parent().parent().children('input[name="completionstate"]').val(),f=a(d).closest("li.section"),g=a(f).find(".progress-bar"),h=parseInt(a(g).attr("aria-valuenow")),i=1==e?h+1:h-1,j=parseInt(a(g).attr("aria-valuemax")),k=Math.round(i/j*100);a(g).attr("aria-valuenow",i),a(g).attr("style","width: "+k+"%");var l=[{key:"progresstotal",component:"completion",param:{complete:i,total:j}}];c.get_strings(l).then(function(b){a(g).attr("data-original-title",b)})})})}}}); \ No newline at end of file +define ("format_collapsibletopics/collapsibletopics",["jquery","core/log","core/str"],function(a,b,c){"use strict";var d=function(a,b,c){if("local"==c){window.localStorage.setItem("sections-toggle-"+a,JSON.stringify(b))}else if("session"==c){window.sessionStorage.setItem("sections-toggle-"+a,JSON.stringify(b))}},e=function(a,b){var c;if("local"==b){c=window.localStorage.getItem("sections-toggle-"+a)}else if("session"==b){c=window.sessionStorage.getItem("sections-toggle-"+a)}if(null===c){return{}}else{return JSON.parse(c)}};return{init:function init(f){b.debug("Format collapsibletopics AMD module initialized");a(document).ready(function(a){var b,g=f.keepstateoversession,h;if(1==g){h="local"}else{h="session"}b=e(f.course,h);setTimeout(function(){a(".sectiontoggle").each(function(c){var d="#collapse-"+(c+1);if(a(d).parent().parent().hasClass("current")||c+1 in b){a(d).collapse("show")}else{a(d).collapse("hide")}})},50);a("body").on("click",".expandall",function(c){c.preventDefault();var e=c.target;a(e).removeClass("expandall").addClass("collapseall").html(M.util.get_string("collapseall","moodle"));a(".sectiontoggle").each(function(c){a("#collapse-"+(c+1)).collapse("show");if(!b.hasOwnProperty(c+1)){b[c+1]="true";d(f.course,b,h)}})});a("body").on("click",".collapseall",function(c){c.preventDefault();var e=c.target;a(e).removeClass("collapseall").addClass("expandall").html(M.util.get_string("expandall","moodle"));a(".sectiontoggle").each(function(c){a("#collapse-"+(c+1)).collapse("hide");if(b.hasOwnProperty(c+1)){delete b[c+1];d(f.course,b,h)}})});a("#nav-drawer div.media").on("click",function(b){var c=a(b.target).parent().parent().parent().attr("href");if(-1!=c.lastIndexOf("#section-")){var d=c.substring(c.lastIndexOf("-")+1);a("#collapse-"+d).collapse("show")}});a(".collapse").on("show.bs.collapse",function(c){var e=a(c.target).attr("id"),g=e.substring(e.lastIndexOf("-")+1);if(!b.hasOwnProperty(g)){b[g]="true";d(f.course,b,h)}});a(".collapse").on("hide.bs.collapse",function(c){var e=a(c.target).attr("id"),g=e.substring(e.lastIndexOf("-")+1);if(b.hasOwnProperty(g)){delete b[g];d(f.course,b,h)}});a("body").on("click",".togglecompletion button",function(b){var d=b.target,e=a(d).parent().parent().children("input[name=\"completionstate\"]").val(),f=a(d).closest("li.section"),g=a(f).find(".progress-bar"),h=parseInt(a(g).attr("aria-valuenow")),i=1==e?h+1:h-1,j=parseInt(a(g).attr("aria-valuemax")),k=Math.round(100*(i/j));a(g).attr("aria-valuenow",i);a(g).attr("style","width: "+k+"%");c.get_strings([{key:"progresstotal",component:"completion",param:{complete:i,total:j}}]).then(function(b){a(g).attr("data-original-title",b)})})})}}}); +//# sourceMappingURL=collapsibletopics.min.js.map diff --git a/amd/build/collapsibletopics.min.js.map b/amd/build/collapsibletopics.min.js.map new file mode 100644 index 0000000..2dbba1b --- /dev/null +++ b/amd/build/collapsibletopics.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/collapsibletopics.js"],"names":["define","$","log","str","setState","course","toggles","storage","window","localStorage","setItem","JSON","stringify","sessionStorage","getState","getItem","parse","init","args","debug","document","ready","sectiontoggles","keepstateoversession","setTimeout","each","index","section","parent","hasClass","collapse","on","event","preventDefault","target","removeClass","addClass","html","M","util","get_string","hasOwnProperty","href","attr","lastIndexOf","substring","sectionstringid","sectionid","state","children","val","closest","progressbar","find","oldvalue","parseInt","newvalue","total","percent","Math","round","get_strings","key","component","param","complete","then","progress"],"mappings":"AAwBAA,OAAM,8CAAC,CAAC,QAAD,CAAW,UAAX,CAAuB,UAAvB,CAAD,CAAqC,SAASC,CAAT,CAAYC,CAAZ,CAAiBC,CAAjB,CAAsB,CAE7D,aAF6D,GAOzDC,CAAAA,CAAQ,CAAG,SAASC,CAAT,CAAiBC,CAAjB,CAA0BC,CAA1B,CAAmC,CAC9C,GAAe,OAAX,EAAAA,CAAJ,CAAwB,CACpBC,MAAM,CAACC,YAAP,CAAoBC,OAApB,CAA4B,mBAAqBL,CAAjD,CAAyDM,IAAI,CAACC,SAAL,CAAeN,CAAf,CAAzD,CACH,CAFD,IAEO,IAAe,SAAX,EAAAC,CAAJ,CAA0B,CAC7BC,MAAM,CAACK,cAAP,CAAsBH,OAAtB,CAA8B,mBAAqBL,CAAnD,CAA2DM,IAAI,CAACC,SAAL,CAAeN,CAAf,CAA3D,CACH,CACJ,CAb4D,CAkBzDQ,CAAQ,CAAG,SAAST,CAAT,CAAiBE,CAAjB,CAA0B,CACrC,GAAID,CAAAA,CAAJ,CACA,GAAe,OAAX,EAAAC,CAAJ,CAAwB,CACpBD,CAAO,CAAGE,MAAM,CAACC,YAAP,CAAoBM,OAApB,CAA4B,mBAAqBV,CAAjD,CACb,CAFD,IAEO,IAAe,SAAX,EAAA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,CAAD,CAP0C,CAQ1De,CAAO,CAAGC,IAAI,CAACC,KAAL,CAA+B,GAAnB,EAAAJ,CAAQ,CAAGC,CAAX,CAAZ,CARgD,CAS9DxD,CAAC,CAACmD,CAAD,CAAD,CAAeT,IAAf,CAAoB,eAApB,CAAqCa,CAArC,EACAvD,CAAC,CAACmD,CAAD,CAAD,CAAeT,IAAf,CAAoB,OAApB,CAA6B,UAAYe,CAAZ,CAAsB,GAAnD,EAWAvD,CAAG,CAAC0D,WAAJ,CAVc,CACV,CACIC,GAAG,CAAE,eADT,CAEIC,SAAS,CAAE,YAFf,CAGIC,KAAK,CAAG,CACJC,QAAQ,CAAET,CADN,CAEJC,KAAK,CAAEA,CAFH,CAHZ,CADU,CAUd,EAAyBS,IAAzB,CAA8B,SAASC,CAAT,CAAmB,CAC7ClE,CAAC,CAACmD,CAAD,CAAD,CAAeT,IAAf,CAAoB,qBAApB,CAA2CwB,CAA3C,CACH,CAFD,CAIH,CAzBD,CA0BH,CA/GD,CAgHH,CAnHE,CAqHV,CArJK,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 * Javascript controller for the \"Actions\" panel at the bottom of the page.\n *\n * @package format_collapsibletopics\n * @author Jean-Roch Meurisse\n * @copyright 2018 University of Namur - Cellule TICE\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/log', 'core/str'], function($, log, str) {\n\n \"use strict\";\n\n /**\n * Update toggles state of current course in browser storage.\n */\n var setState = function(course, toggles, storage) {\n if (storage == 'local') {\n window.localStorage.setItem('sections-toggle-' + course, JSON.stringify(toggles));\n } else if (storage == 'session') {\n window.sessionStorage.setItem('sections-toggle-' + course, JSON.stringify(toggles));\n }\n };\n\n /**\n * Update toggles state of current course in browser storage.\n */\n var getState = function(course, storage) {\n var toggles;\n if (storage == 'local') {\n toggles = window.localStorage.getItem('sections-toggle-' + course);\n } else if (storage == 'session') {\n toggles = window.sessionStorage.getItem('sections-toggle-' + course);\n }\n if (toggles === null) {\n return {};\n } else {\n return JSON.parse(toggles);\n }\n };\n\n return {\n init: function(args) {\n log.debug('Format collapsibletopics AMD module initialized');\n $(document).ready(function($) {\n var sectiontoggles;\n var keepstateoversession = args.keepstateoversession;\n var storage;\n if (keepstateoversession == 1) {\n // Use browser local storage.\n storage = 'local';\n } else {\n // Use browser session storage.\n storage = 'session';\n }\n\n sectiontoggles = getState(args.course, storage);\n\n setTimeout(function() {\n\n $('.sectiontoggle').each(function (index) {\n var section = '#collapse-' + (index + 1);\n if ($(section).parent().parent().hasClass('current') || (index + 1) in sectiontoggles) {\n $(section).collapse('show');\n } else {\n $(section).collapse('hide');\n }\n });\n }, 50);\n\n // Handle toggle all sections.\n $('body').on('click', '.expandall', function(event) {\n event.preventDefault();\n var target = event.target;\n $(target).removeClass('expandall').addClass('collapseall').html(M.util.get_string('collapseall', 'moodle'));\n\n $('.sectiontoggle').each(function(index) {\n var section = '#collapse-' + (index + 1);\n $(section).collapse('show');\n if (!sectiontoggles.hasOwnProperty(index + 1)) {\n sectiontoggles[index + 1] = \"true\";\n setState(args.course, sectiontoggles, storage);\n }\n });\n });\n\n $('body').on('click', '.collapseall', function(event) {\n event.preventDefault();\n var target = event.target;\n $(target).removeClass('collapseall').addClass('expandall').html(M.util.get_string('expandall', 'moodle'));\n $('.sectiontoggle').each(function(index) {\n var section = '#collapse-' + (index + 1);\n $(section).collapse('hide');\n if (sectiontoggles.hasOwnProperty(index + 1)) {\n delete sectiontoggles[index + 1];\n setState(args.course, sectiontoggles, storage);\n }\n });\n });\n $('#nav-drawer div.media').on('click', function(event) {\n\n var href = $(event.target).parent().parent().parent().attr('href');\n\n if (href.lastIndexOf('#section-') != -1) {\n var index = href.substring(href.lastIndexOf('-') + 1);\n var attr = '#collapse-' + index;\n $(attr).collapse('show');\n }\n });\n\n $('.collapse').on('show.bs.collapse', function(event) {\n var sectionstringid = $(event.target).attr('id');\n var sectionid = sectionstringid.substring(sectionstringid.lastIndexOf('-') + 1);\n\n if (!sectiontoggles.hasOwnProperty(sectionid)) {\n sectiontoggles[sectionid] = \"true\";\n setState(args.course, sectiontoggles, storage);\n }\n });\n\n $('.collapse').on('hide.bs.collapse', function(event) {\n var sectionstringid = $(event.target).attr('id');\n var sectionid = sectionstringid.substring(sectionstringid.lastIndexOf('-') + 1);\n\n if (sectiontoggles.hasOwnProperty(sectionid)) {\n delete sectiontoggles[sectionid];\n setState(args.course, sectiontoggles, storage);\n }\n });\n $('body').on('click', '.togglecompletion button', function(event) {\n var target = event.target;\n var state = $(target).parent().parent().children('input[name=\"completionstate\"]').val();\n var section = ($(target).closest('li.section'));\n var progressbar = $(section).find('.progress-bar');\n var oldvalue = parseInt($(progressbar).attr('aria-valuenow'));\n var newvalue = state == 1 ? oldvalue + 1 : oldvalue - 1;\n var total = parseInt($(progressbar).attr('aria-valuemax'));\n var percent = Math.round((newvalue / total * 100));\n $(progressbar).attr('aria-valuenow', newvalue);\n $(progressbar).attr('style', 'width: ' + percent + '%');\n var strings = [\n {\n key: 'progresstotal',\n component: 'completion',\n param : {\n complete: newvalue,\n total: total\n }\n }\n ];\n str.get_strings(strings).then(function(progress) {\n $(progressbar).attr('data-original-title', progress);\n });\n\n });\n });\n }\n };\n});\n"],"file":"collapsibletopics.min.js"} \ No newline at end of file diff --git a/amd/src/collapsibletopics.js b/amd/src/collapsibletopics.js index 5325fed..5c47821 100644 --- a/amd/src/collapsibletopics.js +++ b/amd/src/collapsibletopics.js @@ -72,6 +72,7 @@ define(['jquery', 'core/log', 'core/str'], function($, log, str) { sectiontoggles = getState(args.course, storage); setTimeout(function() { + $('.sectiontoggle').each(function (index) { var section = '#collapse-' + (index + 1); if ($(section).parent().parent().hasClass('current') || (index + 1) in sectiontoggles) {