text: YUI.add("aui-palette",function(e,t){var n=e.Lang,r=e.Widget.UI_SRC,i="palette",s=".",o="",u=" ",a="boundingBox",f="click",l="columns",c="containerNode",h="contentBox",p="enter",d="formatter",v="hover",m="items",g="itemsChange",y="leave",b="renderUI",w="select",E="selected",S="selectedChange",x="toggleSelection",T="unselect",N="width",C=e.getClassName,k=C("palette-container"),L=C("palette-item"),A=C("palette-item-hover"),O=C("palette-item-inner"),M=C("palette-item-selected"),_=C("palette-items-container"),D=C("palette-items-container-{index}"),P=e.Base.create(i,e.Widget,[e.WidgetCssClass,e.WidgetToggle],{CONTAINER_TEMPLATE:'<div class="'+k+'">{content}</div>',ITEMS_CONTAINER_TEMPLATE:'<ul class="'+_+u+D+'">{content}</ul>',ITEM_TEMPLATE:'<li class="'+L+' {selectedClassName}" data-column={column} data-index={index} data-row={row} data-value="{value}">'+'<a href="" class="'+O+'" onclick="return false;"></a>'+"</li>",_items:null,initializer:function(){var t=this;t.after(g,t._afterItemsChange,t),t.after(S,t._afterSelectedChange,t),e.after(t._bindUIPalette,t,b),t.publish({enter:{defaultFn:t._defEnterFn},leave:{defaultFn:t._defLeaveFn},select:{defaultFn:t._defSelectFn},unselect:{defaultFn:t._defUnselectFn}})},renderUI:function(){var e=this;e._uiSetItems(e.get(m))},getItem:function(e,t){var n=this;return n.getItemByIndex(e*n.get(l)+t)},getItemByIndex:function(e){var t=this;return t._getIndexedItems().item(e)},getItemByValue:function(t){var r=this,i=-1,s;return n.isObject(t)&&(t=t.value),s=r.get(m),e.Array.some(s,function(e,r){n.isObject(e)&&(e=e.value);if(e===t)return i=r,!0}),r.getItemByIndex(i)},select:function(e){var t=this;t.toggleSelection(e,!0)},toggleSelection:function(e,t){var n=this,r=n.getItemByIndex(e)||n.getItemByValue(e);r&&r.toggleClass(M,t)},unselect:function(e){var t=this;t.toggleSelection(e,!1)},_afterItemsChange:function(e){var t=this;t._items=null,t._uiSetItems(e.newVal)},_afterSelectedChange:function(e){var t=this;t.unselect(e.prevVal),t.select(e.newVal)},_bindUIPalette:function(){var e=this,t=e.get(a);t.delegate(f,e._onItemClick,s+L,e),t.delegate(v,e._onItemMouseEnter,e._onItemMouseLeave,s+L,e)},_defEnterFn:function(e){e.item.addClass(A)},_defLeaveFn:function(e){e.item.removeClass(A)},_defSelectFn:function(e){var t=this;e.src===r&&t.set(E,e.index)},_defUnselectFn:function(e){var t=this;e.src===r&&t.set(E,-1)},_getContent:function(e,t){var n=this,r=n.get(d),i=n.get(E),s,u,a=0,f=o,l=e.length,c,h=Math.ceil(l/t);for(c=0;c<h;c++){u=o;for(s=0;s<t;s++){a=c*t+s;if(a>=l)break;u+=r.call(n,e,a,c,s,i===a)}f+=n._getRowContent(e,a,c,u)}return n._getPaletteContent(e,f)},_getEventsPayload:function(e){var t=this,i=t.get(m),s,o=e.currentTarget;return s=n.toInt(o.getAttribute("data-index")),{column:n.toInt(o.getAttribute("data-column")),item:o,index:s,row:n.toInt(o.getAttribute("data-row")),src:r,value:i[s]}},_getIndexedItems:function(){var e=this;return e._items||(e._items=e.get(h).all(s+L)),e._items},_getPaletteContent:function(e,t){var r=this;return n.sub(r.CONTAINER_TEMPLATE,{className:k,content:t})},_getRowContent:function(e,t,r,i){var s=this;return n.sub(s.ITEMS_CONTAINER_TEMPLATE,{className:D,content:i,index:r})},_onItemClick:function(e){var t=this,r=t.get(E),i=t.get(x),s,o=e.currentTarget,u=n.toInt(o.getAttribute("data-index"));u!==r?s=w:i&&(s=T),s&&t.fire(s,t._getEventsPayload(e))},_onItemMouseEnter:function(e){var t=this;t.fire(p,t._getEventsPayload(e))},_onItemMouseLeave:function(e){var t=this;t.fire(y,t._getEventsPayload(e))},_uiSetItems:function(e){var t=this,n,r=t.get(N);r?n=e.length:(n=t.get(l),n===-1&&(n=e.length)),t.get(h).setHTML(t.get(c)||t._getContent(e,n))},_valueFormatterFn:function(){return function(e,t,r,i,s){var u=this,a=e[t];return n.sub(u.ITEM_TEMPLATE,{column:i,index:t,row:r,selectedClassName:s?M:o,value:n.isObject(a)?a.value:a})}}},{HTML_PARSER:{containerNode:s+k},ATTRS:{columns:{validator:n.isNumber,value:-1},containerNode:{},formatter:{validator:n.isFunction,valueFn:"_valueFormatterFn"},items:{validator:n.isArray,value:[]},selected:{validator:n.isNumber,value:-1},toggleSelection:{validator:n.isBoolean,value:!0}}});e.Palette=P},"2.0.0",{requires:["base-build","event-hover","widget","aui-classnamemanager","aui-base","aui-widget-cssclass","aui-widget-toggle"],skinnable:!0});
  