Your IP : 216.73.216.95


Current Path : /var/www/ljmtc/cbt/grade/grading/form/guide/amd/build/
Upload File :
Current File : /var/www/ljmtc/cbt/grade/grading/form/guide/amd/build/comment_chooser.min.js.map

{"version":3,"sources":["../src/comment_chooser.js"],"names":["define","$","templates","notification","initialise","criterionId","buttonId","remarkId","commentOptions","displayChooserDialog","compiledSource","comments","titleLabel","M","util","get_string","cancelButtonId","cancelButton","chooserDialog","core","dialogue","modal","headerContent","bodyContent","footerContent","focusAfterHide","id","click","hide","each","index","comment","commentOptionId","remarkTextArea","remarkText","val","trim","description","document","off","on","keyCode","event","which","after","e","prevVal","newVal","destroy","show","generateCommentsChooser","render","done","fail","exception","preventDefault"],"mappings":"AAwBAA,OAAM,qCAAC,CAAC,QAAD,CAAW,gBAAX,CAA6B,mBAA7B,CAAkD,UAAlD,CAAD,CAAgE,SAASC,CAAT,CAAYC,CAAZ,CAAuBC,CAAvB,CAAqC,CAIvG,MAA8D,CAa1DC,UAAU,CAAE,oBAASC,CAAT,CAAsBC,CAAtB,CAAgCC,CAAhC,CAA0CC,CAA1C,CAA0D,CAQlE,QAASC,CAAAA,CAAT,CAA8BC,CAA9B,CAA8CC,CAA9C,CAAwD,IAChDC,CAAAA,CAAU,CAAG,UAAYC,CAAC,CAACC,IAAF,CAAOC,UAAP,CAAkB,eAAlB,CAAmC,mBAAnC,CAAZ,CAAsE,UADnC,CAEhDC,CAAc,CAAG,mBAAqBX,CAArB,CAAmC,SAFJ,CAGhDY,CAAY,CAAG,gBAAiBD,CAAjB,CAAkC,KAAlC,CAAyCH,CAAC,CAACC,IAAF,CAAOC,UAAP,CAAkB,QAAlB,CAA4B,QAA5B,CAAzC,CAAiF,WAHhD,CAMhDG,CAAa,CAAG,GAAIL,CAAAA,CAAC,CAACM,IAAF,CAAOC,QAAX,CAAoB,CACpCC,KAAK,GAD+B,CAEpCC,aAAa,CAAEV,CAFqB,CAGpCW,WAAW,CAAEb,CAHuB,CAIpCc,aAAa,CAAEP,CAJqB,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,MAApB,CAA4B,CACxB,KAAKC,OAAL,EACH,CACJ,CALD,CAKG9B,CALH,EAQAA,CAAa,CAAC+B,IAAd,EACH,CAKD,QAASC,CAAAA,CAAT,EAAmC,CAQ/BhD,CAAS,CAACiD,MAAV,CAAiB,mCAAjB,CANc,CACV9C,WAAW,CAAEA,CADH,CAEVM,QAAQ,CAAEH,CAFA,CAMd,EACK4C,IADL,CACU,SAAS1C,CAAT,CAAyB,CAC3BD,CAAoB,CAACC,CAAD,CAAiBF,CAAjB,CACvB,CAHL,EAIK6C,IAJL,CAIUlD,CAAY,CAACmD,SAJvB,CAKH,CAGDrD,CAAC,CAAC,IAAMK,CAAP,CAAD,CAAkBqB,KAAlB,CAAwB,SAASkB,CAAT,CAAY,CAChCA,CAAC,CAACU,cAAF,GACAL,CAAuB,EAC1B,CAHD,CAIH,CA7GyD,CA+GjE,CAnHK,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 code for the frequently used comments chooser for the marking guide grading form.\n *\n * @module     gradingform_guide/comment_chooser\n * @class      comment_chooser\n * @package    core\n * @copyright  2015 Jun Pataleta <jun@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n  */\ndefine(['jquery', 'core/templates', 'core/notification', 'core/yui'], function($, templates, notification) {\n\n    // Private variables and functions.\n\n    return /** @alias module:gradingform_guide/comment_chooser */ {\n        // Public variables and functions.\n        /**\n         * Initialises the module.\n         *\n         * Basically, it performs the binding and handling of the button click event for\n         * the 'Insert frequently used comment' button.\n         *\n         * @param {Integer} criterionId The criterion ID.\n         * @param {String} buttonId The element ID of the button which the handler will be bound to.\n         * @param {String} remarkId The element ID of the remark text area where the text of the selected comment will be copied to.\n         * @param {Array} commentOptions The array of frequently used comments to be used as options.\n         */\n        initialise: function(criterionId, buttonId, remarkId, commentOptions) {\n            /**\n             * Display the chooser dialog using the compiled HTML from the mustache template\n             * and binds onclick events for the generated comment options.\n             *\n             * @param {String} compiledSource The compiled HTML from the mustache template\n             * @param {Array} comments Array containing comments.\n             */\n            function displayChooserDialog(compiledSource, comments) {\n                var titleLabel = '<label>' + M.util.get_string('insertcomment', 'gradingform_guide') + '</label>';\n                var cancelButtonId = 'comment-chooser-' + criterionId + '-cancel';\n                var cancelButton = '<button id=\"' + cancelButtonId + '\">' + M.util.get_string('cancel', 'moodle') + '</button>';\n\n                // Set dialog's body content.\n                var chooserDialog = new M.core.dialogue({\n                    modal: true,\n                    headerContent: titleLabel,\n                    bodyContent: compiledSource,\n                    footerContent: cancelButton,\n                    focusAfterHide: '#' + remarkId,\n                    id: \"comments-chooser-dialog-\" + criterionId\n                });\n\n                // Bind click event to the cancel button.\n                $(\"#\" + cancelButtonId).click(function() {\n                    chooserDialog.hide();\n                });\n\n                // Loop over each comment item and bind click events.\n                $.each(comments, function(index, comment) {\n                    var commentOptionId = '#comment-option-' + criterionId + '-' + comment.id;\n\n                    // Delegate click event for the generated option link.\n                    $(commentOptionId).click(function() {\n                        var remarkTextArea = $('#' + remarkId);\n                        var remarkText = remarkTextArea.val();\n\n                        // Add line break if the current value of the remark text is not empty.\n                        if (remarkText.trim() !== '') {\n                            remarkText += '\\n';\n                        }\n                        remarkText += comment.description;\n\n                        remarkTextArea.val(remarkText);\n\n                        chooserDialog.hide();\n                    });\n\n                    // Handle keypress on list items.\n                    $(document).off('keypress', commentOptionId).on('keypress', commentOptionId, function() {\n                        var keyCode = event.which || event.keyCode;\n\n                        // Enter or space key.\n                        if (keyCode == 13 || keyCode == 32) {\n                            // Trigger click event.\n                            $(commentOptionId).click();\n                        }\n                    });\n                });\n\n                // Destroy the dialog when it is hidden to allow the grading section to\n                // be loaded as a fragment multiple times within the same page.\n                chooserDialog.after('visibleChange', function(e) {\n                    // Going from visible to hidden.\n                    if (e.prevVal && !e.newVal) {\n                        this.destroy();\n                    }\n                }, chooserDialog);\n\n                // Show dialog.\n                chooserDialog.show();\n            }\n\n            /**\n             * Generates the comments chooser dialog from the grading_form/comment_chooser mustache template.\n             */\n            function generateCommentsChooser() {\n                // Template context.\n                var context = {\n                    criterionId: criterionId,\n                    comments: commentOptions\n                };\n\n                // Render the template and display the comment chooser dialog.\n                templates.render('gradingform_guide/comment_chooser', context)\n                    .done(function(compiledSource) {\n                        displayChooserDialog(compiledSource, commentOptions);\n                    })\n                    .fail(notification.exception);\n            }\n\n            // Bind click event for the comments chooser button.\n            $(\"#\" + buttonId).click(function(e) {\n                e.preventDefault();\n                generateCommentsChooser();\n            });\n        }\n    };\n});\n"],"file":"comment_chooser.min.js"}