Commit e6bf10c7 authored by Damyon Wiese's avatar Damyon Wiese
Browse files

MDL-40759 dragdrop: Use a pix icon renderer for drag handles.

parent d3d2f09c
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -26,8 +26,6 @@ Y.extend(DRAGREORDER, M.core.dragdrop, {
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;
......@@ -47,7 +45,8 @@ Y.extend(DRAGREORDER, M.core.dragdrop, {
.all('.' + args.dragHandleInsertClass)
.each(
function(node) {
node.insert(this.draghandle.cloneNode(true));
var draghandle = this.get_drag_handle(args.dragHandleText, CSS.EDITINGMOVE, CSS.ICONCLASS, true);
node.insert(draghandle);
}, this);
},
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -14,8 +14,6 @@ Y.extend(DRAGRESOURCE, M.core.dragdrop, {
this.groups = ['resource'];
this.samenodeclass = CSS.ACTIVITY;
this.parentnodeclass = CSS.SECTION;
this.resourcedraghandle = this.get_drag_handle(M.util.get_string('movecoursemodule', 'moodle'),
CSS.EDITINGMOVE, CSS.ICONCLASS, true);
this.samenodelabel = {
identifier: 'afterresource',
......@@ -109,7 +107,8 @@ Y.extend(DRAGRESOURCE, M.core.dragdrop, {
var move = resourcesnode.one('a.' + CSS.EDITINGMOVE);
if (move) {
var sr = move.getData('sr');
move.replace(this.resourcedraghandle.cloneNode(true).setAttribute('data-sectionreturn', sr));
move.replace(this.get_drag_handle(M.util.get_string('movecoursemodule', 'moodle'),
CSS.EDITINGMOVE, CSS.ICONCLASS, true).setAttribute('data-sectionreturn', sr));
}
}, this);
},
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -98,13 +98,10 @@ BLOCKREGION.prototype = {
* @method change_block_move_icons
*/
change_block_move_icons: function(manager) {
var handle, icon;
var handle;
this.get('node').all('.' + CSS.BLOCK + ' a.' + CSS.EDITINGMOVE).each(function(moveicon) {
moveicon.setStyle('cursor', 'move');
handle = manager.get_drag_handle(moveicon.getAttribute('title'), '', 'icon', true);
icon = handle.one('img');
icon.addClass('iconsmall');
icon.removeClass('icon');
moveicon.replace(handle);
});
},
......
......@@ -142,6 +142,7 @@ Y.extend(DRAGDROP, Y.Base, {
// Make the accessible drag/drop respond to a single click.
this.listeners.push(Y.one(Y.config.doc.body).delegate('click', this.global_keydown,
'.' + MOVEICON.cssclass, this));
},
/**
......@@ -161,25 +162,10 @@ Y.extend(DRAGDROP, Y.Base, {
* @param {String} title The title on the drag handle
* @param {String} classname The name of the class to add to the node
* wrapping the drag icon
* @param {String} [iconclass] The class to add to the icon
* @param {Boolean} [large=false] whether to use the larger version of
* the drag icon
* @param {String} iconclass Additional class to add to the icon.
* @return Node The built drag handle.
*/
get_drag_handle: function(title, classname, iconclass, large) {
var iconname = MOVEICON.pix;
if (large) {
iconname = MOVEICON.largepix;
}
var dragicon = Y.Node.create('<img />')
.setStyle('cursor', 'move')
.setAttrs({
'src': M.util.image_url(iconname, MOVEICON.component),
'alt': title
});
if (iconclass) {
dragicon.addClass(iconclass);
}
get_drag_handle: function(title, classname, iconclass) {
var dragelement = Y.Node.create('<span></span>')
.addClass(classname)
......@@ -187,9 +173,17 @@ Y.extend(DRAGDROP, Y.Base, {
.setAttribute('tabIndex', 0)
.setAttribute('data-draggroups', this.groups)
.setAttribute('role', 'button');
dragelement.appendChild(dragicon);
dragelement.addClass(MOVEICON.cssclass);
window.require(['core/templates'], function(Templates) {
var dragicon = Y.Node.create(Templates.renderPix('i/move_2d', 'core'));
dragicon.addClass('moodle-core-dragdrop-draghandle').setStyle('cursor', 'move');
if (typeof iconclass != 'undefined') {
dragicon.addClass(iconclass);
}
dragelement.appendChild(dragicon);
}.bind(this));
return dragelement;
},
......
......@@ -22,13 +22,13 @@ YUI.add('moodle-mod_feedback-dragdrop', function(Y) {
var groups = ['feedbackitem'];
handletitle = M.util.get_string('move_item', 'feedback');
this.mydraghandle = this.get_drag_handle(handletitle, CSS.DRAGHANDLE, 'icon');
//Get the list of li's in the lists and add the drag handle.
basenode = Y.Node.one(CSS.DRAGLIST);
listitems = basenode.all(CSS.DRAGITEM).each(function(v) {
var item_id = this.get_node_id(v.get('id')); //Get the id of the feedback item.
v.append(this.mydraghandle.cloneNode(true)); // Insert the new handle into the item box.
var mydraghandle = this.get_drag_handle(handletitle, CSS.DRAGHANDLE, 'icon');
v.append(mydraghandle); // Insert the new handle into the item box.
}, this);
//We use a delegate to make all items draggable
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment