Your IP : 216.73.216.95


Current Path : /var/www/ljmtc/cbt/customfield/amd/build/
Upload File :
Current File : /var/www/ljmtc/cbt/customfield/amd/build/form.min.js.map

{"version":3,"sources":["../src/form.js"],"names":["define","$","Str","Notification","Ajax","Templates","SortableList","confirmDelete","id","type","component","area","itemid","get_strings","done","s","confirm","func","call","methodname","args","then","response","render","html","js","replaceNode","fail","exception","createNewCategory","promises","categoryid","window","location","href","init","mainlist","attr","on","e","preventDefault","categoryName","element","closest","find","sortCat","moveHandlerSelector","getElementName","el","Deferred","resolve","evt","info","positionChanged","data","beforeid","targetNextElement","stopPropagation","sort","getDestinationName","parentElement","afterElement","length","get_string","targetList","children","each","fields","nofields","append","remove","setTimeout","width"],"mappings":"AAuBAA,OAAM,yBAAC,CAAC,QAAD,CAAW,UAAX,CAAuB,mBAAvB,CAA4C,WAA5C,CAAyD,gBAAzD,CAA2E,oBAA3E,CAAiG,uBAAjG,CAAD,CACF,SACIC,CADJ,CACOC,CADP,CACYC,CADZ,CAC0BC,CAD1B,CACgCC,CADhC,CAC2CC,CAD3C,CACyD,IAWrDC,CAAAA,CAAa,CAAG,SAASC,CAAT,CAAaC,CAAb,CAAmBC,CAAnB,CAA8BC,CAA9B,CAAoCC,CAApC,CAA4C,CAC5DV,CAAG,CAACW,WAAJ,CAAgB,CACZ,CAAC,IAAO,SAAR,CADY,CAEZ,CAAC,IAAO,gBAAkBJ,CAA1B,CAAgCC,SAAS,CAAE,kBAA3C,CAFY,CAGZ,CAAC,IAAO,KAAR,CAHY,CAIZ,CAAC,IAAO,IAAR,CAJY,CAAhB,EAKGI,IALH,CAKQ,SAASC,CAAT,CAAY,CAChBZ,CAAY,CAACa,OAAb,CAAqBD,CAAC,CAAC,CAAD,CAAtB,CAA2BA,CAAC,CAAC,CAAD,CAA5B,CAAiCA,CAAC,CAAC,CAAD,CAAlC,CAAuCA,CAAC,CAAC,CAAD,CAAxC,CAA6C,UAAW,CACpD,GAAIE,CAAAA,CAAI,CAAa,OAAT,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AAb,EAArC,CACH,CAFS,CAEP,GAFO,CAGb,CALL,CAQH,CAlHE,CAoHV,CAnLK,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 * This module depends on the real jquery - and returns the non-global version of it.\n *\n * @module     core_customfield/form\n * @package    core_customfield\n * @copyright  2018 Toni Barbera\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/str', 'core/notification', 'core/ajax', 'core/templates', 'core/sortable_list', 'core/inplace_editable'],\n    function(\n        $, Str, Notification, Ajax, Templates, SortableList) {\n\n    /**\n     * Display confirmation dialogue\n     *\n     * @param {Number} id\n     * @param {String} type\n     * @param {String} component\n     * @param {String} area\n     * @param {Number} itemid\n     */\n    var confirmDelete = function(id, type, component, area, itemid) {\n        Str.get_strings([\n            {'key': 'confirm'},\n            {'key': 'confirmdelete' + type, component: 'core_customfield'},\n            {'key': 'yes'},\n            {'key': 'no'},\n        ]).done(function(s) {\n            Notification.confirm(s[0], s[1], s[2], s[3], function() {\n                var func = (type === 'field') ? 'core_customfield_delete_field' : 'core_customfield_delete_category';\n                Ajax.call([\n                    {methodname: func, args: {id: id}},\n                    {methodname: 'core_customfield_reload_template', args: {component: component, area: area, itemid: itemid}}\n                ])[1].then(function(response) {\n                    return Templates.render('core_customfield/list', response);\n                }).then(function(html, js) {\n                    Templates.replaceNode($('[data-region=\"list-page\"]'), html, js);\n                    return null;\n                }).fail(Notification.exception);\n            });\n        }).fail(Notification.exception);\n    };\n\n    /**\n     * Creates a new custom fields category with default name and updates the list\n     *\n     * @param {String} component\n     * @param {String} area\n     * @param {Number} itemid\n     */\n    var createNewCategory = function(component, area, itemid) {\n        var promises = Ajax.call([\n                {methodname: 'core_customfield_create_category', args: {component: component, area: area, itemid: itemid}},\n                {methodname: 'core_customfield_reload_template', args: {component: component, area: area, itemid: itemid}}\n            ]),\n            categoryid;\n\n        promises[0].then(function(response) {\n            categoryid = response;\n            return null;\n        }).fail(Notification.exception);\n\n        promises[1].then(function(response) {\n            return Templates.render('core_customfield/list', response);\n        }).then(function(html, js) {\n            Templates.replaceNode($('[data-region=\"list-page\"]'), html, js);\n            window.location.href = '#category-' + categoryid;\n            return null;\n        }).fail(Notification.exception);\n    };\n\n    return {\n        /**\n         * Initialise the custom fields manager\n         */\n        init: function() {\n            var mainlist = $('#customfield_catlist'),\n                component = mainlist.attr('data-component'),\n                area = mainlist.attr('data-area'),\n                itemid = mainlist.attr('data-itemid');\n            $(\"[data-role=deletefield]\").on('click', function(e) {\n                confirmDelete($(this).attr('data-id'), 'field', component, area, itemid);\n                e.preventDefault();\n            });\n            $(\"[data-role=deletecategory]\").on('click', function(e) {\n                confirmDelete($(this).attr('data-id'), 'category', component, area, itemid);\n                e.preventDefault();\n            });\n            $('[data-role=addnewcategory]').on('click', function() {\n                createNewCategory(component, area, itemid);\n            });\n\n            var categoryName = function(element) {\n                return element\n                    .closest('[data-category-id]')\n                    .find('[data-inplaceeditable][data-itemtype=category][data-component=core_customfield]')\n                    .attr('data-value');\n            };\n\n            // Sort category.\n            var sortCat = new SortableList(\n                $('#customfield_catlist .categorieslist'),\n                {moveHandlerSelector: '.movecategory [data-drag-type=move]'}\n            );\n\n            sortCat.getElementName = function(el) {\n                return $.Deferred().resolve(categoryName(el));\n            };\n\n            $('[data-category-id]').on('sortablelist-drop', function(evt, info) {\n                if (info.positionChanged) {\n                    var promises = Ajax.call([\n                        {\n                            methodname: 'core_customfield_move_category',\n                            args: {\n                                id: info.element.data('category-id'),\n                                beforeid: info.targetNextElement.data('category-id')\n                            }\n\n                        },\n                    ]);\n                    promises[0].fail(Notification.exception);\n                }\n                evt.stopPropagation(); // Important for nested lists to prevent multiple targets.\n            });\n\n            // Sort fields.\n            var sort = new SortableList(\n                $('#customfield_catlist .fieldslist tbody'),\n                {moveHandlerSelector: '.movefield [data-drag-type=move]'}\n            );\n\n            sort.getDestinationName = function(parentElement, afterElement) {\n                if (!afterElement.length) {\n                    return Str.get_string('totopofcategory', 'customfield', categoryName(parentElement));\n                } else if (afterElement.attr('data-field-name')) {\n                    return Str.get_string('afterfield', 'customfield', afterElement.attr('data-field-name'));\n                } else {\n                    return $.Deferred().resolve('');\n                }\n            };\n\n            $('[data-field-name]').on('sortablelist-drop', function(evt, info) {\n                evt.stopPropagation(); // Important for nested lists to prevent multiple targets.\n                if (info.positionChanged) {\n                    var promises = Ajax.call([\n                        {\n                            methodname: 'core_customfield_move_field',\n                            args: {\n                                id: info.element.data('field-id'),\n                                beforeid: info.targetNextElement.data('field-id'),\n                                categoryid: Number(info.targetList.closest('[data-category-id]').attr('data-category-id'))\n                            },\n                        },\n                    ]);\n                    promises[0].fail(Notification.exception);\n                }\n            }).on('sortablelist-drag', function(evt) {\n                evt.stopPropagation(); // Important for nested lists to prevent multiple targets.\n                // Refreshing fields tables.\n                Str.get_string('therearenofields', 'core_customfield').then(function(s) {\n                    $('#customfield_catlist .categorieslist').children().each(function() {\n                        var fields = $(this).find($('.field')),\n                            nofields = $(this).find($('.nofields'));\n                        if (!fields.length && !nofields.length) {\n                            $(this).find('tbody').append(\n                                '<tr class=\"nofields\"><td colspan=\"5\">' + s + '</td></tr>'\n                            );\n                        }\n                        if (fields.length && nofields.length) {\n                            nofields.remove();\n                        }\n                    });\n                    return null;\n                }).fail(Notification.exception);\n            });\n\n            $('[data-category-id], [data-field-name]').on('sortablelist-dragstart',\n                function(evt, info) {\n                    setTimeout(function() {\n                        $('.sortable-list-is-dragged').width(info.element.width());\n                    }, 501);\n                }\n            );\n\n        }\n    };\n});\n"],"file":"form.min.js"}