{"version":3,"file":"accessibilitybar.min.js","sources":["https:\/\/moodle.saludpublica.fcm.unc.edu.ar\/theme\/moove\/amd\/src\/accessibilitybar.js"],"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 * Contain the logic for accessibility bar.\n *\n * @package\n * @copyright 2022 Willian Mano - https:\/\/conecti.me\n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\ndefine(['jquery', 'core\/ajax'], function(jQuery, Ajax) {\n\n window.jQuery = jQuery;\n\n var SELECTORS = {\n FONT_SIZE: '#fontsize_dec, #fontsize_reset, #fontsize_inc',\n SITE_COLOR: '#sitecolor_color1, #sitecolor_color2, #sitecolor_color3, #sitecolor_color4'\n };\n\n var fontsizeClass = null;\n var fontsizeClassOp = null;\n var fontsizeClassSize = null;\n var fontsizeCurrentAction = null;\n var sitecolorCurrentAction = null;\n\n var AccessibilityBar = function() {\n var classList = jQuery('body').attr('class').split(\/\\s+\/);\n jQuery.each(classList, function(index, item) {\n if (item.includes('fontsize-inc-') || item.includes('fontsize-dec-')) {\n var itemarr = item.split('-');\n\n fontsizeClass = item;\n fontsizeClassOp = itemarr[1];\n fontsizeClassSize = itemarr[2];\n }\n });\n\n this.toggleFontsizeButtons();\n\n this.registerEventListeners();\n };\n\n AccessibilityBar.prototype.registerEventListeners = function() {\n jQuery(SELECTORS.FONT_SIZE).click(function(element) {\n var btn = jQuery(element.currentTarget);\n\n fontsizeCurrentAction = btn.data('action');\n\n this.fontSize();\n }.bind(this));\n\n jQuery(SELECTORS.SITE_COLOR).click(function(element) {\n var btn = jQuery(element.currentTarget);\n\n sitecolorCurrentAction = btn.data('action');\n\n this.siteColor();\n }.bind(this));\n };\n\n AccessibilityBar.prototype.fontSize = function() {\n var request = Ajax.call([{\n methodname: 'theme_moove_fontsize',\n args: {\n action: fontsizeCurrentAction\n }\n }]);\n\n request[0].done(function() {\n this.reloadFontsizeClass();\n }.bind(this));\n };\n\n AccessibilityBar.prototype.reloadFontsizeClass = function() {\n if (fontsizeCurrentAction === 'reset'\n || (fontsizeCurrentAction === 'increase' && fontsizeClass === 'fontsize-dec-1')\n || (fontsizeCurrentAction === 'decrease' && fontsizeClass === 'fontsize-inc-1')\n ) {\n jQuery('body').removeClass(fontsizeClass);\n fontsizeClass = null;\n fontsizeClassOp = null;\n fontsizeClassSize = null;\n\n this.toggleFontsizeButtons();\n\n return;\n }\n\n if (fontsizeCurrentAction === 'increase') {\n if (fontsizeClassSize === null) {\n fontsizeClass = 'fontsize-inc-1';\n fontsizeClassOp = 'inc';\n fontsizeClassSize = 1;\n } else if (fontsizeClassOp === 'inc' && fontsizeClassSize < 6) {\n jQuery('body').removeClass(fontsizeClass);\n fontsizeClassSize++;\n fontsizeClass = 'fontsize-inc-' + fontsizeClassSize;\n } else if (fontsizeClassOp === 'dec') {\n jQuery('body').removeClass(fontsizeClass);\n fontsizeClassSize--;\n fontsizeClass = 'fontsize-dec-' + fontsizeClassSize;\n }\n\n jQuery('body').addClass(fontsizeClass);\n }\n\n if (fontsizeCurrentAction === 'decrease') {\n if (fontsizeClassSize === null) {\n fontsizeClass = 'fontsize-dec-1';\n fontsizeClassOp = 'dec';\n fontsizeClassSize = 1;\n } else if (fontsizeClassOp === 'dec' && fontsizeClassSize < 6) {\n jQuery('body').removeClass(fontsizeClass);\n fontsizeClassSize++;\n fontsizeClass = 'fontsize-dec-' + fontsizeClassSize;\n } else if (fontsizeClassOp === 'inc') {\n jQuery('body').removeClass(fontsizeClass);\n fontsizeClassSize--;\n fontsizeClass = 'fontsize-inc-' + fontsizeClassSize;\n }\n\n jQuery('body').addClass(fontsizeClass);\n }\n\n this.toggleFontsizeButtons();\n };\n\n AccessibilityBar.prototype.toggleFontsizeButtons = function() {\n if (fontsizeClass === null) {\n jQuery('#fontsize_reset').addClass('disabled');\n jQuery('#fontsize_inc').removeClass('disabled');\n jQuery('#fontsize_dec').removeClass('disabled');\n }\n\n if (fontsizeClass !== null) {\n jQuery('#fontsize_reset').removeClass('disabled');\n }\n\n if (fontsizeClassOp === 'inc') {\n if (fontsizeClassSize == 6) {\n jQuery('#fontsize_inc').addClass('disabled');\n }\n\n if (fontsizeClassSize < 6) {\n jQuery('#fontsize_inc').removeClass('disabled');\n }\n }\n\n if (fontsizeClassOp === 'dec') {\n if (fontsizeClassSize == 6) {\n jQuery('#fontsize_dec').addClass('disabled');\n }\n\n if (fontsizeClassSize < 6) {\n jQuery('#fontsize_dec').removeClass('disabled');\n }\n }\n };\n\n AccessibilityBar.prototype.siteColor = function() {\n var request = Ajax.call([{\n methodname: 'theme_moove_sitecolor',\n args: {\n action: sitecolorCurrentAction\n }\n }]);\n\n request[0].done(function() {\n this.reloadSitecolorClass();\n }.bind(this));\n };\n\n AccessibilityBar.prototype.reloadSitecolorClass = function() {\n jQuery('body').removeClass(function(index, className) {\n return (className.match(\/(^|\\s)sitecolor-color-\\S+\/g) || []).join(' ');\n });\n\n if (sitecolorCurrentAction !== 'reset') {\n jQuery('body').addClass(sitecolorCurrentAction);\n }\n };\n\n return {\n 'init': function() {\n return new AccessibilityBar();\n }\n };\n});"],"names":["define","jQuery","Ajax","window","SELECTORS","fontsizeClass","fontsizeClassOp","fontsizeClassSize","fontsizeCurrentAction","sitecolorCurrentAction","AccessibilityBar","classList","attr","split","each","index","item","includes","itemarr","toggleFontsizeButtons","registerEventListeners","prototype","click","element","btn","currentTarget","data","fontSize","bind","this","siteColor","call","methodname","args","action","done","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