<!--
@license
Copyright 2017 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<link rel="import" href="../../../polymer/polymer.html">
<link rel="import" href="../../../iron-icons/iron-icons.html">
<link rel="import" href="../../../paper-button/paper-button.html">
<link rel="import" href="../facets-dive-controls/facets-dive-controls.html">
<link rel="import" href="../facets-dive-info-card/facets-dive-info-card.html">
<link rel="import" href="../facets-dive-legend/facets-dive-legend.html">
<link rel="import" href="../facets-dive-vis/facets-dive-vis.html">

<dom-module id='facets-dive'>
  <template>

    <style>
      /**
       * paper-input-container uses an element containing only &nbsp; for
       * spacing purposes. Aggressive vulcanizers sometimes remove this content.
       * This CSS rule forces the containing element to have the correct height
       * in either case.
       */
      ::content paper-input-container > .floated-label-placeholder {
        min-height: 20px;
      }

      :host {
        background: #ffffff;
        box-sizing: border-box;
        display: flex;
        flex-grow: 1;
        height: 100%;
        overflow: hidden;
        position: relative;
        width: 100%;
      }
      .fill {
        display: flex;
        flex-grow: 1;
        position: relative;
      }
      .main {
        flex-direction: column;
      }
      facets-dive-controls {
        border-bottom: 1px solid black;
        flex-grow: 0;
        flex-shrink: 0;
        height: 60px;
      }
      .row {
        display: flex;
        flex-direction: row;
      }
      facets-dive-legend {
        position: absolute;
        bottom: 14px;
        right: 24px;
      }
      .zoom-controls {
        bottom: 14px;
        box-sizing: border-box;
        left: 0;
        position: absolute;
      }
      .zoom-controls paper-button {
        background-color: #e7e7e7;
        clear: left;
        color: #2b2b2b;
        display: block;
        float: left;
        margin: 4px 8px;
        min-width: 0;
        padding: 8px;
      }
      facets-dive-info-card {
        background: #fff8f4;
        border-left: 1px solid #c6c6c6;
        box-sizing: border-box;
        flex-grow: 0;
        flex-shrink: 0;
        width: 240px;
      }
    </style>

    <div class="fill main">
      <facets-dive-controls
          id="controls"
          atlas-url="[[atlasUrl]]"
          keys="[[_keys]]"
          stats="[[stats]]"
          vertical-facet="{{verticalFacet}}"
          vertical-buckets="{{verticalBuckets}}"
          vertical-bag-of-words="{{verticalBagOfWords}}"
          horizontal-facet="{{horizontalFacet}}"
          horizontal-buckets="{{horizontalBuckets}}"
          horizontal-bag-of-words="{{horizontalBagOfWords}}"
          position-mode="{{positionMode}}"
          vertical-position="{{verticalPosition}}"
          horizontal-position="{{horizontalPosition}}"
          color-by="{{colorBy}}"
          image-field-name="{{imageFieldName}}"
          palette="[[_palette]]"
          palette-choice="{{paletteChoice}}"
          grid-faceting-vertical-label-color="[[gridFacetingVerticalLabelColor]]"
          grid-faceting-horizontal-label-color="[[gridFacetingHorizontalLabelColor]]"
          item-positioning-vertical-label-color="[[itemPositioningVerticalLabelColor]]"
          item-positioning-horizontal-label-color="[[itemPositioningHorizontalLabelColor]]"
        ></facets-dive-controls>

      <div class="fill row">
        <div class="fill">
          <facets-dive-vis
              id="vis"
              class="fill"
              data="[[data]]"
              filtered-data-indices="[[filteredDataIndices]]"
              atlas-url="[[atlasUrl]]"
              sprite-url="[[spriteUrl]]"
              cross-origin="[[crossOrigin]]"
              keys="{{_keys}}"
              stats="{{stats}}"
              sprite-image-width="[[spriteImageWidth]]"
              sprite-image-height="[[spriteImageHeight]]"
              vertical-facet="[[verticalFacet]]"
              vertical-buckets="[[verticalBuckets]]"
              vertical-bag-of-words="[[verticalBagOfWords]]"
              horizontal-facet="[[horizontalFacet]]"
              horizontal-buckets="[[horizontalBuckets]]"
              horizontal-bag-of-words="[[horizontalBagOfWords]]"
              position-mode="[[positionMode]]"
              vertical-position="[[verticalPosition]]"
              horizontal-position="[[horizontalPosition]]"
              color-by="{{colorBy}}"
              image-field-name="{{imageFieldName}}"
              palette="{{_palette}}"
              palette-choice="[[paletteChoice]]"
              grid-faceting-vertical-label-color="{{gridFacetingVerticalLabelColor}}"
              grid-faceting-horizontal-label-color="{{gridFacetingHorizontalLabelColor}}"
              item-positioning-vertical-label-color="{{itemPositioningVerticalLabelColor}}"
              item-positioning-horizontal-label-color="{{itemPositioningHorizontalLabelColor}}"
              fit-grid-aspect-ratio-to-viewport="[[fitGridAspectRatioToViewport]]"
              selected-data="{{selectedData}}"
              selected-indices="{{selectedIndices}}"
              compared-data="{{comparedData}}"
              compared-indices="{{comparedIndices}}"
              stable-colors="[[stableColors]]"
            ></facets-dive-vis>

          <div class="zoom-controls">
            <paper-button raised id="zoomInButton">
              <iron-icon icon="icons:add"></iron-icon>
            </paper-button>
            <paper-button raised id="zoomOutButton">
              <iron-icon icon="icons:remove"></iron-icon>
            </paper-button>
            <paper-button raised id="fitButton">
              <iron-icon icon="icons:aspect-ratio"></iron-icon>
            </paper-button>
          </div>

          <facets-dive-legend id="legend" color-by="[[colorBy]]"
              palette="[[_palette]]">
          </facets-dive-legend>
        </div>

        <template is="dom-if" if="[[!hideInfoCard]]">
          <facets-dive-info-card
              id="infoCard"
              selected-data="[[selectedData]]"
              info-renderer="[[infoRenderer]]">
          </facets-dive-info-card>
        </template>
      </div>
    </div>

  </template>
</dom-module>

<script src="facets-dive.js"></script>
