Your IP : 192.168.165.1


Current Path : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/
Upload File :
Current File : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/scaleconfig.min.js

define ("tool_lp/scaleconfig",["jquery","core/notification","core/templates","core/ajax","tool_lp/dialogue","tool_lp/scalevalues"],function(a,b,c,d,e,f){var g=function(b,c,d){this.selectSelector=b;this.inputSelector=c;this.triggerSelector=d;this.originalscaleid=a(b).val();a(b).on("change",this.scaleChangeHandler.bind(this)).change();a(d).click(this.showConfig.bind(this))};g.prototype.selectSelector=null;g.prototype.inputSelector=null;g.prototype.triggerSelector=null;g.prototype.scalevalues=null;g.prototype.originalscaleid=0;g.prototype.scaleid=0;g.prototype.popup=null;g.prototype.showConfig=function(){var d=this;this.scaleid=a(this.selectSelector).val();if(0>=this.scaleid){return}var f=a(this.selectSelector).find("option:selected").text();this.getScaleValues(this.scaleid).done(function(){var a={scalename:f,scales:d.scalevalues};c.render("tool_lp/scale_configuration_page",a).done(function(a){new e(f,a,d.initScaleConfig.bind(d))}).fail(b.exception)}).fail(b.exception)};g.prototype.retrieveOriginalScaleConfig=function(){var b=a(this.inputSelector).val();if(""!==b){var c=a.parseJSON(b),d=c.shift();if(d.scaleid===this.originalscaleid){return c}}return""};g.prototype.initScaleConfig=function(b){this.popup=b;var c=a(b.getContent());if(this.originalscaleid===this.scaleid){var d=this.retrieveOriginalScaleConfig();if(""!==d){d.forEach(function(a){if(1===a.scaledefault){c.find("[data-field=\"tool_lp_scale_default_"+a.id+"\"]").attr("checked",!0)}if(1===a.proficient){c.find("[data-field=\"tool_lp_scale_proficient_"+a.id+"\"]").attr("checked",!0)}})}}c.on("click","[data-action=\"close\"]",function(){this.setScaleConfig();b.close()}.bind(this));c.on("click","[data-action=\"cancel\"]",function(){b.close()})};g.prototype.setScaleConfig=function(){var b=a(this.popup.getContent()),c=[{scaleid:this.scaleid}];this.scalevalues.forEach(function(a){var d=0,e=0;if(b.find("[data-field=\"tool_lp_scale_default_"+a.id+"\"]").is(":checked")){d=1}if(b.find("[data-field=\"tool_lp_scale_proficient_"+a.id+"\"]").is(":checked")){e=1}if(!d&&!e){return}c.push({id:a.id,scaledefault:d,proficient:e})});var d=JSON.stringify(c);a(this.inputSelector).val(d);this.originalscaleid=this.scaleid};g.prototype.getScaleValues=function(a){return f.get_values(a).then(function(a){this.scalevalues=a;return a}.bind(this))};g.prototype.scaleChangeHandler=function(b){if(0>=a(b.target).val()){a(this.triggerSelector).prop("disabled",!0)}else{a(this.triggerSelector).prop("disabled",!1)}};return{init:function init(a,b,c){return new g(a,b,c)}}});
//# sourceMappingURL=scaleconfig.min.js.map