Merge branch 'MDL-57139-master' of git://github.com/danpoltawski/moodle

This commit is contained in:
Jun Pataleta 2017-06-06 14:47:52 +08:00
commit 4b64128f5b
61 changed files with 349 additions and 366 deletions

View File

@ -1,4 +1,7 @@
{
'plugins': [
'promise',
],
'env': {
'browser': true,
'amd': true
@ -170,11 +173,22 @@
'unicode-bom': 'error',
'wrap-regex': 'off',
// === Promises ===
'promise/always-return': 'warn',
'promise/no-return-wrap': 'warn',
'promise/param-names': 'warn',
'promise/catch-or-return': ['warn', {terminationMethod: ['catch', 'fail']}],
'promise/no-native': 'warn',
'promise/no-promise-in-callback': 'warn',
'promise/no-callback-in-promise': 'warn',
'promise/avoid-new': 'warn',
// === Deprecations ===
"no-restricted-properties": ['warn', {
'object': 'M',
'property': 'str',
'message': 'Use AMD module "core/str" or M.util.get_string()'
}],
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
define(["jquery","core/notification","core/ajax","core/templates","core/str","tool_lp/tree","tool_lp/competencypicker"],function(a,b,c,d,e,f,g){var h=function(a,b,c){g.prototype.constructor.apply(this,[1,!1,"self",c]),this._userId=a,this._plans=[],b&&(this._planId=b,this._singlePlan=!0)};return h.prototype=Object.create(g.prototype),h.prototype._plans=null,h.prototype._planId=null,h.prototype._singlePlan=!1,h.prototype._userId=null,h.prototype._afterRender=function(){var b=this;g.prototype._afterRender.apply(b,arguments),b._singlePlan||b._find('[data-action="chooseplan"]').change(function(c){b._planId=a(c.target).val(),b._loadCompetencies().then(b._refresh.bind(b))})},h.prototype._fetchCompetencies=function(a,d){var e=this;return c.call([{methodname:"core_competency_list_plan_competencies",args:{id:a}}])[0].done(function(a){var b,c,f=[];for(b=0;b<a.length;b++)c=a[b].competency,c.shortname.toLowerCase().indexOf(d.toLowerCase())<0||(c.children=[],c.haschildren=0,f.push(c));e._competencies=f}).fail(b.exception)},h.prototype._getPlan=function(b){var c;return a.each(this._plans,function(a,d){if(d.id==b)return void(c=d)}),c},h.prototype._loadCompetencies=function(){return this._fetchCompetencies(this._planId,this._searchText)},h.prototype._loadPlans=function(){var d,e=this;return e._plans.length>0?a.when():(d=e._singlePlan?c.call([{methodname:"core_competency_read_plan",args:{id:this._planId}}])[0].then(function(a){return[a]}):c.call([{methodname:"core_competency_list_user_plans",args:{userid:e._userId}}])[0],d.done(function(a){e._plans=a}).fail(b.exception))},h.prototype._preRender=function(){var b=this;return b._loadPlans().then(function(){return!b._planId&&b._plans.length>0&&(b._planId=b._plans[0].id),b._planId?b._loadCompetencies():(b._plans=[],a.when())})},h.prototype._render=function(){var b=this;return b._preRender().then(function(){b._singlePlan||a.each(b._plans,function(a,c){c.id==b._planId?c.selected=!0:c.selected=!1});var c={competencies:b._competencies,plan:b._getPlan(b._planId),plans:b._plans,search:b._searchText,singlePlan:b._singlePlan};return d.render("tool_lp/competency_picker_user_plans",c)})},h});
define(["jquery","core/notification","core/ajax","core/templates","core/str","tool_lp/tree","tool_lp/competencypicker"],function(a,b,c,d,e,f,g){var h=function(a,b,c){g.prototype.constructor.apply(this,[1,!1,"self",c]),this._userId=a,this._plans=[],b&&(this._planId=b,this._singlePlan=!0)};return h.prototype=Object.create(g.prototype),h.prototype._plans=null,h.prototype._planId=null,h.prototype._singlePlan=!1,h.prototype._userId=null,h.prototype._afterRender=function(){var c=this;g.prototype._afterRender.apply(c,arguments),c._singlePlan||c._find('[data-action="chooseplan"]').change(function(d){c._planId=a(d.target).val(),c._loadCompetencies().then(c._refresh.bind(c))["catch"](b.exception)})},h.prototype._fetchCompetencies=function(a,d){var e=this;return c.call([{methodname:"core_competency_list_plan_competencies",args:{id:a}}])[0].done(function(a){var b,c,f=[];for(b=0;b<a.length;b++)c=a[b].competency,c.shortname.toLowerCase().indexOf(d.toLowerCase())<0||(c.children=[],c.haschildren=0,f.push(c));e._competencies=f}).fail(b.exception)},h.prototype._getPlan=function(b){var c;return a.each(this._plans,function(a,d){if(d.id==b)return void(c=d)}),c},h.prototype._loadCompetencies=function(){return this._fetchCompetencies(this._planId,this._searchText)},h.prototype._loadPlans=function(){var d,e=this;return e._plans.length>0?a.when():(d=e._singlePlan?c.call([{methodname:"core_competency_read_plan",args:{id:this._planId}}])[0].then(function(a){return[a]}):c.call([{methodname:"core_competency_list_user_plans",args:{userid:e._userId}}])[0],d.done(function(a){e._plans=a}).fail(b.exception))},h.prototype._preRender=function(){var b=this;return b._loadPlans().then(function(){return!b._planId&&b._plans.length>0&&(b._planId=b._plans[0].id),b._planId?b._loadCompetencies():(b._plans=[],a.when())})},h.prototype._render=function(){var b=this;return b._preRender().then(function(){b._singlePlan||a.each(b._plans,function(a,c){c.id==b._planId?c.selected=!0:c.selected=!1});var c={competencies:b._competencies,plan:b._getPlan(b._planId),plans:b._plans,search:b._searchText,singlePlan:b._singlePlan};return d.render("tool_lp/competency_picker_user_plans",c)})},h});

View File

@ -1 +1 @@
define(["jquery","core/notification","core/templates","tool_lp/dialogue","tool_lp/competency_outcomes","core/str"],function(a,b,c,d,e,f){var g=function(b,c){this._eventNode=a("<div></div>"),this._tree=b,this._rulesModules=c,this._setUp()};return g.prototype._competency=null,g.prototype._eventNode=null,g.prototype._outcomesOption=null,g.prototype._popup=null,g.prototype._ready=null,g.prototype._rules=null,g.prototype._rulesModules=null,g.prototype._tree=null,g.prototype._afterChange=function(){this._isValid()?this._find('[data-action="save"]').prop("disabled",!1):this._find('[data-action="save"]').prop("disabled",!0)},g.prototype._afterRuleConfigChange=function(a,b){b==this._getRule()&&this._afterChange()},g.prototype._afterRender=function(){var a=this;a._find('[name="outcome"]').on("change",function(){a._switchedOutcome()}).trigger("change"),a._find('[name="rule"]').on("change",function(){a._switchedRule()}).trigger("change"),a._find('[data-action="save"]').on("click",function(){a._trigger("save",a._getConfig()),a.close()}),a._find('[data-action="cancel"]').on("click",function(){a.close()})},g.prototype.canBeConfigured=function(){var b=!1;return a.each(this._rules,function(a,c){if(c.canConfig())return void(b=!0)}),b},g.prototype.close=function(){this._popup.close(),this._popup=null},g.prototype.display=function(){var a=this;return!!a._competency&&a._render().then(function(b){return f.get_string("competencyrule","tool_lp").then(function(c){a._popup=new d(c,b,a._afterRender.bind(a))})}).fail(b.exception)},g.prototype._find=function(b){return a(this._popup.getContent()).find(b)},g.prototype._getApplicableOutcomesOptions=function(){var b=this,c=[];return a.each(b._outcomesOption,function(a,d){c.push({code:d.code,name:d.name,selected:d.code==b._competency.ruleoutcome})}),c},g.prototype._getApplicableRulesOptions=function(){var b=this,c=[];return a.each(b._rules,function(a,d){d.canConfig()&&c.push({name:b._getRuleName(d.getType()),type:d.getType(),selected:d.getType()==b._competency.ruletype})}),c},g.prototype._getConfig=function(){var a=this._getRule();return{ruletype:a?a.getType():null,ruleconfig:a?a.getConfig():null,ruleoutcome:this._getOutcome()}},g.prototype._getOutcome=function(){return this._find('[name="outcome"]').val()},g.prototype._getRule=function(){var b,c=this._find('[name="rule"]').val();return a.each(this._rules,function(a,d){if(d.getType()==c)return void(b=d)}),b},g.prototype._getRuleName=function(b){var c,d=this;return a.each(d._rulesModules,function(a,d){if(d.type==b)return void(c=d.name)}),c},g.prototype._initOutcomes=function(){var a=this;return e.getAll().then(function(b){a._outcomesOption=b})},g.prototype._initRules=function(){var b=this,c=[];return a.each(b._rules,function(d,e){var f=e.init().then(function(){e.setTargetCompetency(b._competency),e.on("change",b._afterRuleConfigChange.bind(b))},function(){return b._rules.splice(d,1),a.when()});c.push(f)}),a.when.apply(a.when,c)},g.prototype._isValid=function(){var a=this._getOutcome(),b=this._getRule();return a==e.NONE||!!b&&b.isValid()},g.prototype.on=function(a,b){this._eventNode.on(a,b)},g.prototype._preRender=function(){return this.ready()},g.prototype.ready=function(){return this._ready.promise()},g.prototype._render=function(){var a=this;return this._preRender().then(function(){var b;a.canBeConfigured()?(b={},b.outcomes=a._getApplicableOutcomesOptions(),b.rules=a._getApplicableRulesOptions()):b=!1;var d={competencyshortname:a._competency.shortname,config:b};return c.render("tool_lp/competency_rule_config",d)})},g.prototype.setTargetCompetencyId=function(b){var c=this;c._competency=c._tree.getCompetency(b),a.each(c._rules,function(a,b){b.setTargetCompetency(c._competency)})},g.prototype._setUp=function(){var b=this,c=[],d=[];b._ready=a.Deferred(),b._rules=[],a.each(b._rulesModules,function(a,b){d.push(b.amd)}),require(d,function(){a.each(arguments,function(a,c){var d=new c(b._tree);b._rules.push(d)}),c.push(b._initRules()),c.push(b._initOutcomes()),a.when.apply(a.when,c).always(function(){b._ready.resolve()})})},g.prototype._switchedOutcome=function(){var a=this,b=a._getOutcome();return b==e.NONE?(a._find('[data-region="rule-type"]').hide().find('[name="rule"]').val(-1),a._find('[data-region="rule-config"]').empty().hide(),void a._afterChange()):(a._find('[data-region="rule-type"]').show(),a._find('[data-region="rule-config"]').show(),void a._afterChange())},g.prototype._switchedRule=function(){var a=this,b=a._find('[data-region="rule-config"]'),c=a._getRule();return c?void c.injectTemplate(b).then(function(){b.show()},function(){b.empty().hide()}).always(function(){a._afterChange()}):(b.empty().hide(),void a._afterChange())},g.prototype._trigger=function(a,b){this._eventNode.trigger(a,[b])},g});
define(["jquery","core/notification","core/templates","tool_lp/dialogue","tool_lp/competency_outcomes","core/str"],function(a,b,c,d,e,f){var g=function(b,c){this._eventNode=a("<div></div>"),this._tree=b,this._rulesModules=c,this._setUp()};return g.prototype._competency=null,g.prototype._eventNode=null,g.prototype._outcomesOption=null,g.prototype._popup=null,g.prototype._ready=null,g.prototype._rules=null,g.prototype._rulesModules=null,g.prototype._tree=null,g.prototype._afterChange=function(){this._isValid()?this._find('[data-action="save"]').prop("disabled",!1):this._find('[data-action="save"]').prop("disabled",!0)},g.prototype._afterRuleConfigChange=function(a,b){b==this._getRule()&&this._afterChange()},g.prototype._afterRender=function(){var a=this;a._find('[name="outcome"]').on("change",function(){a._switchedOutcome()}).trigger("change"),a._find('[name="rule"]').on("change",function(){a._switchedRule()}).trigger("change"),a._find('[data-action="save"]').on("click",function(){a._trigger("save",a._getConfig()),a.close()}),a._find('[data-action="cancel"]').on("click",function(){a.close()})},g.prototype.canBeConfigured=function(){var b=!1;return a.each(this._rules,function(a,c){if(c.canConfig())return void(b=!0)}),b},g.prototype.close=function(){this._popup.close(),this._popup=null},g.prototype.display=function(){var c=this;return!!c._competency&&a.when(f.get_string("competencyrule","tool_lp"),c._render()).then(function(a,b){c._popup=new d(a,b[0],c._afterRender.bind(c))}).fail(b.exception)},g.prototype._find=function(b){return a(this._popup.getContent()).find(b)},g.prototype._getApplicableOutcomesOptions=function(){var b=this,c=[];return a.each(b._outcomesOption,function(a,d){c.push({code:d.code,name:d.name,selected:d.code==b._competency.ruleoutcome})}),c},g.prototype._getApplicableRulesOptions=function(){var b=this,c=[];return a.each(b._rules,function(a,d){d.canConfig()&&c.push({name:b._getRuleName(d.getType()),type:d.getType(),selected:d.getType()==b._competency.ruletype})}),c},g.prototype._getConfig=function(){var a=this._getRule();return{ruletype:a?a.getType():null,ruleconfig:a?a.getConfig():null,ruleoutcome:this._getOutcome()}},g.prototype._getOutcome=function(){return this._find('[name="outcome"]').val()},g.prototype._getRule=function(){var b,c=this._find('[name="rule"]').val();return a.each(this._rules,function(a,d){if(d.getType()==c)return void(b=d)}),b},g.prototype._getRuleName=function(b){var c,d=this;return a.each(d._rulesModules,function(a,d){if(d.type==b)return void(c=d.name)}),c},g.prototype._initOutcomes=function(){var a=this;return e.getAll().then(function(b){a._outcomesOption=b})},g.prototype._initRules=function(){var b=this,c=[];return a.each(b._rules,function(d,e){var f=e.init().then(function(){e.setTargetCompetency(b._competency),e.on("change",b._afterRuleConfigChange.bind(b))},function(){return b._rules.splice(d,1),a.when()});c.push(f)}),a.when.apply(a.when,c)},g.prototype._isValid=function(){var a=this._getOutcome(),b=this._getRule();return a==e.NONE||!!b&&b.isValid()},g.prototype.on=function(a,b){this._eventNode.on(a,b)},g.prototype._preRender=function(){return this.ready()},g.prototype.ready=function(){return this._ready.promise()},g.prototype._render=function(){var a=this;return this._preRender().then(function(){var b;a.canBeConfigured()?(b={},b.outcomes=a._getApplicableOutcomesOptions(),b.rules=a._getApplicableRulesOptions()):b=!1;var d={competencyshortname:a._competency.shortname,config:b};return c.render("tool_lp/competency_rule_config",d)})},g.prototype.setTargetCompetencyId=function(b){var c=this;c._competency=c._tree.getCompetency(b),a.each(c._rules,function(a,b){b.setTargetCompetency(c._competency)})},g.prototype._setUp=function(){var b=this,c=[],d=[];b._ready=a.Deferred(),b._rules=[],a.each(b._rulesModules,function(a,b){d.push(b.amd)}),require(d,function(){a.each(arguments,function(a,c){var d=new c(b._tree);b._rules.push(d)}),c.push(b._initRules()),c.push(b._initOutcomes()),a.when.apply(a.when,c).always(function(){b._ready.resolve()})})},g.prototype._switchedOutcome=function(){var a=this,b=a._getOutcome();return b==e.NONE?(a._find('[data-region="rule-type"]').hide().find('[name="rule"]').val(-1),a._find('[data-region="rule-config"]').empty().hide(),void a._afterChange()):(a._find('[data-region="rule-type"]').show(),a._find('[data-region="rule-config"]').show(),void a._afterChange())},g.prototype._switchedRule=function(){var a=this,b=a._find('[data-region="rule-config"]'),c=a._getRule();return c?void c.injectTemplate(b).then(function(){b.show()}).always(function(){a._afterChange()})["catch"](function(){b.empty().hide()}):(b.empty().hide(),void a._afterChange())},g.prototype._trigger=function(a,b){this._eventNode.trigger(a,[b])},g});

View File

@ -1 +1 @@
define(["jquery","core/ajax","core/templates"],function(a,b,c){return{processResults:function(b,c){var d=[];return a.each(c,function(a,b){d.push({value:b.id,label:b._label})}),d},transport:function(d,e,f,g){var h,i=parseInt(a(d).data("contextid"),10),j=a(d).data("includes");h=b.call([{methodname:"tool_lp_search_cohorts",args:{query:e,context:{contextid:i},includes:j}}]),h[0].then(function(b){var d=[],e=0;return a.each(b.cohorts,function(a,b){d.push(c.render("tool_lp/form-cohort-selector-suggestion",b))}),a.when.apply(a.when,d).then(function(){var c=arguments;a.each(b.cohorts,function(a,b){b._label=c[e],e++}),f(b.cohorts)})},g)}}});
define(["jquery","core/ajax","core/templates"],function(a,b,c){return{processResults:function(b,c){var d=[];return a.each(c,function(a,b){d.push({value:b.id,label:b._label})}),d},transport:function(d,e,f,g){var h,i=parseInt(a(d).data("contextid"),10),j=a(d).data("includes");h=b.call([{methodname:"tool_lp_search_cohorts",args:{query:e,context:{contextid:i},includes:j}}]),h[0].then(function(b){var d=[],e=0;return a.each(b.cohorts,function(a,b){d.push(c.render("tool_lp/form-cohort-selector-suggestion",b))}),a.when.apply(a.when,d).then(function(){var c=arguments;a.each(b.cohorts,function(a,b){b._label=c[e],e++}),f(b.cohorts)})})["catch"](g)}}});

View File

@ -1 +1 @@
define(["jquery","core/ajax","core/templates"],function(a,b,c){return{processResults:function(b,c){var d=[];return a.each(c,function(a,b){d.push({value:b.id,label:b._label})}),d},transport:function(d,e,f,g){var h,i=a(d).data("capability");"undefined"==typeof i&&(i=""),h=b.call([{methodname:"tool_lp_search_users",args:{query:e,capability:i}}]),h[0].then(function(b){var d=[],e=0;return a.each(b.users,function(b,e){var f=e,g=[];a.each(["idnumber","email","phone1","phone2","department","institution"],function(a,b){"undefined"!=typeof e[b]&&""!==e[b]&&(f.hasidentity=!0,g.push(e[b]))}),f.identity=g.join(", "),d.push(c.render("tool_lp/form-user-selector-suggestion",f))}),a.when.apply(a.when,d).then(function(){var c=arguments;a.each(b.users,function(a,b){b._label=c[e],e++}),f(b.users)})},g)}}});
define(["jquery","core/ajax","core/templates"],function(a,b,c){return{processResults:function(b,c){var d=[];return a.each(c,function(a,b){d.push({value:b.id,label:b._label})}),d},transport:function(d,e,f,g){var h,i=a(d).data("capability");"undefined"==typeof i&&(i=""),h=b.call([{methodname:"tool_lp_search_users",args:{query:e,capability:i}}]),h[0].then(function(b){var d=[],e=0;return a.each(b.users,function(b,e){var f=e,g=[];a.each(["idnumber","email","phone1","phone2","department","institution"],function(a,b){"undefined"!=typeof e[b]&&""!==e[b]&&(f.hasidentity=!0,g.push(e[b]))}),f.identity=g.join(", "),d.push(c.render("tool_lp/form-user-selector-suggestion",f))}),a.when.apply(a.when,d).then(function(){var c=arguments;a.each(b.users,function(a,b){b._label=c[e],e++}),f(b.users)})})["catch"](g)}}});

View File

@ -1 +1 @@
define(["jquery","core/ajax","core/notification"],function(a,b,c){return{list:function(d,e){var f,g={context:{contextid:d}};return a.extend(g,"undefined"==typeof e?{}:e),f=b.call([{methodname:"core_competency_list_competency_frameworks",args:g}])[0],f.fail(c.exception)},processResults:function(b,c){var d=[];return a.each(c,function(a,b){d.push({value:b.id,label:b.shortname+" "+b.idnumber})}),d},transport:function(b,c,d){var e=a(b),f=e.data("contextid"),g=e.data("onlyvisible");if(!f)throw new Error("The attribute data-contextid is required on "+b);this.list(f,{query:c,onlyvisible:g}).then(d)}}});
define(["jquery","core/ajax","core/notification"],function(a,b,c){return{list:function(c,d){var e={context:{contextid:c}};return a.extend(e,"undefined"==typeof d?{}:d),b.call([{methodname:"core_competency_list_competency_frameworks",args:e}])[0]},processResults:function(b,c){var d=[];return a.each(c,function(a,b){d.push({value:b.id,label:b.shortname+" "+b.idnumber})}),d},transport:function(b,d,e){var f=a(b),g=f.data("contextid"),h=f.data("onlyvisible");if(!g)throw new Error("The attribute data-contextid is required on "+b);this.list(g,{query:d,onlyvisible:h}).then(e)["catch"](c.exception)}}});

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
define(["jquery","core/notification","core/str","core/ajax","core/templates","tool_lp/dialogue"],function(a,b,c,d,e,f){var g=function(b,c,d){this._regionSelector=b,this._userCompetencySelector=c,this._planId=d,a(this._regionSelector).on("click",this._userCompetencySelector,this._handleClick.bind(this))};return g.prototype._handleClick=function(c){c.preventDefault();var e=a(c.target).closest("tr"),f=a(e).data("competencyid"),g=a(e).data("userid"),h=this._planId,i=d.call([{methodname:"tool_lp_data_for_user_competency_summary_in_plan",args:{competencyid:f,planid:h},done:this._contextLoaded.bind(this),fail:b.exception}]);i[0].then(function(a){var c="core_competency_user_competency_viewed_in_plan";a.plan.iscompleted&&(c="core_competency_user_competency_plan_viewed"),d.call([{methodname:c,args:{competencyid:f,userid:g,planid:h},fail:b.exception}])})},g.prototype._contextLoaded=function(a){var d=this;e.render("tool_lp/user_competency_summary_in_plan",a).done(function(a,g){c.get_string("usercompetencysummary","report_competency").done(function(b){new f(b,a,e.runTemplateJS.bind(e,g),d._refresh.bind(d),(!0))}).fail(b.exception)}).fail(b.exception)},g.prototype._refresh=function(){var a=this._planId;d.call([{methodname:"tool_lp_data_for_plan_page",args:{planid:a},done:this._pageContextLoaded.bind(this),fail:b.exception}])},g.prototype._pageContextLoaded=function(a){var c=this;e.render("tool_lp/plan_page",a).done(function(a,b){e.replaceNode(c._regionSelector,a,b)}).fail(b.exception)},g.prototype._regionSelector=null,g.prototype._userCompetencySelector=null,g.prototype._planId=null,g});
define(["jquery","core/notification","core/str","core/ajax","core/templates","tool_lp/dialogue"],function(a,b,c,d,e,f){var g=function(b,c,d){this._regionSelector=b,this._userCompetencySelector=c,this._planId=d,a(this._regionSelector).on("click",this._userCompetencySelector,this._handleClick.bind(this))};return g.prototype._handleClick=function(c){c.preventDefault();var e=a(c.target).closest("tr"),f=a(e).data("competencyid"),g=a(e).data("userid"),h=this._planId,i=d.call([{methodname:"tool_lp_data_for_user_competency_summary_in_plan",args:{competencyid:f,planid:h},done:this._contextLoaded.bind(this),fail:b.exception}]);i[0].then(function(a){var b="core_competency_user_competency_viewed_in_plan";return a.plan.iscompleted&&(b="core_competency_user_competency_plan_viewed"),d.call([{methodname:b,args:{competencyid:f,userid:g,planid:h}}])[0]})["catch"](b.exception)},g.prototype._contextLoaded=function(a){var d=this;e.render("tool_lp/user_competency_summary_in_plan",a).done(function(a,g){c.get_string("usercompetencysummary","report_competency").done(function(b){new f(b,a,e.runTemplateJS.bind(e,g),d._refresh.bind(d),(!0))}).fail(b.exception)}).fail(b.exception)},g.prototype._refresh=function(){var a=this._planId;d.call([{methodname:"tool_lp_data_for_plan_page",args:{planid:a},done:this._pageContextLoaded.bind(this),fail:b.exception}])},g.prototype._pageContextLoaded=function(a){var c=this;e.render("tool_lp/plan_page",a).done(function(a,b){e.replaceNode(c._regionSelector,a,b)}).fail(b.exception)},g.prototype._regionSelector=null,g.prototype._userCompetencySelector=null,g.prototype._planId=null,g});

View File

@ -1 +1 @@
define(["jquery","core/templates","core/ajax","core/notification","core/str","tool_lp/menubar","tool_lp/event_base"],function(a,b,c,d,e,f,g){var h=function(){g.prototype.constructor.apply(this,[])};return h.prototype=Object.create(g.prototype),h.prototype._nodeSelector='[data-node="user-competency"]',h.prototype._cancelReviewRequest=function(a){var b={methodname:"core_competency_user_competency_cancel_review_request",args:{userid:a.userid,competencyid:a.competencyid}};c.call([b])[0].then(function(){this._trigger("review-request-cancelled",a),this._trigger("status-changed",a)}.bind(this),function(){this._trigger("error-occured",a)}.bind(this))},h.prototype.cancelReviewRequest=function(a){this._cancelReviewRequest(a)},h.prototype._cancelReviewRequestHandler=function(b){b.preventDefault();var c=this._findUserCompetencyData(a(b.target));this.cancelReviewRequest(c)},h.prototype._requestReview=function(a){var b={methodname:"core_competency_user_competency_request_review",args:{userid:a.userid,competencyid:a.competencyid}};c.call([b])[0].then(function(){this._trigger("review-requested",a),this._trigger("status-changed",a)}.bind(this),function(){this._trigger("error-occured",a)}.bind(this))},h.prototype.requestReview=function(a){this._requestReview(a)},h.prototype._requestReviewHandler=function(b){b.preventDefault();var c=this._findUserCompetencyData(a(b.target));this.requestReview(c)},h.prototype._startReview=function(a){var b={methodname:"core_competency_user_competency_start_review",args:{userid:a.userid,competencyid:a.competencyid}};c.call([b])[0].then(function(){this._trigger("review-started",a),this._trigger("status-changed",a)}.bind(this),function(){this._trigger("error-occured",a)}.bind(this))},h.prototype.startReview=function(a){this._startReview(a)},h.prototype._startReviewHandler=function(b){b.preventDefault();var c=this._findUserCompetencyData(a(b.target));this.startReview(c)},h.prototype._stopReview=function(a){var b={methodname:"core_competency_user_competency_stop_review",args:{userid:a.userid,competencyid:a.competencyid}};c.call([b])[0].then(function(){this._trigger("review-stopped",a),this._trigger("status-changed",a)}.bind(this),function(){this._trigger("error-occured",a)}.bind(this))},h.prototype.stopReview=function(a){this._stopReview(a)},h.prototype._stopReviewHandler=function(b){b.preventDefault();var c=this._findUserCompetencyData(a(b.target));this.stopReview(c)},h.prototype.enhanceMenubar=function(a){f.enhance(a,{'[data-action="request-review"]':this._requestReviewHandler.bind(this),'[data-action="cancel-review-request"]':this._cancelReviewRequestHandler.bind(this)})},h.prototype._findUserCompetencyData=function(a){var b,c=a.parents(this._nodeSelector);if(1!=c.length)throw new Error("The evidence node was not located.");if(b=c.data(),"undefined"==typeof b||"undefined"==typeof b.userid||"undefined"==typeof b.competencyid)throw new Error("User competency data could not be found.");return b},h.prototype.enhanceMenubar=function(a){f.enhance(a,{'[data-action="request-review"]':this._requestReviewHandler.bind(this),'[data-action="cancel-review-request"]':this._cancelReviewRequestHandler.bind(this),'[data-action="start-review"]':this._startReviewHandler.bind(this),'[data-action="stop-review"]':this._stopReviewHandler.bind(this)})},h.prototype.registerEvents=function(b){var c=a(b);c.find('[data-action="request-review"]').click(this._requestReviewHandler.bind(this)),c.find('[data-action="cancel-review-request"]').click(this._cancelReviewRequestHandler.bind(this)),c.find('[data-action="start-review"]').click(this._startReviewHandler.bind(this)),c.find('[data-action="stop-review"]').click(this._stopReviewHandler.bind(this))},h});
define(["jquery","core/templates","core/ajax","core/notification","core/str","tool_lp/menubar","tool_lp/event_base"],function(a,b,c,d,e,f,g){var h=function(){g.prototype.constructor.apply(this,[])};return h.prototype=Object.create(g.prototype),h.prototype._nodeSelector='[data-node="user-competency"]',h.prototype._cancelReviewRequest=function(a){var b={methodname:"core_competency_user_competency_cancel_review_request",args:{userid:a.userid,competencyid:a.competencyid}};c.call([b])[0].then(function(){this._trigger("review-request-cancelled",a),this._trigger("status-changed",a)}.bind(this))["catch"](function(){this._trigger("error-occured",a)}.bind(this))},h.prototype.cancelReviewRequest=function(a){this._cancelReviewRequest(a)},h.prototype._cancelReviewRequestHandler=function(b){b.preventDefault();var c=this._findUserCompetencyData(a(b.target));this.cancelReviewRequest(c)},h.prototype._requestReview=function(a){var b={methodname:"core_competency_user_competency_request_review",args:{userid:a.userid,competencyid:a.competencyid}};c.call([b])[0].then(function(){this._trigger("review-requested",a),this._trigger("status-changed",a)}.bind(this))["catch"](function(){this._trigger("error-occured",a)}.bind(this))},h.prototype.requestReview=function(a){this._requestReview(a)},h.prototype._requestReviewHandler=function(b){b.preventDefault();var c=this._findUserCompetencyData(a(b.target));this.requestReview(c)},h.prototype._startReview=function(a){var b={methodname:"core_competency_user_competency_start_review",args:{userid:a.userid,competencyid:a.competencyid}};c.call([b])[0].then(function(){this._trigger("review-started",a),this._trigger("status-changed",a)}.bind(this))["catch"](function(){this._trigger("error-occured",a)}.bind(this))},h.prototype.startReview=function(a){this._startReview(a)},h.prototype._startReviewHandler=function(b){b.preventDefault();var c=this._findUserCompetencyData(a(b.target));this.startReview(c)},h.prototype._stopReview=function(a){var b={methodname:"core_competency_user_competency_stop_review",args:{userid:a.userid,competencyid:a.competencyid}};c.call([b])[0].then(function(){this._trigger("review-stopped",a),this._trigger("status-changed",a)}.bind(this))["catch"](function(){this._trigger("error-occured",a)}.bind(this))},h.prototype.stopReview=function(a){this._stopReview(a)},h.prototype._stopReviewHandler=function(b){b.preventDefault();var c=this._findUserCompetencyData(a(b.target));this.stopReview(c)},h.prototype.enhanceMenubar=function(a){f.enhance(a,{'[data-action="request-review"]':this._requestReviewHandler.bind(this),'[data-action="cancel-review-request"]':this._cancelReviewRequestHandler.bind(this)})},h.prototype._findUserCompetencyData=function(a){var b,c=a.parents(this._nodeSelector);if(1!=c.length)throw new Error("The evidence node was not located.");if(b=c.data(),"undefined"==typeof b||"undefined"==typeof b.userid||"undefined"==typeof b.competencyid)throw new Error("User competency data could not be found.");return b},h.prototype.enhanceMenubar=function(a){f.enhance(a,{'[data-action="request-review"]':this._requestReviewHandler.bind(this),'[data-action="cancel-review-request"]':this._cancelReviewRequestHandler.bind(this),'[data-action="start-review"]':this._startReviewHandler.bind(this),'[data-action="stop-review"]':this._stopReviewHandler.bind(this)})},h.prototype.registerEvents=function(b){var c=a(b);c.find('[data-action="request-review"]').click(this._requestReviewHandler.bind(this)),c.find('[data-action="cancel-review-request"]').click(this._cancelReviewRequestHandler.bind(this)),c.find('[data-action="start-review"]').click(this._startReviewHandler.bind(this)),c.find('[data-action="stop-review"]').click(this._stopReviewHandler.bind(this))},h});

File diff suppressed because one or more lines are too long

View File

@ -131,6 +131,7 @@ define(['jquery',
html,
self._afterRender.bind(self)
);
return;
}).fail(Notification.exception);
};
@ -156,6 +157,7 @@ define(['jquery',
return self._render().then(function(html) {
self._find('[data-region="action-selector"]').replaceWith(html);
self._afterRender();
return;
});
};

View File

@ -181,13 +181,13 @@ define(['jquery',
pagerender = 'tool_lp/plan_page';
pageregion = 'plan-page';
}
ajax.call(requests)[requests.length - 1].then(function(context) {
return templates.render(pagerender, context).done(function(html, js) {
$('[data-region="' + pageregion + '"]').replaceWith(html);
templates.runTemplateJS(js);
});
}, notification.exception);
return templates.render(pagerender, context);
}).then(function(html, js) {
$('[data-region="' + pageregion + '"]').replaceWith(html);
templates.runTemplateJS(js);
return;
}).catch(notification.exception);
});
}

View File

@ -166,6 +166,7 @@ define(['jquery',
// We're done, let's trigger a change.
self._templateLoaded = true;
self._triggerChange();
return;
});
};

View File

@ -430,12 +430,13 @@ define(['jquery',
var promises = ajax.call(calls);
promises[calls.length - 1].then(function(context) {
return templates.render('tool_lp/related_competencies', context).done(function(html, js) {
$('[data-region="relatedcompetencies"]').replaceWith(html);
templates.runTemplateJS(js);
updatedRelatedCompetencies();
});
}, notification.exception);
return templates.render('tool_lp/related_competencies', context);
}).then(function(html, js) {
$('[data-region="relatedcompetencies"]').replaceWith(html);
templates.runTemplateJS(js);
updatedRelatedCompetencies();
return;
}).catch(notification.exception);
});
}
@ -472,7 +473,8 @@ define(['jquery',
relatedTarget.ruleconfig = config.ruleconfig;
renderCompetencySummary(relatedTarget);
}
}, notification.exception);
return;
}).catch(notification.exception);
};
/**
@ -692,28 +694,27 @@ define(['jquery',
type: strs[1]
};
}
}).then(function() {
return templates.render('tool_lp/competency_summary', context).then(function(html) {
$('[data-region="competencyinfo"]').html(html);
$('[data-action="deleterelation"]').on('click', deleteRelatedHandler);
});
}).then(function() {
return context;
}).then(function(context) {
return templates.render('tool_lp/competency_summary', context);
}).then(function(html) {
$('[data-region="competencyinfo"]').html(html);
$('[data-action="deleterelation"]').on('click', deleteRelatedHandler);
return templates.render('tool_lp/loading', {});
}).then(function(html, js) {
templates.replaceNodeContents('[data-region="relatedcompetencies"]', html, js);
}).done(function() {
ajax.call([{
return ajax.call([{
methodname: 'tool_lp_data_for_related_competencies_section',
args: {competencyid: competency.id},
done: function(context) {
return templates.render('tool_lp/related_competencies', context).done(function(html, js) {
$('[data-region="relatedcompetencies"]').replaceWith(html);
templates.runTemplateJS(js);
updatedRelatedCompetencies();
});
}
}]);
}).fail(notification.exception);
args: {competencyid: competency.id}
}])[0];
}).then(function(context) {
return templates.render('tool_lp/related_competencies', context);
}).then(function(html, js) {
$('[data-region="relatedcompetencies"]').replaceWith(html);
templates.runTemplateJS(js);
updatedRelatedCompetencies();
return;
}).catch(notification.exception);
};
/**
@ -776,16 +777,17 @@ define(['jquery',
// Log Competency viewed event.
triggerCompetencyViewedEvent(competency);
}
strSelectedTaxonomy(level).then(function(str) {
selectedTitle.text(str);
});
return;
}).catch(notification.exception);
strAddTaxonomy(sublevel).then(function(str) {
btn.show()
.find('[data-region="term"]')
.text(str);
});
return;
}).catch(notification.exception);
// We handled this event so consume it.
evt.preventDefault();

View File

@ -134,7 +134,7 @@ define(['jquery',
if (!self._singleFramework) {
self._find('[data-action="chooseframework"]').change(function(e) {
self._frameworkId = $(e.target).val();
self._loadCompetencies().then(self._refresh.bind(self));
self._loadCompetencies().then(self._refresh.bind(self)).catch(Notification.exception);
});
}
@ -203,15 +203,15 @@ define(['jquery',
*/
Picker.prototype.display = function() {
var self = this;
return self._render().then(function(html) {
return Str.get_string('competencypicker', 'tool_lp').then(function(title) {
self._popup = new Dialogue(
title,
html,
self._afterRender.bind(self)
);
});
}).fail(Notification.exception);
return $.when(Str.get_string('competencypicker', 'tool_lp'), self._render())
.then(function(title, render) {
self._popup = new Dialogue(
title,
render[0],
self._afterRender.bind(self)
);
return;
}).catch(Notification.exception);
};
/**
@ -388,6 +388,7 @@ define(['jquery',
return self._render().then(function(html) {
self._find('[data-region="competencylinktree"]').replaceWith(html);
self._afterRender();
return;
});
};

View File

@ -77,7 +77,8 @@ define(['jquery',
if (!self._singlePlan) {
self._find('[data-action="chooseplan"]').change(function(e) {
self._planId = $(e.target).val();
self._loadCompetencies().then(self._refresh.bind(self));
self._loadCompetencies().then(self._refresh.bind(self))
.catch(Notification.exception);
});
}
};

View File

@ -165,14 +165,14 @@ define(['jquery',
if (!self._competency) {
return false;
}
return self._render().then(function(html) {
return Str.get_string('competencyrule', 'tool_lp').then(function(title) {
self._popup = new Dialogue(
title,
html,
self._afterRender.bind(self)
);
});
return $.when(Str.get_string('competencyrule', 'tool_lp'), self._render())
.then(function(title, render) {
self._popup = new Dialogue(
title,
render[0],
self._afterRender.bind(self)
);
return;
}).fail(Notification.exception);
};
@ -312,9 +312,9 @@ define(['jquery',
*/
RuleConfig.prototype._initOutcomes = function() {
var self = this;
return Outcomes.getAll().then(function(outcomes) {
self._outcomesOption = outcomes;
return;
});
};
@ -328,11 +328,11 @@ define(['jquery',
RuleConfig.prototype._initRules = function() {
var self = this,
promises = [];
$.each(self._rules, function(index, rule) {
var promise = rule.init().then(function() {
rule.setTargetCompetency(self._competency);
rule.on('change', self._afterRuleConfigChange.bind(self));
return;
}, function() {
// Upon failure remove the rule, and resolve the promise.
self._rules.splice(index, 1);
@ -518,13 +518,13 @@ define(['jquery',
self._afterChange();
return;
}
rule.injectTemplate(container).then(function() {
container.show();
}, function() {
container.empty().hide();
return;
}).always(function() {
self._afterChange();
}).catch(function() {
container.empty().hide();
});
};

View File

@ -76,6 +76,7 @@ define(['jquery',
}]);
promise[0].then(function() {
parent.remove();
return;
}).fail(Notification.exception);
}
);

View File

@ -51,7 +51,6 @@ define(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {
includes: includes
}
}]);
promise[0].then(function(results) {
var promises = [],
i = 0;
@ -69,9 +68,10 @@ define(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {
i++;
});
success(results.cohorts);
return;
});
}, failure);
}).catch(failure);
}
};

View File

@ -79,9 +79,10 @@ define(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {
i++;
});
success(results.users);
return;
});
}, failure);
}).catch(failure);
}
};

View File

@ -35,20 +35,17 @@ define(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notificat
* @return {Promise}
*/
list: function(contextId, options) {
var promise,
args = {
var args = {
context: {
contextid: contextId
}
};
$.extend(args, typeof options === 'undefined' ? {} : options);
promise = Ajax.call([{
return Ajax.call([{
methodname: 'core_competency_list_competency_frameworks',
args: args
}])[0];
return promise.fail(Notification.exception);
},
/**
@ -76,6 +73,7 @@ define(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notificat
* @param {String} query The query string.
* @param {Function} callback A callback function receiving an array of results.
*/
/* eslint-disable promise/no-callback-in-promise */
transport: function(selector, query, callback) {
var el = $(selector),
contextId = el.data('contextid'),
@ -84,11 +82,10 @@ define(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notificat
if (!contextId) {
throw new Error('The attribute data-contextid is required on ' + selector);
}
this.list(contextId, {
query: query,
onlyvisible: onlyVisible,
}).then(callback);
}).then(callback).catch(Notification.exception);
}
};

View File

@ -81,6 +81,7 @@ define(['jquery', 'core/ajax', 'core/str', 'tool_lp/competencypicker', 'core/tem
Str.get_string('competencyframeworkroot', 'tool_lp').then(function(rootframework) {
$(self.staticElementSelector).html(rootframework);
$(self.inputHiddenSelector).val(data.competencyId);
return;
}).fail(Notification.exception);
}
};

View File

@ -110,15 +110,16 @@ define(['jquery',
* Callback to render the region template.
*
* @param {Object} context The context for the template.
* @return {Promise}
*/
PlanActions.prototype._renderView = function(context) {
var self = this;
templates.render(self._template, context)
.done(function(newhtml, newjs) {
return templates.render(self._template, context)
.then(function(newhtml, newjs) {
$(self._region).replaceWith(newhtml);
templates.runTemplateJS(newjs);
})
.fail(notification.exception);
return;
});
};
/**
@ -130,16 +131,15 @@ define(['jquery',
*/
PlanActions.prototype._callAndRefresh = function(calls, planData) {
var self = this;
calls.push({
methodname: self._contextMethod,
args: self._getContextArgs(planData)
});
// Apply all the promises, and refresh when the last one is resolved.
return $.when.apply($.when, ajax.call(calls))
return $.when.apply($, ajax.call(calls))
.then(function() {
self._renderView(arguments[arguments.length - 1]);
return self._renderView(arguments[arguments.length - 1]);
})
.fail(notification.exception);
};

View File

@ -58,7 +58,6 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/templates'
done: this._contextLoaded.bind(this),
fail: notification.exception
}]);
// Log the user competency viewed in plan event.
requests[0].then(function(result) {
var eventMethodName = 'core_competency_user_competency_viewed_in_plan';
@ -66,12 +65,11 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/templates'
if (result.plan.iscompleted) {
eventMethodName = 'core_competency_user_competency_plan_viewed';
}
ajax.call([{
return ajax.call([{
methodname: eventMethodName,
args: {competencyid: competencyId, userid: userId, planid: planId},
fail: notification.exception
}]);
});
args: {competencyid: competencyId, userid: userId, planid: planId}
}])[0];
}).catch(notification.exception);
};
/**

View File

@ -61,7 +61,7 @@ define(['jquery',
Ajax.call([call])[0].then(function() {
this._trigger('review-request-cancelled', data);
this._trigger('status-changed', data);
}.bind(this), function() {
}.bind(this)).catch(function() {
this._trigger('error-occured', data);
}.bind(this));
};
@ -106,7 +106,7 @@ define(['jquery',
Ajax.call([call])[0].then(function() {
this._trigger('review-requested', data);
this._trigger('status-changed', data);
}.bind(this), function() {
}.bind(this)).catch(function() {
this._trigger('error-occured', data);
}.bind(this));
};
@ -147,11 +147,10 @@ define(['jquery',
competencyid: data.competencyid
}
};
Ajax.call([call])[0].then(function() {
this._trigger('review-started', data);
this._trigger('status-changed', data);
}.bind(this), function() {
}.bind(this)).catch(function() {
this._trigger('error-occured', data);
}.bind(this));
};
@ -196,7 +195,7 @@ define(['jquery',
Ajax.call([call])[0].then(function() {
this._trigger('review-stopped', data);
this._trigger('status-changed', data);
}.bind(this), function() {
}.bind(this)).catch(function() {
this._trigger('error-occured', data);
}.bind(this));
};

View File

@ -98,14 +98,15 @@ define(['jquery',
* Callback to render the region template.
*
* @param {Object} context The context for the template.
* @return {Promise}
*/
UserEvidenceActions.prototype._renderView = function(context) {
var self = this;
templates.render(self._template, context)
.done(function(newhtml, newjs) {
return templates.render(self._template, context)
.then(function(newhtml, newjs) {
templates.replaceNode($(self._region), newhtml, newjs);
})
.fail(notification.exception);
return;
});
};
/**
@ -117,7 +118,6 @@ define(['jquery',
*/
UserEvidenceActions.prototype._callAndRefresh = function(calls, evidenceData) {
var self = this;
calls.push({
methodname: self._contextMethod,
args: self._getContextArgs(evidenceData)
@ -126,7 +126,7 @@ define(['jquery',
// Apply all the promises, and refresh when the last one is resolved.
return $.when.apply($.when, ajax.call(calls))
.then(function() {
self._renderView(arguments[arguments.length - 1]);
return self._renderView(arguments[arguments.length - 1]);
})
.fail(notification.exception);
};

View File

@ -68,6 +68,7 @@ function(ajax, BootstrapTour, $, templates, str, log, notification) {
templates.render('tool_usertours/tourstep', {})
).then(function(response, template) {
usertours.startBootstrapTour(tourId, template[0], response.tourconfig);
return;
}).fail(notification.exception);
},
@ -213,6 +214,7 @@ function(ajax, BootstrapTour, $, templates, str, log, notification) {
if (response.startTour) {
usertours.fetchTour(response.startTour);
}
return;
}).fail(notification.exception);
}
};

View File

@ -1 +1 @@
define(["jquery","core/notification","core/templates","core/custom_interaction_events","block_myoverview/calendar_events_repository"],function(a,b,c,d,e){var f=86400,g={EMPTY_MESSAGE:'[data-region="empty-message"]',ROOT:'[data-region="event-list-container"]',EVENT_LIST:'[data-region="event-list"]',EVENT_LIST_CONTENT:'[data-region="event-list-content"]',EVENT_LIST_GROUP_CONTAINER:'[data-region="event-list-group-container"]',LOADING_ICON_CONTAINER:'[data-region="loading-icon-container"]',VIEW_MORE_BUTTON:'[data-action="view-more"]'},h={EVENT_LIST_ITEMS:"block_myoverview/event-list-items",COURSE_EVENT_LIST_ITEMS:"block_myoverview/course-event-list-items"},i=function(a){a.attr("data-loaded-all",!0)},j=function(a){return!!a.attr("data-loaded-all")},k=function(a){var b=a.find(g.LOADING_ICON_CONTAINER),c=a.find(g.VIEW_MORE_BUTTON);a.addClass("loading"),b.removeClass("hidden"),c.prop("disabled",!0)},l=function(a){var b=a.find(g.LOADING_ICON_CONTAINER),c=a.find(g.VIEW_MORE_BUTTON);a.removeClass("loading"),b.addClass("hidden"),j(a)||c.prop("disabled",!1)},m=function(a){return a.hasClass("loading")},n=function(a){a.attr("data-has-events",!0)},o=function(a){return!!a.attr("data-has-events")},p=function(a,b){b?n(a):o(a)||q(a)},q=function(a){a.find(g.EVENT_LIST_CONTENT).addClass("hidden"),a.find(g.EMPTY_MESSAGE).removeClass("hidden")},r=function(a,b,d){return a.removeClass("hidden"),c.render(d,{events:b}).done(function(b,d){c.appendNodeContents(a.find(g.EVENT_LIST),b,d)})},s=function(a,b){var c=b.timesort||0;return c-a},t=function(a,b,c){var d=a.attr("data-midnight"),e=+c.attr("data-start-day")*f,g=+c.attr("data-end-day")*f,h=s(d,b);return""===c.attr("data-end-day")?e<=h:e<=h&&h<g},u=function(b,c){return function(d){return t(b,d,a(c))}},v=function(b,c){var d=0,e=h.EVENT_LIST_ITEMS;return b.attr("data-course-id")&&(e=h.COURSE_EVENT_LIST_ITEMS),a.when.apply(a,a.map(b.find(g.EVENT_LIST_GROUP_CONTAINER),function(f){var g=c.filter(u(b,f));return g.length?(d+=g.length,r(a(f),g,e)):null})).then(function(){return d})},w=function(c,d){c=a(c);var g=+c.attr("data-limit"),h=+c.attr("data-course-id"),j=c.attr("data-last-id"),n=c.attr("data-midnight"),o=n-14*f;if(m(c))return a.Deferred().resolve();if(k(c),"undefined"==typeof d){var q={starttime:o,limit:g};j&&(q.aftereventid=j),h?(q.courseid=h,d=e.queryByCourse(q)):d=e.queryByTime(q)}return d.then(function(a){return a.events}).then(function(a){return(!a.length||a.length<g)&&i(c),a.length?(c.attr("data-last-id",a[a.length-1].id),v(c,a).then(function(b){p(c,a.length),b<a.length&&i(c)})):void p(c,a.length)}).fail(b.exception).always(function(){l(c)})},x=function(a){d.define(a,[d.events.activate]),a.on(d.events.activate,g.VIEW_MORE_BUTTON,function(){w(a)})};return{init:function(b){b=a(b),w(b),x(b)},registerEventListeners:x,load:w,rootSelector:g.ROOT}});
define(["jquery","core/notification","core/templates","core/custom_interaction_events","block_myoverview/calendar_events_repository"],function(a,b,c,d,e){var f=86400,g={EMPTY_MESSAGE:'[data-region="empty-message"]',ROOT:'[data-region="event-list-container"]',EVENT_LIST:'[data-region="event-list"]',EVENT_LIST_CONTENT:'[data-region="event-list-content"]',EVENT_LIST_GROUP_CONTAINER:'[data-region="event-list-group-container"]',LOADING_ICON_CONTAINER:'[data-region="loading-icon-container"]',VIEW_MORE_BUTTON:'[data-action="view-more"]'},h={EVENT_LIST_ITEMS:"block_myoverview/event-list-items",COURSE_EVENT_LIST_ITEMS:"block_myoverview/course-event-list-items"},i=function(a){a.attr("data-loaded-all",!0)},j=function(a){return!!a.attr("data-loaded-all")},k=function(a){var b=a.find(g.LOADING_ICON_CONTAINER),c=a.find(g.VIEW_MORE_BUTTON);a.addClass("loading"),b.removeClass("hidden"),c.prop("disabled",!0)},l=function(a){var b=a.find(g.LOADING_ICON_CONTAINER),c=a.find(g.VIEW_MORE_BUTTON);a.removeClass("loading"),b.addClass("hidden"),j(a)||c.prop("disabled",!1)},m=function(a){return a.hasClass("loading")},n=function(a){a.attr("data-has-events",!0)},o=function(a){return!!a.attr("data-has-events")},p=function(a,b){b?n(a):o(a)||q(a)},q=function(a){a.find(g.EVENT_LIST_CONTENT).addClass("hidden"),a.find(g.EMPTY_MESSAGE).removeClass("hidden")},r=function(a,b,d){return a.removeClass("hidden"),c.render(d,{events:b}).done(function(b,d){c.appendNodeContents(a.find(g.EVENT_LIST),b,d)})},s=function(a,b){var c=b.timesort||0;return c-a},t=function(a,b,c){var d=a.attr("data-midnight"),e=+c.attr("data-start-day")*f,g=+c.attr("data-end-day")*f,h=s(d,b);return""===c.attr("data-end-day")?e<=h:e<=h&&h<g},u=function(b,c){return function(d){return t(b,d,a(c))}},v=function(b,c){var d=0,e=h.EVENT_LIST_ITEMS;return b.attr("data-course-id")&&(e=h.COURSE_EVENT_LIST_ITEMS),a.when.apply(a,a.map(b.find(g.EVENT_LIST_GROUP_CONTAINER),function(f){var g=c.filter(u(b,f));return g.length?(d+=g.length,r(a(f),g,e)):null})).then(function(){return d})},w=function(c,d){c=a(c);var g=+c.attr("data-limit"),h=+c.attr("data-course-id"),j=c.attr("data-last-id"),n=c.attr("data-midnight"),o=n-14*f;if(m(c))return a.Deferred().resolve();if(k(c),"undefined"==typeof d){var q={starttime:o,limit:g};j&&(q.aftereventid=j),h?(q.courseid=h,d=e.queryByCourse(q)):d=e.queryByTime(q)}return d.then(function(a){if(!a.events.length)return i(c),0;var b=a.events;return c.attr("data-last-id",b[b.length-1].id),b.length<=g&&i(c),v(c,b).then(function(a){return a<b.length&&i(c),b.length})}).then(function(a){return p(c,a)}).fail(b.exception).always(function(){l(c)})},x=function(a){d.define(a,[d.events.activate]),a.on(d.events.activate,g.VIEW_MORE_BUTTON,function(){w(a)})};return{init:function(b){b=a(b),w(b),x(b)},registerEventListeners:x,load:w,rootSelector:g.ROOT}});

View File

@ -350,34 +350,37 @@ define(['jquery', 'core/notification', 'core/templates',
// Request data from the server.
return promise.then(function(result) {
return result.events;
}).then(function(calendarEvents) {
if (!calendarEvents.length || (calendarEvents.length < limit)) {
// We have no more events so mark the list as done.
if (!result.events.length) {
// No events, nothing to do.
setLoadedAll(root);
return 0;
}
var calendarEvents = result.events;
// Remember the last id we've seen.
root.attr('data-last-id', calendarEvents[calendarEvents.length - 1].id);
if (calendarEvents.length <= limit) {
// No more events to load, disable loading button.
setLoadedAll(root);
}
if (calendarEvents.length) {
// Remember the last id we've seen.
root.attr('data-last-id', calendarEvents[calendarEvents.length - 1].id);
// Render the events.
return render(root, calendarEvents).then(function(renderCount) {
updateContentVisibility(root, calendarEvents.length);
if (renderCount < calendarEvents.length) {
// if the number of events that was rendered is less than
// the number we sent for rendering we can assume that there
// are no groups to add them in. Since the ordering of the
// events is guaranteed it means that any future requests will
// also yield events that can't be rendered, so let's not bother
// sending any more requests.
setLoadedAll(root);
}
});
} else {
updateContentVisibility(root, calendarEvents.length);
}
// Render the events.
return render(root, calendarEvents).then(function(renderCount) {
if (renderCount < calendarEvents.length) {
// if the number of events that was rendered is less than
// the number we sent for rendering we can assume that there
// are no groups to add them in. Since the ordering of the
// events is guaranteed it means that any future requests will
// also yield events that can't be rendered, so let's not bother
// sending any more requests.
setLoadedAll(root);
}
return calendarEvents.length;
});
}).then(function(eventCount) {
return updateContentVisibility(root, eventCount);
}).fail(
Notification.exception
).always(function() {

File diff suppressed because one or more lines are too long

View File

@ -354,27 +354,32 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
* @param {String} titlestr string for "title" attribute (if different from stringname)
* @param {String} titlecomponent
* @param {String} newaction new value for data-action attribute of the link
* @return {Promise} promise which is resolved when the replacement has completed
*/
var replaceActionItem = function(actionitem, image, stringname,
stringcomponent, titlestr, titlecomponent, newaction) {
str.get_string(stringname, stringcomponent).done(function(newstring) {
actionitem.find('span.menu-action-text').html(newstring);
actionitem.attr('title', newstring);
});
var stringRequests = [{key: stringname, component: stringcomponent}];
if (titlestr) {
str.get_string(titlestr, titlecomponent).then(function(newtitle) {
templates.renderPix(image, 'core', newtitle).then(function(html) {
actionitem.find('.icon').replaceWith(html);
});
actionitem.attr('title', newtitle);
});
} else {
templates.renderPix(image, 'core', '').then(function(html) {
actionitem.find('.icon').replaceWith(html);
});
stringRequests.push({key: titlestr, component: titlecomponent});
}
actionitem.attr('data-action', newaction);
return str.get_strings(stringRequests).then(function(strings) {
actionitem.find('span.menu-action-text').html(strings[0]);
actionitem.attr('title', strings[0]);
var title = '';
if (titlestr) {
title = strings[1];
actionitem.attr('title', title);
}
return templates.renderPix(image, 'core', title);
}).then(function(pixhtml) {
actionitem.find('.icon').replaceWith(pixhtml);
actionitem.attr('data-action', newaction);
return;
}).catch(notification.exception);
};
/**

View File

@ -1 +1 @@
define(["jquery","core/ajax"],function(a,b){var c=function(c,d,e,f){var g=[];for(var h in f)g.push({name:h,value:f[h]});var i=a.Deferred(),j=b.call([{methodname:"core_get_fragment",args:{component:c,callback:d,contextid:e,args:g}}],!1);return j[0].done(function(a){i.resolve(a)}).fail(function(a){i.reject(a)}),i.promise()};return{loadFragment:function(b,d,e,f){var g=a.Deferred();return a.when(c(b,d,e,f)).then(function(b){var c=a(b.javascript),d="";c.each(function(b,c){c=a(c);var e=c.prop("tagName");if(e&&"script"==e.toLowerCase())if(c.attr("src")){var f=!1;a("script").each(function(b,d){return a(d).attr("src")==c.attr("src")&&(f=!0),!f}),f||(d+=" { ",d+=' node = document.createElement("script"); ',d+=' node.type = "text/javascript"; ',d+=' node.src = decodeURI("'+encodeURI(c.attr("src"))+'"); ',d+=' document.getElementsByTagName("head")[0].appendChild(node); ',d+=" } ")}else d+=" "+c.text()}),g.resolve(b.html,d)}).fail(function(a){g.reject(a)}),g.promise()}}});
define(["jquery","core/ajax"],function(a,b){var c=function(a,c,d,e){var f=[];for(var g in e)f.push({name:g,value:e[g]});return b.call([{methodname:"core_get_fragment",args:{component:a,callback:c,contextid:d,args:f}}])[0]};return{loadFragment:function(b,d,e,f){var g=a.Deferred();return c(b,d,e,f).then(function(b){var c=a(b.javascript),d="";c.each(function(b,c){c=a(c);var e=c.prop("tagName");if(e&&"script"==e.toLowerCase())if(c.attr("src")){var f=!1;a("script").each(function(b,d){return a(d).attr("src")==c.attr("src")&&(f=!0),!f}),f||(d+=" { ",d+=' node = document.createElement("script"); ',d+=' node.type = "text/javascript"; ',d+=' node.src = decodeURI("'+encodeURI(c.attr("src"))+'"); ',d+=' document.getElementsByTagName("head")[0].appendChild(node); ',d+=" } ")}else d+=" "+c.text()}),g.resolve(b.html,d)}).fail(function(a){g.reject(a)}),g.promise()}}});

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
define(["jquery","core/ajax","core/sessionstorage","core/config"],function(a,b,c,d){var e={},f=function(b){var c=a("html").attr("lang").replace(/-/g,"_");return"core_user_date/"+c+"/"+d.usertimezone+"/"+b.timestamp+"/"+b.format},g=function(a){return c.get(a)},h=function(a,b){c.set(a,b)},i=function(a){return"undefined"!=typeof e[a]},j=function(a){return e[a]},k=function(a,b){e[a]=b},l=function(a){var c=a.map(function(a){return{timestamp:a.timestamp,format:a.format}}),e={methodname:"core_get_user_dates",args:{contextid:d.contextid,timestamps:c}};return b.call([e],!0,!0)[0].then(function(b){b.dates.forEach(function(b,c){var d=a[c],e=f(d);h(e,b),d.deferred.resolve(b)})}).fail(function(b){a.forEach(function(a){a.deferred.reject(b)})})},m=function(b){var c=[],d=[];return b.forEach(function(b){var e=f(b);if(i(e))d.push(j(e));else{var h=a.Deferred(),l=g(e);l?h.resolve(l):(b.deferred=h,c.push(b)),k(e,h.promise()),d.push(h.promise())}}),c.length&&l(c),a.when.apply(a,d).then(function(){return 1===arguments.length?[arguments[0]]:Array.apply(null,arguments)})};return{get:m}});
define(["jquery","core/ajax","core/sessionstorage","core/config"],function(a,b,c,d){var e={},f=function(b){var c=a("html").attr("lang").replace(/-/g,"_");return"core_user_date/"+c+"/"+d.usertimezone+"/"+b.timestamp+"/"+b.format},g=function(a){return c.get(a)},h=function(a,b){c.set(a,b)},i=function(a){return"undefined"!=typeof e[a]},j=function(a){return e[a]},k=function(a,b){e[a]=b},l=function(a){var c=a.map(function(a){return{timestamp:a.timestamp,format:a.format}}),e={methodname:"core_get_user_dates",args:{contextid:d.contextid,timestamps:c}};return b.call([e],!0,!0)[0].then(function(b){b.dates.forEach(function(b,c){var d=a[c],e=f(d);h(e,b),d.deferred.resolve(b)})})["catch"](function(b){a.forEach(function(a){a.deferred.reject(b)})})},m=function(b){var c=[],d=[];return b.forEach(function(b){var e=f(b);if(i(e))d.push(j(e));else{var h=a.Deferred(),l=g(e);l?h.resolve(l):(b.deferred=h,c.push(b)),k(e,h.promise()),d.push(h.promise())}}),c.length&&l(c),a.when.apply(a,d).then(function(){return 1===arguments.length?[arguments[0]]:Array.apply(null,arguments)})};return{get:m}});

View File

@ -45,10 +45,7 @@ define(['jquery', 'core/ajax'], function($, ajax) {
});
}
// Ajax stuff.
var deferred = $.Deferred();
var promises = ajax.call([{
return ajax.call([{
methodname: 'core_get_fragment',
args: {
component: component,
@ -56,14 +53,7 @@ define(['jquery', 'core/ajax'], function($, ajax) {
contextid: contextid,
args: formattedparams
}
}], false);
promises[0].done(function(data) {
deferred.resolve(data);
}).fail(function(ex) {
deferred.reject(ex);
});
return deferred.promise();
}])[0];
};
return /** @alias module:core/fragment */{
@ -81,7 +71,7 @@ define(['jquery', 'core/ajax'], function($, ajax) {
*/
loadFragment: function(component, callback, contextid, params) {
var promise = $.Deferred();
$.when(loadFragment(component, callback, contextid, params)).then(function(data) {
loadFragment(component, callback, contextid, params).then(function(data) {
var jsNodes = $(data.javascript);
var allScript = '';
jsNodes.each(function(index, scriptNode) {
@ -111,6 +101,7 @@ define(['jquery', 'core/ajax'], function($, ajax) {
}
});
promise.resolve(data.html, allScript);
return;
}).fail(function(ex) {
promise.reject(ex);
});

View File

@ -170,7 +170,7 @@ define(['core/mustache',
ready.reject('Invalid icon system specified' + config.iconsystemmodule);
} else {
iconSystem = system;
system.init().then(ready.resolve);
system.init().then(ready.resolve).catch(notification.exception);
}
});
@ -698,7 +698,7 @@ define(['core/mustache',
ready.reject('Invalid icon system specified' + config.iconsystem);
} else {
iconSystem = system;
system.init().then(ready.resolve);
system.init().then(ready.resolve).catch(notification.exception);
}
});

View File

@ -127,8 +127,9 @@ define(['jquery', 'core/ajax', 'core/sessionstorage', 'core/config'],
addToLocalStorage(key, value);
date.deferred.resolve(value);
});
return;
})
.fail(function(ex) {
.catch(function(ex) {
// If we failed to retrieve the dates then reject the date's
// deferred objects to make sure they don't hang.
dates.forEach(function(date) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -455,9 +455,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
}
});
});
if (requests.length > 0) {
Ajax.call(requests)[requests.length - 1].then(function() {
$.when(Ajax.call(requests)).then(function() {
// Store the last message on the page, and the last message being deleted.
var updatemessage = null;
var messages = this.messageArea.find(SELECTORS.MESSAGE);
@ -491,7 +490,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
// Trigger event letting other modules know messages were deleted.
this.messageArea.trigger(Events.MESSAGESDELETED, [this._getUserId(), updatemessage]);
}.bind(this), Notification.exception);
}.bind(this)).catch(Notification.exception);
} else {
// Trigger event letting other modules know messages were deleted.
this.messageArea.trigger(Events.MESSAGESDELETED, this._getUserId());
@ -526,49 +525,47 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* @private
*/
Messages.prototype._deleteAllMessages = function() {
// Create the confirmation modal if we haven't already.
if (!this._confirmationModal) {
Str.get_strings([
{key: 'confirm'},
{key: 'deleteallconfirm', component: 'message'}
]).done(function(s) {
ModalFactory.create({
title: s[0],
type: ModalFactory.types.CONFIRM,
body: s[1]
}, this.messageArea.find(SELECTORS.DELETEALLMESSAGES))
.done(function(modal) {
this._confirmationModal = modal;
// Only delete the conversation if the user agreed in the confirmation modal.
modal.getRoot().on(ModalEvents.yes, function() {
var otherUserId = this._getUserId();
var request = {
methodname: 'core_message_delete_conversation',
args: {
userid: this.messageArea.getCurrentUserId(),
otheruserid: otherUserId
}
};
// Delete the conversation.
Ajax.call([request])[0].then(function() {
// Clear the message area.
this.messageArea.find(SELECTORS.MESSAGESAREA).empty();
// Let the app know a conversation was deleted.
this.messageArea.trigger(Events.CONVERSATIONDELETED, otherUserId);
this._hideDeleteAction();
}.bind(this), Notification.exception);
}.bind(this));
// Display the confirmation.
modal.show();
}.bind(this));
}.bind(this));
} else {
// Otherwise just show the existing modal.
if (this._confirmationModal) {
// Just show the existing modal.
this._confirmationModal.show();
return;
}
Str.get_strings([
{key: 'confirm'},
{key: 'deleteallconfirm', component: 'message'}
]).then(function(s) {
return ModalFactory.create({
title: s[0],
type: ModalFactory.types.CONFIRM,
body: s[1]
}, this.messageArea.find(SELECTORS.DELETEALLMESSAGES));
}.bind(this)).then(function(modal) {
this._confirmationModal = modal;
// Only delete the conversation if the user agreed in the confirmation modal.
modal.getRoot().on(ModalEvents.yes, function() {
var otherUserId = this._getUserId();
var request = {
methodname: 'core_message_delete_conversation',
args: {
userid: this.messageArea.getCurrentUserId(),
otheruserid: otherUserId
}
};
// Delete the conversation.
Ajax.call([request])[0].then(function() {
// Clear the message area.
this.messageArea.find(SELECTORS.MESSAGESAREA).empty();
// Let the app know a conversation was deleted.
this.messageArea.trigger(Events.CONVERSATIONDELETED, otherUserId);
this._hideDeleteAction();
}.bind(this)).catch(Notification.exception);
}.bind(this));
// Display the confirmation.
modal.show();
}.bind(this)).catch(Notification.exception);
};
/**

View File

@ -385,7 +385,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
this.messageArea.find(SELECTORS.SEARCHFILTER).html(text);
Str.get_string('removecoursefilter', 'message', text).then(function(languagestring) {
this.messageArea.find(SELECTORS.SEARCHFILTERAREA).attr('aria-label', languagestring);
}.bind(this));
}.bind(this)).catch(Notification.exception);
};
/**

View File

@ -1 +1 @@
define(["jquery","core/ajax","core/templates","core/str","core/notification","core/custom_interaction_events","core/popover_region_controller","core_message/message_repository","core/url"],function(a,b,c,d,e,f,g,h,i){var j={MARK_ALL_READ_BUTTON:'[data-action="mark-all-read"]',CONTENT:'[data-region="messages"]',CONTENT_ITEM_CONTAINER:'[data-region="message-content-item-container"]',EMPTY_MESSAGE:'[data-region="empty-message"]',COUNT_CONTAINER:'[data-region="count-container"]'},k=function(a){g.call(this,a),this.markAllReadButton=this.root.find(j.MARK_ALL_READ_BUTTON),this.content=this.root.find(j.CONTENT),this.userId=this.root.attr("data-userid"),this.limit=20,this.offset=0,this.loadedAll=!1,this.initialLoad=!1,this.loadUnreadMessageCount()};return k.prototype=Object.create(g.prototype),k.prototype.constructor=k,k.prototype.getContent=function(){return this.content},k.prototype.incrementOffset=function(){this.offset+=this.limit},k.prototype.updateButtonAriaLabel=function(){this.isMenuOpen()?d.get_string("hidemessagewindow","message").done(function(a){this.menuToggle.attr("aria-label",a)}.bind(this)):this.unreadCount?d.get_string("showmessagewindowwithcount","message",this.unreadCount).done(function(a){this.menuToggle.attr("aria-label",a)}.bind(this)):d.get_string("showmessagewindownonew","message").done(function(a){this.menuToggle.attr("aria-label",a)}.bind(this))},k.prototype.renderUnreadCount=function(){var a=this.root.find(j.COUNT_CONTAINER);this.unreadCount?(a.text(this.unreadCount),a.removeClass("hidden")):a.addClass("hidden")},k.prototype.hideUnreadCount=function(){this.root.find(j.COUNT_CONTAINER).addClass("hidden")},k.prototype.loadUnreadMessageCount=function(){h.countUnreadConversations({useridto:this.userId}).then(function(a){this.unreadCount=a,this.renderUnreadCount(),this.updateButtonAriaLabel()}.bind(this))},k.prototype.renderMessages=function(b,d){var e=[],f=[],g=[];return b.length&&a.each(b,function(a,b){b.contexturl=i.relativeUrl("/message/index.php",{user:this.userId,id:b.userid}),b.profileurl=i.relativeUrl("/user/profile.php",{id:b.userid});var d=c.render("message_popup/message_content_item",b);e.push(d),d.then(function(b,c){f[a]=b,g[a]=c})}.bind(this)),a.when.apply(a.when,e).then(function(){b.length&&a.each(b,function(a){d.append(f[a]),c.runTemplateJS(g[a])})})},k.prototype.loadMoreMessages=function(){if(this.isLoading||this.loadedAll)return a.Deferred().resolve();this.startLoading();var b={userid:this.userId,limit:this.limit,offset:this.offset},c=this.getContent();return h.query(b).then(function(a){var b=a.contacts;return this.loadedAll=!b.length||b.length<this.limit,this.initialLoad=!0,this.updateButtonAriaLabel(),!!b.length&&(this.incrementOffset(),this.renderMessages(b,c))}.bind(this)).always(function(){this.stopLoading()}.bind(this))},k.prototype.markAllAsRead=function(){return this.markAllReadButton.hasClass("loading")?a.Deferred().resolve():(this.markAllReadButton.addClass("loading"),h.markAllAsRead({useridto:this.userId}).then(function(){this.unreadCount=0,this.hideUnreadCount(),this.getContent().find(j.CONTENT_ITEM_CONTAINER).removeClass("unread")}.bind(this)).always(function(){this.markAllReadButton.removeClass("loading")}.bind(this)))},k.prototype.registerEventListeners=function(){f.define(this.root,[f.events.keyboardActivate]),this.root.on(this.events().menuOpened,function(){this.hideUnreadCount(),this.updateButtonAriaLabel(),this.initialLoad||this.loadMoreMessages()}.bind(this)),this.root.on(this.events().menuClosed,function(){this.renderUnreadCount(),this.updateButtonAriaLabel()}.bind(this)),this.root.on(f.events.scrollBottom,function(){this.loadMoreMessages()}.bind(this)),this.root.on(f.events.activate,j.MARK_ALL_READ_BUTTON,function(a,b){this.markAllAsRead(),a.stopPropagation(),b.originalEvent.preventDefault()}.bind(this)),f.define(this.getContentContainer(),[f.events.scrollLock]),a(document).on("messagearea:conversationselected",function(){this.unreadCount--,this.renderUnreadCount()}.bind(this))},k});
define(["jquery","core/ajax","core/templates","core/str","core/notification","core/custom_interaction_events","core/popover_region_controller","core_message/message_repository","core/url"],function(a,b,c,d,e,f,g,h,i){var j={MARK_ALL_READ_BUTTON:'[data-action="mark-all-read"]',CONTENT:'[data-region="messages"]',CONTENT_ITEM_CONTAINER:'[data-region="message-content-item-container"]',EMPTY_MESSAGE:'[data-region="empty-message"]',COUNT_CONTAINER:'[data-region="count-container"]'},k=function(a){g.call(this,a),this.markAllReadButton=this.root.find(j.MARK_ALL_READ_BUTTON),this.content=this.root.find(j.CONTENT),this.userId=this.root.attr("data-userid"),this.limit=20,this.offset=0,this.loadedAll=!1,this.initialLoad=!1,this.loadUnreadMessageCount()};return k.prototype=Object.create(g.prototype),k.prototype.constructor=k,k.prototype.getContent=function(){return this.content},k.prototype.incrementOffset=function(){this.offset+=this.limit},k.prototype.updateButtonAriaLabel=function(){this.isMenuOpen()?d.get_string("hidemessagewindow","message").done(function(a){this.menuToggle.attr("aria-label",a)}.bind(this)):this.unreadCount?d.get_string("showmessagewindowwithcount","message",this.unreadCount).done(function(a){this.menuToggle.attr("aria-label",a)}.bind(this)):d.get_string("showmessagewindownonew","message").done(function(a){this.menuToggle.attr("aria-label",a)}.bind(this))},k.prototype.renderUnreadCount=function(){var a=this.root.find(j.COUNT_CONTAINER);this.unreadCount?(a.text(this.unreadCount),a.removeClass("hidden")):a.addClass("hidden")},k.prototype.hideUnreadCount=function(){this.root.find(j.COUNT_CONTAINER).addClass("hidden")},k.prototype.loadUnreadMessageCount=function(){h.countUnreadConversations({useridto:this.userId}).then(function(a){this.unreadCount=a,this.renderUnreadCount(),this.updateButtonAriaLabel()}.bind(this))["catch"](e.exception)},k.prototype.renderMessages=function(b,d){var e=[];return a.each(b,function(a,b){b.contexturl=i.relativeUrl("/message/index.php",{user:this.userId,id:b.userid}),b.profileurl=i.relativeUrl("/user/profile.php",{id:b.userid});var f=c.render("message_popup/message_content_item",b).then(function(a,b){d.append(a),c.runTemplateJS(b)});e.push(f)}.bind(this)),a.when.apply(a,e)},k.prototype.loadMoreMessages=function(){if(this.isLoading||this.loadedAll)return a.Deferred().resolve();this.startLoading();var b={userid:this.userId,limit:this.limit,offset:this.offset},c=this.getContent();return h.query(b).then(function(a){var b=a.contacts;return this.loadedAll=!b.length||b.length<this.limit,this.initialLoad=!0,this.updateButtonAriaLabel(),!!b.length&&(this.incrementOffset(),this.renderMessages(b,c))}.bind(this)).always(function(){this.stopLoading()}.bind(this))},k.prototype.markAllAsRead=function(){return this.markAllReadButton.hasClass("loading")?a.Deferred().resolve():(this.markAllReadButton.addClass("loading"),h.markAllAsRead({useridto:this.userId}).then(function(){this.unreadCount=0,this.hideUnreadCount(),this.getContent().find(j.CONTENT_ITEM_CONTAINER).removeClass("unread")}.bind(this)).always(function(){this.markAllReadButton.removeClass("loading")}.bind(this)))},k.prototype.registerEventListeners=function(){f.define(this.root,[f.events.keyboardActivate]),this.root.on(this.events().menuOpened,function(){this.hideUnreadCount(),this.updateButtonAriaLabel(),this.initialLoad||this.loadMoreMessages()}.bind(this)),this.root.on(this.events().menuClosed,function(){this.renderUnreadCount(),this.updateButtonAriaLabel()}.bind(this)),this.root.on(f.events.scrollBottom,function(){this.loadMoreMessages()}.bind(this)),this.root.on(f.events.activate,j.MARK_ALL_READ_BUTTON,function(a,b){this.markAllAsRead(),a.stopPropagation(),b.originalEvent.preventDefault()}.bind(this)),f.define(this.getContentContainer(),[f.events.scrollLock]),a(document).on("messagearea:conversationselected",function(){this.unreadCount--,this.renderUnreadCount()}.bind(this))},k});

View File

@ -1 +1 @@
define(["jquery","core/templates","core/notification","core/custom_interaction_events","message_popup/notification_repository","message_popup/notification_area_events"],function(a,b,c,d,e,f){var g={CONTAINER:'[data-region="notification-area"]',CONTENT:'[data-region="content"]',NOTIFICATION:'[data-region="notification-content-item-container"]',CAN_RECEIVE_FOCUS:'input:not([type="hidden"]), a[href], button, textarea, select, [tabindex]'},h={NOTIFICATION:"message_popup/notification_content_item"},i=function(b,c){this.root=a(b),this.container=this.root.closest(g.CONTAINER),this.userId=c,this.content=this.root.find(g.CONTENT),this.offset=0,this.limit=20,this.initialLoad=!1,this.isLoading=!1,this.loadedAll=!1,this.notifications={},this.registerEventListeners()};return i.prototype.getRoot=function(){return this.root},i.prototype.getContainer=function(){return this.container},i.prototype.getUserId=function(){return this.userId},i.prototype.getContent=function(){return this.content},i.prototype.getOffset=function(){return this.offset},i.prototype.getLimit=function(){return this.limit},i.prototype.setOffset=function(a){this.offset=a},i.prototype.setLimit=function(a){this.limit=a},i.prototype.incrementOffset=function(){this.offset+=this.limit},i.prototype.startLoading=function(){this.isLoading=!0,this.getRoot().addClass("loading")},i.prototype.stopLoading=function(){this.isLoading=!1,this.getRoot().removeClass("loading")},i.prototype.hasDoneInitialLoad=function(){return this.initialLoad},i.prototype.hasLoadedAllContent=function(){return this.loadedAll},i.prototype.setLoadedAllContent=function(a){this.loadedAll=a},i.prototype.setCacheNotification=function(a){this.notifications[a.id]=a},i.prototype.getCacheNotification=function(a){return this.notifications[a]},i.prototype.getNotificationElement=function(a){var b=this.getRoot().find(g.NOTIFICATION+'[data-id="'+a+'"]');return 1==b.length?b:null},i.prototype.scrollNotificationIntoView=function(a){var b=a.position(),c=this.getRoot(),d=b.top-c.scrollTop();if(d>c.innerHeight()){var e=a.outerHeight();e=4*e;var f=b.top-e;c.scrollTop(f)}},i.prototype.showNotification=function(b){if("object"!=typeof b&&(b=this.getNotificationElement(b)),b&&b.length){this.getRoot().find(g.NOTIFICATION).removeClass("selected"),b.addClass("selected").find(g.CAN_RECEIVE_FOCUS).focus();var c=b.attr("data-id"),d=this.getCacheNotification(c);this.scrollNotificationIntoView(b),this.getContainer().trigger(f.showNotification,[a.extend({},d)])}},i.prototype.markNotificationAsRead=function(a){return e.markAsRead(a.attr("data-id")).done(function(){a.removeClass("unread")})},i.prototype.renderNotifications=function(d){var e=[],f=[],g=[],i=this.getContent();return d.length&&a.each(d,function(a,d){var i=d.contexturl;delete d.contexturl;var j=b.render(h.NOTIFICATION,d);e.push(j),j.then(function(b,c){f[a]=b,g[a]=c,d.contexturl=i,this.setCacheNotification(d)}.bind(this)).fail(c.exception)}.bind(this)),a.when.apply(a.when,e).then(function(){d.length&&a.each(d,function(a){i.append(f[a]),b.runTemplateJS(g[a])})})},i.prototype.loadMoreNotifications=function(){if(this.isLoading||this.hasLoadedAllContent())return a.Deferred().resolve();this.startLoading();var b={limit:this.getLimit(),offset:this.getOffset(),useridto:this.getUserId()};this.initialLoad||(b.limit=this.getOffset()+this.getLimit(),b.offset=0);var c=e.query(b).then(function(a){var b=a.notifications;return this.unreadCount=a.unreadcount,this.setLoadedAllContent(!b.length||b.length<this.getLimit()),this.initialLoad=!0,!!b.length&&(this.incrementOffset(),this.renderNotifications(b))}.bind(this)).always(function(){this.stopLoading()}.bind(this));return c},i.prototype.registerEventListeners=function(){d.define(this.getRoot(),[d.events.activate,d.events.scrollBottom,d.events.scrollLock,d.events.up,d.events.down]),this.getRoot().on(d.events.scrollBottom,function(){this.loadMoreNotifications()}.bind(this)),this.getRoot().on(d.events.activate,g.NOTIFICATION,function(b){var c=a(b.target).closest(g.NOTIFICATION);this.showNotification(c)}.bind(this)),this.getRoot().on(d.events.up,g.NOTIFICATION,function(b,c){var d=a(b.target).closest(g.NOTIFICATION);this.showNotification(d.prev()),c.originalEvent.preventDefault()}.bind(this)),this.getRoot().on(d.events.down,g.NOTIFICATION,function(b,c){var d=a(b.target).closest(g.NOTIFICATION);this.showNotification(d.next()),c.originalEvent.preventDefault()}.bind(this)),this.getContainer().on(f.notificationShown,function(a,b){if(!b.read){var c=this.getNotificationElement(b.id);c&&this.markNotificationAsRead(c);var d=this.getCacheNotification(b.id);d&&(d.read=!0)}}.bind(this))},i});
define(["jquery","core/templates","core/notification","core/custom_interaction_events","message_popup/notification_repository","message_popup/notification_area_events"],function(a,b,c,d,e,f){var g={CONTAINER:'[data-region="notification-area"]',CONTENT:'[data-region="content"]',NOTIFICATION:'[data-region="notification-content-item-container"]',CAN_RECEIVE_FOCUS:'input:not([type="hidden"]), a[href], button, textarea, select, [tabindex]'},h={NOTIFICATION:"message_popup/notification_content_item"},i=function(b,c){this.root=a(b),this.container=this.root.closest(g.CONTAINER),this.userId=c,this.content=this.root.find(g.CONTENT),this.offset=0,this.limit=20,this.initialLoad=!1,this.isLoading=!1,this.loadedAll=!1,this.notifications={},this.registerEventListeners()};return i.prototype.getRoot=function(){return this.root},i.prototype.getContainer=function(){return this.container},i.prototype.getUserId=function(){return this.userId},i.prototype.getContent=function(){return this.content},i.prototype.getOffset=function(){return this.offset},i.prototype.getLimit=function(){return this.limit},i.prototype.setOffset=function(a){this.offset=a},i.prototype.setLimit=function(a){this.limit=a},i.prototype.incrementOffset=function(){this.offset+=this.limit},i.prototype.startLoading=function(){this.isLoading=!0,this.getRoot().addClass("loading")},i.prototype.stopLoading=function(){this.isLoading=!1,this.getRoot().removeClass("loading")},i.prototype.hasDoneInitialLoad=function(){return this.initialLoad},i.prototype.hasLoadedAllContent=function(){return this.loadedAll},i.prototype.setLoadedAllContent=function(a){this.loadedAll=a},i.prototype.setCacheNotification=function(a){this.notifications[a.id]=a},i.prototype.getCacheNotification=function(a){return this.notifications[a]},i.prototype.getNotificationElement=function(a){var b=this.getRoot().find(g.NOTIFICATION+'[data-id="'+a+'"]');return 1==b.length?b:null},i.prototype.scrollNotificationIntoView=function(a){var b=a.position(),c=this.getRoot(),d=b.top-c.scrollTop();if(d>c.innerHeight()){var e=a.outerHeight();e=4*e;var f=b.top-e;c.scrollTop(f)}},i.prototype.showNotification=function(b){if("object"!=typeof b&&(b=this.getNotificationElement(b)),b&&b.length){this.getRoot().find(g.NOTIFICATION).removeClass("selected"),b.addClass("selected").find(g.CAN_RECEIVE_FOCUS).focus();var c=b.attr("data-id"),d=this.getCacheNotification(c);this.scrollNotificationIntoView(b),this.getContainer().trigger(f.showNotification,[a.extend({},d)])}},i.prototype.markNotificationAsRead=function(a){return e.markAsRead(a.attr("data-id")).done(function(){a.removeClass("unread")})},i.prototype.renderNotifications=function(c){var d=[],e=this.getContent();return a.each(c,function(a,c){var f=c.contexturl;delete c.contexturl;var g=b.render(h.NOTIFICATION,c).then(function(a,d){e.append(a),b.runTemplateJS(d),c.contexturl=f,this.setCacheNotification(c)}.bind(this));d.push(g)}.bind(this)),a.when.apply(a,d)},i.prototype.loadMoreNotifications=function(){if(this.isLoading||this.hasLoadedAllContent())return a.Deferred().resolve();this.startLoading();var b={limit:this.getLimit(),offset:this.getOffset(),useridto:this.getUserId()};this.initialLoad||(b.limit=this.getOffset()+this.getLimit(),b.offset=0);var c=e.query(b).then(function(a){var b=a.notifications;return this.unreadCount=a.unreadcount,this.setLoadedAllContent(!b.length||b.length<this.getLimit()),this.initialLoad=!0,!!b.length&&(this.incrementOffset(),this.renderNotifications(b))}.bind(this)).always(function(){this.stopLoading()}.bind(this));return c},i.prototype.registerEventListeners=function(){d.define(this.getRoot(),[d.events.activate,d.events.scrollBottom,d.events.scrollLock,d.events.up,d.events.down]),this.getRoot().on(d.events.scrollBottom,function(){this.loadMoreNotifications()}.bind(this)),this.getRoot().on(d.events.activate,g.NOTIFICATION,function(b){var c=a(b.target).closest(g.NOTIFICATION);this.showNotification(c)}.bind(this)),this.getRoot().on(d.events.up,g.NOTIFICATION,function(b,c){var d=a(b.target).closest(g.NOTIFICATION);this.showNotification(d.prev()),c.originalEvent.preventDefault()}.bind(this)),this.getRoot().on(d.events.down,g.NOTIFICATION,function(b,c){var d=a(b.target).closest(g.NOTIFICATION);this.showNotification(d.next()),c.originalEvent.preventDefault()}.bind(this)),this.getContainer().on(f.notificationShown,function(a,b){if(!b.read){var c=this.getNotificationElement(b.id);c&&this.markNotificationAsRead(c);var d=this.getCacheNotification(b.id);d&&(d.read=!0)}}.bind(this))},i});

File diff suppressed because one or more lines are too long

View File

@ -151,7 +151,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str',
this.unreadCount = count;
this.renderUnreadCount();
this.updateButtonAriaLabel();
}.bind(this));
}.bind(this)).catch(Notification.exception);
};
/**
@ -165,38 +165,27 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str',
*/
MessagePopoverController.prototype.renderMessages = function(messages, container) {
var promises = [];
var allhtml = [];
var alljs = [];
if (messages.length) {
$.each(messages, function(index, message) {
message.contexturl = URL.relativeUrl('/message/index.php', {
user: this.userId,
id: message.userid,
});
$.each(messages, function(index, message) {
message.contexturl = URL.relativeUrl('/message/index.php', {
user: this.userId,
id: message.userid,
});
message.profileurl = URL.relativeUrl('/user/profile.php', {
id: message.userid,
});
message.profileurl = URL.relativeUrl('/user/profile.php', {
id: message.userid,
});
var promise = Templates.render('message_popup/message_content_item', message);
promises.push(promise);
var promise = Templates.render('message_popup/message_content_item', message)
.then(function(html, js) {
container.append(html);
Templates.runTemplateJS(js);
return;
});
promises.push(promise);
}.bind(this));
promise.then(function(html, js) {
allhtml[index] = html;
alljs[index] = js;
});
}.bind(this));
}
return $.when.apply($.when, promises).then(function() {
if (messages.length) {
$.each(messages, function(index) {
container.append(allhtml[index]);
Templates.runTemplateJS(alljs[index]);
});
}
});
return $.when.apply($, promises);
};
/**

View File

@ -307,39 +307,27 @@ define(['jquery', 'core/templates', 'core/notification', 'core/custom_interactio
*/
ControlArea.prototype.renderNotifications = function(notifications) {
var promises = [];
var allhtml = [];
var alljs = [];
var container = this.getContent();
if (notifications.length) {
$.each(notifications, function(index, notification) {
// Need to remove the contexturl so the item isn't rendered
// as a link.
var contextUrl = notification.contexturl;
delete notification.contexturl;
$.each(notifications, function(index, notification) {
// Need to remove the contexturl so the item isn't rendered
// as a link.
var contextUrl = notification.contexturl;
delete notification.contexturl;
var promise = Templates.render(TEMPLATES.NOTIFICATION, notification);
promises.push(promise);
promise.then(function(html, js) {
allhtml[index] = html;
alljs[index] = js;
// Restore it for the cache.
notification.contexturl = contextUrl;
this.setCacheNotification(notification);
}.bind(this))
.fail(DebugNotification.exception);
var promise = Templates.render(TEMPLATES.NOTIFICATION, notification)
.then(function(html, js) {
container.append(html);
Templates.runTemplateJS(js);
// Restore it for the cache.
notification.contexturl = contextUrl;
this.setCacheNotification(notification);
return;
}.bind(this));
}
promises.push(promise);
}.bind(this));
return $.when.apply($.when, promises).then(function() {
if (notifications.length) {
$.each(notifications, function(index) {
container.append(allhtml[index]);
Templates.runTemplateJS(alljs[index]);
});
}
});
return $.when.apply($, promises);
};
/**

View File

@ -200,7 +200,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str', 'core/url',
this.unreadCount = count;
this.renderUnreadCount();
this.updateButtonAriaLabel();
}.bind(this));
}.bind(this)).catch(DebugNotification.exception);
};
/**
@ -226,39 +226,27 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str', 'core/url',
*/
NotificationPopoverController.prototype.renderNotifications = function(notifications, container) {
var promises = [];
var allhtml = [];
var alljs = [];
if (notifications.length) {
$.each(notifications, function(index, notification) {
// Determine what the offset was when loading this notification.
var offset = this.getOffset() - this.limit;
// Update the view more url to contain the offset to allow the notifications
// page to load to the correct position in the list of notifications.
notification.viewmoreurl = URL.relativeUrl('/message/output/popup/notifications.php', {
notificationid: notification.id,
offset: offset,
});
$.each(notifications, function(index, notification) {
// Determine what the offset was when loading this notification.
var offset = this.getOffset() - this.limit;
// Update the view more url to contain the offset to allow the notifications
// page to load to the correct position in the list of notifications.
notification.viewmoreurl = URL.relativeUrl('/message/output/popup/notifications.php', {
notificationid: notification.id,
offset: offset,
});
var promise = Templates.render('message_popup/notification_content_item', notification);
promises.push(promise);
var promise = Templates.render('message_popup/notification_content_item', notification)
.then(function(html, js) {
container.append(html);
Templates.runTemplateJS(js);
return;
});
promises.push(promise);
}.bind(this));
promise.then(function(html, js) {
allhtml[index] = html;
alljs[index] = js;
})
.fail(DebugNotification.exception);
}.bind(this));
}
return $.when.apply($.when, promises).then(function() {
if (notifications.length) {
$.each(notifications, function(index) {
container.append(allhtml[index]);
Templates.runTemplateJS(alljs[index]);
});
}
});
return $.when.apply($, promises);
};
/**

View File

@ -107,6 +107,7 @@ define(['core/ajax', 'jquery', 'core/templates'], function(ajax, $, templates) {
}
success(users);
return;
}).catch(failure);
}
};

View File

@ -1 +1 @@
define(["jquery","core/notification","core/str","core/templates","mod_lti/form-field","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f,g){var h,i={init:function(a,e){var i="";c.get_string("selectcontent","lti").then(function(c){i=c;var j={url:a,postData:e},k=d.render("mod_lti/contentitem",j);h?(h.setBody(k),h.show()):f.create({title:i,body:k,large:!0}).done(function(a){h=a,h.show(),a.getRoot().on(g.hidden,function(){a.setBody(""),b.fetchNotifications()})})})}},j=[new e("name",e.TYPES.TEXT,(!1),""),new e("introeditor",e.TYPES.EDITOR,(!1),""),new e("toolurl",e.TYPES.TEXT,(!0),""),new e("securetoolurl",e.TYPES.TEXT,(!0),""),new e("instructorchoiceacceptgrades",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorchoicesendname",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorchoicesendemailaddr",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorcustomparameters",e.TYPES.TEXT,(!0),""),new e("icon",e.TYPES.TEXT,(!0),""),new e("secureicon",e.TYPES.TEXT,(!0),""),new e("launchcontainer",e.TYPES.SELECT,(!0),0)];return window.processContentItemReturnData=function(b){h&&h.hide();var c;for(c in j){var d=j[c],e=null;"undefined"!==a.type(b[d.name])&&(e=b[d.name]),d.setFieldValue(e)}},i});
define(["jquery","core/notification","core/str","core/templates","mod_lti/form-field","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f,g){var h,i={init:function(a,e){var i={url:a,postData:e},j=d.render("mod_lti/contentitem",i);return h?(h.setBody(j),void h.show()):void c.get_string("selectcontent","lti").then(function(a){return f.create({title:a,body:j,large:!0})}).then(function(a){h=a,a.getRoot().on(g.hidden,function(){a.setBody(""),b.fetchNotifications()}),a.show()})["catch"](b.exception)}},j=[new e("name",e.TYPES.TEXT,(!1),""),new e("introeditor",e.TYPES.EDITOR,(!1),""),new e("toolurl",e.TYPES.TEXT,(!0),""),new e("securetoolurl",e.TYPES.TEXT,(!0),""),new e("instructorchoiceacceptgrades",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorchoicesendname",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorchoicesendemailaddr",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorcustomparameters",e.TYPES.TEXT,(!0),""),new e("icon",e.TYPES.TEXT,(!0),""),new e("secureicon",e.TYPES.TEXT,(!0),""),new e("launchcontainer",e.TYPES.SELECT,(!0),0)];return window.processContentItemReturnData=function(b){h&&h.hide();var c;for(c in j){var d=j[c],e=null;"undefined"!==a.type(b[d.name])&&(e=b[d.name]),d.setFieldValue(e)}},i});

View File

@ -1 +1 @@
define(["jquery","core/ajax","core/notification","core/templates","mod_lti/tool_type","mod_lti/events","mod_lti/keys","core/str"],function(a,b,c,d,e,f,g,h){var i={DELETE_BUTTON:".delete",NAME_ELEMENT:".name",DESCRIPTION_ELEMENT:".description",CAPABILITIES_CONTAINER:".capabilities-container",ACTIVATE_BUTTON:".tool-card-footer a.activate"},j=2e3,k=function(a){return a.find(i.DELETE_BUTTON)},l=function(a){return a.find(i.NAME_ELEMENT)},m=function(a){return a.find(i.DESCRIPTION_ELEMENT)},n=function(a){return a.find(i.ACTIVATE_BUTTON)},o=function(a){return!!n(a).length},p=function(a){return a.find(i.CAPABILITIES_CONTAINER)},q=function(a){return!!p(a).length},r=function(a){return a.attr("data-type-id")},s=function(a){a.removeClass("announcement loading success fail capabilities")},t=function(a){s(a),a.addClass("announcement loading")},u=function(a){a.removeClass("announcement loading")},v=function(b){var c=a.Deferred();return s(b),b.addClass("announcement success"),setTimeout(function(){b.removeClass("announcement success"),c.resolve()},j),c},w=function(b){var c=a.Deferred();return s(b),b.addClass("announcement fail"),setTimeout(function(){b.removeClass("announcement fail"),c.resolve()},j),c},x=function(b){var d=a.Deferred(),f=r(b);return t(b),""===f?a.Deferred().resolve():(h.get_strings([{key:"delete",component:"mod_lti"},{key:"delete_confirmation",component:"mod_lti"},{key:"delete",component:"mod_lti"},{key:"cancel",component:"core"}]).done(function(a){c.confirm(a[0],a[1],a[2],a[3],function(){e["delete"](f).done(function(){u(b),v(b).done(function(){b.remove()}).fail(c.exception).always(function(){d.resolve()})}).fail(function(a){w(b),d.reject(a)})},function(){u(b),d.resolve()})}).fail(function(a){u(b),c.exception(a),d.reject(a)}),d)},y=function(a,b){a.attr("data-val-snapshot",b)},z=function(a){return a.attr("data-val-snapshot")},A=function(a){var b=m(a);if(!b.hasClass("loading")){var c=b.text().trim();y(b,c)}},B=function(b){var d=r(b);if(""===d)return a.Deferred().resolve();var f=m(b);if(f.hasClass("loading"))return a.Deferred().resolve();var g=f.text().trim(),h=z(f);if(h==g)return a.Deferred().resolve();f.addClass("loading");var i=e.update({id:d,description:g});return i.done(function(a){f.removeClass("loading"),f.text(a.description)}).fail(c.exception),i.fail(function(){f.removeClass("loading")}),i},C=function(a){var b=l(a);if(!b.hasClass("loading")){var c=b.text().trim();y(b,c)}},D=function(b){var c=r(b);if(""===c)return a.Deferred().resolve();var d=l(b);if(d.hasClass("loading"))return a.Deferred().resolve();var f=d.text().trim(),g=z(d);if(g==f)return a.Deferred().resolve();d.addClass("loading");var h=e.update({id:c,name:f});return h.done(function(a){d.removeClass("loading"),d.text(a.name)}),h.fail(function(){d.removeClass("loading")}),h},E=function(b){var c=r(b);if(""===c)return a.Deferred().resolve();t(b);var f=e.update({id:c,state:e.constants.state.configured});return f.done(function(c){u(b);var e=v(b),f=d.render("mod_lti/tool_card",c);a.when(f,e).then(function(a){var c=a[0],e=a[1];d.replaceNode(b,c,e)})}),f.fail(function(){u(b),w(b)}),f},F=function(a){a.addClass("announcement capabilities")},G=function(a){a.removeClass("announcement capabilities")},H=function(a){q(a)?F(a):E(a)},I=function(a){var b=k(a);b.click(function(b){b.preventDefault(),x(a)}),b.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||a.keyCode!=g.ENTER&&a.keyCode!=g.SPACE||(a.preventDefault(),b.click())});var c=m(a);c.focus(function(b){b.preventDefault(),A(a)}),c.blur(function(b){b.preventDefault(),B(a)}),c.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||a.keyCode==g.ENTER&&(a.preventDefault(),c.blur())});var d=l(a);if(d.focus(function(b){b.preventDefault(),C(a)}),d.blur(function(b){b.preventDefault(),D(a)}),d.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||a.keyCode==g.ENTER&&(a.preventDefault(),d.blur())}),o(a)){var e=n(a);e.click(function(b){b.preventDefault(),H(a)}),e.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||a.keyCode!=g.ENTER&&a.keyCode!=g.SPACE||(a.preventDefault(),e.click())})}if(q(a)){var h=p(a);h.on(f.CAPABILITIES_AGREE,function(){E(a)}),h.on(f.CAPABILITIES_DECLINE,function(){G(a)})}};return{init:function(a){I(a)}}});
define(["jquery","core/ajax","core/notification","core/templates","mod_lti/tool_type","mod_lti/events","mod_lti/keys","core/str"],function(a,b,c,d,e,f,g,h){var i={DELETE_BUTTON:".delete",NAME_ELEMENT:".name",DESCRIPTION_ELEMENT:".description",CAPABILITIES_CONTAINER:".capabilities-container",ACTIVATE_BUTTON:".tool-card-footer a.activate"},j=2e3,k=function(a){return a.find(i.DELETE_BUTTON)},l=function(a){return a.find(i.NAME_ELEMENT)},m=function(a){return a.find(i.DESCRIPTION_ELEMENT)},n=function(a){return a.find(i.ACTIVATE_BUTTON)},o=function(a){return!!n(a).length},p=function(a){return a.find(i.CAPABILITIES_CONTAINER)},q=function(a){return!!p(a).length},r=function(a){return a.attr("data-type-id")},s=function(a){a.removeClass("announcement loading success fail capabilities")},t=function(a){s(a),a.addClass("announcement loading")},u=function(a){a.removeClass("announcement loading")},v=function(b){var c=a.Deferred();return s(b),b.addClass("announcement success"),setTimeout(function(){b.removeClass("announcement success"),c.resolve()},j),c},w=function(b){var c=a.Deferred();return s(b),b.addClass("announcement fail"),setTimeout(function(){b.removeClass("announcement fail"),c.resolve()},j),c},x=function(b){var d=a.Deferred(),f=r(b);return t(b),""===f?a.Deferred().resolve():(h.get_strings([{key:"delete",component:"mod_lti"},{key:"delete_confirmation",component:"mod_lti"},{key:"delete",component:"mod_lti"},{key:"cancel",component:"core"}]).done(function(a){c.confirm(a[0],a[1],a[2],a[3],function(){e["delete"](f).done(function(){u(b),v(b).done(function(){b.remove()}).fail(c.exception).always(function(){d.resolve()})}).fail(function(a){w(b),d.reject(a)})},function(){u(b),d.resolve()})}).fail(function(a){u(b),c.exception(a),d.reject(a)}),d)},y=function(a,b){a.attr("data-val-snapshot",b)},z=function(a){return a.attr("data-val-snapshot")},A=function(a){var b=m(a);if(!b.hasClass("loading")){var c=b.text().trim();y(b,c)}},B=function(b){var d=r(b);if(""===d)return a.Deferred().resolve();var f=m(b);if(f.hasClass("loading"))return a.Deferred().resolve();var g=f.text().trim(),h=z(f);if(h==g)return a.Deferred().resolve();f.addClass("loading");var i=e.update({id:d,description:g});return i.done(function(a){f.removeClass("loading"),f.text(a.description)}).fail(c.exception),i.fail(function(){f.removeClass("loading")}),i},C=function(a){var b=l(a);if(!b.hasClass("loading")){var c=b.text().trim();y(b,c)}},D=function(b){var c=r(b);if(""===c)return a.Deferred().resolve();var d=l(b);if(d.hasClass("loading"))return a.Deferred().resolve();var f=d.text().trim(),g=z(d);if(g==f)return a.Deferred().resolve();d.addClass("loading");var h=e.update({id:c,name:f});return h.done(function(a){d.removeClass("loading"),d.text(a.name)}),h.fail(function(){d.removeClass("loading")}),h},E=function(b){var c=r(b);if(""===c)return a.Deferred().resolve();t(b);var f=e.update({id:c,state:e.constants.state.configured});return f.then(function(a){return u(b),v(b),a}).then(function(a){return d.render("mod_lti/tool_card",a)}).then(function(a){var c=a[0],e=a[1];d.replaceNode(b,c,e)})["catch"](function(){u(b),w(b)}),f},F=function(a){a.addClass("announcement capabilities")},G=function(a){a.removeClass("announcement capabilities")},H=function(a){q(a)?F(a):E(a)},I=function(a){var b=k(a);b.click(function(b){b.preventDefault(),x(a)}),b.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||a.keyCode!=g.ENTER&&a.keyCode!=g.SPACE||(a.preventDefault(),b.click())});var c=m(a);c.focus(function(b){b.preventDefault(),A(a)}),c.blur(function(b){b.preventDefault(),B(a)}),c.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||a.keyCode==g.ENTER&&(a.preventDefault(),c.blur())});var d=l(a);if(d.focus(function(b){b.preventDefault(),C(a)}),d.blur(function(b){b.preventDefault(),D(a)}),d.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||a.keyCode==g.ENTER&&(a.preventDefault(),d.blur())}),o(a)){var e=n(a);e.click(function(b){b.preventDefault(),H(a)}),e.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||a.keyCode!=g.ENTER&&a.keyCode!=g.SPACE||(a.preventDefault(),e.click())})}if(q(a)){var h=p(a);h.on(f.CAPABILITIES_AGREE,function(){E(a)}),h.on(f.CAPABILITIES_DECLINE,function(){G(a)})}};return{init:function(a){I(a)}}});

View File

@ -46,42 +46,41 @@ define(
* @param {object} postData The data to be sent for the content item selection request.
*/
init: function(url, postData) {
var dialogueTitle = '';
var context = {
url: url,
postData: postData
};
var bodyPromise = templates.render('mod_lti/contentitem', context);
if (dialogue) {
// Set dialogue body.
dialogue.setBody(bodyPromise);
// Display the dialogue.
dialogue.show();
return;
}
str.get_string('selectcontent', 'lti').then(function(title) {
dialogueTitle = title;
var context = {
url: url,
postData: postData
};
return ModalFactory.create({
title: title,
body: bodyPromise,
large: true
});
}).then(function(modal) {
dialogue = modal;
// On hide handler.
modal.getRoot().on(ModalEvents.hidden, function() {
// Empty modal contents when it's hidden.
modal.setBody('');
var body = templates.render('mod_lti/contentitem', context);
if (dialogue) {
// Set dialogue body.
dialogue.setBody(body);
// Display the dialogue.
dialogue.show();
} else {
ModalFactory.create({
title: dialogueTitle,
body: body,
large: true
}).done(function(modal) {
dialogue = modal;
// Fetch notifications.
notification.fetchNotifications();
});
// Display the dialogue.
dialogue.show();
// On hide handler.
modal.getRoot().on(ModalEvents.hidden, function() {
// Empty modal contents when it's hidden.
modal.setBody('');
// Fetch notifications.
notification.fetchNotifications();
});
});
}
});
// Display the dialogue.
modal.show();
return;
}).catch(notification.exception);
}
};

View File

@ -477,21 +477,19 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/templates', 'mod_lti/t
state: toolType.constants.state.configured
});
promise.done(function(toolTypeData) {
promise.then(function(toolTypeData) {
stopLoading(element);
announceSuccess(element);
return toolTypeData;
}).then(function(toolTypeData) {
return templates.render('mod_lti/tool_card', toolTypeData);
}).then(function(renderResult) {
var html = renderResult[0];
var js = renderResult[1];
var announcePromise = announceSuccess(element);
var renderPromise = templates.render('mod_lti/tool_card', toolTypeData);
$.when(renderPromise, announcePromise).then(function(renderResult) {
var html = renderResult[0];
var js = renderResult[1];
templates.replaceNode(element, html, js);
});
});
promise.fail(function() {
templates.replaceNode(element, html, js);
return;
}).catch(function() {
stopLoading(element);
announceFailure(element);
});

View File

@ -1 +1 @@
define(["jquery","core/str","core/modal_factory","core/notification"],function(a,b,c,d){return{ensureRadiosChosen:function(e){var f=b.get_strings([{key:"error",component:"moodle"},{key:"questionsnotanswered",component:"survey"}]).then(function(a){return c.create({type:c.types.CANCEL,title:a[0],body:a[1]})})["catch"](d.exception),g=a("#"+e);g.submit(function(a){return 0===g.find('input:radio[data-survey-default="true"]:checked').length||(a.preventDefault(),f.then(function(a){a.show()}),!1)})}}});
define(["jquery","core/str","core/modal_factory","core/notification"],function(a,b,c,d){return{ensureRadiosChosen:function(e){var f=b.get_strings([{key:"error",component:"moodle"},{key:"questionsnotanswered",component:"survey"}]).then(function(a){return c.create({type:c.types.CANCEL,title:a[0],body:a[1]})})["catch"](d.exception),g=a("#"+e);g.submit(function(a){return 0===g.find('input:radio[data-survey-default="true"]:checked').length||(a.preventDefault(),f.then(function(a){return a.show(),!1}))})}}});

View File

@ -49,11 +49,10 @@ define(['jquery', 'core/str', 'core/modal_factory', 'core/notification'], functi
if (form.find('input:radio[data-survey-default="true"]:checked').length !== 0) {
e.preventDefault();
// Display the modal error.
modalPromise.then(function(modal) {
return modalPromise.then(function(modal) {
modal.show();
return;
return false;
});
return false;
}
return true;

6
npm-shrinkwrap.json generated
View File

@ -821,6 +821,12 @@
"integrity": "sha1-f6qEWZ4P6kIvBLwy20kFQFGj8Ro=",
"dev": true
},
"eslint-plugin-promise": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-3.5.0.tgz",
"integrity": "sha1-ePu2/+BHIBYnVp6FpsU3OvKmj8o=",
"dev": true
},
"espree": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/espree/-/espree-3.4.3.tgz",

View File

@ -5,6 +5,7 @@
"devDependencies": {
"async": "1.5.2",
"eslint": "3.7.1",
"eslint-plugin-promise": "3.5.0",
"gherkin-lint": "1.1.3",
"grunt": "1.0.1",
"grunt-contrib-less": "1.3.0",

View File

@ -1 +1 @@
define(["jquery","core/notification","core/str","core/ajax","core/log","core/templates","tool_lp/dialogue"],function(a,b,c,d,e,f,g){var h=function(b,c){this._regionSelector=b,this._userCompetencySelector=c,a(this._regionSelector).on("click",this._userCompetencySelector,this._handleClick.bind(this))};return h.prototype._handleClick=function(c){var f=a(c.target).closest(this._userCompetencySelector),g=a(f).data("competencyid"),h=a(f).data("courseid"),i=a(f).data("userid");e.debug("Clicked on cell: competencyId="+g+", courseId="+h+", userId="+i);var j=d.call([{methodname:"tool_lp_data_for_user_competency_summary_in_course",args:{userid:i,competencyid:g,courseid:h},done:this._contextLoaded.bind(this),fail:b.exception}]);j[0].then(function(){d.call([{methodname:"core_competency_user_competency_viewed_in_course",args:{userid:i,competencyid:g,courseid:h},fail:b.exception}])})},h.prototype._contextLoaded=function(a){var d=this;a.displayuser=!0,f.render("tool_lp/user_competency_summary_in_course",a).done(function(a,e){c.get_string("usercompetencysummary","report_competency").done(function(b){new g(b,a,f.runTemplateJS.bind(f,e),d._refresh.bind(d),(!0))}).fail(b.exception)}).fail(b.exception)},h.prototype._refresh=function(){var c=a(this._regionSelector),e=c.data("courseid"),f=c.data("userid");d.call([{methodname:"report_competency_data_for_report",args:{courseid:e,userid:f},done:this._pageContextLoaded.bind(this),fail:b.exception}])},h.prototype._pageContextLoaded=function(a){var c=this;f.render("report_competency/report",a).done(function(a,b){f.replaceNode(c._regionSelector,a,b)}).fail(b.exception)},h.prototype._regionSelector=null,h.prototype._userCompetencySelector=null,h});
define(["jquery","core/notification","core/str","core/ajax","core/log","core/templates","tool_lp/dialogue"],function(a,b,c,d,e,f,g){var h=function(b,c){this._regionSelector=b,this._userCompetencySelector=c,a(this._regionSelector).on("click",this._userCompetencySelector,this._handleClick.bind(this))};return h.prototype._handleClick=function(c){var f=a(c.target).closest(this._userCompetencySelector),g=a(f).data("competencyid"),h=a(f).data("courseid"),i=a(f).data("userid");e.debug("Clicked on cell: competencyId="+g+", courseId="+h+", userId="+i);var j=d.call([{methodname:"tool_lp_data_for_user_competency_summary_in_course",args:{userid:i,competencyid:g,courseid:h}},{methodname:"core_competency_user_competency_viewed_in_course",args:{userid:i,competencyid:g,courseid:h}}]);a.when.apply(a,j).then(function(){this._contextLoaded.bind(this)})["catch"](b.exception)},h.prototype._contextLoaded=function(a){var d=this;a.displayuser=!0,f.render("tool_lp/user_competency_summary_in_course",a).done(function(a,e){c.get_string("usercompetencysummary","report_competency").done(function(b){new g(b,a,f.runTemplateJS.bind(f,e),d._refresh.bind(d),(!0))}).fail(b.exception)}).fail(b.exception)},h.prototype._refresh=function(){var c=a(this._regionSelector),e=c.data("courseid"),f=c.data("userid");d.call([{methodname:"report_competency_data_for_report",args:{courseid:e,userid:f},done:this._pageContextLoaded.bind(this),fail:b.exception}])},h.prototype._pageContextLoaded=function(a){var c=this;f.render("report_competency/report",a).done(function(a,b){f.replaceNode(c._regionSelector,a,b)}).fail(b.exception)},h.prototype._regionSelector=null,h.prototype._userCompetencySelector=null,h});

View File

@ -54,18 +54,15 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
var requests = ajax.call([{
methodname: 'tool_lp_data_for_user_competency_summary_in_course',
args: {userid: userId, competencyid: competencyId, courseid: courseId},
done: this._contextLoaded.bind(this),
fail: notification.exception
}, {
methodname: 'core_competency_user_competency_viewed_in_course',
args: {userid: userId, competencyid: competencyId, courseid: courseId},
}]);
// Log the user competency viewed in course event.
requests[0].then(function() {
ajax.call([{
methodname: 'core_competency_user_competency_viewed_in_course',
args: {userid: userId, competencyid: competencyId, courseid: courseId},
fail: notification.exception
}]);
});
$.when.apply($, requests).then(function() {
this._contextLoaded.bind(this);
return;
}).catch(notification.exception);
};
/**