Your IP : 192.168.165.1


Current Path : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/
Upload File :
Current File : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/competencytree.min.js.map

{"version":3,"sources":["../src/competencytree.js"],"names":["define","ajax","notification","templates","Ariatree","CompOutcomes","$","competencies","competencyFrameworkId","competencyFrameworkShortName","treeSelector","currentNodeId","competencyFramworkCanManage","addChildren","parent","all","i","current","haschildren","children","length","parentid","id","push","loadCompetencies","searchtext","deferred","Deferred","render","done","loadinghtml","loadingjs","replaceNodeContents","promises","call","methodname","args","competencyframeworkid","result","competency","parseInt","context","shortname","canmanage","html","js","tree","node","find","selectItem","updateFocus","resolve","fail","reject","promise","rememberCurrent","evt","params","selected","attr","init","search","selector","competencyid","exception","on","eventname","handler","getChildren","each","index","getCompetencyFrameworkId","getCompetency","getCompetencyLevel","level","path","replace","split","hasChildren","hasRule","comp","ruleoutcome","OUTCOME_NONE","ruletype","reloadCompetencies","listCompetencies"],"mappings":"AAuBAA,OAAM,0BAAC,CAAC,WAAD,CAAc,mBAAd,CAAmC,gBAAnC,CAAqD,cAArD,CAAqE,6BAArE,CAAoG,QAApG,CAAD,CACC,SAASC,CAAT,CAAeC,CAAf,CAA6BC,CAA7B,CAAwCC,CAAxC,CAAkDC,CAAlD,CAAgEC,CAAhE,CAAmE,IAIlEC,CAAAA,CAAY,CAAG,EAJmD,CAOlEC,CAAqB,CAAG,CAP0C,CAUlEC,CAA4B,CAAG,EAVmC,CAalEC,CAAY,CAAG,EAbmD,CAgBlEC,CAAa,CAAG,EAhBkD,CAmBlEC,CAA2B,GAnBuC,CA0BlEC,CAAW,CAAG,SAASC,CAAT,CAAiBC,CAAjB,CAAsB,IAChCC,CAAAA,CAAC,CAAG,CAD4B,CAEhCC,CAAO,GAFyB,CAGpCH,CAAM,CAACI,WAAP,IACAJ,CAAM,CAACK,QAAP,CAAkB,EAAlB,CACA,IAAKH,CAAC,CAAG,CAAT,CAAYA,CAAC,CAAGD,CAA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E/CgE,aAAa,CAAE,uBAASlD,CAAT,CAAa,CACxB,MAAOf,CAAAA,CAAY,CAACe,CAAD,CACtB,CAzE8C,CAiF/CmD,kBAAkB,CAAE,4BAASnD,CAAT,CAAa,CAC7B,GAAIiB,CAAAA,CAAU,CAAG,KAAKiC,aAAL,CAAmBlD,CAAnB,CAAjB,CACIoD,CAAK,CAAGnC,CAAU,CAACoC,IAAX,CAAgBC,OAAhB,CAAwB,UAAxB,CAAoC,EAApC,EAAwCC,KAAxC,CAA8C,GAA9C,EAAmDzD,MAD/D,CAEA,MAAOsD,CAAAA,CACV,CArF8C,CA8F/CI,WAAW,CAAE,qBAASxD,CAAT,CAAa,CACtB,MAAqC,EAA9B,MAAK8C,WAAL,CAAiB9C,CAAjB,EAAqBF,MAC/B,CAhG8C,CAwG/C2D,OAAO,CAAE,iBAASzD,CAAT,CAAa,CAClB,GAAI0D,CAAAA,CAAI,CAAG,KAAKR,aAAL,CAAmBlD,CAAnB,CAAX,CACA,GAAI0D,CAAJ,CAAU,CACN,MAAOA,CAAAA,CAAI,CAACC,WAAL,EAAoB5E,CAAY,CAAC6E,YAAjC,EACAF,CAAI,CAACG,QACf,CACD,QACH,CA/G8C,CAsH/CC,kBAAkB,CAAE,6BAAW,CAC3B,MAAO5D,CAAAA,CAAgB,CAAC,EAAD,CAAhB,CAAqB4B,IAArB,CAA0BlD,CAAY,CAAC8D,SAAvC,CACV,CAxH8C,CA+H/CqB,gBAAgB,CAAE,2BAAW,CACzB,MAAO9E,CAAAA,CACV,CAjI8C,CAoIrD,CAlPI,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 * Handle selection changes on the competency tree.\n *\n * @module     tool_lp/competencyselect\n * @package    tool_lp\n * @copyright  2015 Damyon Wiese <damyon@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/ajax', 'core/notification', 'core/templates', 'tool_lp/tree', 'tool_lp/competency_outcomes', 'jquery'],\n       function(ajax, notification, templates, Ariatree, CompOutcomes, $) {\n\n    // Private variables and functions.\n    /** @var {Object[]} competencies - Cached list of competencies */\n    var competencies = {};\n\n    /** @var {Number} competencyFrameworkId - The current framework id */\n    var competencyFrameworkId = 0;\n\n    /** @var {String} competencyFrameworkShortName - The current framework short name */\n    var competencyFrameworkShortName = '';\n\n    /** @var {String} treeSelector - The selector for the root of the tree. */\n    var treeSelector = '';\n\n    /** @var {String} currentNodeId - The data-id of the current node in the tree. */\n    var currentNodeId = '';\n\n     /** @var {Boolean} competencyFramworkCanManage - Can manage the competencies framework */\n    var competencyFramworkCanManage = false;\n\n    /**\n     * Build a tree from the flat list of competencies.\n     * @param {Object} parent The parent competency.\n     * @param {Array} all The list of all competencies.\n     */\n    var addChildren = function(parent, all) {\n        var i = 0;\n        var current = false;\n        parent.haschildren = false;\n        parent.children = [];\n        for (i = 0; i < all.length; i++) {\n            current = all[i];\n            if (current.parentid == parent.id) {\n                parent.haschildren = true;\n                parent.children.push(current);\n                addChildren(current, all);\n            }\n        }\n    };\n\n    /**\n     * Load the list of competencies via ajax. Competencies are filtered by the searchtext.\n     * @param {String} searchtext The text to filter on.\n     * @return {promise}\n     */\n    var loadCompetencies = function(searchtext) {\n        var deferred = $.Deferred();\n\n        templates.render('tool_lp/loading', {}).done(function(loadinghtml, loadingjs) {\n            templates.replaceNodeContents($(treeSelector), loadinghtml, loadingjs);\n\n            var promises = ajax.call([{\n                methodname: 'core_competency_search_competencies',\n                args: {\n                    searchtext: searchtext,\n                    competencyframeworkid: competencyFrameworkId\n                }\n            }]);\n            promises[0].done(function(result) {\n                competencies = {};\n                var i = 0;\n                for (i = 0; i < result.length; i++) {\n                    competencies[result[i].id] = result[i];\n                }\n\n                var children = [];\n                var competency = false;\n                for (i = 0; i < result.length; i++) {\n                    competency = result[i];\n                    if (parseInt(competency.parentid, 10) === 0) {\n                        children.push(competency);\n                        addChildren(competency, result);\n                    }\n                }\n                var context = {\n                    shortname: competencyFrameworkShortName,\n                    canmanage: competencyFramworkCanManage,\n                    competencies: children\n                };\n                templates.render('tool_lp/competencies_tree_root', context).done(function(html, js) {\n                    templates.replaceNodeContents($(treeSelector), $(html).html(), js);\n                    var tree = new Ariatree(treeSelector, false);\n\n                    if (currentNodeId) {\n                        var node = $(treeSelector).find('[data-id=' + currentNodeId + ']');\n                        if (node.length) {\n                            tree.selectItem(node);\n                            tree.updateFocus(node);\n                        }\n                    }\n                    deferred.resolve(competencies);\n                }).fail(deferred.reject);\n            }).fail(deferred.reject);\n        });\n\n        return deferred.promise();\n    };\n\n    /**\n     * Whenever the current item in the tree is changed - remember the \"id\".\n     * @param {Event} evt\n     * @param {Object} params The parameters for the event (This is the selected node).\n     */\n    var rememberCurrent = function(evt, params) {\n        var node = params.selected;\n        currentNodeId = node.attr('data-id');\n    };\n\n    return /** @alias module:tool_lp/competencytree */ {\n        // Public variables and functions.\n        /**\n         * Initialise the tree.\n         *\n         * @param {Number} id The competency framework id.\n         * @param {String} shortname The framework shortname\n         * @param {String} search The current search string\n         * @param {String} selector The selector for the tree div\n         * @param {Boolean} canmanage Can manage the competencies\n         * @param {Number} competencyid The id of the competency to show first\n         */\n        init: function(id, shortname, search, selector, canmanage, competencyid) {\n            competencyFrameworkId = id;\n            competencyFrameworkShortName = shortname;\n            competencyFramworkCanManage = canmanage;\n            treeSelector = selector;\n            loadCompetencies(search).fail(notification.exception);\n            if (competencyid > 0) {\n                currentNodeId = competencyid;\n            }\n\n            this.on('selectionchanged', rememberCurrent);\n         },\n\n        /**\n         * Add an event handler for custom events emitted by the tree.\n         *\n         * @param {String} eventname The name of the event - only \"selectionchanged\" for now\n         * @param {Function} handler The handler for the event.\n         */\n        on: function(eventname, handler) {\n            // We can't use the tree on function directly\n            // because the tree gets rebuilt whenever the search string changes,\n            // instead we attach the listner to the root node of the tree which never\n            // gets destroyed (same as \"on()\" code in the tree.js).\n            $(treeSelector).on(eventname, handler);\n        },\n\n        /**\n         * Get the children of a competency.\n         *\n         * @param  {Number} id The competency ID.\n         * @return {Array}\n         * @method getChildren\n         */\n        getChildren: function(id) {\n            var children = [];\n            $.each(competencies, function(index, competency) {\n                if (competency.parentid == id) {\n                    children.push(competency);\n                }\n            });\n            return children;\n        },\n\n        /**\n         * Get the competency framework id this model was initiliased with.\n         *\n         * @return {Number}\n         */\n        getCompetencyFrameworkId: function() {\n            return competencyFrameworkId;\n        },\n\n        /**\n         * Get a competency by id\n         *\n         * @param {Number} id The competency id\n         * @return {Object}\n         */\n        getCompetency: function(id) {\n            return competencies[id];\n        },\n\n        /**\n         * Get the competency level.\n         *\n         * @param  {Number} id The competency ID.\n         * @return {Number}\n         */\n        getCompetencyLevel: function(id) {\n            var competency = this.getCompetency(id),\n                level = competency.path.replace(/^\\/|\\/$/g, '').split('/').length;\n            return level;\n        },\n\n        /**\n         * Whether a competency has children.\n         *\n         * @param  {Number} id The competency ID.\n         * @return {Boolean}\n         * @method hasChildren\n         */\n        hasChildren: function(id) {\n            return this.getChildren(id).length > 0;\n        },\n\n        /**\n         * Does the competency have a rule?\n         *\n         * @param  {Number}  id The competency ID.\n         * @return {Boolean}\n         */\n        hasRule: function(id) {\n            var comp = this.getCompetency(id);\n            if (comp) {\n                return comp.ruleoutcome != CompOutcomes.OUTCOME_NONE\n                    && comp.ruletype;\n            }\n            return false;\n        },\n\n        /**\n         * Reload all the page competencies framework competencies.\n         * @method reloadCompetencies\n         * @return {Promise}\n         */\n        reloadCompetencies: function() {\n            return loadCompetencies('').fail(notification.exception);\n        },\n\n        /**\n         * Get all competencies for this framework.\n         *\n         * @return {Object[]}\n         */\n        listCompetencies: function() {\n            return competencies;\n        },\n\n     };\n });\n"],"file":"competencytree.min.js"}