Proyectos de Subversion Moodle

Rev

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

{"version":3,"file":"move.min.js","sources":["../src/move.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\ndefine(['jquery', 'core/sortable_list', 'core/ajax', 'core/notification'], function($, SortableList, Ajax, Notification) {\n    return {\n        init: function(tableid, moveaction) {\n            // Initialise sortable for the given list.\n            var sort = new SortableList('#' + tableid + ' tbody');\n            sort.getElementName = function(element) {\n                return $.Deferred().resolve(element.attr('data-name'));\n            };\n            var origIndex;\n            $('#' + tableid + ' tbody tr').on(SortableList.EVENTS.DRAGSTART, function(_, info) {\n                // Remember position of the element in the beginning of dragging.\n                origIndex = info.sourceList.children().index(info.element);\n                // Resize the \"proxy\" element to be the same width as the main element.\n                setTimeout(function() {\n                    $('.sortable-list-is-dragged').width(info.element.width());\n                }, 501);\n            }).on(SortableList.EVENTS.DROP, function(_, info) {\n                // When a list element was moved send AJAX request to the server.\n                var newIndex = info.targetList.children().index(info.element);\n                var t = info.element.find('[data-action=' + moveaction + ']');\n                if (info.positionChanged && t.length) {\n                    var request = {\n                        methodname: 'tool_xmldb_invoke_move_action',\n                        args: {\n                            action: moveaction,\n                            dir: t.attr('data-dir'),\n                            table: t.attr('data-table'),\n                            field: t.attr('data-field'),\n                            key: t.attr('data-key'),\n                            index: t.attr('data-index'),\n                            position: newIndex - origIndex\n                        }\n                    };\n                    Ajax.call([request])[0].fail(Notification.exception);\n                }\n            });\n        }\n    };\n});\n"],"names":["define","$","SortableList","Ajax","Notification","init","tableid","moveaction","origIndex","getElementName","element","Deferred","resolve","attr","on","EVENTS","DRAGSTART","_","info","sourceList","children","index","setTimeout","width","DROP","newIndex","targetList","t","find","positionChanged","length","request","methodname","args","action","dir","table","field","key","position","call","fail","exception"],"mappings":"AAeAA,yBAAO,CAAC,SAAU,qBAAsB,YAAa,sBAAsB,SAASC,EAAGC,aAAcC,KAAMC,oBAChG,CACHC,KAAM,SAASC,QAASC,gBAMhBC,UAJO,IAAIN,aAAa,IAAMI,QAAU,UACvCG,eAAiB,SAASC,gBACpBT,EAAEU,WAAWC,QAAQF,QAAQG,KAAK,eAG7CZ,EAAE,IAAMK,QAAU,aAAaQ,GAAGZ,aAAaa,OAAOC,WAAW,SAASC,EAAGC,MAEzEV,UAAYU,KAAKC,WAAWC,WAAWC,MAAMH,KAAKR,SAElDY,YAAW,WACPrB,EAAE,6BAA6BsB,MAAML,KAAKR,QAAQa,WACnD,QACJT,GAAGZ,aAAaa,OAAOS,MAAM,SAASP,EAAGC,UAEpCO,SAAWP,KAAKQ,WAAWN,WAAWC,MAAMH,KAAKR,SACjDiB,EAAIT,KAAKR,QAAQkB,KAAK,gBAAkBrB,WAAa,QACrDW,KAAKW,iBAAmBF,EAAEG,OAAQ,KAC9BC,QAAU,CACVC,WAAY,gCACZC,KAAM,CACFC,OAAQ3B,WACR4B,IAAKR,EAAEd,KAAK,YACZuB,MAAOT,EAAEd,KAAK,cACdwB,MAAOV,EAAEd,KAAK,cACdyB,IAAKX,EAAEd,KAAK,YACZQ,MAAOM,EAAEd,KAAK,cACd0B,SAAUd,SAAWjB,YAG7BL,KAAKqC,KAAK,CAACT,UAAU,GAAGU,KAAKrC,aAAasC"}