Your IP : 192.168.165.1


Current Path : C:/xampp/htdocs/moodle/report/progress/amd/build/
Upload File :
Current File : C:/xampp/htdocs/moodle/report/progress/amd/build/completion_override.min.js.map

{"version":3,"sources":["../src/completion_override.js"],"names":["define","$","Ajax","Str","ModalFactory","ModalEvents","Notification","CustomEvents","Templates","userFullName","triggerElement","getIconKeyFromState","state","tracking","setOverride","override","render","then","html","append","call","methodname","args","results","completionState","tooltipKey","get_string","stateString","params","date","user","attr","activity","titleString","completionTracking","renderPix","oppositeState","find","remove","data","userid","cmid","children","replaceWith","catch","exception","userConfirm","e","originalEvent","preventDefault","stopPropagation","currentTarget","elemData","split","newstate","newStateStr","get_strings","key","component","strings","param","create","type","types","SAVE_CANCEL","title","body","modal","getRoot","on","save","hidden","focus","destroy","show","init","fullName","each","index","element","events","activate"],"mappings":"AAwBAA,OAAM,uCAAC,CAAC,QAAD,CAAW,WAAX,CAAwB,UAAxB,CAAoC,oBAApC,CAA0D,mBAA1D,CAA+E,mBAA/E,CACC,gCADD,CACmC,gBADnC,CAAD,CAEF,SAASC,CAAT,CAAYC,CAAZ,CAAkBC,CAAlB,CAAuBC,CAAvB,CAAqCC,CAArC,CAAkDC,CAAlD,CAAgEC,CAAhE,CAA8EC,CAA9E,CAAyF,IAMjFC,CAAAA,CANiF,CAYjFC,CAZiF,CAsBjFC,CAAmB,CAAG,SAASC,CAAT,CAAgBC,CAAhB,CAA0B,CAChD,MAAe,EAAR,CAAAD,CAAK,CAAO,gBAAkBC,CAAlB,CAA6B,aAApC,CAAoD,gBAAkBA,CAAlB,CAA6B,aAChG,CAxBoF,CAgCjFC,CAAW,CAAG,SAASC,CAAT,CAAmB,CAEjCP,CAAS,CAACQ,MAAV,CAAiB,cAAjB,CAAiC,EAAjC,EAAqCC,IAArC,CAA0C,SAASC,CAAT,CAAe,CAErDR,CAAc,CAACS,MAAf,CAAsBD,CAAtB,EAGA,MAAOhB,CAAAA,CAAI,CAACkB,IAAL,CAAU,CAAC,CACdC,UAAU,C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eAA3D,CAA4E,SAASlC,CAAT,CAAYR,CAAZ,CAAkB,CAC1FO,CAAW,CAACC,CAAD,CAAIR,CAAJ,CACd,CAFD,CAGH,CAE+D,CAGnE,CA1JC,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 * AMD module to handle overriding activity completion status.\n *\n * @module     report_progress/completion_override\n * @package    report_progress\n * @copyright  2016 onwards Eiz Eddin Al Katrib <eiz@barasoft.co.uk>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since      3.1\n */\ndefine(['jquery', 'core/ajax', 'core/str', 'core/modal_factory', 'core/modal_events', 'core/notification',\n        'core/custom_interaction_events', 'core/templates'],\n    function($, Ajax, Str, ModalFactory, ModalEvents, Notification, CustomEvents, Templates) {\n\n        /**\n         * @type {String} the full name of the current user.\n         * @private\n         */\n        var userFullName;\n\n        /**\n         * @type {JQuery} JQuery object containing the element (completion link) that was most recently activated.\n         * @private\n         */\n        var triggerElement;\n\n        /**\n         * Helper function to get the pix icon key based on the completion state.\n         * @method getIconDescriptorFromState\n         * @param {number} state The current completion state.\n         * @param {string} tracking The completion tracking type, either 'manual' or 'auto'.\n         * @return {string} the key for the respective icon.\n         * @private\n         */\n        var getIconKeyFromState = function(state, tracking) {\n            return state > 0 ? 'i/completion-' + tracking + '-y-override' : 'i/completion-' + tracking + '-n-override';\n        };\n\n        /**\n         * Handles the confirmation of an override change, calling the web service to update it.\n         * @method setOverride\n         * @param {Object} override the override data\n         * @private\n         */\n        var setOverride = function(override) {\n            // Generate a loading spinner while we're working.\n            Templates.render('core/loading', {}).then(function(html) {\n                // Append the loading spinner to the trigger element.\n                triggerElement.append(html);\n\n                // Update the completion status override.\n                return Ajax.call([{\n                    methodname: 'core_completion_override_activity_completion_status',\n                    args: override\n                }])[0];\n            }).then(function(results) {\n                var completionState = (results.state > 0) ? 1 : 0;\n\n                // Now, build the new title string, get the new icon, and update the DOM.\n                var tooltipKey = completionState ? 'completion-y-override' : 'completion-n-override';\n                Str.get_string(tooltipKey, 'completion', userFullName).then(function(stateString) {\n                    var params = {\n                        state: stateString,\n                        date: '',\n                        user: triggerElement.attr('data-userfullname'),\n                        activity: triggerElement.attr('data-activityname')\n                    };\n                    return Str.get_string('progress-title', 'completion', params);\n                }).then(function(titleString) {\n                    var completionTracking = triggerElement.attr('data-completiontracking');\n                    return Templates.renderPix(getIconKeyFromState(completionState, completionTracking), 'core', titleString);\n                }).then(function(html) {\n                    var oppositeState = completionState > 0 ? 0 : 1;\n                    triggerElement.find('.loading-icon').remove();\n                    triggerElement.data('changecompl', override.userid + '-' + override.cmid + '-' + oppositeState);\n                    triggerElement.attr('data-changecompl', override.userid + '-' + override.cmid + '-' + oppositeState);\n                    triggerElement.children(\"img\").replaceWith(html);\n                    return;\n                }).catch(Notification.exception);\n\n                return;\n            }).catch(Notification.exception);\n        };\n\n        /**\n         * Handler for activation of a completion status button element.\n         * @method userConfirm\n         * @param {Event} e the CustomEvents event (CustomEvents.events.activate in this case)\n         * @param {Object} data an object containing the original event (click, keydown, etc.).\n         * @private\n         */\n        var userConfirm = function(e, data) {\n            data.originalEvent.preventDefault();\n            data.originalEvent.stopPropagation();\n            e.preventDefault();\n            e.stopPropagation();\n\n            triggerElement = $(e.currentTarget);\n            var elemData = triggerElement.data('changecompl').split('-');\n            var override = {\n                userid: elemData[0],\n                cmid: elemData[1],\n                newstate: elemData[2]\n            };\n            var newStateStr = (override.newstate == 1) ? 'completion-y' : 'completion-n';\n\n            Str.get_strings([\n                {key: newStateStr, component: 'completion'}\n            ]).then(function(strings) {\n                return Str.get_strings([\n                    {key: 'confirm', component: 'moodle'},\n                    {key: 'areyousureoverridecompletion', component: 'completion', param: strings[0]}\n                ]);\n            }).then(function(strings) {\n                // Create a save/cancel modal.\n                return ModalFactory.create({\n                    type: ModalFactory.types.SAVE_CANCEL,\n                    title: strings[0],\n                    body: strings[1],\n                });\n            }).then(function(modal) {\n                // Now set up the handlers for the confirmation or cancellation of the modal, and show it.\n\n                // Confirmation only.\n                modal.getRoot().on(ModalEvents.save, function() {\n                    setOverride(override);\n                });\n\n                // Confirming, closing, or cancelling will destroy the modal and return focus to the trigger element.\n                modal.getRoot().on(ModalEvents.hidden, function() {\n                    triggerElement.focus();\n                    modal.destroy();\n                });\n\n                // Display.\n                modal.show();\n                return;\n            }).catch(Notification.exception);\n        };\n\n        /**\n         * Init this module which allows activity completion state to be changed via ajax.\n         * @method init\n         * @param {string} fullName The current user's full name.\n         * @private\n         */\n        var init = function(fullName) {\n            userFullName = fullName;\n\n            // Register the click, space and enter events as activators for the trigger element.\n            $('#completion-progress a.changecompl').each(function(index, element) {\n                CustomEvents.define(element, [CustomEvents.events.activate]);\n            });\n\n            // Set the handler on the parent element (the table), but filter so the callback is only called for <a> type children\n            // having the '.changecompl' class. The <a> element can then be accessed in the callback via e.currentTarget.\n            $('#completion-progress').on(CustomEvents.events.activate, \"a.changecompl\", function(e, data) {\n                userConfirm(e, data);\n            });\n        };\n\n        return /** @alias module:report_progress/completion_override */ {\n            init: init\n        };\n    });\n"],"file":"completion_override.min.js"}