From e6bf10c772185d088c46124cc306434663e6fc8d Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Tue, 20 Dec 2016 15:19:14 +0800 Subject: [PATCH] MDL-40759 dragdrop: Use a pix icon renderer for drag handles. --- .../moodle-tool_lp-dragdrop-reorder-debug.js | 5 ++-- .../moodle-tool_lp-dragdrop-reorder-min.js | 2 +- .../moodle-tool_lp-dragdrop-reorder.js | 5 ++-- .../dragdrop-reorder/js/dragdropreorder.js | 5 ++-- .../moodle-course-dragdrop-debug.js | 5 ++-- .../moodle-course-dragdrop-min.js | 4 +-- .../moodle-course-dragdrop.js | 5 ++-- course/yui/src/dragdrop/js/resource.js | 5 ++-- .../moodle-core-blocks-debug.js | 5 +--- .../moodle-core-blocks-min.js | 2 +- .../moodle-core-blocks/moodle-core-blocks.js | 5 +--- .../moodle-core-dragdrop-debug.js | 30 ++++++++----------- .../moodle-core-dragdrop-min.js | 4 +-- .../moodle-core-dragdrop.js | 30 ++++++++----------- lib/yui/src/blocks/js/blockregion.js | 5 +--- lib/yui/src/dragdrop/js/dragdrop.js | 30 ++++++++----------- mod/feedback/yui/dragdrop/dragdrop.js | 4 +-- .../moodle-mod_quiz-dragdrop-debug.js | 5 ++-- .../moodle-mod_quiz-dragdrop-min.js | 4 +-- .../moodle-mod_quiz-dragdrop.js | 5 ++-- mod/quiz/yui/src/dragdrop/js/resource.js | 5 ++-- 21 files changed, 70 insertions(+), 100 deletions(-) diff --git a/admin/tool/lp/yui/build/moodle-tool_lp-dragdrop-reorder/moodle-tool_lp-dragdrop-reorder-debug.js b/admin/tool/lp/yui/build/moodle-tool_lp-dragdrop-reorder/moodle-tool_lp-dragdrop-reorder-debug.js index 240dc6dd7aa..8e01d1add83 100644 --- a/admin/tool/lp/yui/build/moodle-tool_lp-dragdrop-reorder/moodle-tool_lp-dragdrop-reorder-debug.js +++ b/admin/tool/lp/yui/build/moodle-tool_lp-dragdrop-reorder/moodle-tool_lp-dragdrop-reorder-debug.js @@ -28,8 +28,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; @@ -49,7 +47,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); }, diff --git a/admin/tool/lp/yui/build/moodle-tool_lp-dragdrop-reorder/moodle-tool_lp-dragdrop-reorder-min.js b/admin/tool/lp/yui/build/moodle-tool_lp-dragdrop-reorder/moodle-tool_lp-dragdrop-reorder-min.js index 47c197ccb7c..25b8682ffc7 100644 --- a/admin/tool/lp/yui/build/moodle-tool_lp-dragdrop-reorder/moodle-tool_lp-dragdrop-reorder-min.js +++ b/admin/tool/lp/yui/build/moodle-tool_lp-dragdrop-reorder/moodle-tool_lp-dragdrop-reorder-min.js @@ -1 +1 @@ -YUI.add("moodle-tool_lp-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:"tool_lp-dragdrop-reorder",ATTRS:{}}),M.tool_lp=M.tool_lp||{},M.tool_lp.dragdrop_reorder=function(e){return new n(e)}},"@VERSION@",{requires:["moodle-core-dragdrop"]}); +YUI.add("moodle-tool_lp-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.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){var n=this.get_drag_handle(t.dragHandleText,r.EDITINGMOVE,r.ICONCLASS,!0);e.insert(n)},this)},drop_hit:function(e){this.callback(e)}},{NAME:"tool_lp-dragdrop-reorder",ATTRS:{}}),M.tool_lp=M.tool_lp||{},M.tool_lp.dragdrop_reorder=function(e){return new n(e)}},"@VERSION@",{requires:["moodle-core-dragdrop"]}); diff --git a/admin/tool/lp/yui/build/moodle-tool_lp-dragdrop-reorder/moodle-tool_lp-dragdrop-reorder.js b/admin/tool/lp/yui/build/moodle-tool_lp-dragdrop-reorder/moodle-tool_lp-dragdrop-reorder.js index 240dc6dd7aa..8e01d1add83 100644 --- a/admin/tool/lp/yui/build/moodle-tool_lp-dragdrop-reorder/moodle-tool_lp-dragdrop-reorder.js +++ b/admin/tool/lp/yui/build/moodle-tool_lp-dragdrop-reorder/moodle-tool_lp-dragdrop-reorder.js @@ -28,8 +28,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; @@ -49,7 +47,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); }, diff --git a/admin/tool/lp/yui/src/dragdrop-reorder/js/dragdropreorder.js b/admin/tool/lp/yui/src/dragdrop-reorder/js/dragdropreorder.js index c422595e9be..def1df2f3b2 100644 --- a/admin/tool/lp/yui/src/dragdrop-reorder/js/dragdropreorder.js +++ b/admin/tool/lp/yui/src/dragdrop-reorder/js/dragdropreorder.js @@ -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); }, diff --git a/course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop-debug.js b/course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop-debug.js index 8eed14d12cb..691b588a32c 100644 --- a/course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop-debug.js +++ b/course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop-debug.js @@ -329,8 +329,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', @@ -424,7 +422,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); }, diff --git a/course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop-min.js b/course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop-min.js index 1dc79224e08..c632074b6c9 100644 --- a/course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop-min.js +++ b/course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop-min.js @@ -1,2 +1,2 @@ -YUI.add("moodle-course-dragdrop",function(e,t){var n={ACTIONAREA:".actions",ACTIVITY:"activity",ACTIVITYINSTANCE:"activityinstance",CONTENT:"content",COURSECONTENT:"course-content",EDITINGMOVE:"editing_move",ICONCLASS:"iconsmall",JUMPMENU:"jumpmenu",LEFT:"left",LIGHTBOX:"lightbox",MOVEDOWN:"movedown",MOVEUP:"moveup",PAGECONTENT:"page-content",RIGHT:"right",SECTION:"section",SECTIONADDMENUS:"section_add_menus",SECTIONHANDLE:"section-handle",SUMMARY:"summary",SECTIONDRAGGABLE:"sectiondraggable"};M.course=M.course||{};var r=function(){r.superclass.constructor.apply(this,arguments)};e.extend(r,M.core.dragdrop,{sectionlistselector:null,initializer:function(){this.groups=[n.SECTIONDRAGGABLE],this.samenodeclass=M.course.format.get_sectionwrapperclass(),this.parentnodeclass=M.course.format.get_containerclass();if(e.Node.one("."+n.JUMPMENU))return!1;this.sectionlistselector=M.course.format.get_section_wrapper(e);if(this.sectionlistselector){this.sectionlistselector="."+n.COURSECONTENT+" "+this.sectionlistselector,this.setup_for_section(this.sectionlistselector);var t=new e.DD.Delegate({container:"."+n.COURSECONTENT,nodes:"."+n.SECTIONDRAGGABLE,target:!0,handles:["."+n.LEFT],dragConfig:{groups:this.groups}});t.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),t.dd.plug(e.Plugin.DDConstrained,{constrain:"#"+n.PAGECONTENT,stickY:!0}),t.dd.plug(e.Plugin.DDWinScroll)}},setup_for_section:function(t){e.Node.all(t).each(function(t){var r=e.Moodle.core_course.util.section.getId(t);if(r>0){var i=t.one("."+n.RIGHT+" a."+n.MOVEDOWN),s=t.one("."+n.RIGHT+" a."+n.MOVEUP),o=M.util.get_string("movesection","moodle",r),u=t.one("."+n.LEFT);if((i||s)&&u){u.setStyle("cursor","move"),u.appendChild(this.get_drag_handle(o,n.SECTIONHANDLE,"icon",!0)),s&&(s.previous("br")?s.previous("br").remove():s.next("br")&&s.next("br").remove(),s.ancestor(".section_action_menu")&&s.ancestor().get("nodeName").toLowerCase()=="li"?s.ancestor().remove():s.remove());if(i){i.previous("br")?i.previous("br").remove():i.next("br")&&i.next("br").remove();var a=i.ancestor().get("nodeName").toLowerCase();i.ancestor(".section_action_menu")&&a=="li"?i.ancestor().remove():i.remove()}t.addClass(n.SECTIONDRAGGABLE)}}},this)},drag_start:function(t){var r=t.target,i=e.Node.create("<"+M.course.format.get_containernode()+">");i.addClass(M.course.format.get_containerclass());var s=e.Node.create("<"+M.course.format.get_sectionwrappernode()+">");s.addClass(M.course.format.get_sectionwrapperclass()),s.setStyle("margin",0),s.setContent(r.get("node").get("innerHTML")),i.appendChild(s),r.get("dragNode").setContent(i),r.get("dragNode").addClass(n.COURSECONTENT)},drag_dropmiss:function(e){this.drop_hit(e)},get_section_index:function(t){var r="."+n.COURSECONTENT+" "+M.course.format.get_section_selector(e),i=e.all(r),s=i.indexOf(t),o=i.indexOf(e.one("#section-0"));return s-o},drop_hit:function(t){var r=t.drag,i=r.get("node"),s=e.Moodle.core_course.util.section.getId(i),o=s,u=this.get_section_index(i),a=u;if(s===u)return;o>a&&(o=u,a=s),r.get("dragNode").removeClass(n.COURSECONTENT);var f=e.Node.all(this.sectionlistselector),l=M.util.add_lightbox(e,i),c={},h=this.get("config").pageparams,p;for(p in h){if(!h.hasOwnProperty(p))continue;c[p]=h[p]}c.sesskey=M.cfg.sesskey,c.courseId=this.get("courseid"),c["class"]="section",c.field="move",c.id=s,c.value=u;var d=M.cfg.wwwroot+this.get("ajaxurl");e.io(d,{method:"POST",data:c,on:{start:function(){l.show()},success:function(t,n){try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r),M.course.format.process_sections(e,f,r,o,a)}catch(i){}var s,u=!1;do{u=!1;for(s=o;s<=a;s++)if(e.Moodle.core_course.util.section.getId(f.item(s-1))>e.Moodle.core_course.util.section.getId(f.item(s))){var c=f.item(s-1).get("id");f.item(s-1).set("id",f.item(s).get("id")),f.item(s).set("id",c),M.course.format.swap_sections(e,s-1,s),u=!0}a-=1}while(u);window.setTimeout(function(){l.hide()},250)},failure:function(e,t){this.ajax_failure(t),l.hide()}},context:this})}},{NAME:"course-dragdrop-section",ATTRS:{courseid:{value:null},ajaxurl:{value:0},config:{value:0}}}),M.course=M.course||{},M.course.init_section_dragdrop=function(e){new r(e)};var i=function(){i.superclass.constructor.apply(this,arguments)};e.extend(i,M.core.dragdrop,{initializer:function(){this.groups=["resource"],this.samenodeclass=n.ACTIVITY,this.parentnodeclass=n.SECTION,this.resourcedraghandle=this.get_drag_handle(M.util.get_string("movecoursemodule","moodle"),n.EDITINGMOVE,n.ICONCLASS,!0),this.samenodelabel={identifier:"afterresource",component:"moodle"},this.parentnodelabel={identifier:"totopofsection",component:"moodle"};var t=M.course.format.get_section_selector(e);if(t){t="."+n.COURSECONTENT+" "+t,this.setup_for_section(t);var r=t.slice(n.COURSECONTENT.length+2)+" li."+n.ACTIVITY,i=new e.DD.Delegate({container:"."+n.COURSECONTENT,nodes:r,target:!0,handles:["."+n.EDITINGMOVE],dragConfig:{groups:this.groups}});i.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1,cloneNode:!0}),i.dd.plug(e.Plugin.DDConstrained,{constrain:"#"+n.PAGECONTENT}),i.dd.plug(e.Plugin.DDWinScroll),M.course.coursebase.register_module(this),M.course.dragres=this}},setup_for_section:function(t){e.Node.all(t).each(function(t){var r=t.one("."+n.CONTENT+" ul."+n.SECTION);r||(r=e.Node.create(""),r.addClass(n.SECTION),t.one("."+n.CONTENT+" div."+n.SUMMARY).insert(r,"after")),r.setAttribute("data-draggroups",this.groups.join(" ")),new e.DD.Drop({node:r,groups:this.groups,padding:"20 0 20 0"}),this.setup_for_resource("#"+t.get("id")+" li."+n.ACTIVITY)},this)},setup_for_resource:function(t){e.Node.all(t).each(function(t){var r=t.getData("draggroups");r||(t.setAttribute("data-draggroups",this.groups.join(" ")),new e.DD.Drop({node:t,groups:this.groups,padding:"20 0 20 0"}));var i=t.one("a."+n.EDITINGMOVE);if(i){var s=i.getData("sr");i.replace(this.resourcedraghandle.cloneNode(!0).setAttribute("data-sectionreturn",s))}},this)},drag_start -:function(e){var t=e.target;t.get("dragNode").setContent(t.get("node").get("innerHTML")),t.get("dragNode").all("img.iconsmall").setStyle("vertical-align","baseline")},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(t){var r=t.drag,i=r.get("node"),s=t.drop.get("node"),o=i.one(n.ACTIONAREA),u=M.util.add_spinner(e,o),a={},f=this.get("config").pageparams,l;for(l in f)a[l]=f[l];a.sesskey=M.cfg.sesskey,a.courseId=this.get("courseid"),a["class"]="resource",a.field="move",a.id=Number(e.Moodle.core_course.util.cm.getId(i)),a.sectionId=e.Moodle.core_course.util.section.getId(s.ancestor(M.course.format.get_section_wrapper(e),!0)),i.next()&&(a.beforeId=Number(e.Moodle.core_course.util.cm.getId(i.next())));var c=M.cfg.wwwroot+this.get("ajaxurl");e.io(c,{method:"POST",data:a,on:{start:function(){this.lock_drag_handle(r,n.EDITINGMOVE),u.show()},success:function(t,s){var o=e.JSON.parse(s.responseText),a={element:i,visible:o.visible};M.course.coursebase.invoke_function("set_visibility_resource_ui",a),this.unlock_drag_handle(r,n.EDITINGMOVE),window.setTimeout(function(){u.hide()},250)},failure:function(e,t){this.ajax_failure(t),this.unlock_drag_handle(r,n.SECTIONHANDLE),u.hide()}},context:this})}},{NAME:"course-dragdrop-resource",ATTRS:{courseid:{value:null},ajaxurl:{value:0},config:{value:0}}}),M.course=M.course||{},M.course.init_resource_dragdrop=function(e){new i(e)}},"@VERSION@",{requires:["base","node","io","dom","dd","dd-scroll","moodle-core-dragdrop","moodle-core-notification","moodle-course-coursebase","moodle-course-util"]}); +YUI.add("moodle-course-dragdrop",function(e,t){var n={ACTIONAREA:".actions",ACTIVITY:"activity",ACTIVITYINSTANCE:"activityinstance",CONTENT:"content",COURSECONTENT:"course-content",EDITINGMOVE:"editing_move",ICONCLASS:"iconsmall",JUMPMENU:"jumpmenu",LEFT:"left",LIGHTBOX:"lightbox",MOVEDOWN:"movedown",MOVEUP:"moveup",PAGECONTENT:"page-content",RIGHT:"right",SECTION:"section",SECTIONADDMENUS:"section_add_menus",SECTIONHANDLE:"section-handle",SUMMARY:"summary",SECTIONDRAGGABLE:"sectiondraggable"};M.course=M.course||{};var r=function(){r.superclass.constructor.apply(this,arguments)};e.extend(r,M.core.dragdrop,{sectionlistselector:null,initializer:function(){this.groups=[n.SECTIONDRAGGABLE],this.samenodeclass=M.course.format.get_sectionwrapperclass(),this.parentnodeclass=M.course.format.get_containerclass();if(e.Node.one("."+n.JUMPMENU))return!1;this.sectionlistselector=M.course.format.get_section_wrapper(e);if(this.sectionlistselector){this.sectionlistselector="."+n.COURSECONTENT+" "+this.sectionlistselector,this.setup_for_section(this.sectionlistselector);var t=new e.DD.Delegate({container:"."+n.COURSECONTENT,nodes:"."+n.SECTIONDRAGGABLE,target:!0,handles:["."+n.LEFT],dragConfig:{groups:this.groups}});t.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),t.dd.plug(e.Plugin.DDConstrained,{constrain:"#"+n.PAGECONTENT,stickY:!0}),t.dd.plug(e.Plugin.DDWinScroll)}},setup_for_section:function(t){e.Node.all(t).each(function(t){var r=e.Moodle.core_course.util.section.getId(t);if(r>0){var i=t.one("."+n.RIGHT+" a."+n.MOVEDOWN),s=t.one("."+n.RIGHT+" a."+n.MOVEUP),o=M.util.get_string("movesection","moodle",r),u=t.one("."+n.LEFT);if((i||s)&&u){u.setStyle("cursor","move"),u.appendChild(this.get_drag_handle(o,n.SECTIONHANDLE,"icon",!0)),s&&(s.previous("br")?s.previous("br").remove():s.next("br")&&s.next("br").remove(),s.ancestor(".section_action_menu")&&s.ancestor().get("nodeName").toLowerCase()=="li"?s.ancestor().remove():s.remove());if(i){i.previous("br")?i.previous("br").remove():i.next("br")&&i.next("br").remove();var a=i.ancestor().get("nodeName").toLowerCase();i.ancestor(".section_action_menu")&&a=="li"?i.ancestor().remove():i.remove()}t.addClass(n.SECTIONDRAGGABLE)}}},this)},drag_start:function(t){var r=t.target,i=e.Node.create("<"+M.course.format.get_containernode()+">");i.addClass(M.course.format.get_containerclass());var s=e.Node.create("<"+M.course.format.get_sectionwrappernode()+">");s.addClass(M.course.format.get_sectionwrapperclass()),s.setStyle("margin",0),s.setContent(r.get("node").get("innerHTML")),i.appendChild(s),r.get("dragNode").setContent(i),r.get("dragNode").addClass(n.COURSECONTENT)},drag_dropmiss:function(e){this.drop_hit(e)},get_section_index:function(t){var r="."+n.COURSECONTENT+" "+M.course.format.get_section_selector(e),i=e.all(r),s=i.indexOf(t),o=i.indexOf(e.one("#section-0"));return s-o},drop_hit:function(t){var r=t.drag,i=r.get("node"),s=e.Moodle.core_course.util.section.getId(i),o=s,u=this.get_section_index(i),a=u;if(s===u)return;o>a&&(o=u,a=s),r.get("dragNode").removeClass(n.COURSECONTENT);var f=e.Node.all(this.sectionlistselector),l=M.util.add_lightbox(e,i),c={},h=this.get("config").pageparams,p;for(p in h){if(!h.hasOwnProperty(p))continue;c[p]=h[p]}c.sesskey=M.cfg.sesskey,c.courseId=this.get("courseid"),c["class"]="section",c.field="move",c.id=s,c.value=u;var d=M.cfg.wwwroot+this.get("ajaxurl");e.io(d,{method:"POST",data:c,on:{start:function(){l.show()},success:function(t,n){try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r),M.course.format.process_sections(e,f,r,o,a)}catch(i){}var s,u=!1;do{u=!1;for(s=o;s<=a;s++)if(e.Moodle.core_course.util.section.getId(f.item(s-1))>e.Moodle.core_course.util.section.getId(f.item(s))){var c=f.item(s-1).get("id");f.item(s-1).set("id",f.item(s).get("id")),f.item(s).set("id",c),M.course.format.swap_sections(e,s-1,s),u=!0}a-=1}while(u);window.setTimeout(function(){l.hide()},250)},failure:function(e,t){this.ajax_failure(t),l.hide()}},context:this})}},{NAME:"course-dragdrop-section",ATTRS:{courseid:{value:null},ajaxurl:{value:0},config:{value:0}}}),M.course=M.course||{},M.course.init_section_dragdrop=function(e){new r(e)};var i=function(){i.superclass.constructor.apply(this,arguments)};e.extend(i,M.core.dragdrop,{initializer:function(){this.groups=["resource"],this.samenodeclass=n.ACTIVITY,this.parentnodeclass=n.SECTION,this.samenodelabel={identifier:"afterresource",component:"moodle"},this.parentnodelabel={identifier:"totopofsection",component:"moodle"};var t=M.course.format.get_section_selector(e);if(t){t="."+n.COURSECONTENT+" "+t,this.setup_for_section(t);var r=t.slice(n.COURSECONTENT.length+2)+" li."+n.ACTIVITY,i=new e.DD.Delegate({container:"."+n.COURSECONTENT,nodes:r,target:!0,handles:["."+n.EDITINGMOVE],dragConfig:{groups:this.groups}});i.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1,cloneNode:!0}),i.dd.plug(e.Plugin.DDConstrained,{constrain:"#"+n.PAGECONTENT}),i.dd.plug(e.Plugin.DDWinScroll),M.course.coursebase.register_module(this),M.course.dragres=this}},setup_for_section:function(t){e.Node.all(t).each(function(t){var r=t.one("."+n.CONTENT+" ul."+n.SECTION);r||(r=e.Node.create(""),r.addClass(n.SECTION),t.one("."+n.CONTENT+" div."+n.SUMMARY).insert(r,"after")),r.setAttribute("data-draggroups",this.groups.join(" ")),new e.DD.Drop({node:r,groups:this.groups,padding:"20 0 20 0"}),this.setup_for_resource("#"+t.get("id")+" li."+n.ACTIVITY)},this)},setup_for_resource:function(t){e.Node.all(t).each(function(t){var r=t.getData("draggroups");r||(t.setAttribute("data-draggroups",this.groups.join(" ")),new e.DD.Drop({node:t,groups:this.groups,padding:"20 0 20 0"}));var i=t.one("a."+n.EDITINGMOVE);if(i){var s=i.getData("sr");i.replace(this.get_drag_handle(M.util.get_string("movecoursemodule","moodle"),n.EDITINGMOVE,n.ICONCLASS,!0).setAttribute("data-sectionreturn",s))}},this)},drag_start:function(e){var t=e.target;t.get("dragNode").setContent +(t.get("node").get("innerHTML")),t.get("dragNode").all("img.iconsmall").setStyle("vertical-align","baseline")},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(t){var r=t.drag,i=r.get("node"),s=t.drop.get("node"),o=i.one(n.ACTIONAREA),u=M.util.add_spinner(e,o),a={},f=this.get("config").pageparams,l;for(l in f)a[l]=f[l];a.sesskey=M.cfg.sesskey,a.courseId=this.get("courseid"),a["class"]="resource",a.field="move",a.id=Number(e.Moodle.core_course.util.cm.getId(i)),a.sectionId=e.Moodle.core_course.util.section.getId(s.ancestor(M.course.format.get_section_wrapper(e),!0)),i.next()&&(a.beforeId=Number(e.Moodle.core_course.util.cm.getId(i.next())));var c=M.cfg.wwwroot+this.get("ajaxurl");e.io(c,{method:"POST",data:a,on:{start:function(){this.lock_drag_handle(r,n.EDITINGMOVE),u.show()},success:function(t,s){var o=e.JSON.parse(s.responseText),a={element:i,visible:o.visible};M.course.coursebase.invoke_function("set_visibility_resource_ui",a),this.unlock_drag_handle(r,n.EDITINGMOVE),window.setTimeout(function(){u.hide()},250)},failure:function(e,t){this.ajax_failure(t),this.unlock_drag_handle(r,n.SECTIONHANDLE),u.hide()}},context:this})}},{NAME:"course-dragdrop-resource",ATTRS:{courseid:{value:null},ajaxurl:{value:0},config:{value:0}}}),M.course=M.course||{},M.course.init_resource_dragdrop=function(e){new i(e)}},"@VERSION@",{requires:["base","node","io","dom","dd","dd-scroll","moodle-core-dragdrop","moodle-core-notification","moodle-course-coursebase","moodle-course-util"]}); diff --git a/course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop.js b/course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop.js index 0796caebdf7..767b9c462de 100644 --- a/course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop.js +++ b/course/yui/build/moodle-course-dragdrop/moodle-course-dragdrop.js @@ -325,8 +325,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', @@ -420,7 +418,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); }, diff --git a/course/yui/src/dragdrop/js/resource.js b/course/yui/src/dragdrop/js/resource.js index f8c4e51a23f..4a1c1b7a4d2 100644 --- a/course/yui/src/dragdrop/js/resource.js +++ b/course/yui/src/dragdrop/js/resource.js @@ -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); }, diff --git a/lib/yui/build/moodle-core-blocks/moodle-core-blocks-debug.js b/lib/yui/build/moodle-core-blocks/moodle-core-blocks-debug.js index abdbb5dff13..fd38391dba7 100644 --- a/lib/yui/build/moodle-core-blocks/moodle-core-blocks-debug.js +++ b/lib/yui/build/moodle-core-blocks/moodle-core-blocks-debug.js @@ -897,13 +897,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); }); }, diff --git a/lib/yui/build/moodle-core-blocks/moodle-core-blocks-min.js b/lib/yui/build/moodle-core-blocks/moodle-core-blocks-min.js index 0f25b616d45..dd97f89073b 100644 --- a/lib/yui/build/moodle-core-blocks/moodle-core-blocks-min.js +++ b/lib/yui/build/moodle-core-blocks/moodle-core-blocks-min.js @@ -1,2 +1,2 @@ YUI.add("moodle-core-blocks",function(e,t){var n="/lib/ajax/blocks.php",r={BLOCK:"block",BLOCKREGION:"block-region",BLOCKADMINBLOCK:"block_adminblock",EDITINGMOVE:"editing_move",HEADER:"header",LIGHTBOX:"lightbox",REGIONCONTENT:"region-content",SKIPBLOCK:"skip-block",SKIPBLOCKTO:"skip-block-to",MYINDEX:"page-my-index",REGIONMAIN:"region-main",BLOCKSMOVING:"blocks-moving"},i={DRAGHANDLE:"."+r.HEADER+" .commands .moodle-core-dragdrop-draghandle"},s=function(){s.superclass.constructor.apply(this,arguments)};e.extend(s,M.core.dragdrop,{skipnodetop:null,skipnodebottom:null,dragsourceregion:null,initializer:function(){this.groups=["block"],this.samenodeclass=r.BLOCK,this.parentnodeclass=r.REGIONCONTENT;var t=e.Node.all("body#"+r.MYINDEX+" #"+r.REGIONMAIN+" > ."+r.REGIONCONTENT);if(t.size()>0){var n=t.item(0);n.addClass(r.BLOCKREGION),n.set("id",r.REGIONCONTENT),n.one("div").addClass(r.REGIONCONTENT)}var s=e.Node.all("div."+r.BLOCKREGION);if(s.size()===0)return!1;if(s.size()!==this.get("regions").length){var o=e.Node.create("
").addClass(r.BLOCKREGION),u=e.Node.create("
").addClass(r.REGIONCONTENT);o.appendChild(u);var a=s.filter("#region-pre"),f=s.filter("#region-post");a.size()===0&&f.size()===1?(o.setAttrs({id:"region-pre"}),f.item(0).insert(o,"before"),s.unshift(o)):f.size()===0&&a.size()===1&&(o.setAttrs({id:"region-post"}),a.item(0).insert(o,"after"),s.push(o))}s.each(function(t){new e.DD.Drop({node:t.one("div."+r.REGIONCONTENT),groups:this.groups,padding:"40 240 40 240"});var n=new e.DD.Delegate({container:t,nodes:"."+r.BLOCK,target:!0,handles:[i.DRAGHANDLE],invalid:".block-hider-hide, .block-hider-show, .moveto",dragConfig:{groups:this.groups}});n.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),n.dd.plug(e.Plugin.DDWinScroll);var s=t.all("."+r.BLOCK);s.each(function(e){var t=e.one("a."+r.EDITINGMOVE);t&&(t.replace(this.get_drag_handle(t.getAttribute("title"),"","iconsmall",!0)),e.one(i.DRAGHANDLE).setStyle("cursor","move"))},this)},this)},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(t){var n=t.ancestor("div."+r.BLOCKREGION).get("id").replace(/region-/i,"");return e.Array.indexOf(this.get("regions"),n)===-1?(window.right_to_left()&&(n==="post"?n="pre":n==="pre"&&(n="post")),"side-"+n):n},get_region_id:function(e){return e.get("id").replace(/region-/i,"")},drag_start:function(t){var n=t.target;this.dragsourceregion=n.get("node").ancestor("div."+r.BLOCKREGION),n.get("node").previous()&&n.get("node").previous().hasClass(r.SKIPBLOCK)&&(this.skipnodetop=n.get("node").previous()),n.get("node").next()&&n.get("node").next().hasClass(r.SKIPBLOCKTO)&&(this.skipnodebottom=n.get("node").next()),e.one("body").addClass(r.BLOCKSMOVING)},drop_over:function(t){var n=t.drag.get("node"),i=t.drop.get("node");i.hasClass(this.parentnodeclass)&&i.one("."+r.BLOCKADMINBLOCK)&&i.one("."+r.BLOCKADMINBLOCK).next("."+r.BLOCK)&&i.prepend(n);if(this.dragsourceregion.contains(i))return!1;var s=e.one("body"),o=this.get_region_id(this.dragsourceregion);s.hasClass("side-"+o+"-only")&&s.removeClass("side-"+o+"-only"),o=this.get_region_id(i.ancestor("div."+r.BLOCKREGION)),this.dragsourceregion.all("."+r.BLOCK).size()===0&&this.dragsourceregion.get("id").match(/(region-pre|region-post)/i)&&(s.hasClass("side-"+o+"-only")||s.addClass("side-"+o+"-only"))},drag_end:function(){this.skipnodetop=null,this.skipnodebottom=null,this.dragsourceregion=null,e.one("body").removeClass(r.BLOCKSMOVING)},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(t){var i=t.drag,s=i.get("node"),o=t.drop.get("node");s.previous()&&s.previous().hasClass(r.SKIPBLOCK)&&s.insert(s.previous(),"after"),this.skipnodetop&&s.insert(this.skipnodetop,"before"),this.skipnodebottom&&s.insert(this.skipnodebottom,"after");var u=M.util.add_lightbox(e,s),a={sesskey:M.cfg.sesskey,courseid:this.get("courseid"),pagelayout:this.get("pagelayout"),pagetype:this.get("pagetype"),subpage:this.get("subpage"),contextid:this.get("contextid"),action:"move",bui_moveid:this.get_block_id(s),bui_newregion:this.get_block_region(o)};this.get("cmid")&&(a.cmid=this.get("cmid")),s.next("."+this.samenodeclass)&&!s.next("."+this.samenodeclass).hasClass(r.BLOCKADMINBLOCK)&&(a.bui_beforeid=this.get_block_id(s.next("."+this.samenodeclass))),e.io(M.cfg.wwwroot+n,{method:"POST",data:a,on:{start:function(){u.show()},success:function(t,n){window.setTimeout(function(){u.hide()},250);try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r)}catch(i){}},failure:function(e,t){this.ajax_failure(t),u.hide()}},context:this})}},{NAME:"core-blocks-dragdrop",ATTRS:{courseid:{value:null},cmid:{value:null},contextid:{value:null},pagelayout:{value:null},pagetype:{value:null},subpage:{value:null},regions:{value:null}}}),M.core=M.core||{},M.core.blockdraganddrop=M.core.blockdraganddrop||{},M.core.blockdraganddrop._isusingnewblocksmethod=null,M.core.blockdraganddrop.is_using_blocks_render_method=function(){if(this._isusingnewblocksmethod===null){var t=e.all(".block-region[data-blockregion]").size(),n=e.all(".block-region").size();this._isusingnewblocksmethod=n===t,t>0&&n>0&&t!==n}return this._isusingnewblocksmethod},M.core.blockdraganddrop.init=function(e){this.is_using_blocks_render_method()?new o(e):new s(e)},M.core_blocks=M.core_blocks||{},M.core_blocks.init_dragdrop=function(e){M.core.blockdraganddrop.init(e)};var o=function(){o.superclass.constructor.apply(this,arguments)};o.prototype={skipnodetop:null,skipnodebottom:null,regionobjects:{},initializer:function(){var t=this.get("regions"),n=0,s,o,a;this.groups=["block"],this.samenodeclass=r.BLOCK,this.parentnodeclass=r.BLOCKREGION;var f=e.Node.all("body#"+r.MYINDEX+" #"+r.REGIONMAIN+" > ."+r.REGIONCONTENT);if(f.size()>0){var l=f.item(0);l.addClass(r.BLOCKREGION),l.set("id",r.REGIONCONTENT),l.one("div").addClass(r.REGIONCONTENT)}for(n in t)o=t[n],s=new u({manager:this,region:o,node:e.one("#block-region-"+o)}),this.regionobjects[o]=s,new e.DD.Drop({node:s.get_droptarget() -,groups:this.groups,padding:"40 240 40 240"}),a=new e.DD.Delegate({container:s.get_droptarget(),nodes:"."+r.BLOCK,target:!0,handles:[i.DRAGHANDLE],invalid:".block-hider-hide, .block-hider-show, .moveto, .block_fake",dragConfig:{groups:this.groups}}),a.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),a.dd.plug(e.Plugin.DDWinScroll),e.DD.DDM.on("ddm:start",this.enable_all_regions,this),s.change_block_move_icons(this)},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(e){return e.test("[data-blockregion]")||(e=e.ancestor("[data-blockregion]")),e.getData("blockregion")},get_region_object:function(e){return this.regionobjects[this.get_block_region(e)]},enable_all_regions:function(){var t=e.DD.DDM.activeDrag.get("groups");if(!t||e.Array.indexOf(t,"block")===-1)return;var n;for(n in this.regionobjects){if(!this.regionobjects.hasOwnProperty(n))continue;this.regionobjects[n].enable()}},disable_regions_if_required:function(){var e=0;for(e in this.regionobjects)this.regionobjects[e].disable_if_required()},drag_start:function(e){var t=e.target;t.get("node").previous()&&t.get("node").previous().hasClass(r.SKIPBLOCK)&&(this.skipnodetop=t.get("node").previous()),t.get("node").next()&&t.get("node").next().hasClass(r.SKIPBLOCKTO)&&(this.skipnodebottom=t.get("node").next())},drop_over:function(e){var t=e.drag.get("node"),n=e.drop.get("node");n.hasClass(r.REGIONCONTENT)&&n.one("."+r.BLOCKADMINBLOCK)&&n.one("."+r.BLOCKADMINBLOCK).next("."+r.BLOCK)&&n.prepend(t)},drop_end:function(){this.skipnodetop=null,this.skipnodebottom=null,this.disable_regions_if_required()},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(t){var i=t.drag.get("node"),s=t.drop.get("node");i.previous()&&i.previous().hasClass(r.SKIPBLOCK)&&i.insert(i.previous(),"after"),this.skipnodetop&&i.insert(this.skipnodetop,"before"),this.skipnodebottom&&i.insert(this.skipnodebottom,"after");var o=M.util.add_lightbox(e,i),u={sesskey:M.cfg.sesskey,courseid:this.get("courseid"),pagelayout:this.get("pagelayout"),pagetype:this.get("pagetype"),subpage:this.get("subpage"),contextid:this.get("contextid"),action:"move",bui_moveid:this.get_block_id(i),bui_newregion:this.get_block_region(s)};this.get("cmid")&&(u.cmid=this.get("cmid")),i.next("."+r.BLOCK)&&!i.next("."+r.BLOCK).hasClass(r.BLOCKADMINBLOCK)&&(u.bui_beforeid=this.get_block_id(i.next("."+r.BLOCK))),e.io(M.cfg.wwwroot+n,{method:"POST",data:u,on:{start:function(){o.show()},success:function(t,n){window.setTimeout(function(){o.hide()},250);try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r)}catch(i){}},failure:function(e,t){this.ajax_failure(t),o.hide()},complete:function(){this.disable_regions_if_required()}},context:this})}},e.extend(o,M.core.dragdrop,o.prototype,{NAME:"core-blocks-dragdrop-manager",ATTRS:{courseid:{value:null},cmid:{value:null},contextid:{value:null},pagelayout:{value:null},pagetype:{value:null},subpage:{value:null},regions:{value:[]}}});var u=function(){u.superclass.constructor.apply(this,arguments)};u.prototype={initializer:function(){var t=this.get("node");t||(t=this.create_and_add_node());var n=e.one("body"),i=t.all("."+r.BLOCK).size()>0,s=this.get_has_region_class();this.set("hasblocks",i),n.hasClass(s)||n.addClass(s),n.addClass(i?this.get_used_region_class():this.get_empty_region_class()),n.removeClass(i?this.get_empty_region_class():this.get_used_region_class())},create_and_add_node:function(){var t=e.Node.create,n=this.get("region"),i=t('
').addClass(r.BLOCKREGION).setData("blockregion",n),s=this.get("manager").get("regions"),o,u=!1,a=!1,f=!1,l,c;for(o in s)s[o].match(/(pre|left)/)?u=s[o]:s[o].match(/(post|right)/)&&(a=s[o]);return u!==!1&&a!==!1&&(n===u?(c=e.one("#block-region-"+a),c&&(c.insert(i,"before"),f=!0)):(l=e.one("#block-region-"+u),l&&(l.insert(i,"after"),f=!0))),f===!1&&e.one("body").append(i),this.set("node",i),i},change_block_move_icons:function(e){var t,n;this.get("node").all("."+r.BLOCK+" a."+r.EDITINGMOVE).each(function(r){r.setStyle("cursor","move"),t=e.get_drag_handle(r.getAttribute("title"),"","icon",!0),n=t.one("img"),n.addClass("iconsmall"),n.removeClass("icon"),r.replace(t)})},get_has_region_class:function(){return"has-region-"+this.get("region")},get_empty_region_class:function(){return"empty-region-"+this.get("region")},get_used_region_class:function(){return"used-region-"+this.get("region")},get_droptarget:function(){var e=this.get("node");return e.test('[data-droptarget="1"]')?e:e.one('[data-droptarget="1"]')},enable:function(){e.one("body").addClass(this.get_used_region_class()).removeClass(this.get_empty_region_class())},disable_if_required:function(){this.get("node").all("."+r.BLOCK).size()===0&&e.one("body").addClass(this.get_empty_region_class()).removeClass(this.get_used_region_class())}},e.extend(u,e.Base,u.prototype,{NAME:"core-blocks-dragdrop-blockregion",ATTRS:{manager:{writeOnce:"initOnly",validator:function(t){return e.Lang.isObject(t)&&t instanceof o}},region:{writeOnce:"initOnly",validator:function(t){return e.Lang.isString(t)}},node:{validator:function(t){return e.Lang.isObject(t)||e.Lang.isNull(t)}},hasblocks:{value:!1,validator:function(t){return e.Lang.isBoolean(t)}}}})},"@VERSION@",{requires:["base","node","io","dom","dd","dd-scroll","moodle-core-dragdrop","moodle-core-notification"]}); +,groups:this.groups,padding:"40 240 40 240"}),a=new e.DD.Delegate({container:s.get_droptarget(),nodes:"."+r.BLOCK,target:!0,handles:[i.DRAGHANDLE],invalid:".block-hider-hide, .block-hider-show, .moveto, .block_fake",dragConfig:{groups:this.groups}}),a.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),a.dd.plug(e.Plugin.DDWinScroll),e.DD.DDM.on("ddm:start",this.enable_all_regions,this),s.change_block_move_icons(this)},get_block_id:function(e){return Number(e.get("id").replace(/inst/i,""))},get_block_region:function(e){return e.test("[data-blockregion]")||(e=e.ancestor("[data-blockregion]")),e.getData("blockregion")},get_region_object:function(e){return this.regionobjects[this.get_block_region(e)]},enable_all_regions:function(){var t=e.DD.DDM.activeDrag.get("groups");if(!t||e.Array.indexOf(t,"block")===-1)return;var n;for(n in this.regionobjects){if(!this.regionobjects.hasOwnProperty(n))continue;this.regionobjects[n].enable()}},disable_regions_if_required:function(){var e=0;for(e in this.regionobjects)this.regionobjects[e].disable_if_required()},drag_start:function(e){var t=e.target;t.get("node").previous()&&t.get("node").previous().hasClass(r.SKIPBLOCK)&&(this.skipnodetop=t.get("node").previous()),t.get("node").next()&&t.get("node").next().hasClass(r.SKIPBLOCKTO)&&(this.skipnodebottom=t.get("node").next())},drop_over:function(e){var t=e.drag.get("node"),n=e.drop.get("node");n.hasClass(r.REGIONCONTENT)&&n.one("."+r.BLOCKADMINBLOCK)&&n.one("."+r.BLOCKADMINBLOCK).next("."+r.BLOCK)&&n.prepend(t)},drop_end:function(){this.skipnodetop=null,this.skipnodebottom=null,this.disable_regions_if_required()},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(t){var i=t.drag.get("node"),s=t.drop.get("node");i.previous()&&i.previous().hasClass(r.SKIPBLOCK)&&i.insert(i.previous(),"after"),this.skipnodetop&&i.insert(this.skipnodetop,"before"),this.skipnodebottom&&i.insert(this.skipnodebottom,"after");var o=M.util.add_lightbox(e,i),u={sesskey:M.cfg.sesskey,courseid:this.get("courseid"),pagelayout:this.get("pagelayout"),pagetype:this.get("pagetype"),subpage:this.get("subpage"),contextid:this.get("contextid"),action:"move",bui_moveid:this.get_block_id(i),bui_newregion:this.get_block_region(s)};this.get("cmid")&&(u.cmid=this.get("cmid")),i.next("."+r.BLOCK)&&!i.next("."+r.BLOCK).hasClass(r.BLOCKADMINBLOCK)&&(u.bui_beforeid=this.get_block_id(i.next("."+r.BLOCK))),e.io(M.cfg.wwwroot+n,{method:"POST",data:u,on:{start:function(){o.show()},success:function(t,n){window.setTimeout(function(){o.hide()},250);try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r)}catch(i){}},failure:function(e,t){this.ajax_failure(t),o.hide()},complete:function(){this.disable_regions_if_required()}},context:this})}},e.extend(o,M.core.dragdrop,o.prototype,{NAME:"core-blocks-dragdrop-manager",ATTRS:{courseid:{value:null},cmid:{value:null},contextid:{value:null},pagelayout:{value:null},pagetype:{value:null},subpage:{value:null},regions:{value:[]}}});var u=function(){u.superclass.constructor.apply(this,arguments)};u.prototype={initializer:function(){var t=this.get("node");t||(t=this.create_and_add_node());var n=e.one("body"),i=t.all("."+r.BLOCK).size()>0,s=this.get_has_region_class();this.set("hasblocks",i),n.hasClass(s)||n.addClass(s),n.addClass(i?this.get_used_region_class():this.get_empty_region_class()),n.removeClass(i?this.get_empty_region_class():this.get_used_region_class())},create_and_add_node:function(){var t=e.Node.create,n=this.get("region"),i=t('
').addClass(r.BLOCKREGION).setData("blockregion",n),s=this.get("manager").get("regions"),o,u=!1,a=!1,f=!1,l,c;for(o in s)s[o].match(/(pre|left)/)?u=s[o]:s[o].match(/(post|right)/)&&(a=s[o]);return u!==!1&&a!==!1&&(n===u?(c=e.one("#block-region-"+a),c&&(c.insert(i,"before"),f=!0)):(l=e.one("#block-region-"+u),l&&(l.insert(i,"after"),f=!0))),f===!1&&e.one("body").append(i),this.set("node",i),i},change_block_move_icons:function(e){var t;this.get("node").all("."+r.BLOCK+" a."+r.EDITINGMOVE).each(function(n){n.setStyle("cursor","move"),t=e.get_drag_handle(n.getAttribute("title"),"","icon",!0),n.replace(t)})},get_has_region_class:function(){return"has-region-"+this.get("region")},get_empty_region_class:function(){return"empty-region-"+this.get("region")},get_used_region_class:function(){return"used-region-"+this.get("region")},get_droptarget:function(){var e=this.get("node");return e.test('[data-droptarget="1"]')?e:e.one('[data-droptarget="1"]')},enable:function(){e.one("body").addClass(this.get_used_region_class()).removeClass(this.get_empty_region_class())},disable_if_required:function(){this.get("node").all("."+r.BLOCK).size()===0&&e.one("body").addClass(this.get_empty_region_class()).removeClass(this.get_used_region_class())}},e.extend(u,e.Base,u.prototype,{NAME:"core-blocks-dragdrop-blockregion",ATTRS:{manager:{writeOnce:"initOnly",validator:function(t){return e.Lang.isObject(t)&&t instanceof o}},region:{writeOnce:"initOnly",validator:function(t){return e.Lang.isString(t)}},node:{validator:function(t){return e.Lang.isObject(t)||e.Lang.isNull(t)}},hasblocks:{value:!1,validator:function(t){return e.Lang.isBoolean(t)}}}})},"@VERSION@",{requires:["base","node","io","dom","dd","dd-scroll","moodle-core-dragdrop","moodle-core-notification"]}); diff --git a/lib/yui/build/moodle-core-blocks/moodle-core-blocks.js b/lib/yui/build/moodle-core-blocks/moodle-core-blocks.js index 87890f2603e..3a4ef1ae458 100644 --- a/lib/yui/build/moodle-core-blocks/moodle-core-blocks.js +++ b/lib/yui/build/moodle-core-blocks/moodle-core-blocks.js @@ -890,13 +890,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); }); }, diff --git a/lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-debug.js b/lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-debug.js index 4df59c2252a..aba5306c291 100644 --- a/lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-debug.js +++ b/lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-debug.js @@ -144,6 +144,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)); + }, /** @@ -163,25 +164,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('') - .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('') .addClass(classname) @@ -189,9 +175,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; }, diff --git a/lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-min.js b/lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-min.js index b85943f6e42..080e6ab808e 100644 --- a/lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-min.js +++ b/lib/yui/build/moodle-core-dragdrop/moodle-core-dragdrop-min.js @@ -1,2 +1,2 @@ -YUI.add("moodle-core-dragdrop",function(e,t){var n={pix:"i/move_2d",largepix:"i/dragdrop",component:"moodle",cssclass:"moodle-core-dragdrop-draghandle"},r=function(){r.superclass.constructor.apply(this,arguments)};e.extend(r,e.Base,{goingup:null,absgoingup:null,samenodeclass:null,parentnodeclass:null,samenodelabel:null,parentnodelabel:null,groups:[],lastdroptarget:null,listeners:null,initializer:function(){this.listeners=[],this.listeners.push(e.DD.DDM.on("drag:start",this.global_drag_start,this)),this.listeners.push(e.DD.DDM.on("drag:end",this.global_drag_end,this)),this.listeners.push(e.DD.DDM.on("drag:drag",this.global_drag_drag,this)),this.listeners.push(e.DD.DDM.on("drop:over",this.global_drop_over,this)),this.listeners.push(e.DD.DDM.on("drop:hit",this.global_drop_hit,this)),this.listeners.push(e.DD.DDM.on("drag:dropmiss",this.global_drag_dropmiss,this)),this.listeners.push(e.one(e.config.doc.body).delegate("key",this.global_keydown,"down:32, enter, esc","."+n.cssclass,this)),this.listeners.push(e.one(e.config.doc.body).delegate("click",this.global_keydown,"."+n.cssclass,this))},destructor:function(){(new e.EventHandle(this.listeners)).detach()},get_drag_handle:function(t,r,i,s){var o=n.pix;s&&(o=n.largepix);var u=e.Node.create("").setStyle("cursor","move").setAttrs({src:M.util.image_url(o,n.component),alt:t});i&&u.addClass(i);var a=e.Node.create("").addClass(r).setAttribute("title",t).setAttribute("tabIndex",0).setAttribute("data-draggroups",this.groups).setAttribute("role","button");return a.appendChild(u),a.addClass(n.cssclass),a},lock_drag_handle:function(e,t){e.removeHandle("."+t)},unlock_drag_handle:function(e,t){e.addHandle("."+t),e.get("activeHandle").focus()},ajax_failure:function(e){var t={name:e.status+" "+e.statusText,message:e.responseText};return new M.core.exception(t)},in_group:function(t){var n=!1;return e.each(this.groups,function(e){t._groups[e]&&(n=!0)},this),n},global_drag_start:function(e){var t=e.target;if(!this.in_group(t))return;this.originalstyle=t.get("node").getAttribute("style"),t.get("node").setStyle("opacity",".25"),t.get("dragNode").setStyles({opacity:".75",borderColor:t.get("node").getStyle("borderColor"),backgroundColor:t.get("node").getStyle("backgroundColor")}),t.get("dragNode").empty(),this.drag_start(e)},global_drag_end:function(e){var t=e.target;if(!this.in_group(t))return;t.get("node").setAttribute("style",this.originalstyle),this.drag_end(e)},global_drag_drag:function(e){var t=e.target,n=e.info;if(!this.in_group(t))return;n.start[1]n.xy[1]&&(this.absgoingup=!1),n.delta[1]<0?this.goingup=!0:n.delta[1]>0&&(this.goingup=!1),this.drag_drag(e)},global_drop_over:function(e){if(!e.drop||!e.drop.inGroup(this.groups))return;var t=e.drag.get("node"),n=e.drop.get("node");this.lastdroptarget=e.drop;if(n.hasClass(this.samenodeclass)){var r;this.goingup?r="before":r="after",n.insert(t,r)}else(n.hasClass(this.parentnodeclass)||n.test('[data-droptarget="1"]'))&&!n.contains(t)&&(this.goingup?n.append(t):n.prepend(t));this.drop_over(e)},global_drag_dropmiss:function(e){e.drag=e.target,e.drop=this.lastdroptarget;if(!this.in_group(e.drag))return;if(!e.drop||!e.drop.inGroup(this.groups))return;this.drag_dropmiss(e)},global_drop_hit:function(e){if(!e.drop||!e.drop.inGroup(this.groups))return;this.drop_hit(e)},find_element_text:function(t){var n="";n=t.get("aria-label")||"";if(n.length>0)return n;var r=t.get("aria-labelledby");if(r){var i=e.one("#"+r);if(i&&i.get("text").length>0)return i.get("text")}var s=t.all("h2, h3, h4, h5, span:not(.actions):not(.menu-action-text), p, div.no-overflow, div.dimmed_text");return s.each(function(){n===""&&e.Lang.trim(this.get("text"))!==""&&(n=this.get("text"))}),n!==""?n:M.util.get_string("emptydragdropregion","moodle")},global_start_keyboard_drag:function(t,n,r){M.core.dragdrop.keydragcontainer=r,M.core.dragdrop.keydraghandle=n;var i=this.find_element_text(r),s=M.util.get_string("movecontent","moodle",i),o=e.Node.create("");o.addClass("dragdrop-keyboard-drag");var u,a,f,l=e.all("."+this.samenodeclass+", ."+this.parentnodeclass);l.each(function(t){var n=!1,s=t,l=t.getAttribute("class").split(" ").join(", .");if(t.drop&&t.drop.inGroup(this.groups)&&t.drop.get("node")!==r&&t.next(l)!==r)n=!0;else{var c=t.getAttribute("data-draggroups").split(" "),h,p;for(h=0;h"),a=e.Node.create(""),i=this.find_element_text(s),this.samenodelabel&&t.hasClass(this.samenodeclass)?f=M.util.get_string(this.samenodelabel.identifier,this.samenodelabel.component,i):this.parentnodelabel&&t.hasClass(this.parentnodeclass)?f=M.util.get_string(this.parentnodelabel.identifier,this.parentnodelabel.component,i):f=M.util.get_string("tocontent","moodle",i),a.setContent(f),a.setAttribute("data-drop-target",t.get("id")),a.setAttribute("tabindex","0"),a.on("click",this.global_keyboard_drop,this),a.on("key",this.global_keyboard_drop,"down:enter,32",this),u.append(a),o.append(u))},this),M.core.dragdrop.dropui=new M.core.dialogue({headerContent:s,bodyContent:o,draggable:!0,visible:!0,center:!0,modal:!0}),M.core.dragdrop.dropui.after("visibleChange",function(e){e.prevVal&&!e.newVal&&this.global_cancel_keyboard_drag()},this),o.one("a")&&o.one("a").focus()},simulated_drag_drop_event:function(e,t){var n=function(e){this.node=e};n.prototype.get=function(e){return e==="node"||e==="dragNode"||e==="dropNode"?this.node:e==="activeHandle"?this.node.one(".editing_move"):null},n.prototype.inGroup=function(){return!0},n.prototype.addHandle=function(){},n.prototype.removeHandle=function(){},this.drop=new n(t),this.drag=new n(e),this.target=this.drop},global_keyboard_drop:function(t){var n=M.core.dragdrop.keydragcontainer,r=e.one("#"+t.target.getAttribute("data-drop-target"));M.core.dragdrop.dropui.hide(),t.preventDefault -();var i=new this.simulated_drag_drop_event(n,n),s=new this.simulated_drag_drop_event(n,r);this.drag_start(i),this.global_drop_over(s),r.hasClass(this.parentnodeclass)&&r.contains(n)&&r.prepend(n),this.global_drop_hit(s)},global_cancel_keyboard_drag:function(){M.core.dragdrop.keydragcontainer&&(M.core.dragdrop.keydraghandle.focus(),M.core.dragdrop.keydragcontainer=null),M.core.dragdrop.dropui&&M.core.dragdrop.dropui.destroy()},global_keydown:function(e){var t=e.target.ancestor("."+n.cssclass,!0),r,i;if(t===null)return;if(e.keyCode===27){this.global_cancel_keyboard_drag(),e.preventDefault();return}if(!t.hasClass(n.cssclass))return;if(e.keyCode!==13&&e.keyCode!==32&&e.type!=="click")return;i=t.getAttribute("data-draggroups").split(" ");var s,o,u=!1;for(s=0;s").addClass(r).setAttribute("title",t).setAttribute("tabIndex",0).setAttribute("data-draggroups",this.groups).setAttribute("role","button");return s.addClass(n.cssclass),window.require(["core/templates"],function(t){var n=e.Node.create(t.renderPix("i/move_2d","core"));n.addClass("moodle-core-dragdrop-draghandle").setStyle("cursor","move"),typeof i!="undefined"&&n.addClass(i),s.appendChild(n)}.bind(this)),s},lock_drag_handle:function(e,t){e.removeHandle("."+t)},unlock_drag_handle:function(e,t){e.addHandle("."+t),e.get("activeHandle").focus()},ajax_failure:function(e){var t={name:e.status+" "+e.statusText,message:e.responseText};return new M.core.exception(t)},in_group:function(t){var n=!1;return e.each(this.groups,function(e){t._groups[e]&&(n=!0)},this),n},global_drag_start:function(e){var t=e.target;if(!this.in_group(t))return;this.originalstyle=t.get("node").getAttribute("style"),t.get("node").setStyle("opacity",".25"),t.get("dragNode").setStyles({opacity:".75",borderColor:t.get("node").getStyle("borderColor"),backgroundColor:t.get("node").getStyle("backgroundColor")}),t.get("dragNode").empty(),this.drag_start(e)},global_drag_end:function(e){var t=e.target;if(!this.in_group(t))return;t.get("node").setAttribute("style",this.originalstyle),this.drag_end(e)},global_drag_drag:function(e){var t=e.target,n=e.info;if(!this.in_group(t))return;n.start[1]n.xy[1]&&(this.absgoingup=!1),n.delta[1]<0?this.goingup=!0:n.delta[1]>0&&(this.goingup=!1),this.drag_drag(e)},global_drop_over:function(e){if(!e.drop||!e.drop.inGroup(this.groups))return;var t=e.drag.get("node"),n=e.drop.get("node");this.lastdroptarget=e.drop;if(n.hasClass(this.samenodeclass)){var r;this.goingup?r="before":r="after",n.insert(t,r)}else(n.hasClass(this.parentnodeclass)||n.test('[data-droptarget="1"]'))&&!n.contains(t)&&(this.goingup?n.append(t):n.prepend(t));this.drop_over(e)},global_drag_dropmiss:function(e){e.drag=e.target,e.drop=this.lastdroptarget;if(!this.in_group(e.drag))return;if(!e.drop||!e.drop.inGroup(this.groups))return;this.drag_dropmiss(e)},global_drop_hit:function(e){if(!e.drop||!e.drop.inGroup(this.groups))return;this.drop_hit(e)},find_element_text:function(t){var n="";n=t.get("aria-label")||"";if(n.length>0)return n;var r=t.get("aria-labelledby");if(r){var i=e.one("#"+r);if(i&&i.get("text").length>0)return i.get("text")}var s=t.all("h2, h3, h4, h5, span:not(.actions):not(.menu-action-text), p, div.no-overflow, div.dimmed_text");return s.each(function(){n===""&&e.Lang.trim(this.get("text"))!==""&&(n=this.get("text"))}),n!==""?n:M.util.get_string("emptydragdropregion","moodle")},global_start_keyboard_drag:function(t,n,r){M.core.dragdrop.keydragcontainer=r,M.core.dragdrop.keydraghandle=n;var i=this.find_element_text(r),s=M.util.get_string("movecontent","moodle",i),o=e.Node.create("
    ");o.addClass("dragdrop-keyboard-drag");var u,a,f,l=e.all("."+this.samenodeclass+", ."+this.parentnodeclass);l.each(function(t){var n=!1,s=t,l=t.getAttribute("class").split(" ").join(", .");if(t.drop&&t.drop.inGroup(this.groups)&&t.drop.get("node")!==r&&t.next(l)!==r)n=!0;else{var c=t.getAttribute("data-draggroups").split(" "),h,p;for(h=0;h"),a=e.Node.create(""),i=this.find_element_text(s),this.samenodelabel&&t.hasClass(this.samenodeclass)?f=M.util.get_string(this.samenodelabel.identifier,this.samenodelabel.component,i):this.parentnodelabel&&t.hasClass(this.parentnodeclass)?f=M.util.get_string(this.parentnodelabel.identifier,this.parentnodelabel.component,i):f=M.util.get_string("tocontent","moodle",i),a.setContent(f),a.setAttribute("data-drop-target",t.get("id")),a.setAttribute("tabindex","0"),a.on("click",this.global_keyboard_drop,this),a.on("key",this.global_keyboard_drop,"down:enter,32",this),u.append(a),o.append(u))},this),M.core.dragdrop.dropui=new M.core.dialogue({headerContent:s,bodyContent:o,draggable:!0,visible:!0,center:!0,modal:!0}),M.core.dragdrop.dropui.after("visibleChange",function(e){e.prevVal&&!e.newVal&&this.global_cancel_keyboard_drag()},this),o.one("a")&&o.one("a").focus()},simulated_drag_drop_event:function(e,t){var n=function(e){this.node=e};n.prototype.get=function(e){return e==="node"||e==="dragNode"||e==="dropNode"?this.node:e==="activeHandle"?this.node.one(".editing_move"):null},n.prototype.inGroup=function(){return!0},n.prototype.addHandle=function(){},n.prototype.removeHandle=function(){},this.drop=new n(t),this.drag=new n(e),this.target=this.drop},global_keyboard_drop:function(t){var n=M.core.dragdrop.keydragcontainer,r=e.one("#"+t.target.getAttribute("data-drop-target" +));M.core.dragdrop.dropui.hide(),t.preventDefault();var i=new this.simulated_drag_drop_event(n,n),s=new this.simulated_drag_drop_event(n,r);this.drag_start(i),this.global_drop_over(s),r.hasClass(this.parentnodeclass)&&r.contains(n)&&r.prepend(n),this.global_drop_hit(s)},global_cancel_keyboard_drag:function(){M.core.dragdrop.keydragcontainer&&(M.core.dragdrop.keydraghandle.focus(),M.core.dragdrop.keydragcontainer=null),M.core.dragdrop.dropui&&M.core.dragdrop.dropui.destroy()},global_keydown:function(e){var t=e.target.ancestor("."+n.cssclass,!0),r,i;if(t===null)return;if(e.keyCode===27){this.global_cancel_keyboard_drag(),e.preventDefault();return}if(!t.hasClass(n.cssclass))return;if(e.keyCode!==13&&e.keyCode!==32&&e.type!=="click")return;i=t.getAttribute("data-draggroups").split(" ");var s,o,u=!1;for(s=0;s') - .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('') .addClass(classname) @@ -189,9 +175,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; }, diff --git a/lib/yui/src/blocks/js/blockregion.js b/lib/yui/src/blocks/js/blockregion.js index 0d105c7c962..5cc1c2caf2e 100644 --- a/lib/yui/src/blocks/js/blockregion.js +++ b/lib/yui/src/blocks/js/blockregion.js @@ -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); }); }, diff --git a/lib/yui/src/dragdrop/js/dragdrop.js b/lib/yui/src/dragdrop/js/dragdrop.js index 6609279ae89..8f85a05bd3b 100644 --- a/lib/yui/src/dragdrop/js/dragdrop.js +++ b/lib/yui/src/dragdrop/js/dragdrop.js @@ -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('') - .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('') .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; }, diff --git a/mod/feedback/yui/dragdrop/dragdrop.js b/mod/feedback/yui/dragdrop/dragdrop.js index ac4af8ff6d7..1b5638950cc 100644 --- a/mod/feedback/yui/dragdrop/dragdrop.js +++ b/mod/feedback/yui/dragdrop/dragdrop.js @@ -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 diff --git a/mod/quiz/yui/build/moodle-mod_quiz-dragdrop/moodle-mod_quiz-dragdrop-debug.js b/mod/quiz/yui/build/moodle-mod_quiz-dragdrop/moodle-mod_quiz-dragdrop-debug.js index 13fbf6711d6..d0d3c5f214f 100644 --- a/mod/quiz/yui/build/moodle-mod_quiz-dragdrop/moodle-mod_quiz-dragdrop-debug.js +++ b/mod/quiz/yui/build/moodle-mod_quiz-dragdrop/moodle-mod_quiz-dragdrop-debug.js @@ -316,7 +316,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('move', 'moodle'), CSS.EDITINGMOVE, CSS.ICONCLASS, true); this.samenodelabel = { identifier: 'dragtoafter', @@ -386,7 +385,9 @@ Y.extend(DRAGRESOURCE, M.core.dragdrop, { // Replace move icons var move = resourcesnode.one('a.' + CSS.EDITINGMOVE); if (move) { - move.replace(this.resourcedraghandle.cloneNode(true)); + var resourcedraghandle = this.get_drag_handle(M.util.get_string('move', 'moodle'), + CSS.EDITINGMOVE, CSS.ICONCLASS, true); + move.replace(resourcedraghandle); } }, this); }, diff --git a/mod/quiz/yui/build/moodle-mod_quiz-dragdrop/moodle-mod_quiz-dragdrop-min.js b/mod/quiz/yui/build/moodle-mod_quiz-dragdrop/moodle-mod_quiz-dragdrop-min.js index 141e45af80f..0640ba0a9a8 100644 --- a/mod/quiz/yui/build/moodle-mod_quiz-dragdrop/moodle-mod_quiz-dragdrop-min.js +++ b/mod/quiz/yui/build/moodle-mod_quiz-dragdrop/moodle-mod_quiz-dragdrop-min.js @@ -1,2 +1,2 @@ -YUI.add("moodle-mod_quiz-dragdrop",function(e,t){var n={ACTIONAREA:".actions",ACTIVITY:"activity",ACTIVITYINSTANCE:"activityinstance",CONTENT:"content",COURSECONTENT:"mod-quiz-edit-content",EDITINGMOVE:"editing_move",ICONCLASS:"iconsmall",JUMPMENU:"jumpmenu",LEFT:"left",LIGHTBOX:"lightbox",MOVEDOWN:"movedown",MOVEUP:"moveup",PAGE:"page",PAGECONTENT:"page-content",RIGHT:"right",SECTION:"slots",SECTIONADDMENUS:"section_add_menus",SECTIONHANDLE:"section-handle",SLOTS:"slots",SUMMARY:"summary",SECTIONDRAGGABLE:"sectiondraggable"},r={PAGE:"li.page",SLOT:"li.slot"},i=function(){i.superclass.constructor.apply(this,arguments)};e.extend(i,M.core.dragdrop,{sectionlistselector:null,initializer:function(){this.groups=[n.SECTIONDRAGGABLE],this.samenodeclass="section",this.parentnodeclass="slots";if(e.Node.one("."+n.JUMPMENU))return!1;this.sectionlistselector="li.section";if(this.sectionlistselector){this.sectionlistselector="."+n.COURSECONTENT+" "+this.sectionlistselector,this.setup_for_section(this.sectionlistselector);var t=new e.DD.Delegate({container:"."+n.COURSECONTENT,nodes:"."+n.SECTIONDRAGGABLE,target:!0,handles:["."+n.LEFT],dragConfig:{groups:this.groups}});t.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),t.dd.plug(e.Plugin.DDConstrained,{constrain:"#"+n.PAGECONTENT,stickY:!0}),t.dd.plug(e.Plugin.DDWinScroll)}},setup_for_section:function(t){e.Node.all(t).each(function(t){var r=e.Moodle.core_course.util.section.getId(t);if(r>0){var i=t.one("."+n.RIGHT+" a."+n.MOVEDOWN),s=t.one("."+n.RIGHT+" a."+n.MOVEUP),o=M.util.get_string("movesection","moodle",r),u=t.one("."+n.LEFT);(i||s)&&u&&(u.setStyle("cursor","move"),u.appendChild(this.get_drag_handle(o,n.SECTIONHANDLE,"icon",!0)),s&&s.remove(),i&&i.remove(),t.addClass(n.SECTIONDRAGGABLE))}},this)},drag_start:function(t){var r=t.target,i=e.Node.create('
      '),s=e.Node.create('
        ');s.setStyle("margin",0),s.setContent(r.get("node").get("innerHTML")),i.appendChild(s),r.get("dragNode").setContent(i),r.get("dragNode").addClass(n.COURSECONTENT)},drag_dropmiss:function(e){this.drop_hit(e)},get_section_index:function(t){var r="."+n.COURSECONTENT+" li.section",i=e.all(r),s=i.indexOf(t),o=i.indexOf(e.one("#section-0"));return s-o},drop_hit:function(t){var r=t.drag,i=r.get("node"),s=e.Moodle.core_course.util.section.getId(i),o=s,u=this.get_section_index(i),a=u;if(s===u)return;o>a&&(o=u,a=s),r.get("dragNode").removeClass(n.COURSECONTENT);var f=e.Node.all(this.sectionlistselector),l=M.util.add_lightbox(e,i),c={},h=this.get("config").pageparams,p;for(p in h){if(!h.hasOwnProperty(p))continue;c[p]=h[p]}c.sesskey=M.cfg.sesskey,c.courseid=this.get("courseid"),c.quizid=this.get("quizid"),c["class"]="section",c.field="move",c.id=s,c.value=u;var d=M.cfg.wwwroot+this.get("ajaxurl");e.io(d,{method:"POST",data:c,on:{start:function(){l.show()},success:function(t,n){try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r),M.mod_quiz.edit.process_sections(e,f,r,o,a)}catch(i){}var s,u=!1;do{u=!1;for(s=o;s<=a;s++)if(e.Moodle.core_course.util.section.getId(f.item(s-1))>e.Moodle.core_course.util.section.getId(f.item(s))){var c=f.item(s-1).get("id");f.item(s-1).set("id",f.item(s).get("id")),f.item(s).set("id",c),M.mod_quiz.edit.swap_sections(e,s-1,s),u=!0}a-=1}while(u);window.setTimeout(function(){l.hide()},250)},failure:function(e,t){this.ajax_failure(t),l.hide()}},context:this})}},{NAME:"mod_quiz-dragdrop-section",ATTRS:{courseid:{value:null},quizid:{value:null},ajaxurl:{value:0},config:{value:0}}}),M.mod_quiz=M.mod_quiz||{},M.mod_quiz.init_section_dragdrop=function(e){new i(e)};var s=function(){s.superclass.constructor.apply(this,arguments)};e.extend(s,M.core.dragdrop,{initializer:function(){this.groups=["resource"],this.samenodeclass=n.ACTIVITY,this.parentnodeclass=n.SECTION,this.resourcedraghandle=this.get_drag_handle(M.util.get_string("move","moodle"),n.EDITINGMOVE,n.ICONCLASS,!0),this.samenodelabel={identifier:"dragtoafter",component:"quiz"},this.parentnodelabel={identifier:"dragtostart",component:"quiz"},this.setup_for_section();var t="li."+n.ACTIVITY,r=new e.DD.Delegate({container:"."+n.COURSECONTENT,nodes:t,target:!0,handles:["."+n.EDITINGMOVE],dragConfig:{groups:this.groups}});r.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1,cloneNode:!0}),r.dd.plug(e.Plugin.DDConstrained,{constrain:"#"+n.SLOTS}),r.dd.plug(e.Plugin.DDWinScroll),M.mod_quiz.quizbase.register_module(this),M.mod_quiz.dragres=this},setup_for_section:function(){e.Node.all(".mod-quiz-edit-content ul.slots ul.section").each(function(t){t.setAttribute("data-draggroups",this.groups.join(" ")),new e.DD.Drop({node:t,groups:this.groups,padding:"20 0 20 0"}),this.setup_for_resource("li.activity")},this)},setup_for_resource:function(t){e.Node.all(t).each(function(e){var t=e.one("a."+n.EDITINGMOVE);t&&t.replace(this.resourcedraghandle.cloneNode(!0))},this)},drag_start:function(e){var t=e.target;t.get("dragNode").setContent(t.get("node").get("innerHTML")),t.get("dragNode").all("img.iconsmall").setStyle("vertical-align","baseline")},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(t){var i=t.drag,s=i.get("node"),o=t.drop.get("node"),u=s.one(n.ACTIONAREA),a=M.util.add_spinner(e,u),f={},l=this.get("config").pageparams,c;for(c in l)f[c]=l[c];f.sesskey=M.cfg.sesskey,f.courseid=this.get("courseid"),f.quizid=this.get("quizid"),f["class"]="resource",f.field="move",f.id=Number(e.Moodle.mod_quiz.util.slot.getId(s)),f.sectionId=e.Moodle.core_course.util.section.getId(o.ancestor("li.section",!0));var h=s.previous(r.SLOT);h&&(f.previousid=Number(e.Moodle.mod_quiz.util.slot.getId(h)));var p=s.previous(r.PAGE);p&&(f.page=Number(e.Moodle.mod_quiz.util.page.getId(p)));var d=M.cfg.wwwroot+this.get("ajaxurl");e.io(d,{method:"POST",data:f,on:{start:function(){this.lock_drag_handle(i,n.EDITINGMOVE),a.show()},success:function(t,r){var o=e.JSON.parse(r.responseText),u={element:s,visible:o.visible};M.mod_quiz.quizbase.invoke_function("set_visibility_resource_ui",u),this.unlock_drag_handle -(i,n.EDITINGMOVE),window.setTimeout(function(){a.hide()},250),M.mod_quiz.resource_toolbox.reorganise_edit_page()},failure:function(e,t){this.ajax_failure(t),this.unlock_drag_handle(i,n.SECTIONHANDLE),a.hide(),window.location.reload(!0)}},context:this})},global_drop_over:function(e){if(!e.drop||!e.drop.inGroup(this.groups))return;var t=e.drag.get("node"),n=e.drop.get("node");this.lastdroptarget=e.drop;if(n.hasClass(this.samenodeclass)){var r;this.goingup?r="before":r="after",n.insert(t,r)}else(n.hasClass(this.parentnodeclass)||n.test('[data-droptarget="1"]'))&&!n.contains(t)&&(this.goingup?n.append(t):n.prepend(t));this.drop_over(e)}},{NAME:"mod_quiz-dragdrop-resource",ATTRS:{courseid:{value:null},quizid:{value:null},ajaxurl:{value:0},config:{value:0}}}),M.mod_quiz=M.mod_quiz||{},M.mod_quiz.init_resource_dragdrop=function(e){new s(e)}},"@VERSION@",{requires:["base","node","io","dom","dd","dd-scroll","moodle-core-dragdrop","moodle-core-notification","moodle-mod_quiz-quizbase","moodle-mod_quiz-util-base","moodle-mod_quiz-util-page","moodle-mod_quiz-util-slot","moodle-course-util"]}); +YUI.add("moodle-mod_quiz-dragdrop",function(e,t){var n={ACTIONAREA:".actions",ACTIVITY:"activity",ACTIVITYINSTANCE:"activityinstance",CONTENT:"content",COURSECONTENT:"mod-quiz-edit-content",EDITINGMOVE:"editing_move",ICONCLASS:"iconsmall",JUMPMENU:"jumpmenu",LEFT:"left",LIGHTBOX:"lightbox",MOVEDOWN:"movedown",MOVEUP:"moveup",PAGE:"page",PAGECONTENT:"page-content",RIGHT:"right",SECTION:"slots",SECTIONADDMENUS:"section_add_menus",SECTIONHANDLE:"section-handle",SLOTS:"slots",SUMMARY:"summary",SECTIONDRAGGABLE:"sectiondraggable"},r={PAGE:"li.page",SLOT:"li.slot"},i=function(){i.superclass.constructor.apply(this,arguments)};e.extend(i,M.core.dragdrop,{sectionlistselector:null,initializer:function(){this.groups=[n.SECTIONDRAGGABLE],this.samenodeclass="section",this.parentnodeclass="slots";if(e.Node.one("."+n.JUMPMENU))return!1;this.sectionlistselector="li.section";if(this.sectionlistselector){this.sectionlistselector="."+n.COURSECONTENT+" "+this.sectionlistselector,this.setup_for_section(this.sectionlistselector);var t=new e.DD.Delegate({container:"."+n.COURSECONTENT,nodes:"."+n.SECTIONDRAGGABLE,target:!0,handles:["."+n.LEFT],dragConfig:{groups:this.groups}});t.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1}),t.dd.plug(e.Plugin.DDConstrained,{constrain:"#"+n.PAGECONTENT,stickY:!0}),t.dd.plug(e.Plugin.DDWinScroll)}},setup_for_section:function(t){e.Node.all(t).each(function(t){var r=e.Moodle.core_course.util.section.getId(t);if(r>0){var i=t.one("."+n.RIGHT+" a."+n.MOVEDOWN),s=t.one("."+n.RIGHT+" a."+n.MOVEUP),o=M.util.get_string("movesection","moodle",r),u=t.one("."+n.LEFT);(i||s)&&u&&(u.setStyle("cursor","move"),u.appendChild(this.get_drag_handle(o,n.SECTIONHANDLE,"icon",!0)),s&&s.remove(),i&&i.remove(),t.addClass(n.SECTIONDRAGGABLE))}},this)},drag_start:function(t){var r=t.target,i=e.Node.create('
          '),s=e.Node.create('
            ');s.setStyle("margin",0),s.setContent(r.get("node").get("innerHTML")),i.appendChild(s),r.get("dragNode").setContent(i),r.get("dragNode").addClass(n.COURSECONTENT)},drag_dropmiss:function(e){this.drop_hit(e)},get_section_index:function(t){var r="."+n.COURSECONTENT+" li.section",i=e.all(r),s=i.indexOf(t),o=i.indexOf(e.one("#section-0"));return s-o},drop_hit:function(t){var r=t.drag,i=r.get("node"),s=e.Moodle.core_course.util.section.getId(i),o=s,u=this.get_section_index(i),a=u;if(s===u)return;o>a&&(o=u,a=s),r.get("dragNode").removeClass(n.COURSECONTENT);var f=e.Node.all(this.sectionlistselector),l=M.util.add_lightbox(e,i),c={},h=this.get("config").pageparams,p;for(p in h){if(!h.hasOwnProperty(p))continue;c[p]=h[p]}c.sesskey=M.cfg.sesskey,c.courseid=this.get("courseid"),c.quizid=this.get("quizid"),c["class"]="section",c.field="move",c.id=s,c.value=u;var d=M.cfg.wwwroot+this.get("ajaxurl");e.io(d,{method:"POST",data:c,on:{start:function(){l.show()},success:function(t,n){try{var r=e.JSON.parse(n.responseText);r.error&&new M.core.ajaxException(r),M.mod_quiz.edit.process_sections(e,f,r,o,a)}catch(i){}var s,u=!1;do{u=!1;for(s=o;s<=a;s++)if(e.Moodle.core_course.util.section.getId(f.item(s-1))>e.Moodle.core_course.util.section.getId(f.item(s))){var c=f.item(s-1).get("id");f.item(s-1).set("id",f.item(s).get("id")),f.item(s).set("id",c),M.mod_quiz.edit.swap_sections(e,s-1,s),u=!0}a-=1}while(u);window.setTimeout(function(){l.hide()},250)},failure:function(e,t){this.ajax_failure(t),l.hide()}},context:this})}},{NAME:"mod_quiz-dragdrop-section",ATTRS:{courseid:{value:null},quizid:{value:null},ajaxurl:{value:0},config:{value:0}}}),M.mod_quiz=M.mod_quiz||{},M.mod_quiz.init_section_dragdrop=function(e){new i(e)};var s=function(){s.superclass.constructor.apply(this,arguments)};e.extend(s,M.core.dragdrop,{initializer:function(){this.groups=["resource"],this.samenodeclass=n.ACTIVITY,this.parentnodeclass=n.SECTION,this.samenodelabel={identifier:"dragtoafter",component:"quiz"},this.parentnodelabel={identifier:"dragtostart",component:"quiz"},this.setup_for_section();var t="li."+n.ACTIVITY,r=new e.DD.Delegate({container:"."+n.COURSECONTENT,nodes:t,target:!0,handles:["."+n.EDITINGMOVE],dragConfig:{groups:this.groups}});r.dd.plug(e.Plugin.DDProxy,{moveOnEnd:!1,cloneNode:!0}),r.dd.plug(e.Plugin.DDConstrained,{constrain:"#"+n.SLOTS}),r.dd.plug(e.Plugin.DDWinScroll),M.mod_quiz.quizbase.register_module(this),M.mod_quiz.dragres=this},setup_for_section:function(){e.Node.all(".mod-quiz-edit-content ul.slots ul.section").each(function(t){t.setAttribute("data-draggroups",this.groups.join(" ")),new e.DD.Drop({node:t,groups:this.groups,padding:"20 0 20 0"}),this.setup_for_resource("li.activity")},this)},setup_for_resource:function(t){e.Node.all(t).each(function(e){var t=e.one("a."+n.EDITINGMOVE);if(t){var r=this.get_drag_handle(M.util.get_string("move","moodle"),n.EDITINGMOVE,n.ICONCLASS,!0);t.replace(r)}},this)},drag_start:function(e){var t=e.target;t.get("dragNode").setContent(t.get("node").get("innerHTML")),t.get("dragNode").all("img.iconsmall").setStyle("vertical-align","baseline")},drag_dropmiss:function(e){this.drop_hit(e)},drop_hit:function(t){var i=t.drag,s=i.get("node"),o=t.drop.get("node"),u=s.one(n.ACTIONAREA),a=M.util.add_spinner(e,u),f={},l=this.get("config").pageparams,c;for(c in l)f[c]=l[c];f.sesskey=M.cfg.sesskey,f.courseid=this.get("courseid"),f.quizid=this.get("quizid"),f["class"]="resource",f.field="move",f.id=Number(e.Moodle.mod_quiz.util.slot.getId(s)),f.sectionId=e.Moodle.core_course.util.section.getId(o.ancestor("li.section",!0));var h=s.previous(r.SLOT);h&&(f.previousid=Number(e.Moodle.mod_quiz.util.slot.getId(h)));var p=s.previous(r.PAGE);p&&(f.page=Number(e.Moodle.mod_quiz.util.page.getId(p)));var d=M.cfg.wwwroot+this.get("ajaxurl");e.io(d,{method:"POST",data:f,on:{start:function(){this.lock_drag_handle(i,n.EDITINGMOVE),a.show()},success:function(t,r){var o=e.JSON.parse(r.responseText),u={element:s,visible:o.visible};M.mod_quiz.quizbase.invoke_function("set_visibility_resource_ui",u),this.unlock_drag_handle(i,n.EDITINGMOVE),window.setTimeout(function(){a. +hide()},250),M.mod_quiz.resource_toolbox.reorganise_edit_page()},failure:function(e,t){this.ajax_failure(t),this.unlock_drag_handle(i,n.SECTIONHANDLE),a.hide(),window.location.reload(!0)}},context:this})},global_drop_over:function(e){if(!e.drop||!e.drop.inGroup(this.groups))return;var t=e.drag.get("node"),n=e.drop.get("node");this.lastdroptarget=e.drop;if(n.hasClass(this.samenodeclass)){var r;this.goingup?r="before":r="after",n.insert(t,r)}else(n.hasClass(this.parentnodeclass)||n.test('[data-droptarget="1"]'))&&!n.contains(t)&&(this.goingup?n.append(t):n.prepend(t));this.drop_over(e)}},{NAME:"mod_quiz-dragdrop-resource",ATTRS:{courseid:{value:null},quizid:{value:null},ajaxurl:{value:0},config:{value:0}}}),M.mod_quiz=M.mod_quiz||{},M.mod_quiz.init_resource_dragdrop=function(e){new s(e)}},"@VERSION@",{requires:["base","node","io","dom","dd","dd-scroll","moodle-core-dragdrop","moodle-core-notification","moodle-mod_quiz-quizbase","moodle-mod_quiz-util-base","moodle-mod_quiz-util-page","moodle-mod_quiz-util-slot","moodle-course-util"]}); diff --git a/mod/quiz/yui/build/moodle-mod_quiz-dragdrop/moodle-mod_quiz-dragdrop.js b/mod/quiz/yui/build/moodle-mod_quiz-dragdrop/moodle-mod_quiz-dragdrop.js index 179c460dbad..abba2623c0a 100644 --- a/mod/quiz/yui/build/moodle-mod_quiz-dragdrop/moodle-mod_quiz-dragdrop.js +++ b/mod/quiz/yui/build/moodle-mod_quiz-dragdrop/moodle-mod_quiz-dragdrop.js @@ -310,7 +310,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('move', 'moodle'), CSS.EDITINGMOVE, CSS.ICONCLASS, true); this.samenodelabel = { identifier: 'dragtoafter', @@ -380,7 +379,9 @@ Y.extend(DRAGRESOURCE, M.core.dragdrop, { // Replace move icons var move = resourcesnode.one('a.' + CSS.EDITINGMOVE); if (move) { - move.replace(this.resourcedraghandle.cloneNode(true)); + var resourcedraghandle = this.get_drag_handle(M.util.get_string('move', 'moodle'), + CSS.EDITINGMOVE, CSS.ICONCLASS, true); + move.replace(resourcedraghandle); } }, this); }, diff --git a/mod/quiz/yui/src/dragdrop/js/resource.js b/mod/quiz/yui/src/dragdrop/js/resource.js index d51131def60..c23f8353519 100644 --- a/mod/quiz/yui/src/dragdrop/js/resource.js +++ b/mod/quiz/yui/src/dragdrop/js/resource.js @@ -15,7 +15,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('move', 'moodle'), CSS.EDITINGMOVE, CSS.ICONCLASS, true); this.samenodelabel = { identifier: 'dragtoafter', @@ -85,7 +84,9 @@ Y.extend(DRAGRESOURCE, M.core.dragdrop, { // Replace move icons var move = resourcesnode.one('a.' + CSS.EDITINGMOVE); if (move) { - move.replace(this.resourcedraghandle.cloneNode(true)); + var resourcedraghandle = this.get_drag_handle(M.util.get_string('move', 'moodle'), + CSS.EDITINGMOVE, CSS.ICONCLASS, true); + move.replace(resourcedraghandle); } }, this); },