Skip to content
Snippets Groups Projects
Select Git revision
  • 2222c4a853c010f86086c18002d274892805d1a2
  • master default
2 results

forms.py

Blame
  • catchshortcuts.min.js.map 6.36 KiB
    {"version":3,"sources":["../src/catchshortcuts.js"],"names":["define","$","initcatchshortcuts","value","document","keydown","e","keyCode","checkForActiveFormElement","scrollToBottomOfCourse","navigator","appVersion","indexOf","metaKey","ctrlKey","event","preventDefault","animate","scrollTop","offset","top","window","height","activeElement","returnvalue","tagName","isContentEditable","init","params","i","len","length"],"mappings":"AAuBAA,OAAM,qCAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,CAC3B,aAOA,QAASC,CAAAA,CAAT,CAA4BC,CAA5B,CAAmC,CAC/B,GAAa,KAAT,EAAAA,CAAJ,CAAoB,CAEhBF,CAAC,CAACG,QAAD,CAAD,CAAYC,OAAZ,CAAoB,SAASC,CAAT,CAAY,CAC5B,GAAiB,EAAb,EAAAA,CAAC,CAACC,OAAN,CAAqB,CAEjB,GAAI,IAAAC,CAAyB,EAA7B,CAAyC,CAErCC,CAAsB,CAACH,CAAD,CACzB,CACJ,CACJ,CARD,CASH,CAED,GAA2C,CAAC,CAAxC,EAAAI,SAAS,CAACC,UAAV,CAAqBC,OAArB,CAA6B,KAA7B,GAAsD,cAAT,EAAAT,CAAjD,CAA0E,CAEtEF,CAAC,CAACG,QAAD,CAAD,CAAYC,OAAZ,CAAoB,SAASC,CAAT,CAAY,CAC5B,GAAiB,EAAb,EAAAA,CAAC,CAACC,OAAF,EAAmBD,CAAC,CAACO,OAAzB,CAAkC,CAE9B,GAAI,IAAAL,CAAyB,EAA7B,CAAyC,CAErCC,CAAsB,CAACH,CAAD,CACzB,CACJ,CACJ,CARD,CASH,CAED,GAA2C,CAAC,CAAxC,EAAAI,SAAS,CAACC,UAAV,CAAqBC,OAArB,CAA6B,KAA7B,GAAsD,eAAT,EAAAT,CAAjD,CAA2E,CAEvEF,CAAC,CAACG,QAAD,CAAD,CAAYC,OAAZ,CAAoB,SAASC,CAAT,CAAY,CAC5B,GAAiB,EAAb,EAAAA,CAAC,CAACC,OAAF,EAAmBD,CAAC,CAACQ,OAAzB,CAAkC,CAE9B,GAAI,IAAAN,CAAyB,EAA7B,CAAyC,CAErCC,CAAsB,CAACH,CAAD,CACzB,CACJ,CACJ,CARD,CASH,CACJ,CAOD,QAASG,CAAAA,CAAT,CAAgCM,CAAhC,CAAuC,CAEnCA,CAAK,CAACC,cAAN,GAEAf,CAAC,CAAC,YAAD,CAAD,CAAgBgB,OAAhB,CAAwB,CACpBC,SAAS,CAAEjB,CAAC,CAAC,cAAD,CAAD,CAAkBkB,MAAlB,GAA2BC,GAA3B,CAAiCnB,CAAC,CAACoB,MAAD,CAAD,CAAUC,MAAV,EAAjC,CAAsD,EAD7C,CAAxB,CAEG,GAFH,CAGH,CAOD,QAASd,CAAAA,CAAT,EAAqC,IAE7Be,CAAAA,CAAa,CAAGnB,QAAQ,CAACmB,aAFI,CAG7BC,CAAW,GAHkB,CAKjC,GAA6B,OAAzB,EAAAD,CAAa,CAACE,OAAd,EAA6D,UAAzB,EAAAF,CAAa,CAACE,OAAlD,EAA2E,IAAAF,CAAa,CAACG,iBAA7F,CAAwH,CACpHF,CAAW,GACd,CACD,MAAOA,CAAAA,CACV,CAED,MAAO,CACHG,IAAI,CAAE,cAASC,CAAT,CAAiB,CACnB,IAAK,GAAIC,CAAAA,CAAC,CAAG,CAAR,CAAWC,CAAG,CAAGF,CAAM,CAACG,MAA7B,CAAqCF,CAAC,CAAGC,CAAzC,CAA8CD,CAAC,EAA/C,CAAmD,CAC/C3B,CAAkB,CAAC0B,CAAM,CAACC,CAAD,CAAP,CACrB,CACJ,CALE,CAOV,CAtFK,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 <http://www.gnu.org/licenses/>.\n\n/**\n * Theme Boost Campus - JS code for catching pressed keys.\n *\n * @package    theme_boost_campus\n * @copyright  2017 Kathrin Osswald, Ulm University <kathrin.osswald@uni-ulm.de>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery'], function($) {\n    \"use strict\";\n\n    /**\n     * Initialising.\n     *\n     * @param {string} value\n     */\n    function initcatchshortcuts(value) {\n        if (value == 'end') {\n            // Catch the end key to be able to change the behavior.\n            $(document).keydown(function(e) {\n                if (e.keyCode == 35) {\n                    // Additionally check no active focus in form elements.\n                    if (checkForActiveFormElement() != true) {\n                        // Scroll only to the bottom of the course content.\n                        scrollToBottomOfCourse(e);\n                    }\n                }\n            });\n        }\n        // This shortcut is only relevant for users operating on MacOS.\n        if (navigator.appVersion.indexOf(\"Mac\") != -1 && value == 'cmdarrowdown') {\n            // Bind the cmd + arrow down shortcut to be able to change the behavior.\n            $(document).keydown(function(e) {\n                if (e.keyCode == 40 && e.metaKey) {\n                    // Additionally check no active focus in form elements.\n                    if (checkForActiveFormElement() != true) {\n                        // Scroll only to the bottom of the course content.\n                        scrollToBottomOfCourse(e);\n                    }\n                }\n            });\n        }\n        // This shortcut is only relevant for users operating on Windows.\n        if (navigator.appVersion.indexOf(\"Win\") != -1 && value == 'ctrlarrowdown') {\n            // Bind the ctrl + arrow down shortcut to be able to change the behavior.\n            $(document).keydown(function(e) {\n                if (e.keyCode == 40 && e.ctrlKey) {\n                    // Additionally check no active focus in form elements.\n                    if (checkForActiveFormElement() != true) {\n                        // Scroll only to the bottom of the course content.\n                        scrollToBottomOfCourse(e);\n                    }\n                }\n            });\n        }\n    }\n\n    /**\n     * Function to scroll only to the bottom of the course and not the bottom of the whole page.\n     *\n     * @param {object} event\n     */\n    function scrollToBottomOfCourse(event) {\n        // Prevent default behavior.\n        event.preventDefault();\n        // Scroll only to the bottom of the course content.\n        $('html, body').animate({\n            scrollTop: $('#page-footer').offset().top - $(window).height() + 50\n        }, 500);\n    }\n\n    /**\n     * Function to check for an active form element.\n     *\n     * @return {boolean}\n     */\n    function checkForActiveFormElement() {\n        // Get the active Element for the current page.\n        var activeElement = document.activeElement;\n        var returnvalue = false;\n        // Check if the given active element is type of input field, textarea or editable content.\n        if (activeElement.tagName == 'INPUT' || activeElement.tagName == 'TEXTAREA' || activeElement.isContentEditable == true) {\n            returnvalue = true;\n        }\n        return returnvalue;\n    }\n\n    return {\n        init: function(params) {\n            for (var i = 0, len = params.length; i < len; i++) {\n                initcatchshortcuts(params[i]);\n            }\n        }\n    };\n});\n"],"file":"catchshortcuts.min.js"}