<?xml version="1.0" encoding="UTF-8"?>

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://xmlns.jcp.org/jsp/jstl/core" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:h="http://xmlns.jcp.org/jsf/html"
  xmlns:p="http://primefaces.org/ui" xmlns:e="http://www.ivu.de/elect/tags">

  <!--@elvariable id="msgs" type="de.ivu.elect.business.lokalisierung.control.LokalisierungResourceBundle"-->

  <!--@elvariable id="sitzeSearchView" type="de.ivu.elect.presentation.ergebnis.AbstractCoreSitzeSearchView"-->

  <ui:param name="chartName" value="SitzverteilungDonut" />

  <h:form>
    <!-- DEAKTIVIERT
       <e:outputPanel deferred="true" layout="inline">
            <e:chartPieChart id="pieChartModelSitzeGesamt" rendered="#{sitzeSearchView.pieChartAnzeigen}" model="#{sitzeSearchView.pieChartModel}" />
            </...>
            -->

    <c:if test="#{sitzeSearchView.pieChartAnzeigen}">
      <p:outputPanel layout="inline">
        <p:donutChart widgetVar="msc" model="#{sitzeSearchView.pieChartJsModel}" style="width: 100%; height: 200px;" />
        <br />
        <br />
      </p:outputPanel>

      <!--<p:outputPanel layout="inline" id="#{chartName}">-->
      <!--<h:outputText escape="false" value="#{sitzeSearchView.donutChartHtml}"   />-->

      <!--<p:commandButton value="#{msgs['chart.export.image']}" icon="#{icons.iconExternalLink}" ajax="false"-->
      <!--onclick="exportChart('#{componentHelper.getClientId(chartName)}', '#{chartName}'); return true;">-->
      <!--<p:fileDownload value="#{svgDownloader.streamedContent}" contentDisposition="inline" />-->
      <!--</p:commandButton>-->

      <!--</p:outputPanel>-->
      <!--<p:remoteCommand name="svgDownloader" actionListener="#{svgDownloader.prePareDownload}" async="false" />-->

      <!--<script type="text/javascript">-->

      <!--function exportChart(parentId, name) {-->
      <!--escapedParentId = PrimeFaces.escapeClientId(parentId);-->
      <!--svgString = $($(escapedParentId +" .svggroup")[0]).html();-->

      <!--svgDownloader([{name:'svg', value:svgString}, {name:'filename', value:name}]);-->
      <!--//a = document.createElement('a');-->
      <!--//a.download = name+'.svg';-->
      <!--//a.type = 'image/svg+xml';-->
      <!--//blob = new Blob([svgString], {"type": "image/svg+xml"});-->
      <!--//a.href = (window.URL || webkitURL).createObjectURL(blob);-->
      <!--//a.click();-->
      <!--return true;-->
      <!--}-->
      <!--</script>-->
    </c:if>

    <!--
        <p:commandButton type="button" value="Export" icon="ui-icon-extlink"
                onclick="exportChart(PF('pieChartModelSitzeGesamtWidget'), '#{componentHelper.getClientId('chartImageBase64')}');return true;"
                actionListener="#{chartExport.exportChart()}"
                rendered="#{sitzeSearchView.pisChartAnzeigen}" ajax="true"/>
        <h:inputHidden id="chartImageBase64" value="#{chartExport.chartBase64}"/>
        <script type="text/javascript">
            function exportChart(chart, id) {
                //export image
                console.log(chart);
                console.log(id);
                var hidden = document.getElementById(id);
                console.log(hidden);
                if (hidden) {
                    img = chart.exportAsImage();
                    hidden.value = img.src;
                }
                return true;
            }
        </script>
        -->
  </h:form>

  <e:formSearch>
    <ui:insert />

    <ui:define name="dataTable">
      <e:searchTable searchView="#{sitzeSearchView}" columnBuilder="#{sitzeColumnBuilder}" />
    </ui:define>
  </e:formSearch>
</ui:composition>
