<!--
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.
-->

<div id="{{paragraph.id}}_container"
     ng-class="{'paragraph': !asIframe, 'paragraphAsIframe': asIframe}">

  <div ng-show="paragraph.config.title"
       id="{{paragraph.id}}_title"
       class="title">
    <input type="text"
           pu-elastic-input
           style="min-width: 400px; max-width: 80%;"
           placeholder="Untitled"
           ng-model="paragraph.title"
           ng-show="showTitleEditor"
           ng-escape="showTitleEditor = false; paragraph.title = oldTitle;"
           ng-blur="setTitle(); showTitleEditor = false"
           ng-enter="setTitle(); showTitleEditor = false"
           focus-if="showTitleEditor" />
    <div ng-click="showTitleEditor = !asIframe && !viewOnly; oldTitle = paragraph.title;"
         ng-show="!showTitleEditor"
         ng-bind-html="paragraph.title || 'Untitled'">
    </div>
  </div>

  <div>
    <div ng-show="!paragraph.config.editorHide && !viewOnly" style="margin-bottom:3px;">
      <div id="{{paragraph.id}}_editor"
           style="opacity: 1;"
           class="editor"
           ui-ace="{
                     onLoad : aceLoaded,
                     require : ['ace/ext/language_tools']
                   }"
           ng-model="paragraph.text"
           ng-class="{'disable': paragraph.status == 'RUNNING' || paragraph.status == 'PENDING',
             'paragraph-text--dirty' : dirtyText !== originalText && dirtyText !== undefined}">
      </div>
    </div>

    <div ng-include src="'app/notebook/paragraph/paragraph-progressBar.html'"></div>
    <div ng-include src="'app/notebook/paragraph/paragraph-parameterizedQueryForm.html'"></div>

    <!-- Rendering -->
    <div class='tableDisplay' ng-show="!paragraph.config.tableHide">
      <div ng-include src="'app/notebook/paragraph/paragraph-chart-selector.html'"></div>
      <div ng-include src="'app/notebook/paragraph/paragraph-pivot.html'"></div>
      <div ng-include src="'app/notebook/paragraph/paragraph-results.html'"></div>
    </div>
  </div>

  <div ng-include src="'app/notebook/paragraph/paragraph-control.html'"></div>

  <div ng-if="!asIframe" class="paragraphFooter">
    <div ng-show="!paragraph.config.tableHide && !viewOnly"
         id="{{paragraph.id}}_executionTime"
         class="executionTime" ng-bind-html="getExecutionTime()">
    </div>
    <div ng-if = "paragraph.status === 'RUNNING'" class = "paragraphFooterElapsed">
      <div
           id="{{paragraph.id}}_elapsedTime"
           class="elapsedTime" ng-bind-html="getElapsedTime()">
      </div>
    </div>
  </div>
</div>
