YUI.add("moodle-availability_profile-form",function(e,t){M.availability_profile=M.availability_profile||{},M.availability_profile.form=e.Object(M.core_availability.plugin),M.availability_profile.form.profiles=null,M.availability_profile.form.initInner=function(e,t){this.standardFields=e,this.customFields=t},M.availability_profile.form.getNode=function(t){var n=M.str.availability_profile,r='<span class="availability-group"><label>'+n.conditiontitle+" "+'<select name="field">'+'<option value="choose">'+M.str.moodle.choosedots+"</option>",i;for(var s=0;s<this.standardFields.length;s++)i=this.standardFields[s],r+='<option value="sf_'+i.field+'">'+i.display+"</option>";for(s=0;s<this.customFields.length;s++)i=this.customFields[s],r+='<option value="cf_'+i.field+'">'+i.display+"</option>";r+='</select></label> <label><span class="accesshide">'+n.label_operator+' </span><select name="op" title="'+n.label_operator+'">';var o=["isequalto","contains","doesnotcontain","startswith","endswith","isempty","isnotempty"];for(s=0;s<o.length;s++)r+='<option value="'+o[s]+'">'+n["op_"+o[s]]+"</option>";r+='</select></label> <label><span class="accesshide">'+n.label_value+'</span><input name="value" type="text" style="width: 10em" title="'+n.label_value+'"/></label></span>';var u=e.Node.create("<span>"+r+"</span>");t.sf!==undefined&&u.one("select[name=field] > option[value=sf_"+t.sf+"]")?u.one("select[name=field]").set("value","sf_"+t.sf):t.cf!==undefined&&u.one("select[name=field] > option[value=cf_"+t.cf+"]")&&u.one("select[name=field]").set("value","cf_"+t.cf),t.op!==undefined&&u.one("select[name=op] > option[value="+t.op+"]")&&(u.one("select[name=op]").set("value",t.op),(t.op==="isempty"||t.op==="isnotempty")&&u.one("input[name=value]").set("disabled",!0)),t.v!==undefined&&u.one("input").set("value",t.v);if(!M.availability_profile.form.addedEvents){M.availability_profile.form.addedEvents=!0;var a=function(e){var t=e.ancestor("span.availability_profile"),n=t.one("select[name=op]"),r=n.get("value")==="isempty"||n.get("value")==="isnotempty";t.one("input[name=value]").set("disabled",r),M.core_availability.form.update()},f=e.one("#fitem_id_availabilityconditionsjson");f.delegate("change",function(){a(this)},".availability_profile select"),f.delegate("change",function(){a(this)},".availability_profile input[name=value]")}return u},M.availability_profile.form.fillValue=function(e,t){var n=t.one("select[name=field]").get("value");n.substr(0,3)==="sf_"?e.sf=n.substr(3):n.substr(0,3)==="cf_"&&(e.cf=n.substr(3)),e.op=t.one("select[name=op]").get("value");var r=t.one("input[name=value]");r.get("disabled")||(e.v=r.get("value"))},M.availability_profile.form.fillErrors=function(e,t){var n={};this.fillValue(n,t),n.sf===undefined&&n.cf===undefined&&e.push("availability_profile:error_selectfield"),n.v!==undefined&&/^\s*$/.test(n.v)&&e.push("availability_profile:error_setvalue")}},"@VERSION@",{requires:["base","node","event","moodle-core_availability-form"]});
