YUI.add("checklist",function(d){var c=d.Widget,a=d.Node;function b(e){b.superclass.constructor.apply(this,arguments)}b.NAME="checklist";b.ATTRS={countSelected:{value:0},tabIndex:{value:null}};b.CONTROL_TEMPLATE='<ul class="controls clear"><li class="action-select-all"><a href="#">Select All</a></li><li class="action-deselect-all"><a href="#">Clear</a></li><li class="action-close"><a href="#">Close</a></li></ul>';b.DROPDOWN_TEMPLATE='<a class="dropdown"><span>0</span> Selected</a>';d.extend(b,c,{initializer:function(){this.get("contentBox").addClass("hide")},renderUI:function(){this._renderDropdownToggle();this._renderControls()},_renderDropdownToggle:function(){var e=this.get("contentBox"),f=this._createDropdownToggle();this.dropdownToggle=e.insert(f,"before")},_renderControls:function(){var f=this.get("contentBox"),e=this._createControlList();this.controls=f.appendChild(e)},bindUI:function(){var g=this.get("boundingBox"),e=this.get("contentBox"),f=g.one(".dropdown"),h=this;d.on("click",function(i){if(i.target.hasClass("dropdown")||i.target.get("parentNode").hasClass("action-close")){i.preventDefault();h._toggleDropdown()}else{if(i.target.get("parentNode").hasClass("action-select-all")){i.preventDefault();h._selectAll()}else{if(i.target.get("parentNode").hasClass("action-deselect-all")){i.preventDefault();h._deselectAll()}else{if(i.target.get("tagName")=="INPUT"||i.target.get("tagName")=="IMG"){h._countSelected();h._setSelectedCount()}}}}},g);e.get("ownerDocument").on("mousedown",function(j){var i=j.target;if(!i.compareTo(f)&&!f.contains(i)&&!i.compareTo(e)&&!e.contains(i)){if(!e.hasClass("hide")){e.addClass("hide")}}});g.one("li.action-close a").on("keydown",function(j){var i=9;if(j.keyCode==i){e.addClass("hide")}},this,true);g.all("li a").on("focus",function(i){i.currentTarget.setStyle("color","black")},this,true);g.all("li a").on("blur",function(i){i.currentTarget.setStyle("color","")},this,true)},syncUI:function(){},_createControlList:function(){return a.create(b.CONTROL_TEMPLATE)},_createDropdownToggle:function(){this._countSelected();var e=a.create(b.DROPDOWN_TEMPLATE);e.one("span").set("innerHTML",this.get("countSelected"));return e},_toggleDropdown:function(){var e=this.get("contentBox");if(e.hasClass("hide")){e.removeClass("hide")}else{e.addClass("hide")}},_selectAll:function(){var f=this._getAllCheckboxes();f.set("checked","checked");var e=this._getAllBoxImages();e.addClass("NFh");this._countSelected();this._setSelectedCount()},_deselectAll:function(){var f=this._getAllCheckboxes();f.set("checked","");var e=this._getAllBoxImages();e.removeClass("NFh");this._countSelected();this._setSelectedCount()},_getAllCheckboxes:function(){return this.get("contentBox").all("input")},_getAllBoxImages:function(){return this.get("contentBox").all("img")},_countSelected:function(){var e=this._getAllCheckboxes(),f=0,g=this;e.each(function(h){if(g._isSelected(h)){f++}});this.set("countSelected",f)},_setSelectedCount:function(){var e=this.get("boundingBox");e.one(".dropdown span").set("innerHTML",this.get("countSelected"))},_isSelected:function(f){var e=a.getDOMNode(f);if(e.checked){return true}return false}});d.namespace("Widget");d.Widget.Checklist=b},"@VERSION@",{requires:["widget"]});YUI().use("checklist",function(b){var a=b.all(".checklist-container");a.each(function(d){var c=new b.Widget.Checklist({contentBox:d});c.render()})});
