mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
MDL-50308 tool_lp: Big javascript cleanup
This includes: * Move all JS modules from lib/amd to admin/tool/lp/amd * Add all jsdocs * fix all jshint warnings * Rewrite the actionmenu wrapper to a real amd module
This commit is contained in:
parent
d629323f72
commit
7e8d4dac9b
41 changed files with 1805 additions and 398 deletions
1
lib/amd/build/dragdrop-reorder.min.js
vendored
1
lib/amd/build/dragdrop-reorder.min.js
vendored
|
@ -1 +0,0 @@
|
|||
define(["core/str","core/yui"],function(a,b){var c=function(a){var b=a.drag.get("node"),c=a.drop.get("node");this.callback(b.getDOMNode(),c.getDOMNode())};return{dragdrop:function(d,e,f,g,h,i,j,k){a.get_strings([{key:"emptydragdropregion",component:"moodle"},{key:"movecontent",component:"moodle"},{key:"tocontent",component:"moodle"}]).done(function(){b.use("moodle-core-dragdrop-reorder",function(){var a={callback:k};M.core.dragdrop_reorder({group:d,dragHandleText:e,sameNodeText:f,parentNodeText:g,sameNodeClass:h,parentNodeClass:i,dragHandleInsertClass:j,callback:b.bind(c,a)})})})}}});
|
1
lib/amd/build/menu.min.js
vendored
1
lib/amd/build/menu.min.js
vendored
|
@ -1 +0,0 @@
|
|||
define(["jquery","core/templates","core/notification","core/yui"],function(a,b,c,d){var e=function(b){var c=a(b);c.find("li a").each(function(b,c){a(c).addClass("menu-action"),a(c).attr("role","menuitem")}),a(this).replaceWith(c),d.use("moodle-core-actionmenu",function(){if(null===M.core.actionmenu.instance)M.core.actionmenu.init();else{var a=d.one(c.get(0));M.core.actionmenu.newDOMNode(a.ancestor())}})};return{menu:function(d,f){a(f).each(function(f,g){var h=[];a(g).find("li").each(function(b,c){h.push(a(c).html().trim())});var i={triggerMessage:d,links:h},j=a.proxy(e,g);b.render("core/menu",i).done(j).fail(c.exception)})}}});
|
|
@ -1,76 +0,0 @@
|
|||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Wrapper for the YUI M.core.notification class. Allows us to
|
||||
* use the YUI version in AMD code until it is replaced.
|
||||
*
|
||||
* @module core/dialogue
|
||||
* @package core
|
||||
* @copyright 2015 Damyon Wiese <damyon@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['core/yui'], function(Y) {
|
||||
|
||||
// Private variables and functions.
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param {string} title Title for the window.
|
||||
* @param {string} content The content for the window.
|
||||
* @param {function} afterShow Callback executed after the window is opened.
|
||||
*/
|
||||
var dialogue = function(title, content, afterShow) {
|
||||
this.yuiDialogue = null;
|
||||
var parent = this;
|
||||
|
||||
Y.use('moodle-core-notification', function () {
|
||||
|
||||
parent.yuiDialogue = new M.core.dialogue({
|
||||
headerContent: title,
|
||||
bodyContent: content,
|
||||
draggable: true,
|
||||
visible: false,
|
||||
center: true,
|
||||
modal: true
|
||||
});
|
||||
|
||||
parent.yuiDialogue.after('visibleChange', function(e) {
|
||||
if (e.newVal) {
|
||||
afterShow(parent);
|
||||
}
|
||||
});
|
||||
|
||||
parent.yuiDialogue.show();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Close this window.
|
||||
*/
|
||||
dialogue.prototype.close = function() {
|
||||
this.yuiDialogue.hide();
|
||||
this.yuiDialogue.destroy();
|
||||
};
|
||||
|
||||
/**
|
||||
* Get content.
|
||||
*/
|
||||
dialogue.prototype.getContent = function() {
|
||||
return this.yuiDialogue.bodyNode.getDOMNode();
|
||||
};
|
||||
|
||||
return /** @alias module:core/dialogue */ dialogue;
|
||||
});
|
|
@ -1,89 +0,0 @@
|
|||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Wrapper for the YUI M.core.dragdrop class. Allows us to
|
||||
* use the YUI version in AMD code until it is replaced.
|
||||
*
|
||||
* @module core/dragdrop-reorder
|
||||
* @package core
|
||||
* @copyright 2015 Damyon Wiese <damyon@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['core/str', 'core/yui'], function(str, Y) {
|
||||
|
||||
// Private variables and functions.
|
||||
|
||||
/**
|
||||
* Translate the drophit event from YUI
|
||||
* into simple drag and drop nodes.
|
||||
* @param {Y.Event} e The yui drop event.
|
||||
*/
|
||||
var proxyCallback = function(e) {
|
||||
var dragNode = e.drag.get('node');
|
||||
var dropNode = e.drop.get('node');
|
||||
this.callback(dragNode.getDOMNode(), dropNode.getDOMNode());
|
||||
};
|
||||
|
||||
return /** @alias module:core/dragdrop-reorder */ {
|
||||
// Public variables and functions.
|
||||
/**
|
||||
* Create an instance of M.core.dragdrop
|
||||
*
|
||||
* @param {string} group Unique string to identify this interaction.
|
||||
* @param {string} dragHandleText Alt text for the drag handle.
|
||||
* @param {string} sameNodeText Used in keyboard drag drop for the list of items target.
|
||||
* @param {string} parentNodeText Used in keyboard drag drop for the parent target.
|
||||
* @param {string} sameNodeClass class used to find the each of the list of items.
|
||||
* @param {string} parentNodeClass class used to find the container for the list of items.
|
||||
* @param {string} dragHandleInsertClass class used to find the location to insert the drag handles.
|
||||
* @param {function} callback Drop hit handler.
|
||||
*/
|
||||
dragdrop: function(group,
|
||||
dragHandleText,
|
||||
sameNodeText,
|
||||
parentNodeText,
|
||||
sameNodeClass,
|
||||
parentNodeClass,
|
||||
dragHandleInsertClass,
|
||||
callback) {
|
||||
// Here we are wrapping YUI. This allows us to start transitioning, but
|
||||
// wait for a good alternative without having inconsistent UIs.
|
||||
str.get_strings([
|
||||
{ key: 'emptydragdropregion', component: 'moodle' },
|
||||
{ key: 'movecontent', component: 'moodle' },
|
||||
{ key: 'tocontent', component: 'moodle' },
|
||||
]).done( function () {
|
||||
Y.use('moodle-core-dragdrop-reorder', function () {
|
||||
|
||||
var context = {
|
||||
callback: callback
|
||||
};
|
||||
M.core.dragdrop_reorder({
|
||||
group: group,
|
||||
dragHandleText: dragHandleText,
|
||||
sameNodeText: sameNodeText,
|
||||
parentNodeText: parentNodeText,
|
||||
sameNodeClass: sameNodeClass,
|
||||
parentNodeClass: parentNodeClass,
|
||||
dragHandleInsertClass: dragHandleInsertClass,
|
||||
callback: Y.bind(proxyCallback, context)
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
});
|
|
@ -1,82 +0,0 @@
|
|||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Wrapper for the YUI M.core.actionmenu class. Allows us to
|
||||
* use the YUI version in AMD code until it is replaced.
|
||||
*
|
||||
* @module core/menu
|
||||
* @package core
|
||||
* @copyright 2015 Damyon Wiese <damyon@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/templates', 'core/notification', 'core/yui'], function($, templates, notification, Y) {
|
||||
|
||||
// Private variables and functions.
|
||||
/**
|
||||
* Replace the menu node in the dom by this new HTML
|
||||
* rendered from a template and then call enhance on it.
|
||||
*
|
||||
* @param {string} newHTML
|
||||
*/
|
||||
var enhanceMenu = function(newHTML) {
|
||||
var newMenu = $(newHTML);
|
||||
// Insert some more aria attrs into the menu entries.
|
||||
newMenu.find('li a').each(function(index, element) {
|
||||
$(element).addClass('menu-action');
|
||||
$(element).attr('role', 'menuitem');
|
||||
});
|
||||
$(this).replaceWith(newMenu);
|
||||
|
||||
Y.use('moodle-core-actionmenu', function() {
|
||||
if (M.core.actionmenu.instance === null) {
|
||||
M.core.actionmenu.init();
|
||||
} else {
|
||||
var yuiNode = Y.one(newMenu.get(0));
|
||||
M.core.actionmenu.newDOMNode(yuiNode.ancestor());
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return /** @alias module:core/menu */ {
|
||||
// Public variables and functions.
|
||||
/**
|
||||
* Wrap M.core.actionmenu.
|
||||
* @param {string} triggerMessage Text for the button to open the menu.
|
||||
* @param {string} selector CSS selector for a list of links to turn into a menu (can match mulitple menus).
|
||||
*/
|
||||
menu: function(triggerMessage, selector) {
|
||||
// First we need to modify the list(s) to have markup compatible with actionmenu.
|
||||
|
||||
$(selector).each(function (index, element) {
|
||||
var links = [];
|
||||
$(element).find('li').each(function (index, link) {
|
||||
links.push($(link).html().trim());
|
||||
});
|
||||
var data = {
|
||||
triggerMessage: triggerMessage,
|
||||
links: links
|
||||
};
|
||||
|
||||
var enhanceCallback = $.proxy(enhanceMenu, element);
|
||||
|
||||
templates.render('core/menu', data)
|
||||
.done(enhanceCallback)
|
||||
.fail(notification.exception);
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
});
|
|
@ -70,7 +70,7 @@ define(['core/config'], function(config) {
|
|||
}
|
||||
|
||||
// Fix admin urls.
|
||||
if (typeof config.admin != "undefined" && config.admin !== 'admin') {
|
||||
if (config.admin !== 'admin') {
|
||||
relativePath = relativePath.replace(/^\/admin\//, '/' + config.admin + '/');
|
||||
}
|
||||
return config.wwwroot + relativePath;
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
Moodle actionmenu template. The purpose of this list is to take a plain
|
||||
HTML list of links and changing into specific DOM structure expected by
|
||||
moodle-actionmenu. It is unlikely you will want to customise this template
|
||||
because the actionmenu code is looking for specific classes, roles and data-attributes.
|
||||
|
||||
Classes required for JS:
|
||||
* moodle-actionmenu
|
||||
* menubar
|
||||
* toggle-display
|
||||
* textmenu
|
||||
* menu
|
||||
|
||||
Data attibutes required for JS:
|
||||
* data-enhance = moodle-core-actionmenu
|
||||
* data-rel = menu-content
|
||||
|
||||
Context variables required for this template:
|
||||
* uniqid - A uniq string that changes every time a template is renderer.
|
||||
* triggerMessage - A message to show in the link that opens the menu.
|
||||
* links - An array of things to show in the menu. Standard menus put a link with a pix_icon and a short bit of text.
|
||||
}}
|
||||
<div class="moodle-actionmenu" data-enhance="moodle-core-actionmenu">
|
||||
<ul class="menubar" role="menubar">
|
||||
<li role="presentation">
|
||||
<a id="{{uniqid}}-action-menu-toggle" class="toggle-display textmenu" role="menuitem" href="#" aria-haspopup="true">{{triggerMessage}}<b class="caret"></b></a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="menu" data-rel="menu-content" aria-labelledby="{{uniqid}}-action-menu-toggle" role="menu" aria-hidden="true">
|
||||
{{#links}}
|
||||
<li role="presentation">
|
||||
{{{.}}}
|
||||
</li>
|
||||
{{/links}}
|
||||
</ul>
|
||||
</div>
|
|
@ -1,72 +0,0 @@
|
|||
YUI.add('moodle-core-dragdrop-reorder', function (Y, NAME) {
|
||||
|
||||
/**
|
||||
* Simple drag and drop.
|
||||
*
|
||||
* Used when we just want a list of things that can be re-ordered by dragging.
|
||||
*
|
||||
* @class M.core.dragdrop_reorder
|
||||
* @constructor
|
||||
* @extends M.core.dragdrop
|
||||
*/
|
||||
var DRAGREORDER = function() {
|
||||
DRAGREORDER.superclass.constructor.apply(this, arguments);
|
||||
};
|
||||
|
||||
var CSS = {
|
||||
EDITINGMOVE: 'editing_move',
|
||||
ICONCLASS: 'iconsmall'
|
||||
};
|
||||
Y.extend(DRAGREORDER, M.core.dragdrop, {
|
||||
initializer: function(args) {
|
||||
if (Y.one('.' + args.parentNodeClass).all('.' + args.dragHandleInsertClass).size() <= 1) {
|
||||
// We can't re-order when there is only one item.
|
||||
return;
|
||||
}
|
||||
// Set group for parent class
|
||||
this.groups = [args.group];
|
||||
this.samenodeclass = args.sameNodeClass;
|
||||
this.parentnodeclass = args.parentNodeClass;
|
||||
this.draghandleinsertclass = args.dragHandleInsertClass;
|
||||
this.draghandle = this.get_drag_handle(args.dragHandleText,
|
||||
CSS.EDITINGMOVE, CSS.ICONCLASS, true);
|
||||
|
||||
this.samenodelabel = args.sameNodeLabel;
|
||||
this.parentnodelabel = args.parentNodeLabel;
|
||||
this.callback = args.callback;
|
||||
|
||||
var delegate = new Y.DD.Delegate({
|
||||
container: '.' + args.parentNodeClass,
|
||||
nodes: '.' + args.sameNodeClass,
|
||||
target: true,
|
||||
handles: ['.' + CSS.EDITINGMOVE],
|
||||
dragConfig: {groups: this.groups}
|
||||
});
|
||||
|
||||
delegate.dd.plug(Y.Plugin.DDProxy);
|
||||
|
||||
Y.one('.' + args.parentNodeClass)
|
||||
.all('.' + args.dragHandleInsertClass)
|
||||
.each(
|
||||
function (node) {
|
||||
node.insert(this.draghandle.cloneNode(true));
|
||||
} , this);
|
||||
},
|
||||
|
||||
drop_hit: function(e) {
|
||||
this.callback(e);
|
||||
}
|
||||
|
||||
}, {
|
||||
NAME: 'core-dragdrop-reorder',
|
||||
ATTRS: {
|
||||
}
|
||||
});
|
||||
|
||||
M.core = M.core || {};
|
||||
M.core.dragdrop_reorder = function(params) {
|
||||
new DRAGREORDER(params);
|
||||
};
|
||||
|
||||
|
||||
}, '@VERSION@', {"requires": ["moodle-core-dragdrop"]});
|
|
@ -1 +0,0 @@
|
|||
YUI.add("moodle-core-dragdrop-reorder",function(e,t){var n=function(){n.superclass.constructor.apply(this,arguments)},r={EDITINGMOVE:"editing_move",ICONCLASS:"iconsmall"};e.extend(n,M.core.dragdrop,{initializer:function(t){if(e.one("."+t.parentNodeClass).all("."+t.dragHandleInsertClass).size()<=1)return;this.groups=[t.group],this.samenodeclass=t.sameNodeClass,this.parentnodeclass=t.parentNodeClass,this.draghandleinsertclass=t.dragHandleInsertClass,this.draghandle=this.get_drag_handle(t.dragHandleText,r.EDITINGMOVE,r.ICONCLASS,!0),this.samenodelabel=t.sameNodeLabel,this.parentnodelabel=t.parentNodeLabel,this.callback=t.callback;var n=new e.DD.Delegate({container:"."+t.parentNodeClass,nodes:"."+t.sameNodeClass,target:!0,handles:["."+r.EDITINGMOVE],dragConfig:{groups:this.groups}});n.dd.plug(e.Plugin.DDProxy),e.one("."+t.parentNodeClass).all("."+t.dragHandleInsertClass).each(function(e){e.insert(this.draghandle.cloneNode(!0))},this)},drop_hit:function(e){this.callback(e)}},{NAME:"core-dragdrop-reorder",ATTRS:{}}),M.core=M.core||{},M.core.dragdrop_reorder=function(e){new n(e)}},"@VERSION@",{requires:["moodle-core-dragdrop"]});
|
|
@ -1,72 +0,0 @@
|
|||
YUI.add('moodle-core-dragdrop-reorder', function (Y, NAME) {
|
||||
|
||||
/**
|
||||
* Simple drag and drop.
|
||||
*
|
||||
* Used when we just want a list of things that can be re-ordered by dragging.
|
||||
*
|
||||
* @class M.core.dragdrop_reorder
|
||||
* @constructor
|
||||
* @extends M.core.dragdrop
|
||||
*/
|
||||
var DRAGREORDER = function() {
|
||||
DRAGREORDER.superclass.constructor.apply(this, arguments);
|
||||
};
|
||||
|
||||
var CSS = {
|
||||
EDITINGMOVE: 'editing_move',
|
||||
ICONCLASS: 'iconsmall'
|
||||
};
|
||||
Y.extend(DRAGREORDER, M.core.dragdrop, {
|
||||
initializer: function(args) {
|
||||
if (Y.one('.' + args.parentNodeClass).all('.' + args.dragHandleInsertClass).size() <= 1) {
|
||||
// We can't re-order when there is only one item.
|
||||
return;
|
||||
}
|
||||
// Set group for parent class
|
||||
this.groups = [args.group];
|
||||
this.samenodeclass = args.sameNodeClass;
|
||||
this.parentnodeclass = args.parentNodeClass;
|
||||
this.draghandleinsertclass = args.dragHandleInsertClass;
|
||||
this.draghandle = this.get_drag_handle(args.dragHandleText,
|
||||
CSS.EDITINGMOVE, CSS.ICONCLASS, true);
|
||||
|
||||
this.samenodelabel = args.sameNodeLabel;
|
||||
this.parentnodelabel = args.parentNodeLabel;
|
||||
this.callback = args.callback;
|
||||
|
||||
var delegate = new Y.DD.Delegate({
|
||||
container: '.' + args.parentNodeClass,
|
||||
nodes: '.' + args.sameNodeClass,
|
||||
target: true,
|
||||
handles: ['.' + CSS.EDITINGMOVE],
|
||||
dragConfig: {groups: this.groups}
|
||||
});
|
||||
|
||||
delegate.dd.plug(Y.Plugin.DDProxy);
|
||||
|
||||
Y.one('.' + args.parentNodeClass)
|
||||
.all('.' + args.dragHandleInsertClass)
|
||||
.each(
|
||||
function (node) {
|
||||
node.insert(this.draghandle.cloneNode(true));
|
||||
} , this);
|
||||
},
|
||||
|
||||
drop_hit: function(e) {
|
||||
this.callback(e);
|
||||
}
|
||||
|
||||
}, {
|
||||
NAME: 'core-dragdrop-reorder',
|
||||
ATTRS: {
|
||||
}
|
||||
});
|
||||
|
||||
M.core = M.core || {};
|
||||
M.core.dragdrop_reorder = function(params) {
|
||||
new DRAGREORDER(params);
|
||||
};
|
||||
|
||||
|
||||
}, '@VERSION@', {"requires": ["moodle-core-dragdrop"]});
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"name": "moodle-core-dragdrop-reorder",
|
||||
"builds": {
|
||||
"moodle-core-dragdrop-reorder": {
|
||||
"jsfiles": [
|
||||
"dragdropreorder.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/**
|
||||
* Simple drag and drop.
|
||||
*
|
||||
* Used when we just want a list of things that can be re-ordered by dragging.
|
||||
*
|
||||
* @class M.core.dragdrop_reorder
|
||||
* @constructor
|
||||
* @extends M.core.dragdrop
|
||||
*/
|
||||
var DRAGREORDER = function() {
|
||||
DRAGREORDER.superclass.constructor.apply(this, arguments);
|
||||
};
|
||||
|
||||
var CSS = {
|
||||
EDITINGMOVE: 'editing_move',
|
||||
ICONCLASS: 'iconsmall'
|
||||
};
|
||||
Y.extend(DRAGREORDER, M.core.dragdrop, {
|
||||
initializer: function(args) {
|
||||
if (Y.one('.' + args.parentNodeClass).all('.' + args.dragHandleInsertClass).size() <= 1) {
|
||||
// We can't re-order when there is only one item.
|
||||
return;
|
||||
}
|
||||
// Set group for parent class
|
||||
this.groups = [args.group];
|
||||
this.samenodeclass = args.sameNodeClass;
|
||||
this.parentnodeclass = args.parentNodeClass;
|
||||
this.draghandleinsertclass = args.dragHandleInsertClass;
|
||||
this.draghandle = this.get_drag_handle(args.dragHandleText,
|
||||
CSS.EDITINGMOVE, CSS.ICONCLASS, true);
|
||||
|
||||
this.samenodelabel = args.sameNodeLabel;
|
||||
this.parentnodelabel = args.parentNodeLabel;
|
||||
this.callback = args.callback;
|
||||
|
||||
var delegate = new Y.DD.Delegate({
|
||||
container: '.' + args.parentNodeClass,
|
||||
nodes: '.' + args.sameNodeClass,
|
||||
target: true,
|
||||
handles: ['.' + CSS.EDITINGMOVE],
|
||||
dragConfig: {groups: this.groups}
|
||||
});
|
||||
|
||||
delegate.dd.plug(Y.Plugin.DDProxy);
|
||||
|
||||
Y.one('.' + args.parentNodeClass)
|
||||
.all('.' + args.dragHandleInsertClass)
|
||||
.each(
|
||||
function (node) {
|
||||
node.insert(this.draghandle.cloneNode(true));
|
||||
} , this);
|
||||
},
|
||||
|
||||
drop_hit: function(e) {
|
||||
this.callback(e);
|
||||
}
|
||||
|
||||
}, {
|
||||
NAME: 'core-dragdrop-reorder',
|
||||
ATTRS: {
|
||||
}
|
||||
});
|
||||
|
||||
M.core = M.core || {};
|
||||
M.core.dragdrop_reorder = function(params) {
|
||||
new DRAGREORDER(params);
|
||||
};
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"moodle-core-dragdrop-reorder": {
|
||||
"requires": [
|
||||
"moodle-core-dragdrop"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue