Autoría | Ultima modificación | Ver Log |
/**
* Grade dialogue.
*
* @module tool_lp/grade_dialogue
* @copyright 2016 Frédéric Massart - FMCorz.net
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("tool_lp/grade_dialogue",["jquery","core/notification","core/templates","tool_lp/dialogue","tool_lp/event_base","core/str"],(function($,Notification,Templates,Dialogue,EventBase,Str){var Grade=function(ratingOptions){EventBase.prototype.constructor.apply(this,[]),this._ratingOptions=ratingOptions};return(Grade.prototype=Object.create(EventBase.prototype))._popup=null,Grade.prototype._ratingOptions=null,Grade.prototype._afterRender=function(){var btnRate=this._find('[data-action="rate"]'),lstRating=this._find('[name="rating"]'),txtComment=this._find('[name="comment"]');this._find('[data-action="cancel"]').click(function(e){e.preventDefault(),this._trigger("cancelled"),this.close()}.bind(this)),lstRating.change((function(){$(this).val()?btnRate.prop("disabled",!1):btnRate.prop("disabled",!0)})).change(),btnRate.click(function(e){e.preventDefault();var val=lstRating.val();val&&(this._trigger("rated",{rating:val,note:txtComment.val()}),this.close())}.bind(this))},Grade.prototype.close=function(){this._pop
up.close(),this._popup=null},Grade.prototype.display=function(){return M.util.js_pending("tool_lp/grade_dialogue:display"),$.when(Str.get_string("rate","tool_lp"),this._render()).then(function(title,templateResult){return this._popup=new Dialogue(title,templateResult[0],function(){this._afterRender(),M.util.js_complete("tool_lp/grade_dialogue:display")}.bind(this)),this._popup}.bind(this)).catch(Notification.exception)},Grade.prototype._find=function(selector){return $(this._popup.getContent()).find(selector)},Grade.prototype._render=function(){var context={cangrade:this._canGrade,ratings:this._ratingOptions};return Templates.render("tool_lp/competency_grader",context)},Grade}));
//# sourceMappingURL=grade_dialogue.min.js.map