YUI.add("moodle-mod_offlinequiz-offlinequizquestionbank",function(o,r){var i="div.questionbankloading",e='.menu [data-action="questionbank"]',t="td.addtoofflinequizaction",n="td.previewaction",a="#advancedsearch",d="addonpage",s="header",l=function(){l.superclass.constructor.apply(this,arguments)};o.extend(l,o.Base,{loadingDiv:"",dialogue:null,addonpage:0,searchRegionInitialised:!1,tags:"",create_dialogue:function(){var e={headerContent:"",bodyContent:o.one(i),draggable:!0,modal:!0,centered:!0,width:null,visible:!1,postmethod:"form",footerContent:null,extraClasses:["mod_offlinequiz_qbank_dialogue"]};this.dialogue=new M.core.dialogue(e),this.dialogue.bodyNode.delegate("click",this.link_clicked,"a[href]",this),this.dialogue.hide(),this.loadingDiv=this.dialogue.bodyNode.getHTML(),o.later(100,this,function(){this.load_content(window.location.search)})},initializer:function(){o.one(i)&&(this.create_dialogue(),o.one("body").delegate("click",this.display_dialogue,e,this))},display_dialogue:function(e){e.preventDefault(),this.dialogue.set("headerContent",e.currentTarget.getData(s)),this.addonpage=e.currentTarget.getData(d),(e=this.dialogue.bodyNode.one(".modulespecificbuttonscontainer"))&&(e.one("input[name=addonpage]")||e.appendChild('<input type="hidden" name="addonpage">')).set("value",this.addonpage),this.initialiseSearchRegion(),this.dialogue.show()},load_content:function(e){this.dialogue.bodyNode.append(this.loadingDiv),o.io(M.cfg.wwwroot+"/mod/offlinequiz/questionbank.ajax.php"+e,{method:"GET",on:{success:this.load_done,failure:this.load_failed},context:this})},load_done:function(e,i){var t=JSON.parse(i.responseText);t.status&&"OK"===t.status?(this.dialogue.bodyNode.setHTML(t.contents),o.one("#qbheadercheckbox")&&o.one("#qbheadercheckbox").on("click",function(e){!0===e._currentTarget.checked?o.all(".questionbankformforpopup .select-multiple-checkbox").set("checked","true"):o.all(".questionbankformforpopup .select-multiple-checkbox").set("checked","")}),o.use("moodle-qbank_editquestion-chooser",function(){M.question.init_chooser({})}),this.dialogue.bodyNode.one("form").delegate("change",this.options_changed,".searchoptions",this),this.dialogue.visible&&o.later(0,this.dialogue,this.dialogue.centerDialogue),require(["jquery","core/form-autocomplete"],function(e,i){var e=e('[class="tag-condition-container"]'),t=e.find('[data-region="tag-select"]'),o=e.find('[data-region="overlay-icon-container"]'),e=M.str.offlinequiz.filterbytags,n=M.str.offlinequiz.notagselected;i.enhance(t,!1,!1,e,!1,!0,n).always(function(){o.addClass("hidden")})}),o.on(M.core.event.FILTER_CONTENT_UPDATED,this.options_changed,this),this.searchRegionInitialised=!1,this.dialogue.get("visible")&&this.initialiseSearchRegion(),this.dialogue.fire("widget:contentUpdate"),this.dialogue.get("visible")&&(this.dialogue.hide(),this.dialogue.show())):this.load_failed(e,i)},load_failed:function(){},link_clicked:function(e){e.currentTarget.ancestor(t)?e.currentTarget.set("href",e.currentTarget.get("href")+"&addonpage="+this.addonpage):e.currentTarget.ancestor(n)?openpopup(e,{url:e.currentTarget.get("href"),name:"questionpreview",options:"NaNresizable,toolbar,status,directories=0,fullscreen=0,dependent"}):e.currentTarget.ancestor(a)||(e.preventDefault(),this.load_content(e.currentTarget.get("search")))},options_changed:function(e){var i,t;e&&e.currentTarget&&e.currentTarget.get?(e.preventDefault(),this.load_content("?"+o.IO.stringify(e.currentTarget.get("form")))):(t=e.nodes._nodes[0].className).includes("form-autocomplete-selection")&&t.includes("form-autocomplete-multiple")&&(i=this.get_tags(e.nodes._nodes[0].children))!==this.tags&&(this.tags=i,t=o.IO.stringify(o.one("#displayoptions")),this.load_content("?"+t),window.onbeforeunload=null)},get_tags:function(e){var i="";for(node in e)i+=e[node].textContent;return i},initialiseSearchRegion:function(){!0!==this.searchRegionInitialised&&o.one(a)&&(M.util.init_collapsible_region(o,"advancedsearch","question_bank_advanced_search",M.util.get_string("clicktohideshow","moodle")),this.searchRegionInitialised=!0)}}),M.mod_offlinequiz=M.mod_offlinequiz||{},M.mod_offlinequiz.offlinequizquestionbank=M.mod_offlinequiz.offlinequizquestionbank||{},M.mod_offlinequiz.offlinequizquestionbank.init=function(){return new l}},"@VERSION@",{requires:["base","event","node","io","io-form","yui-later","moodle-question-qbankmanager","moodle-qbank_editquestion-chooser","moodle-question-searchform","moodle-core-notification"]});