diff --git a/.eslintrc b/.eslintrc index 31bd8ab307e..03dc85aa6e0 100644 --- a/.eslintrc +++ b/.eslintrc @@ -40,7 +40,7 @@ 'no-unreachable': 'warn', 'no-unsafe-finally': 'error', 'use-isnan': 'error', - 'valid-jsdoc': ['warn', { 'requireReturn': false }], + 'valid-jsdoc': ['warn', { 'requireReturn': false, 'requireParamDescription': false, 'requireReturnDescription': false }], 'valid-typeof': 'error', // === Best Practices === @@ -115,7 +115,7 @@ 'max-params': 'off', 'max-statements': 'off', 'max-statements-per-line': 'off', - 'new-cap': 'warn', + 'new-cap': ['warn', { 'properties': false }], 'new-parens': 'warn', 'newline-after-var': 'off', 'newline-before-return': 'off', diff --git a/admin/tool/lp/amd/build/competencies.min.js b/admin/tool/lp/amd/build/competencies.min.js index cf57df2f6fc..c14f7712e08 100644 --- a/admin/tool/lp/amd/build/competencies.min.js +++ b/admin/tool/lp/amd/build/competencies.min.js @@ -1 +1 @@ -define(["jquery","core/notification","core/ajax","core/templates","core/str","tool_lp/competencypicker","tool_lp/dragdrop-reorder"],function(a,b,c,d,e,f,g){var h=function(b,c,d){this.itemid=b,this.itemtype=c,this.pageContextId=d,this.pickerInstance=null,a('[data-region="actions"] button').prop("disabled",!1),this.registerEvents(),this.registerDragDrop()};return h.prototype.registerDragDrop=function(){var a=this;e.get_string("movecompetency","tool_lp").done(function(b){g.dragdrop("movecompetency",b,{identifier:"movecompetency",component:"tool_lp"},{identifier:"movecompetencyafter",component:"tool_lp"},"drag-samenode","drag-parentnode","drag-handlecontainer",function(b,c){a.handleDrop.call(a,b,c)})}).fail(b.exception)},h.prototype.handleDrop=function(d,e){var f=a(d).data("id"),g=a(e).data("id"),h=this,i=[];if("course"==h.itemtype)i=c.call([{methodname:"core_competency_reorder_course_competency",args:{courseid:h.itemid,competencyidfrom:f,competencyidto:g}}]);else if("template"==h.itemtype)i=c.call([{methodname:"core_competency_reorder_template_competency",args:{templateid:h.itemid,competencyidfrom:f,competencyidto:g}}]);else{if("plan"!=h.itemtype)return null;i=c.call([{methodname:"core_competency_reorder_plan_competency",args:{planid:h.itemid,competencyidfrom:f,competencyidto:g}}])}i[0].fail(b.exception)},h.prototype.pickCompetency=function(){var e,g,h,i,j=this;j.pickerInstance||(("template"===j.itemtype||"course"===j.itemtype)&&(i="parents"),j.pickerInstance=new f(j.pageContextId,!1,i),j.pickerInstance.on("save",function(f,i){var k=i.competencyIds;"course"===j.itemtype?(e=[],a.each(k,function(a,b){e.push({methodname:"core_competency_add_competency_to_course",args:{courseid:j.itemid,competencyid:b}})}),e.push({methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:j.itemid}}),g="tool_lp/course_competencies_page",h="coursecompetenciespage"):"template"===j.itemtype?(e=[],a.each(k,function(a,b){e.push({methodname:"core_competency_add_competency_to_template",args:{templateid:j.itemid,competencyid:b}})}),e.push({methodname:"tool_lp_data_for_template_competencies_page",args:{templateid:j.itemid,pagecontext:{contextid:j.pageContextId}}}),g="tool_lp/template_competencies_page",h="templatecompetenciespage"):"plan"===j.itemtype&&(e=[],a.each(k,function(a,b){e.push({methodname:"core_competency_add_competency_to_plan",args:{planid:j.itemid,competencyid:b}})}),e.push({methodname:"tool_lp_data_for_plan_page",args:{planid:j.itemid}}),g="tool_lp/plan_page",h="plan-page"),c.call(e)[e.length-1].then(function(b){return d.render(g,b).done(function(b,c){a('[data-region="'+h+'"]').replaceWith(b),d.runTemplateJS(c)})},b.exception)})),j.pickerInstance.display()},h.prototype.doDelete=function(e){var f=this,g=[],h="",i="";"course"==f.itemtype?(g=c.call([{methodname:"core_competency_remove_competency_from_course",args:{courseid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:f.itemid}}]),h="tool_lp/course_competencies_page",i="coursecompetenciespage"):"template"==f.itemtype?(g=c.call([{methodname:"core_competency_remove_competency_from_template",args:{templateid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_template_competencies_page",args:{templateid:f.itemid,pagecontext:{contextid:f.pageContextId}}}]),h="tool_lp/template_competencies_page",i="templatecompetenciespage"):"plan"==f.itemtype&&(g=c.call([{methodname:"core_competency_remove_competency_from_plan",args:{planid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_plan_page",args:{planid:f.itemid}}]),h="tool_lp/plan_page",i="plan-page"),g[1].done(function(c){d.render(h,c).done(function(b,c){a('[data-region="'+i+'"]').replaceWith(b),d.runTemplateJS(c)}).fail(b.exception)}).fail(b.exception)},h.prototype.deleteHandler=function(a){var d,f=this,g=[];if("course"==f.itemtype)d="unlinkcompetencycourse";else if("template"==f.itemtype)d="unlinkcompetencytemplate";else{if("plan"!=f.itemtype)return;d="unlinkcompetencyplan"}g=c.call([{methodname:"core_competency_read_competency",args:{id:a}}]),g[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:d,component:"tool_lp",param:c.shortname},{key:"confirm",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(c){b.confirm(c[0],c[1],c[2],c[3],function(){f.doDelete(a)})}).fail(b.exception)}).fail(b.exception)},h.prototype.registerEvents=function(){var e=this;"course"==e.itemtype&&a('[data-region="coursecompetenciespage"]').on("change",'select[data-field="ruleoutcome"]',function(f){var g=[],h="tool_lp/course_competencies_page",i="coursecompetenciespage",j=a(f.target).data("id"),k=a(f.target).val();g=c.call([{methodname:"core_competency_set_course_competency_ruleoutcome",args:{coursecompetencyid:j,ruleoutcome:k}},{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:e.itemid}}]),g[1].done(function(c){d.render(h,c).done(function(b,c){a('[data-region="'+i+'"]').replaceWith(b),d.runTemplateJS(c)}).fail(b.exception)}).fail(b.exception)}),a('[data-region="actions"] button').click(function(a){a.preventDefault(),e.pickCompetency()}),a('[data-action="delete-competency-link"]').click(function(b){b.preventDefault();var c=a(b.target).closest("[data-id]").data("id");e.deleteHandler(c)})},h}); \ No newline at end of file +define(["jquery","core/notification","core/ajax","core/templates","core/str","tool_lp/competencypicker","tool_lp/dragdrop-reorder"],function(a,b,c,d,e,f,g){var h=function(b,c,d){this.itemid=b,this.itemtype=c,this.pageContextId=d,this.pickerInstance=null,a('[data-region="actions"] button').prop("disabled",!1),this.registerEvents(),this.registerDragDrop()};return h.prototype.registerDragDrop=function(){var a=this;e.get_string("movecompetency","tool_lp").done(function(b){g.dragdrop("movecompetency",b,{identifier:"movecompetency",component:"tool_lp"},{identifier:"movecompetencyafter",component:"tool_lp"},"drag-samenode","drag-parentnode","drag-handlecontainer",function(b,c){a.handleDrop.call(a,b,c)})}).fail(b.exception)},h.prototype.handleDrop=function(d,e){var f=a(d).data("id"),g=a(e).data("id"),h=this,i=[];if("course"==h.itemtype)i=c.call([{methodname:"core_competency_reorder_course_competency",args:{courseid:h.itemid,competencyidfrom:f,competencyidto:g}}]);else if("template"==h.itemtype)i=c.call([{methodname:"core_competency_reorder_template_competency",args:{templateid:h.itemid,competencyidfrom:f,competencyidto:g}}]);else{if("plan"!=h.itemtype)return;i=c.call([{methodname:"core_competency_reorder_plan_competency",args:{planid:h.itemid,competencyidfrom:f,competencyidto:g}}])}i[0].fail(b.exception)},h.prototype.pickCompetency=function(){var e,g,h,i,j=this;j.pickerInstance||(("template"===j.itemtype||"course"===j.itemtype)&&(i="parents"),j.pickerInstance=new f(j.pageContextId,!1,i),j.pickerInstance.on("save",function(f,i){var k=i.competencyIds;"course"===j.itemtype?(e=[],a.each(k,function(a,b){e.push({methodname:"core_competency_add_competency_to_course",args:{courseid:j.itemid,competencyid:b}})}),e.push({methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:j.itemid}}),g="tool_lp/course_competencies_page",h="coursecompetenciespage"):"template"===j.itemtype?(e=[],a.each(k,function(a,b){e.push({methodname:"core_competency_add_competency_to_template",args:{templateid:j.itemid,competencyid:b}})}),e.push({methodname:"tool_lp_data_for_template_competencies_page",args:{templateid:j.itemid,pagecontext:{contextid:j.pageContextId}}}),g="tool_lp/template_competencies_page",h="templatecompetenciespage"):"plan"===j.itemtype&&(e=[],a.each(k,function(a,b){e.push({methodname:"core_competency_add_competency_to_plan",args:{planid:j.itemid,competencyid:b}})}),e.push({methodname:"tool_lp_data_for_plan_page",args:{planid:j.itemid}}),g="tool_lp/plan_page",h="plan-page"),c.call(e)[e.length-1].then(function(b){return d.render(g,b).done(function(b,c){a('[data-region="'+h+'"]').replaceWith(b),d.runTemplateJS(c)})},b.exception)})),j.pickerInstance.display()},h.prototype.doDelete=function(e){var f=this,g=[],h="",i="";"course"==f.itemtype?(g=c.call([{methodname:"core_competency_remove_competency_from_course",args:{courseid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:f.itemid}}]),h="tool_lp/course_competencies_page",i="coursecompetenciespage"):"template"==f.itemtype?(g=c.call([{methodname:"core_competency_remove_competency_from_template",args:{templateid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_template_competencies_page",args:{templateid:f.itemid,pagecontext:{contextid:f.pageContextId}}}]),h="tool_lp/template_competencies_page",i="templatecompetenciespage"):"plan"==f.itemtype&&(g=c.call([{methodname:"core_competency_remove_competency_from_plan",args:{planid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_plan_page",args:{planid:f.itemid}}]),h="tool_lp/plan_page",i="plan-page"),g[1].done(function(c){d.render(h,c).done(function(b,c){a('[data-region="'+i+'"]').replaceWith(b),d.runTemplateJS(c)}).fail(b.exception)}).fail(b.exception)},h.prototype.deleteHandler=function(a){var d,f=this,g=[];if("course"==f.itemtype)d="unlinkcompetencycourse";else if("template"==f.itemtype)d="unlinkcompetencytemplate";else{if("plan"!=f.itemtype)return;d="unlinkcompetencyplan"}g=c.call([{methodname:"core_competency_read_competency",args:{id:a}}]),g[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:d,component:"tool_lp",param:c.shortname},{key:"confirm",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(c){b.confirm(c[0],c[1],c[2],c[3],function(){f.doDelete(a)})}).fail(b.exception)}).fail(b.exception)},h.prototype.registerEvents=function(){var e=this;"course"==e.itemtype&&a('[data-region="coursecompetenciespage"]').on("change",'select[data-field="ruleoutcome"]',function(f){var g=[],h="tool_lp/course_competencies_page",i="coursecompetenciespage",j=a(f.target).data("id"),k=a(f.target).val();g=c.call([{methodname:"core_competency_set_course_competency_ruleoutcome",args:{coursecompetencyid:j,ruleoutcome:k}},{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:e.itemid}}]),g[1].done(function(c){d.render(h,c).done(function(b,c){a('[data-region="'+i+'"]').replaceWith(b),d.runTemplateJS(c)}).fail(b.exception)}).fail(b.exception)}),a('[data-region="actions"] button').click(function(a){a.preventDefault(),e.pickCompetency()}),a('[data-action="delete-competency-link"]').click(function(b){b.preventDefault();var c=a(b.target).closest("[data-id]").data("id");e.deleteHandler(c)})},h}); \ No newline at end of file diff --git a/admin/tool/lp/amd/build/tree.min.js b/admin/tool/lp/amd/build/tree.min.js index 4cc86111d55..899e3ce92be 100644 --- a/admin/tool/lp/amd/build/tree.min.js +++ b/admin/tool/lp/amd/build/tree.min.js @@ -1 +1 @@ -define(["jquery","core/url","core/log"],function(a,b,c){var d=a(''),e=a(''),f=function(b,c){this.treeRoot=a(b),this.multiSelect="undefined"==typeof c||c===!0,this.items=this.treeRoot.find("li"),this.expandAll=this.items.length<20,this.parents=this.treeRoot.find("li:has(ul)"),c&&this.treeRoot.attr("aria-multiselectable","true"),this.items.attr("aria-selected","false"),this.visibleItems=null,this.activeItem=null,this.lastActiveItem=null,this.keys={tab:9,enter:13,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,eight:56,asterisk:106},this.init(),this.bindEventHandlers()};return f.prototype.init=function(){this.parents.attr("aria-expanded","true"),this.parents.prepend(d.clone()),this.items.attr("role","tree-item"),this.items.attr("tabindex","-1"),this.parents.attr("role","group"),this.treeRoot.attr("role","tree"),this.visibleItems=this.treeRoot.find("li");var b=this;this.expandAll||(this.parents.each(function(){b.collapseGroup(a(this))}),this.expandGroup(this.parents.first()))},f.prototype.expandGroup=function(a){var b=a.children("ul");b.show().attr("aria-hidden","false"),a.attr("aria-expanded","true"),a.children("img").attr("src",d.attr("src")),this.visibleItems=this.treeRoot.find("li:visible")},f.prototype.collapseGroup=function(a){var b=a.children("ul");b.hide().attr("aria-hidden","true"),a.attr("aria-expanded","false"),a.children("img").attr("src",e.attr("src")),this.visibleItems=this.treeRoot.find("li:visible")},f.prototype.toggleGroup=function(a){"true"==a.attr("aria-expanded")?this.collapseGroup(a):this.expandGroup(a)},f.prototype.triggerChange=function(){var a=this.items.filter("[aria-selected=true]");this.multiSelect||(a=a.first()),this.treeRoot.trigger("selectionchanged",{selected:a})},f.prototype.multiSelectItem=function(b){if(this.multiSelect){if(null!==this.lastActiveItem){for(var c=this.visibleItems.index(this.lastActiveItem),d=this.visibleItems.index(this.activeItem),e=null;d>c;)e=a(this.visibleItems.get(c)),e.attr("aria-selected","true"),c++;for(;c>d;)e=a(this.visibleItems.get(c)),e.attr("aria-selected","true"),c--}}else this.items.attr("aria-selected","false");b.attr("aria-selected","true"),this.triggerChange()},f.prototype.selectItem=function(a){for(var b=a.parent();"tree"!=b.attr("role");)b=b.parent(),"false"==b.attr("aria-expanded")&&this.expandGroup(b),b=b.parent();this.items.attr("aria-selected","false"),a.attr("aria-selected","true"),this.triggerChange()},f.prototype.toggleItem=function(a){if(!this.multiSelect)return this.selectItem(a);var b=a.attr("aria-selected");b="true"===b?"false":"true",a.attr("aria-selected",b),this.triggerChange()},f.prototype.updateFocus=function(a){this.lastActiveItem=this.activeItem,this.activeItem=a;for(var b=a.parent();"tree"!=b.attr("role");)b=b.parent(),"false"==b.attr("aria-expanded")&&this.expandGroup(b),b=b.parent();this.items.attr("tabindex","-1"),a.attr("tabindex",0)},f.prototype.handleKeyDown=function(b,c){var d=this.visibleItems.index(b),e=null,f=c.shiftKey||c.ctrlKey||c.metaKey||c.altKey,g=this;switch(c.keyCode){case this.keys.home:return e=this.parents.first(),e.focus(),c.shiftKey?this.multiSelectItem(e):f||this.selectItem(e),c.stopPropagation(),!1;case this.keys.end:return e=this.visibleItems.last(),e.focus(),c.shiftKey?this.multiSelectItem(e):f||this.selectItem(e),c.stopPropagation(),!1;case this.keys.enter:case this.keys.space:return c.shiftKey?this.multiSelectItem(b):c.metaKey||c.ctrlKey?this.toggleItem(b):this.selectItem(b),c.stopPropagation(),!1;case this.keys.left:if(b.has("ul")&&"true"==b.attr("aria-expanded"))this.collapseGroup(b);else{var h=b.parent(),i=h.parent();i.is("li")&&(i.focus(),c.shiftKey?this.multiSelectItem(i):f||this.selectItem(i))}return c.stopPropagation(),!1;case this.keys.right:return b.has("ul")&&"false"==b.attr("aria-expanded")?this.expandGroup(b):(e=b.children("ul").children("li").first(),e.length>0&&(e.focus(),c.shiftKey?this.multiSelectItem(e):f||this.selectItem(e))),c.stopPropagation(),!1;case this.keys.up:if(d>0){var j=this.visibleItems.eq(d-1);j.focus(),c.shiftKey?this.multiSelectItem(j):f||this.selectItem(j)}return c.stopPropagation(),!1;case this.keys.down:if(d'),e=a(''),f=function(b,c){this.treeRoot=a(b),this.multiSelect="undefined"==typeof c||c===!0,this.items=this.treeRoot.find("li"),this.expandAll=this.items.length<20,this.parents=this.treeRoot.find("li:has(ul)"),c&&this.treeRoot.attr("aria-multiselectable","true"),this.items.attr("aria-selected","false"),this.visibleItems=null,this.activeItem=null,this.lastActiveItem=null,this.keys={tab:9,enter:13,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,eight:56,asterisk:106},this.init(),this.bindEventHandlers()};return f.prototype.init=function(){this.parents.attr("aria-expanded","true"),this.parents.prepend(d.clone()),this.items.attr("role","tree-item"),this.items.attr("tabindex","-1"),this.parents.attr("role","group"),this.treeRoot.attr("role","tree"),this.visibleItems=this.treeRoot.find("li");var b=this;this.expandAll||(this.parents.each(function(){b.collapseGroup(a(this))}),this.expandGroup(this.parents.first()))},f.prototype.expandGroup=function(a){var b=a.children("ul");b.show().attr("aria-hidden","false"),a.attr("aria-expanded","true"),a.children("img").attr("src",d.attr("src")),this.visibleItems=this.treeRoot.find("li:visible")},f.prototype.collapseGroup=function(a){var b=a.children("ul");b.hide().attr("aria-hidden","true"),a.attr("aria-expanded","false"),a.children("img").attr("src",e.attr("src")),this.visibleItems=this.treeRoot.find("li:visible")},f.prototype.toggleGroup=function(a){"true"==a.attr("aria-expanded")?this.collapseGroup(a):this.expandGroup(a)},f.prototype.triggerChange=function(){var a=this.items.filter("[aria-selected=true]");this.multiSelect||(a=a.first()),this.treeRoot.trigger("selectionchanged",{selected:a})},f.prototype.multiSelectItem=function(b){if(this.multiSelect){if(null!==this.lastActiveItem){for(var c=this.visibleItems.index(this.lastActiveItem),d=this.visibleItems.index(this.activeItem),e=null;d>c;)e=a(this.visibleItems.get(c)),e.attr("aria-selected","true"),c++;for(;c>d;)e=a(this.visibleItems.get(c)),e.attr("aria-selected","true"),c--}}else this.items.attr("aria-selected","false");b.attr("aria-selected","true"),this.triggerChange()},f.prototype.selectItem=function(a){for(var b=a.parent();"tree"!=b.attr("role");)b=b.parent(),"false"==b.attr("aria-expanded")&&this.expandGroup(b),b=b.parent();this.items.attr("aria-selected","false"),a.attr("aria-selected","true"),this.triggerChange()},f.prototype.toggleItem=function(a){if(!this.multiSelect)return void this.selectItem(a);var b=a.attr("aria-selected");b="true"===b?"false":"true",a.attr("aria-selected",b),this.triggerChange()},f.prototype.updateFocus=function(a){this.lastActiveItem=this.activeItem,this.activeItem=a;for(var b=a.parent();"tree"!=b.attr("role");)b=b.parent(),"false"==b.attr("aria-expanded")&&this.expandGroup(b),b=b.parent();this.items.attr("tabindex","-1"),a.attr("tabindex",0)},f.prototype.handleKeyDown=function(b,c){var d=this.visibleItems.index(b),e=null,f=c.shiftKey||c.ctrlKey||c.metaKey||c.altKey,g=this;switch(c.keyCode){case this.keys.home:return e=this.parents.first(),e.focus(),c.shiftKey?this.multiSelectItem(e):f||this.selectItem(e),c.stopPropagation(),!1;case this.keys.end:return e=this.visibleItems.last(),e.focus(),c.shiftKey?this.multiSelectItem(e):f||this.selectItem(e),c.stopPropagation(),!1;case this.keys.enter:case this.keys.space:return c.shiftKey?this.multiSelectItem(b):c.metaKey||c.ctrlKey?this.toggleItem(b):this.selectItem(b),c.stopPropagation(),!1;case this.keys.left:if(b.has("ul")&&"true"==b.attr("aria-expanded"))this.collapseGroup(b);else{var h=b.parent(),i=h.parent();i.is("li")&&(i.focus(),c.shiftKey?this.multiSelectItem(i):f||this.selectItem(i))}return c.stopPropagation(),!1;case this.keys.right:return b.has("ul")&&"false"==b.attr("aria-expanded")?this.expandGroup(b):(e=b.children("ul").children("li").first(),e.length>0&&(e.focus(),c.shiftKey?this.multiSelectItem(e):f||this.selectItem(e))),c.stopPropagation(),!1;case this.keys.up:if(d>0){var j=this.visibleItems.eq(d-1);j.focus(),c.shiftKey?this.multiSelectItem(j):f||this.selectItem(j)}return c.stopPropagation(),!1;case this.keys.down:if(d". * * @function parseTaxonomies - * @param {String} Comma separated list of taxonomies. + * @param {String} taxonomiesstr Comma separated list of taxonomies. * @return {Array} of level => taxonomystr */ var parseTaxonomies = function(taxonomiesstr) { diff --git a/admin/tool/lp/amd/src/competencydialogue.js b/admin/tool/lp/amd/src/competencydialogue.js index affcea68d2a..9902eed20b5 100644 --- a/admin/tool/lp/amd/src/competencydialogue.js +++ b/admin/tool/lp/amd/src/competencydialogue.js @@ -43,12 +43,13 @@ define(['jquery', * */ var Competencydialogue = function() { + // Intentionally left empty. }; /** * Log the competency viewed event. * - * @param {Number} The competency ID. + * @param {Number} competencyId The competency ID. * @method triggerCompetencyViewedEvent */ Competencydialogue.prototype.triggerCompetencyViewedEvent = function(competencyId) { @@ -112,7 +113,7 @@ define(['jquery', /** * The action on the click event. * - * @param {Event} event click + * @param {Event} e event click * @method clickEventHandler */ Competencydialogue.prototype.clickEventHandler = function(e) { @@ -135,6 +136,7 @@ define(['jquery', * Get a promise on data competency. * * @param {Number} competencyid + * @param {Object} options * @return {Promise} return promise on data request * @method getCompetencyDataPromise */ @@ -160,8 +162,6 @@ define(['jquery', * Initialise the competency dialogue module. * * Only the first call matters. - * - * @return {Void} */ init: function() { if (typeof instance !== 'undefined') { diff --git a/admin/tool/lp/amd/src/competencypicker.js b/admin/tool/lp/amd/src/competencypicker.js index d6247fe4e10..272d3e0418b 100644 --- a/admin/tool/lp/amd/src/competencypicker.js +++ b/admin/tool/lp/amd/src/competencypicker.js @@ -231,7 +231,10 @@ define(['jquery', competencyframeworkid: frameworkId }} ])[0].done(function(competencies) { - + /** + * @param {Object} parent + * @param {Array} competencies + */ function addCompetencyChildren(parent, competencies) { for (var i = 0; i < competencies.length; i++) { if (competencies[i].parentid == parent.id) { @@ -265,6 +268,7 @@ define(['jquery', * Find a node in the dialogue. * * @param {String} selector + * @return {JQuery} * @method _find */ Picker.prototype._find = function(selector) { @@ -275,6 +279,7 @@ define(['jquery', * Convenience method to get a framework object. * * @param {Number} fid The framework ID. + * @return {Object} * @method _getFramework */ Picker.prototype._getFramework = function(fid) { @@ -437,7 +442,7 @@ define(['jquery', * * This needs to be set after reset/close. * - * @params {Number[]} The IDs. + * @param {Number[]} ids The IDs. * @method _setDisallowedCompetencyIDs */ Picker.prototype.setDisallowedCompetencyIDs = function(ids) { @@ -448,7 +453,7 @@ define(['jquery', * Trigger an event. * * @param {String} type The type of event. - * @param {Object} The data to pass to the listeners. + * @param {Object} data The data to pass to the listeners. * @method _reset */ Picker.prototype._trigger = function(type, data) { diff --git a/admin/tool/lp/amd/src/competencypicker_user_plans.js b/admin/tool/lp/amd/src/competencypicker_user_plans.js index 7291829f135..b417b677376 100644 --- a/admin/tool/lp/amd/src/competencypicker_user_plans.js +++ b/admin/tool/lp/amd/src/competencypicker_user_plans.js @@ -39,8 +39,8 @@ define(['jquery', /** * Competency picker in plan class. * + * @param {Number} userId * @param {Number|false} singlePlan The ID of the plan when limited to one. - * @param {String} pageContextIncludes One of 'children', 'parents', 'self'. * @param {Boolean} multiSelect Support multi-select in the tree. */ var Picker = function(userId, singlePlan, multiSelect) { @@ -88,7 +88,7 @@ define(['jquery', * @param {Number} planId The planId. * @param {String} searchText Limit the competencies to those matching the text. * @method _fetchCompetencies - * @return {Promise} + * @return {Promise} The promise object. */ Picker.prototype._fetchCompetencies = function(planId, searchText) { var self = this; diff --git a/admin/tool/lp/amd/src/competencyruleconfig.js b/admin/tool/lp/amd/src/competencyruleconfig.js index 4894d3689f3..f207939f74e 100644 --- a/admin/tool/lp/amd/src/competencyruleconfig.js +++ b/admin/tool/lp/amd/src/competencyruleconfig.js @@ -70,7 +70,6 @@ define(['jquery', * * Triggered when a change occured. * - * @return {Void} * @method _afterChange * @protected */ @@ -87,9 +86,10 @@ define(['jquery', * * Triggered when a change occured in a specific rule config. * - * @return {Void} * @method _afterRuleConfigChange * @protected + * @param {Event} e + * @param {Rule} rule */ RuleConfig.prototype._afterRuleConfigChange = function(e, rule) { if (rule != this._getRule()) { @@ -102,7 +102,6 @@ define(['jquery', /** * After render hook. * - * @return {Promise} * @method _afterRender * @protected */ @@ -181,6 +180,7 @@ define(['jquery', * Find a node in the dialogue. * * @param {String} selector + * @return {JQuery} * @method _find * @protected */ @@ -444,7 +444,6 @@ define(['jquery', /** * Set up the instance. * - * @return {Void} * @method _setUp * @protected */ @@ -482,7 +481,6 @@ define(['jquery', /** * Called when the user switches outcome. * - * @return {Void} * @method _switchedOutcome * @protected */ @@ -507,7 +505,6 @@ define(['jquery', /** * Called when the user switches rule. * - * @return {Void} * @method _switchedRule * @protected */ @@ -535,7 +532,7 @@ define(['jquery', * Trigger an event. * * @param {String} type The type of event. - * @param {Object} The data to pass to the listeners. + * @param {Object} data The data to pass to the listeners. * @method _trigger * @protected */ diff --git a/admin/tool/lp/amd/src/course_competency_settings.js b/admin/tool/lp/amd/src/course_competency_settings.js index bff7349814e..1cc3933c173 100644 --- a/admin/tool/lp/amd/src/course_competency_settings.js +++ b/admin/tool/lp/amd/src/course_competency_settings.js @@ -57,7 +57,7 @@ define(['jquery', e.preventDefault(); templates.render('tool_lp/course_competency_settings', context).done(function(html) { - str.get_string('configurecoursecompetencysettings', 'tool_lp').done(function (title) { + str.get_string('configurecoursecompetencysettings', 'tool_lp').done(function(title) { this._dialogue = new Dialogue( title, html, diff --git a/admin/tool/lp/amd/src/dialogue.js b/admin/tool/lp/amd/src/dialogue.js index 882ee5b6054..04a570fc682 100644 --- a/admin/tool/lp/amd/src/dialogue.js +++ b/admin/tool/lp/amd/src/dialogue.js @@ -43,7 +43,7 @@ define(['core/yui'], function(Y) { wide = false; } - Y.use('moodle-core-notification', 'timers', function () { + Y.use('moodle-core-notification', 'timers', function() { var width = '480px'; if (wide) { width = '800px'; @@ -92,6 +92,7 @@ define(['core/yui'], function(Y) { /** * Get content. + * @return {node} */ dialogue.prototype.getContent = function() { return this.yuiDialogue.bodyNode.getDOMNode(); diff --git a/admin/tool/lp/amd/src/dragdrop-reorder.js b/admin/tool/lp/amd/src/dragdrop-reorder.js index d14c9ddf9aa..a94eb3017d9 100644 --- a/admin/tool/lp/amd/src/dragdrop-reorder.js +++ b/admin/tool/lp/amd/src/dragdrop-reorder.js @@ -70,8 +70,8 @@ define(['core/str', 'core/yui'], function(str, Y) { { key: 'emptydragdropregion', component: 'moodle' }, { key: 'movecontent', component: 'moodle' }, { key: 'tocontent', component: 'moodle' }, - ]).done( function () { - Y.use('moodle-tool_lp-dragdrop-reorder', function () { + ]).done(function() { + Y.use('moodle-tool_lp-dragdrop-reorder', function() { var context = { callback: callback diff --git a/admin/tool/lp/amd/src/event_base.js b/admin/tool/lp/amd/src/event_base.js index 1bda7edac9e..fe8433ccf38 100644 --- a/admin/tool/lp/amd/src/event_base.js +++ b/admin/tool/lp/amd/src/event_base.js @@ -48,7 +48,7 @@ define(['jquery'], function($) { * Trigger an event. * * @param {String} type The type of event. - * @param {Object} The data to pass to the listeners. + * @param {Object} data The data to pass to the listeners. * @method _trigger */ Base.prototype._trigger = function(type, data) { diff --git a/admin/tool/lp/amd/src/evidence_delete.js b/admin/tool/lp/amd/src/evidence_delete.js index 19a5534aabc..44698d1f8f6 100644 --- a/admin/tool/lp/amd/src/evidence_delete.js +++ b/admin/tool/lp/amd/src/evidence_delete.js @@ -35,7 +35,6 @@ define(['jquery', * * @param {String} triggerSelector The node on which the click will happen. * @param {String} containerSelector The parent node that will be removed and contains the evidence ID. - * @return {Void} */ var register = function(triggerSelector, containerSelector) { if (typeof selectors[triggerSelector] !== 'undefined') { @@ -62,7 +61,7 @@ define(['jquery', { key: 'areyousure', component: 'moodle' }, { key: 'delete', component: 'moodle' }, { key: 'cancel', component: 'moodle' } - ]).done(function (strings) { + ]).done(function(strings) { Notification.confirm( strings[0], // Confirm. strings[1], // Are you sure? diff --git a/admin/tool/lp/amd/src/frameworkactions.js b/admin/tool/lp/amd/src/frameworkactions.js index a783033a91e..b554495c2e1 100644 --- a/admin/tool/lp/amd/src/frameworkactions.js +++ b/admin/tool/lp/amd/src/frameworkactions.js @@ -93,17 +93,17 @@ define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str' } } }]); - requests[0].done(function (success) { + requests[0].done(function(success) { if (success === false) { var req = ajax.call([{ methodname: 'core_competency_read_competency_framework', args: { id: frameworkid } }]); - req[0].done(function (framework) { + req[0].done(function(framework) { str.get_strings([ { key: 'frameworkcannotbedeleted', component: 'tool_lp', param: framework.shortname }, { key: 'cancel', component: 'moodle' } - ]).done(function (strings) { + ]).done(function(strings) { notification.alert( null, strings[0] @@ -136,7 +136,7 @@ define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str' { key: 'deletecompetencyframework', component: 'tool_lp', param: framework.shortname }, { key: 'delete', component: 'moodle' }, { key: 'cancel', component: 'moodle' } - ]).done(function (strings) { + ]).done(function(strings) { notification.confirm( strings[0], // Confirm. strings[1], // Delete competency framework X? diff --git a/admin/tool/lp/amd/src/frameworks_datasource.js b/admin/tool/lp/amd/src/frameworks_datasource.js index a4c9274dd6a..3638830c654 100644 --- a/admin/tool/lp/amd/src/frameworks_datasource.js +++ b/admin/tool/lp/amd/src/frameworks_datasource.js @@ -75,7 +75,6 @@ define(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notificat * @param {String} selector The selector of the auto complete element. * @param {String} query The query string. * @param {Function} callback A callback function receiving an array of results. - * @return {Void} */ transport: function(selector, query, callback) { var el = $(selector), diff --git a/admin/tool/lp/amd/src/grade_dialogue.js b/admin/tool/lp/amd/src/grade_dialogue.js index 9063b508eaa..576b511f3d7 100644 --- a/admin/tool/lp/amd/src/grade_dialogue.js +++ b/admin/tool/lp/amd/src/grade_dialogue.js @@ -31,6 +31,7 @@ define(['jquery', /** * Grade dialogue class. + * @param {Array} ratingOptions */ var Grade = function(ratingOptions) { EventBase.prototype.constructor.apply(this, []); @@ -46,7 +47,6 @@ define(['jquery', /** * After render hook. * - * @return {Promise} * @method _afterRender * @protected */ @@ -118,6 +118,7 @@ define(['jquery', * * @param {String} selector * @method _find + * @returns {node} The node * @protected */ Grade.prototype._find = function(selector) { diff --git a/admin/tool/lp/amd/src/grade_user_competency_inline.js b/admin/tool/lp/amd/src/grade_user_competency_inline.js index fd9d6ac76ea..3558b9fb719 100644 --- a/admin/tool/lp/amd/src/grade_user_competency_inline.js +++ b/admin/tool/lp/amd/src/grade_user_competency_inline.js @@ -34,12 +34,12 @@ define(['jquery', * InlineEditor * * @param {String} selector The selector to trigger the grading. - * @param {Number} The id of the scale for this competency. - * @param {Number} The id of the competency. - * @param {Number} The id of the user. - * @param {Number} The id of the plan. - * @param {Number} The id of the course. - * @param {String} Language string for choose a rating. + * @param {Number} scaleId The id of the scale for this competency. + * @param {Number} competencyId The id of the competency. + * @param {Number} userId The id of the user. + * @param {Number} planId The id of the plan. + * @param {Number} courseId The id of the course. + * @param {String} chooseStr Language string for choose a rating. */ var InlineEditor = function(selector, scaleId, competencyId, userId, planId, courseId, chooseStr) { EventBase.prototype.constructor.apply(this, []); diff --git a/admin/tool/lp/amd/src/menubar.js b/admin/tool/lp/amd/src/menubar.js index a91d7700c29..6889936c04b 100644 --- a/admin/tool/lp/amd/src/menubar.js +++ b/admin/tool/lp/amd/src/menubar.js @@ -44,7 +44,7 @@ define(['jquery'], function($) { /** * Constructor * - * @param {$} Jquery collection matching the root of the menu. + * @param {$} menuRoot Jquery collection matching the root of the menu. * @param {Function[]} handlers, called when a menu item is chosen. */ var Menubar = function(menuRoot, handlers) { @@ -144,7 +144,7 @@ define(['jquery'], function($) { * @method handleClick * @param {Object} item is the jquery object of the item firing the event * @param {Event} e is the associated event object - * @return boolean Returns false + * @return {boolean} Returns false */ Menubar.prototype.handleClick = function(item, e) { e.stopPropagation(); @@ -166,7 +166,7 @@ define(['jquery'], function($) { this.activeItem = null; // Close the menu. - this.menuRoot.find('ul').not('.root-level').attr('aria-hidden','true'); + this.menuRoot.find('ul').not('.root-level').attr('aria-hidden', 'true'); // Follow any link, or call the click handlers. var anchor = item.find('a').first(); var clickEvent = new $.Event('click'); @@ -290,7 +290,7 @@ define(['jquery'], function($) { subMenuContainer.css('margin-right', '-' + marginright + 'px'); } } else { - if ( pos.left + menuRealWidth > $(window).width()) { + if (pos.left + menuRealWidth > $(window).width()) { marginleft = menuRealWidth - widthmenuRoot; subMenuContainer.css('margin-left', '-' + marginleft + 'px'); } @@ -319,7 +319,7 @@ define(['jquery'], function($) { return true; } - switch(e.keyCode) { + switch (e.keyCode) { case this.keys.tab: { // Hide all menu items and update their aria attributes. @@ -438,7 +438,7 @@ define(['jquery'], function($) { // This is the root level move to next sibling. This will require closing // the current child menu and opening the new one. - if (menuIndex < menuNum-1) { + if (menuIndex < menuNum - 1) { // Not the last root menu. newItem = item.next(); } else { // Wrap to first item. @@ -501,7 +501,7 @@ define(['jquery'], function($) { menuIndex = this.rootMenus.index(rootItem); // If this is not the last root menu item, move to the next one. - if (menuIndex < this.rootMenus.length-1) { + if (menuIndex < this.rootMenus.length - 1) { newItem = rootItem.next(); } else { // Loop. @@ -687,7 +687,7 @@ define(['jquery'], function($) { // to the next item with a title that begins with that character. if (startChr) { var match = false; - var curNdx = menuIndex+1; + var curNdx = menuIndex + 1; // Check if the active item was the last one on the list. if (curNdx == menuNum) { @@ -696,7 +696,7 @@ define(['jquery'], function($) { // Iterate through the menu items (starting from the current item and wrapping) until a match is found // or the loop returns to the current menu item. - while (curNdx != menuIndex) { + while (curNdx != menuIndex) { var titleChr = menuItems.eq(curNdx).html().charAt(0); @@ -705,7 +705,7 @@ define(['jquery'], function($) { break; } - curNdx = curNdx+1; + curNdx = curNdx + 1; if (curNdx == menuNum) { // Reached the end of the list, start again at the beginning. @@ -724,8 +724,8 @@ define(['jquery'], function($) { return item; } } else { - if (menuIndex < menuNum-1) { - newItem = menuItems.eq(menuIndex+1); + if (menuIndex < menuNum - 1) { + newItem = menuItems.eq(menuIndex + 1); } else { newItem = menuItems.first(); } @@ -763,7 +763,7 @@ define(['jquery'], function($) { // If item is not the first item in its menu, move to the previous item. if (menuIndex > 0) { - newItem = menuItems.eq(menuIndex-1); + newItem = menuItems.eq(menuIndex - 1); } else { // Loop to top of menu. newItem = menuItems.last(); @@ -823,7 +823,7 @@ define(['jquery'], function($) { * { "[data-action='add']" : callAddFunction } */ enhance: function(selector, handler) { - $(selector).each(function (index, element) { + $(selector).each(function(index, element) { var menuRoot = $(element); // Don't enhance the same menu twice. if (menuRoot.data("menubarEnhanced") !== true) { diff --git a/admin/tool/lp/amd/src/parentcompetency_form.js b/admin/tool/lp/amd/src/parentcompetency_form.js index 2dabb3cd084..5a2648be203 100644 --- a/admin/tool/lp/amd/src/parentcompetency_form.js +++ b/admin/tool/lp/amd/src/parentcompetency_form.js @@ -61,7 +61,7 @@ define(['jquery', 'core/ajax', 'core/str', 'tool_lp/competencypicker', 'core/tem /** * Set the parent competency in the competency form. * - * @param {Object} Data containing selected cmpetency. + * @param {Object} data Data containing selected competency. * @method setParent */ ParentCompetencyForm.prototype.setParent = function(data) { @@ -129,7 +129,7 @@ define(['jquery', 'core/ajax', 'core/str', 'tool_lp/competencypicker', 'core/tem /** * Main initialisation. * @param {String} buttonSelector The parent competency button selector. - * @param {String} inputHiddenSelector The hidden input field selector. + * @param {String} inputSelector The hidden input field selector. * @param {String} staticElementSelector The static element displaying the parent competency. * @param {Number} frameworkId The competency framework ID. * @param {Number} pageContextId The page context ID. diff --git a/admin/tool/lp/amd/src/planactions.js b/admin/tool/lp/amd/src/planactions.js index 8d3e05043f2..39efd98b0bf 100644 --- a/admin/tool/lp/amd/src/planactions.js +++ b/admin/tool/lp/amd/src/planactions.js @@ -178,7 +178,7 @@ define(['jquery', { key: 'deleteplan', component: 'tool_lp', param: plan.name }, { key: 'delete', component: 'moodle' }, { key: 'cancel', component: 'moodle' } - ]).done(function (strings) { + ]).done(function(strings) { notification.confirm( strings[0], // Confirm. strings[1], // Delete plan X? @@ -225,7 +225,7 @@ define(['jquery', { key: 'reopenplanconfirm', component: 'tool_lp', param: plan.name }, { key: 'reopenplan', component: 'tool_lp' }, { key: 'cancel', component: 'moodle' } - ]).done(function (strings) { + ]).done(function(strings) { notification.confirm( strings[0], // Confirm. strings[1], // Reopen plan X? @@ -272,7 +272,7 @@ define(['jquery', { key: 'completeplanconfirm', component: 'tool_lp', param: plan.name }, { key: 'completeplan', component: 'tool_lp' }, { key: 'cancel', component: 'moodle' } - ]).done(function (strings) { + ]).done(function(strings) { notification.confirm( strings[0], // Confirm. strings[1], // Complete plan X? @@ -318,7 +318,7 @@ define(['jquery', { key: 'unlinkplantemplateconfirm', component: 'tool_lp', param: plan.name }, { key: 'unlinkplantemplate', component: 'tool_lp' }, { key: 'cancel', component: 'moodle' } - ]).done(function (strings) { + ]).done(function(strings) { notification.confirm( strings[0], // Confirm. strings[1], // Unlink plan X? @@ -507,7 +507,7 @@ define(['jquery', courses: courses }; templates.render('tool_lp/linked_courses_summary', context).done(function(html) { - str.get_string('linkedcourses', 'tool_lp').done(function (linkedcourses) { + str.get_string('linkedcourses', 'tool_lp').done(function(linkedcourses) { new Dialogue( linkedcourses, // Title. html // The linked courses. diff --git a/admin/tool/lp/amd/src/scaleconfig.js b/admin/tool/lp/amd/src/scaleconfig.js index 11c8568fa00..9ba1fd463b5 100644 --- a/admin/tool/lp/amd/src/scaleconfig.js +++ b/admin/tool/lp/amd/src/scaleconfig.js @@ -198,7 +198,6 @@ define(['jquery', 'core/notification', 'core/templates', 'core/ajax', 'tool_lp/d * * @name scaleChangeHandler * @param {Event} e - * @return {Void} * @function */ ScaleConfig.prototype.scaleChangeHandler = function(e) { diff --git a/admin/tool/lp/amd/src/scalevalues.js b/admin/tool/lp/amd/src/scalevalues.js index d27abd307d2..46011f82c84 100644 --- a/admin/tool/lp/amd/src/scalevalues.js +++ b/admin/tool/lp/amd/src/scalevalues.js @@ -32,7 +32,7 @@ define(['jquery', 'core/ajax'], function($, ajax) { * @param {Number} scaleid The scale id * @return [] {Promise} */ - + // eslint-disable-next-line camelcase get_values: function(scaleid) { var deferred = $.Deferred(); @@ -40,7 +40,7 @@ define(['jquery', 'core/ajax'], function($, ajax) { if (typeof localCache[scaleid] === 'undefined') { ajax.call([{ methodname: 'core_competency_get_scale_values', - args: {scaleid : scaleid}, + args: {scaleid: scaleid}, done: function(scaleinfo) { localCache[scaleid] = scaleinfo; deferred.resolve(scaleinfo); diff --git a/admin/tool/lp/amd/src/templateactions.js b/admin/tool/lp/amd/src/templateactions.js index 0966cc254d1..e0ceecbbd18 100644 --- a/admin/tool/lp/amd/src/templateactions.js +++ b/admin/tool/lp/amd/src/templateactions.js @@ -21,7 +21,7 @@ * @copyright 2015 Damyon Wiese * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str','tool_lp/actionselector'], +define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str', 'tool_lp/actionselector'], function($, templates, ajax, notification, str, Actionselector) { // Private variables and functions. @@ -135,9 +135,9 @@ define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str' { key: 'unlinkplanstemplate', component: 'tool_lp' }, { key: 'confirm', component: 'moodle' }, { key: 'cancel', component: 'moodle' } - ]).done(function (strings) { - var actions = [{'text': strings[2], 'value' : 'delete'}, - {'text': strings[3], 'value' : 'unlink'}]; + ]).done(function(strings) { + var actions = [{'text': strings[2], 'value': 'delete'}, + {'text': strings[3], 'value': 'unlink'}]; var actionselector = new Actionselector( strings[0], // Title. strings[1], // Message @@ -152,14 +152,13 @@ define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str' doDelete(); }); }).fail(notification.exception); - } - else { + } else { str.get_strings([ { key: 'confirm', component: 'moodle' }, { key: 'deletetemplate', component: 'tool_lp', param: template.shortname }, { key: 'delete', component: 'moodle' }, { key: 'cancel', component: 'moodle' } - ]).done(function (strings) { + ]).done(function(strings) { notification.confirm( strings[0], // Confirm. strings[1], // Delete learning plan template X? diff --git a/admin/tool/lp/amd/src/tree.js b/admin/tool/lp/amd/src/tree.js index f52934d3e18..179dcf64ed5 100644 --- a/admin/tool/lp/amd/src/tree.js +++ b/admin/tool/lp/amd/src/tree.js @@ -186,12 +186,12 @@ define(['jquery', 'core/url', 'core/log'], function($, url, log) { var oneItem = null; while (lastIndex < currentIndex) { - oneItem = $(this.visibleItems.get(lastIndex)); + oneItem = $(this.visibleItems.get(lastIndex)); oneItem.attr('aria-selected', 'true'); lastIndex++; } while (lastIndex > currentIndex) { - oneItem = $(this.visibleItems.get(lastIndex)); + oneItem = $(this.visibleItems.get(lastIndex)); oneItem.attr('aria-selected', 'true'); lastIndex--; } @@ -230,7 +230,8 @@ define(['jquery', 'core/url', 'core/log'], function($, url, log) { */ Tree.prototype.toggleItem = function(item) { if (!this.multiSelect) { - return this.selectItem(item); + this.selectItem(item); + return; } var current = item.attr('aria-selected'); @@ -271,6 +272,7 @@ define(['jquery', 'core/url', 'core/log'], function($, url, log) { * @method handleKeyDown * @param {Object} item is the jquery id of the parent item of the group * @param {Event} e The event. + * @return {Boolean} */ Tree.prototype.handleKeyDown = function(item, e) { var currentIndex = this.visibleItems.index(item); @@ -419,6 +421,7 @@ define(['jquery', 'core/url', 'core/log'], function($, url, log) { * @method handleKeyPress * @param {Object} item is the jquery id of the parent item of the group * @param {Event} e The event. + * @return {Boolean} */ Tree.prototype.handleKeyPress = function(item, e) { if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) { @@ -454,7 +457,7 @@ define(['jquery', 'core/url', 'core/log'], function($, url, log) { // Iterate through the menu items (starting from the current item and wrapping) until a match is found // or the loop returns to the current menu item. - while (currentIndex != itemIndex) { + while (currentIndex != itemIndex) { var currentItem = this.visibleItems.eq(currentIndex); var titleChr = currentItem.text().charAt(0); @@ -468,7 +471,7 @@ define(['jquery', 'core/url', 'core/log'], function($, url, log) { break; } - currentIndex = currentIndex+1; + currentIndex = currentIndex + 1; if (currentIndex == itemCount) { // Reached the end of the list, start again at the beginning. currentIndex = 0; @@ -483,6 +486,7 @@ define(['jquery', 'core/url', 'core/log'], function($, url, log) { } } + // eslint-disable-next-line no-unreachable return true; }; @@ -507,6 +511,7 @@ define(['jquery', 'core/url', 'core/log'], function($, url, log) { * @method handleDblClick * @param {Object} item is the jquery id of the parent item of the group * @param {Event} e The event. + * @return {Boolean} */ Tree.prototype.handleDblClick = function(item, e) { @@ -531,6 +536,7 @@ define(['jquery', 'core/url', 'core/log'], function($, url, log) { * @method handleExpandCollapseClick * @param {Object} item is the jquery id of the parent item of the group * @param {Event} e The event. + * @return {Boolean} */ Tree.prototype.handleExpandCollapseClick = function(item, e) { @@ -547,6 +553,7 @@ define(['jquery', 'core/url', 'core/log'], function($, url, log) { * @method handleClick * @param {Object} item is the jquery id of the parent item of the group * @param {Event} e The event. + * @return {Boolean} */ Tree.prototype.handleClick = function(item, e) { @@ -568,6 +575,7 @@ define(['jquery', 'core/url', 'core/log'], function($, url, log) { * @method handleBlur * @param {Object} item item is the jquery id of the parent item of the group * @param {Event} e The event. + * @return {Boolean} */ Tree.prototype.handleBlur = function() { return true; @@ -579,6 +587,7 @@ define(['jquery', 'core/url', 'core/log'], function($, url, log) { * @method handleFocus * @param {Object} item item is the jquery id of the parent item of the group * @param {Event} e The event. + * @return {Boolean} */ Tree.prototype.handleFocus = function(item) { diff --git a/admin/tool/lp/amd/src/user_competency_course_navigation.js b/admin/tool/lp/amd/src/user_competency_course_navigation.js index bf61fe5ddb0..a560da7fc33 100644 --- a/admin/tool/lp/amd/src/user_competency_course_navigation.js +++ b/admin/tool/lp/amd/src/user_competency_course_navigation.js @@ -26,12 +26,12 @@ define(['jquery'], function($) { /** * UserCompetencyCourseNavigation * - * @param {String} The selector of the user element. - * @param {String} The selector of the competency element. - * @param {String} The base url for the page (no params). - * @param {Number} The course id - * @param {Number} The user id - * @param {Number} The competency id + * @param {String} userSelector The selector of the user element. + * @param {String} competencySelector The selector of the competency element. + * @param {String} baseUrl The base url for the page (no params). + * @param {Number} userId The user id + * @param {Number} competencyId The competency id + * @param {Number} courseId The course id */ var UserCompetencyCourseNavigation = function(userSelector, competencySelector, baseUrl, userId, competencyId, courseId) { this._baseUrl = baseUrl; diff --git a/admin/tool/lp/amd/src/user_competency_info.js b/admin/tool/lp/amd/src/user_competency_info.js index 2234414f055..334e8ff1962 100644 --- a/admin/tool/lp/amd/src/user_competency_info.js +++ b/admin/tool/lp/amd/src/user_competency_info.js @@ -26,12 +26,12 @@ define(['jquery', 'core/notification', 'core/ajax', 'core/templates'], function( /** * Info * - * @param {JQuery} Selector to replace when the information needs updating. - * @param {Number} The id of the competency. - * @param {Number} The id of the user. - * @param {Number} The id of the plan. - * @param {Number} The id of the course. - * @param {Boolean} If we should display the user info. + * @param {JQuery} rootElement Selector to replace when the information needs updating. + * @param {Number} competencyId The id of the competency. + * @param {Number} userId The id of the user. + * @param {Number} planId The id of the plan. + * @param {Number} courseId The id of the course. + * @param {Boolean} displayuser If we should display the user info. */ var Info = function(rootElement, competencyId, userId, planId, courseId, displayuser) { this._rootElement = rootElement; diff --git a/admin/tool/lp/amd/src/user_competency_plan_popup.js b/admin/tool/lp/amd/src/user_competency_plan_popup.js index 87c977cd0eb..5001991114c 100644 --- a/admin/tool/lp/amd/src/user_competency_plan_popup.js +++ b/admin/tool/lp/amd/src/user_competency_plan_popup.js @@ -27,9 +27,9 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/templates' /** * UserCompetencyPopup * - * @param {String} The regionSelector - * @param {String} The userCompetencySelector - * @param {Number} The plan ID + * @param {String} regionSelector The regionSelector + * @param {String} userCompetencySelector The userCompetencySelector + * @param {Number} planId The plan ID */ var UserCompetencyPopup = function(regionSelector, userCompetencySelector, planId) { this._regionSelector = regionSelector; @@ -53,14 +53,14 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/templates' var planId = this._planId; var requests = ajax.call([{ - methodname : 'tool_lp_data_for_user_competency_summary_in_plan', + methodname: 'tool_lp_data_for_user_competency_summary_in_plan', args: { competencyid: competencyId, planid: planId }, done: this._contextLoaded.bind(this), fail: notification.exception }]); // Log the user competency viewed in plan event. - requests[0].then(function (result) { + requests[0].then(function(result) { var eventMethodName = 'core_competency_user_competency_viewed_in_plan'; // Trigger core_competency_user_competency_plan_viewed event instead if plan is already completed. if (result.plan.iscompleted) { @@ -98,7 +98,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/templates' var planId = this._planId; ajax.call([{ - methodname : 'tool_lp_data_for_plan_page', + methodname: 'tool_lp_data_for_plan_page', args: { planid: planId}, done: this._pageContextLoaded.bind(this), fail: notification.exception diff --git a/admin/tool/lp/amd/src/user_competency_workflow.js b/admin/tool/lp/amd/src/user_competency_workflow.js index 6c4376a4a9e..f61c0f9d67d 100644 --- a/admin/tool/lp/amd/src/user_competency_workflow.js +++ b/admin/tool/lp/amd/src/user_competency_workflow.js @@ -47,7 +47,6 @@ define(['jquery', * Cancel a review request and refresh the view. * * @param {Object} data The user competency data. - * @return {Void} * @method _cancelReviewRequest */ UserCompetencyWorkflow.prototype._cancelReviewRequest = function(data) { @@ -71,7 +70,6 @@ define(['jquery', * Cancel a review request an refresh the view. * * @param {Object} data The user competency data. - * @return {Void} * @method cancelReviewRequest */ UserCompetencyWorkflow.prototype.cancelReviewRequest = function(data) { @@ -82,7 +80,6 @@ define(['jquery', * Cancel a review request handler. * * @param {Event} e The event. - * @return {Void} * @method _cancelReviewRequestHandler */ UserCompetencyWorkflow.prototype._cancelReviewRequestHandler = function(e) { @@ -95,7 +92,6 @@ define(['jquery', * Request a review and refresh the view. * * @param {Object} data The user competency data. - * @return {Void} * @method _requestReview */ UserCompetencyWorkflow.prototype._requestReview = function(data) { @@ -119,7 +115,6 @@ define(['jquery', * Request a review. * * @param {Object} data The user competency data. - * @return {Void} * @method requestReview */ UserCompetencyWorkflow.prototype.requestReview = function(data) { @@ -130,7 +125,6 @@ define(['jquery', * Request a review handler. * * @param {Event} e The event. - * @return {Void} * @method _requestReviewHandler */ UserCompetencyWorkflow.prototype._requestReviewHandler = function(e) { @@ -143,7 +137,6 @@ define(['jquery', * Start a review and refresh the view. * * @param {Object} data The user competency data. - * @return {Void} * @method _startReview */ UserCompetencyWorkflow.prototype._startReview = function(data) { @@ -167,7 +160,6 @@ define(['jquery', * Start a review. * * @param {Object} data The user competency data. - * @return {Void} * @method startReview */ UserCompetencyWorkflow.prototype.startReview = function(data) { @@ -178,7 +170,6 @@ define(['jquery', * Start a review handler. * * @param {Event} e The event. - * @return {Void} * @method _startReviewHandler */ UserCompetencyWorkflow.prototype._startReviewHandler = function(e) { @@ -191,7 +182,6 @@ define(['jquery', * Stop a review and refresh the view. * * @param {Object} data The user competency data. - * @return {Void} * @method _stopReview */ UserCompetencyWorkflow.prototype._stopReview = function(data) { @@ -215,7 +205,6 @@ define(['jquery', * Stop a review. * * @param {Object} data The user competency data. - * @return {Void} * @method stopReview */ UserCompetencyWorkflow.prototype.stopReview = function(data) { @@ -226,7 +215,6 @@ define(['jquery', * Stop a review handler. * * @param {Event} e The event. - * @return {Void} * @method _stopReviewHandler */ UserCompetencyWorkflow.prototype._stopReviewHandler = function(e) { diff --git a/admin/tool/lp/amd/src/user_evidence_actions.js b/admin/tool/lp/amd/src/user_evidence_actions.js index 8c9e47e0466..f1f5cd36059 100644 --- a/admin/tool/lp/amd/src/user_evidence_actions.js +++ b/admin/tool/lp/amd/src/user_evidence_actions.js @@ -165,7 +165,7 @@ define(['jquery', { key: 'deleteuserevidence', component: 'tool_lp', param: evidence.name }, { key: 'delete', component: 'moodle' }, { key: 'cancel', component: 'moodle' } - ]).done(function (strings) { + ]).done(function(strings) { notification.confirm( strings[0], // Confirm. strings[1], // Delete evidence X? @@ -320,7 +320,7 @@ define(['jquery', { key: 'sendallcompetenciestoreview', component: 'tool_lp', param: evidence.name }, { key: 'confirm', component: 'moodle' }, { key: 'cancel', component: 'moodle' } - ]).done(function (strings) { + ]).done(function(strings) { notification.confirm( strings[0], // Confirm. strings[1], // Send all competencies in review for X? diff --git a/admin/tool/templatelibrary/amd/src/display.js b/admin/tool/templatelibrary/amd/src/display.js index 500f7d8e856..66b3fbce950 100644 --- a/admin/tool/templatelibrary/amd/src/display.js +++ b/admin/tool/templatelibrary/amd/src/display.js @@ -120,14 +120,14 @@ define(['jquery', 'core/ajax', 'core/log', 'core/notification', 'core/templates' var promises = ajax.call([{ methodname: 'core_output_load_template', - args:{ + args: { component: component, template: name, themename: config.theme } }, { methodname: 'tool_templatelibrary_load_canonical_template', - args:{ + args: { component: component, template: name } @@ -136,7 +136,9 @@ define(['jquery', 'core/ajax', 'core/log', 'core/notification', 'core/templates' // When returns a new promise that is resolved when all the passed in promises are resolved. // The arguments to the done become the values of each resolved promise. $.when.apply($, promises) - .done( function(source, originalSource) { templateLoaded(templateName, source, originalSource); }) + .done(function(source, originalSource) { + templateLoaded(templateName, source, originalSource); + }) .fail(notification.exception); }; diff --git a/admin/tool/templatelibrary/amd/src/search.js b/admin/tool/templatelibrary/amd/src/search.js index 2c9d828a7fb..2fabeb2fbb5 100644 --- a/admin/tool/templatelibrary/amd/src/search.js +++ b/admin/tool/templatelibrary/amd/src/search.js @@ -28,11 +28,11 @@ define(['jquery', 'core/ajax', 'core/log', 'core/notification', 'core/templates' * The ajax call has returned with a new list of templates. * * @method reloadListTemplate - * @param String[] templates List of template ids. + * @param {String[]} templateList List of template ids. */ var reloadListTemplate = function(templateList) { templates.render('tool_templatelibrary/search_results', { templates: templateList }) - .done(function (result, js) { + .done(function(result, js) { templates.replaceNode($('[data-region="searchresults"]'), result, js); }).fail(notification.exception); }; @@ -63,8 +63,8 @@ define(['jquery', 'core/ajax', 'core/log', 'core/notification', 'core/templates' * the function will only be executed once. * * @method queueRefresh - * @param function callback - * @param int delay The time in milliseconds to delay. + * @param {function} callback + * @param {Number} delay The time in milliseconds to delay. */ var queueRefresh = function(callback, delay) { if (throttle !== null) { diff --git a/blocks/navigation/amd/src/ajax_response_renderer.js b/blocks/navigation/amd/src/ajax_response_renderer.js index 41b9b45b15b..d9357424d1f 100644 --- a/blocks/navigation/amd/src/ajax_response_renderer.js +++ b/blocks/navigation/amd/src/ajax_response_renderer.js @@ -28,9 +28,9 @@ define(['jquery'], function($) { // Copied from lib/navigationlib.php navigation_node constants. var NODETYPE = { // @type int Activity (course module) = 40. - ACTIVITY : 40, + ACTIVITY: 40, // @type int Resource (course module = 50. - RESOURCE : 50, + RESOURCE: 50, }; /** @@ -39,7 +39,6 @@ define(['jquery'], function($) { * @method buildDOM * @param {Object} rootElement the root element of DOM. * @param {object} nodes jquery object representing the nodes to be build. - * @return */ function buildDOM(rootElement, nodes) { var ul = $('
    '); @@ -94,7 +93,7 @@ define(['jquery'], function($) { if (icon) { link.append(icon); - link.append(''+node.name+''); + link.append('' + node.name + ''); } else { link.append(node.name); } @@ -109,7 +108,7 @@ define(['jquery'], function($) { if (icon) { span.append(icon); - span.append(''+node.name+''); + span.append('' + node.name + ''); } else { span.append(node.name); } diff --git a/blocks/navigation/amd/src/nav_loader.js b/blocks/navigation/amd/src/nav_loader.js index 2cb51372ac2..ce5cb997bd9 100644 --- a/blocks/navigation/amd/src/nav_loader.js +++ b/blocks/navigation/amd/src/nav_loader.js @@ -29,8 +29,8 @@ define(['jquery', 'core/ajax', 'core/config', 'block_navigation/ajax_response_re * Get the block instance id. * * @function getBlockInstanceId - * @param element - * @returns {*} + * @param {Element} element + * @returns {String} the instance id */ function getBlockInstanceId(element) { return element.closest('[data-block]').attr('data-instanceid'); diff --git a/grade/grading/form/guide/amd/src/comment_chooser.js b/grade/grading/form/guide/amd/src/comment_chooser.js index 6f9b158d408..09ffb0cf4fb 100644 --- a/grade/grading/form/guide/amd/src/comment_chooser.js +++ b/grade/grading/form/guide/amd/src/comment_chooser.js @@ -22,7 +22,7 @@ * @copyright 2015 Jun Pataleta * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -define(['jquery', 'core/templates', 'core/notification', 'core/yui'], function ($, templates, notification) { +define(['jquery', 'core/templates', 'core/notification', 'core/yui'], function($, templates, notification) { // Private variables and functions. @@ -34,18 +34,18 @@ define(['jquery', 'core/templates', 'core/notification', 'core/yui'], function ( * Basically, it performs the binding and handling of the button click event for * the 'Insert frequently used comment' button. * - * @param criterionId The criterion ID. - * @param buttonId The element ID of the button which the handler will be bound to. - * @param remarkId The element ID of the remark text area where the text of the selected comment will be copied to. - * @param commentOptions The array of frequently used comments to be used as options. + * @param {Integer} criterionId The criterion ID. + * @param {String} buttonId The element ID of the button which the handler will be bound to. + * @param {String} remarkId The element ID of the remark text area where the text of the selected comment will be copied to. + * @param {Array} commentOptions The array of frequently used comments to be used as options. */ - initialise: function (criterionId, buttonId, remarkId, commentOptions) { + initialise: function(criterionId, buttonId, remarkId, commentOptions) { /** * Display the chooser dialog using the compiled HTML from the mustache template * and binds onclick events for the generated comment options. * - * @param compiledSource The compiled HTML from the mustache template - * @param comments Array containing comments. + * @param {String} compiledSource The compiled HTML from the mustache template + * @param {Array} comments Array containing comments. */ function displayChooserDialog(compiledSource, comments) { var titleLabel = ''; @@ -68,11 +68,11 @@ define(['jquery', 'core/templates', 'core/notification', 'core/yui'], function ( }); // Loop over each comment item and bind click events. - $.each(comments, function (index, comment) { + $.each(comments, function(index, comment) { var commentOptionId = '#comment-option-' + criterionId + '-' + comment.id; // Delegate click event for the generated option link. - $(commentOptionId).click(function () { + $(commentOptionId).click(function() { var remarkTextArea = $('#' + remarkId); var remarkText = remarkTextArea.val(); @@ -88,7 +88,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core/yui'], function ( }); // Handle keypress on list items. - $(document).off('keypress', commentOptionId).on('keypress', commentOptionId, function () { + $(document).off('keypress', commentOptionId).on('keypress', commentOptionId, function() { var keyCode = event.which || event.keyCode; // Enter or space key. @@ -124,14 +124,14 @@ define(['jquery', 'core/templates', 'core/notification', 'core/yui'], function ( // Render the template and display the comment chooser dialog. templates.render('gradingform_guide/comment_chooser', context) - .done(function (compiledSource) { + .done(function(compiledSource) { displayChooserDialog(compiledSource, commentOptions); }) .fail(notification.exception); } // Bind click event for the comments chooser button. - $("#" + buttonId).click(function (e) { + $("#" + buttonId).click(function(e) { e.preventDefault(); generateCommentsChooser(); }); diff --git a/lib/amd/build/form-autocomplete.min.js b/lib/amd/build/form-autocomplete.min.js index 73fe814111e..43fb119cd0c 100644 --- a/lib/amd/build/form-autocomplete.min.js +++ b/lib/amd/build/form-autocomplete.min.js @@ -1 +1 @@ -define(["jquery","core/log","core/str","core/templates","core/notification"],function(a,b,c,d,e){var f={DOWN:40,ENTER:13,SPACE:32,ESCAPE:27,COMMA:188,UP:38},g=function(b,c){var d=a(document.getElementById(c.selectionId)),e=d.children("[aria-selected=true]").length;for(b%=e;0>b;)b+=e;var f=a(d.children("[aria-selected=true]").get(b)),g=c.selectionId+"-"+b;d.children().attr("data-active-selection",!1).attr("id",""),f.attr("data-active-selection",!0).attr("id",g),d.attr("aria-activedescendant",g)},h=function(b,c,f){var h=[],i=a(document.getElementById(c.selectionId)),j=i.attr("aria-activedescendant"),k=!1;j&&(k=a(document.getElementById(j)).attr("data-value")),f.children("option").each(function(b,c){a(c).prop("selected")&&h.push({label:a(c).html(),value:a(c).attr("value")})});var l=a.extend({items:h},b,c);d.render("core/form_autocomplete_selection",l).done(function(b){i.empty().append(a(b).html()),k!==!1&&i.children("[aria-selected=true]").each(function(b,d){a(d).attr("data-value")===k&&g(b,c)})}).fail(e.exception)},i=function(a){"undefined"!=typeof M.core_formchangechecker&&M.core_formchangechecker.set_form_changed(),a.change()},j=function(b,c,d,e){var f=a(d).attr("data-value");b.multiple&&e.children("option").each(function(b,c){a(c).attr("value")==f&&(a(c).prop("selected",!1),a(c).attr("data-iscustom")&&a(c).remove())}),h(b,c,e),i(e)},k=function(b,c){var d=a(document.getElementById(c.inputId)),e=a(document.getElementById(c.suggestionsId)),f=e.children("[aria-hidden=false]").length;for(b%=f;0>b;)b+=f;var g=a(e.children("[aria-hidden=false]").get(b)),h=a(e.children("[role=option]")).index(g),i=c.suggestionsId+"-"+h;e.children().attr("aria-selected",!1).attr("id",""),g.attr("aria-selected",!0).attr("id",i),d.attr("aria-activedescendant",i);var j=g.offset().top-e.offset().top+e.scrollTop()-e.height()/2;e.animate({scrollTop:j},100)},l=function(b){var c=a(document.getElementById(b.suggestionsId)),d=c.children("[aria-selected=true]"),e=c.children("[aria-hidden=false]").index(d);k(e+1,b)},m=function(b){var c=a(document.getElementById(b.selectionId)),d=c.children("[data-active-selection=true]");if(!d)return void g(0,b);var e=c.children("[aria-selected=true]").index(d);g(e-1,b)},n=function(b){var c=a(document.getElementById(b.selectionId)),d=c.children("[data-active-selection=true]");if(!d)return void g(0,b);var e=c.children("[aria-selected=true]").index(d);g(e+1,b)},o=function(b){var c=a(document.getElementById(b.suggestionsId)),d=c.children("[aria-selected=true]"),e=c.children("[aria-hidden=false]").index(d);k(e-1,b)},p=function(b){var c=a(document.getElementById(b.inputId)),d=a(document.getElementById(b.suggestionsId));c.attr("aria-expanded",!1).attr("aria-activedescendant",b.selectionId),d.hide().attr("aria-hidden",!0)},q=function(b,f,g,h){var i=a(document.getElementById(f.inputId)),j=a(document.getElementById(f.suggestionsId)),l=!1,m=[];h.children("option").each(function(b,c){a(c).prop("selected")!==!0&&(m[m.length]={label:c.innerHTML,value:a(c).attr("value")})});var n=f.caseSensitive?g:g.toLocaleLowerCase(),o=a.extend({options:m},b,f);d.render("core/form_autocomplete_suggestions",o).done(function(d){j.replaceWith(d),j=a(document.getElementById(f.suggestionsId)),j.show().attr("aria-hidden",!1),j.children().each(function(c,d){d=a(d),b.caseSensitive&&d.text().indexOf(n)>-1||!b.caseSensitive&&d.text().toLocaleLowerCase().indexOf(n)>-1?(d.show().attr("aria-hidden",!1),l=!0):d.hide().attr("aria-hidden",!0)}),i.attr("aria-expanded",!0),l?b.tags||k(0,f):c.get_string("nosuggestions","form").done(function(a){j.html(a)})}).fail(e.exception)},r=function(b,c,d){var e=a(document.getElementById(c.inputId)),f=e.val(),g=f.split(","),j=!1;a.each(g,function(c,e){if(e=e.trim(),""!==e&&(b.multiple||d.children("option").prop("selected",!1),d.children("option").each(function(b,c){a(c).attr("value")==e&&(j=!0,a(c).prop("selected",!0))}),!j)){var f=a("