<%
 import org.exoplatform.webui.form.UIFormInputSet;
 import org.exoplatform.webui.form.UIFormInputBase;
 import org.exoplatform.webui.form.input.UIUploadInput;
 import org.exoplatform.webui.core.UIDropDownControl;
%>
<%
 def viewer = _ctx.getRequestContext().getRemoteUser();
 def rcontext = _ctx.getRequestContext() ;
 def jsManager = rcontext.getJavascriptManager();
 jsManager.require("SHARED/portalControl", "portalControl");
%>
<%uiform.begin()%>
<div class="addonSearchToolbar" id="$uicomponent.id">
 <div class="uiGrayLightBox">
  <div class="clearfix">
   <%   
    List children = uicomponent.getChildren() ;
    def uiDropDownControl = null;
    for(component in children) {
      if(component.isRendered()){

          if(component instanceof UIDropDownControl){
            uiDropDownControl = component;
          }
          fieldName = component.getName(); 
          String isTextArea = "";
         %> 
         <div class="uiSearchForm uiSearchInput pull-left">
          <% if(component instanceof UIFormInputBase && component.isEditable()) { %>
           <% uicomponent.renderChild(component.getClass()) %>
          <% }%>
         </div>
     <% } // end if
    } // end for
   %>
    
    <button type="button"  style="margin-left: 5px;"
      onclick="window.open('https://codenvy.com/f?id=7nop24paia4u2okn', '_blank')" class="btn pull-right">
      <%=_ctx.appRes('UIAddOnSearchPortlet.UIExtensionForm.codeNew')%>
    </button>

    <button type="button"
      onclick="location.href='/portal/intranet/create-addon'" class="btn pull-right">
      <%=_ctx.appRes('UIAddOnSearchPortlet.UIExtensionForm.addNew')%>
    </button>

      <% if(uicomponent.isAdminUser()){ %>
      <button type="button"
              onclick="location.href='/portal/intranet/manage-categories'" class="btn pull-right">
          <%=_ctx.appRes('UIAddOnSearchPortlet.UIExtensionForm.manageCategory')%>
      </button>
      <% } %>

    <% if(uicomponent.getBtnBackToAddonsVisible()){ %>
      <button type="button" onclick="<%=uicomponent.event("Sort","az")%>" class="btn pull-right"><%=_ctx.appRes('UIAddOnSearchPortlet.UIExtensionForm.backToList')%></button>
    <% } %>

    <div class="pull-right">
      <% uicomponent.renderChild("DisplayModesDropDown") %>
    </div>
     <div class="pull-right">
         <% uicomponent.renderChild("CategoryNameDropDown") %>
     </div>
 
   <% for(action in uicomponent.getActions()) {
    String actionLabel = _ctx.appRes(uicomponent.getName() + ".action." + action);
    if (!actionLabel.equals("Sort") && !actionLabel.equals("Remove")){ 
    String link = uicomponent.event(action);
    String typeAction= "btn btn-primary hide";
   %>
   <div onclick="$link" id="btnDoSearch" class="$typeAction" style="margin-right: 5px;">
    $actionLabel
   </div>
   <%  } //end if
    } // end for
   %>
   <% if(uicomponent.isMyAddonsVisible()){ %>
   <a class="<%= uicomponent.getStyleFilterSelected("myaddons")%>" href="<%=uicomponent.event("Sort","myaddons")%>"><%=_ctx.appRes('UIAddOnSearchPortlet.UIExtensionForm.myAddOn')%></a>
   <% } %>  
<!--
   <a class="<%= uicomponent.getStyleFilterSelected("az")%>" href="<%=uicomponent.event("Sort","az")%>"> A <i class="uiIconMiniArrowRight uiIconLightGray"></i> Z</a>
   <a class="<%= uicomponent.getStyleFilterSelected("za")%>" href="<%=uicomponent.event("Sort","za")%>"> Z  <i class="uiIconMiniArrowRight uiIconLightGray"></i> A</a>
-->
   
  </div>
 </div> 
</div>
<script>

jQuery('document').ready(function(){
  
    jQuery('#keywordInput').keypress(function(e){
        if(e.which == 13){//Enter key pressed
            jQuery('#btnDoSearch').click();//Trigger search button click event
            return false;
        }


    });

});
</script>
<%uiform.end()%>
