Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"version":3,"file":"dragdrop-reorder.min.js","sources":["../src/dragdrop-reorder.js"],"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 * Drag and drop reorder via HTML5.\n *\n * @module     tool_lp/dragdrop-reorder\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/str', 'core/yui'], function(str, Y) {\n    // Private variables and functions.\n\n    /**\n     * Store the current instance of the core drag drop.\n     *\n     * @property {object} dragDropInstance M.tool_lp.dragdrop_reorder\n     */\n    var dragDropInstance = null;\n\n    /**\n     * Translate the drophit event from YUI\n     * into simple drag and drop nodes.\n     * @param {Y.Event} e The yui drop event.\n     */\n    var proxyCallback = function(e) {\n        var dragNode = e.drag.get('node');\n        var dropNode = e.drop.get('node');\n        this.callback(dragNode.getDOMNode(), dropNode.getDOMNode());\n    };\n\n    return /** @alias module:tool_lp/dragdrop-reorder */ {\n        // Public variables and functions.\n        /**\n         * Create an instance of M.tool_lp.dragdrop\n         *\n         * @param {String} group Unique string to identify this interaction.\n         * @param {String} dragHandleText Alt text for the drag handle.\n         * @param {String} sameNodeText Used in keyboard drag drop for the list of items target.\n         * @param {String} parentNodeText Used in keyboard drag drop for the parent target.\n         * @param {String} sameNodeClass class used to find the each of the list of items.\n         * @param {String} parentNodeClass class used to find the container for the list of items.\n         * @param {String} dragHandleInsertClass class used to find the location to insert the drag handles.\n         * @param {function} callback Drop hit handler.\n         */\n        dragdrop: function(group,\n                           dragHandleText,\n                           sameNodeText,\n                           parentNodeText,\n                           sameNodeClass,\n                           parentNodeClass,\n                           dragHandleInsertClass,\n                           callback) {\n            // Here we are wrapping YUI. This allows us to start transitioning, but\n            // wait for a good alternative without having inconsistent UIs.\n            str.get_strings([\n                {key: 'emptydragdropregion', component: 'moodle'},\n                {key: 'movecontent', component: 'moodle'},\n                {key: 'tocontent', component: 'moodle'},\n            ]).done(function() {\n                Y.use('moodle-tool_lp-dragdrop-reorder', function() {\n\n                    var context = {\n                        callback: callback\n                    };\n                    if (dragDropInstance) {\n                        dragDropInstance.destroy();\n                    }\n                    dragDropInstance = M.tool_lp.dragdrop_reorder({\n                        group: group,\n                        dragHandleText: dragHandleText,\n                        sameNodeText: sameNodeText,\n                        parentNodeText: parentNodeText,\n                        sameNodeClass: sameNodeClass,\n                        parentNodeClass: parentNodeClass,\n                        dragHandleInsertClass: dragHandleInsertClass,\n                        callback: Y.bind(proxyCallback, context)\n                    });\n                });\n            });\n        }\n\n    };\n});\n"],"names":["define","str","Y","dragDropInstance","proxyCallback","e","dragNode","drag","get","dropNode","drop","callback","getDOMNode","dragdrop","group","dragHandleText","sameNodeText","parentNodeText","sameNodeClass","parentNodeClass","dragHandleInsertClass","get_strings","key","component","done","use","context","destroy","M","tool_lp","dragdrop_reorder","bind"],"mappings":";;;;;;;AAsBAA,kCAAO,CAAC,WAAY,aAAa,SAASC,IAAKC,OAQvCC,iBAAmB,KAOnBC,cAAgB,SAASC,OACrBC,SAAWD,EAAEE,KAAKC,IAAI,QACtBC,SAAWJ,EAAEK,KAAKF,IAAI,aACrBG,SAASL,SAASM,aAAcH,SAASG,qBAGG,CAcjDC,SAAU,SAASC,MACAC,eACAC,aACAC,eACAC,cACAC,gBACAC,sBACAT,UAGfV,IAAIoB,YAAY,CACZ,CAACC,IAAK,sBAAuBC,UAAW,UACxC,CAACD,IAAK,cAAeC,UAAW,UAChC,CAACD,IAAK,YAAaC,UAAW,YAC/BC,MAAK,WACJtB,EAAEuB,IAAI,mCAAmC,eAEjCC,QAAU,CACVf,SAAUA,UAEVR,kBACAA,iBAAiBwB,UAErBxB,iBAAmByB,EAAEC,QAAQC,iBAAiB,CAC1ChB,MAAOA,MACPC,eAAgBA,eAChBC,aAAcA,aACdC,eAAgBA,eAChBC,cAAeA,cACfC,gBAAiBA,gBACjBC,sBAAuBA,sBACvBT,SAAUT,EAAE6B,KAAK3B,cAAesB"}