<!--
 Open MCT, Copyright (c) 2014-2018, United States Government
 as represented by the Administrator of the National Aeronautics and Space
 Administration. All rights reserved.

 Open MCT is 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.

 Open MCT includes source code licensed under additional open source
 licenses. See the Open Source Licenses file (LICENSES.md) included with
 this source code distribution or the Licensing information page available
 at runtime from the About dialog for additional information.
-->
<div class="s-button s-menu-button menu-element t-color-palette {{structure.cssClass}}"
    ng-controller="ClickAwayController as toggle">

    <span class="l-click-area" ng-click="toggle.toggle()"></span>
    <span class="color-swatch"
          ng-class="{'no-selection':ngModel[field] === 'transparent'}"
          ng-style="{
             'background-color': ngModel[field]
         }">
    </span>
    <span class="title-label" ng-if="structure.text">
        {{structure.text}}
    </span>

    <div class="menu l-palette l-color-palette"
        ng-controller="ColorController as colors"
        ng-show="toggle.isActive()">
        <div
            class="l-palette-row l-option-row"
            ng-if="!structure.mandatory">
            <div class="l-palette-item s-palette-item no-selection {{ngModel[field] === 'transparent' ? 'selected' : '' }}"
                ng-click="ngModel[field] = 'transparent'">
            </div>
            <span class="l-palette-item-label">None</span>
        </div>
        <div
            class="l-palette-row"
            ng-repeat="group in colors.groups()">
            <div class="l-palette-item s-palette-item {{ngModel[field] === color ? 'selected' : '' }}"
                ng-repeat="color in group"
                ng-style="{ background: color }"
                ng-click="ngModel[field] = color">
            </div>
        </div>
    </div>
</div>
