<!--
Copyright 2020 Netsyms Technologies.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->

<div class="page" data-name="machine">

    <div class="navbar">
        <div class="navbar-bg"></div>
        <div class="navbar-inner">
            <div class="left">
                <a href="#" class="link icon-only back">
                    <i class="icon icon-back"></i>
                </a>
            </div>
            <div class="title">{{machineid}}</div>
        </div>
    </div>

    <div class="fab fab-right-bottom" id="menu-fab">
        <a href="#" data-fab="#menu-fab">
            <!-- Icons For iOS Theme -->
            <i class="icon f7-icons if-not-md">plus</i>
            <i class="icon f7-icons if-not-md">xmark</i>
            <!-- Icons For MD Theme -->
            <i class="icon material-icons md-only">menu</i>
            <i class="icon material-icons md-only">close</i>
        </a>

        <div class="fab-buttons fab-buttons-top">
            {{#if editable}}
            <a href="#" id="machineEditButton" class="fab-label-button fab-close" data-fab="#menu-fab">
                <span><i class="fas fa-edit"></i></span>
                <span class="fab-label">Edit Machine</span>
            </a>
            {{/if}}
            <a href="#" class="fab-label-button" data-fab="#menu-fab">
                <span><i class="fas fa-location"></i></span>
                <span class="fab-label">Add Event</span>
            </a>
        </div>
    </div>

    <div class="fab fab-extended fab-left-bottom color-red display-none" id="canceledit-fab">
        <a href="#">
            <!-- Icons For iOS Theme -->
            <i class="icon f7-icons if-not-md">xmark</i>
            <!-- Icons For MD Theme -->
            <i class="icon material-icons md-only">close</i>

            <div class="fab-text">Cancel</div>
        </a>
    </div>

    <div class="fab fab-extended fab-right-bottom color-green display-none" id="save-fab">
        <a href="#" onclick="saveMachineEdits()">
            <!-- Icons For iOS Theme -->
            <i class="icon f7-icons if-not-md">floppy_disk</i>
            <!-- Icons For MD Theme -->
            <i class="icon material-icons md-only">save</i>
            <div class="fab-text">Save</div>
        </a>
    </div>

    <div class="page-content">
        <form id="machineform" style="margin-bottom: 5rem;">
            <div class="list no-hairlines no-margin-top">
                <ul>
                    {{#each info}}
                    {{#js_if "this.type == 'select'"}}
                    <li>
                        <a class="item-link smart-select smart-select-init" data-searchbar="true" data-searchbar-placeholder="Search">
                            <select name="{{name}}" class="machinefield" disabled="true" tabindex="{{tabindex}}">
                                {{#each options}}
                                <option value="{{@key}}" {{#js_if "../value == @key"}}selected{{/js_if}}>{{this}}</option>
                                {{/each}}
                            </select>
                            <div class="item-content">
                                <div class="item-inner">
                                    <div class="item-title">{{label}}</div>
                                </div>
                            </div>
                        </a>
                    </li>
                    {{else}}
                    <li class="item-content item-input">
                        <div class="item-inner">
                            <div class="item-title item-floating-label">{{label}}</div>
                            <div class="item-input-wrap">
                                {{#js_if "this.type == 'textarea'"}}
                                <textarea class="machinefield" disabled="true" rows="4" name="{{name}}" placeholder="" tabindex="{{tabindex}}">{{value}}</textarea>
                                {{else}}
                                <input class="machinefield" disabled="true" type="{{type}}" name="{{name}}" placeholder="" value="{{value}}" tabindex="{{tabindex}}">
                                <span class="input-clear-button machinefield-clear-button display-none"></span>
                                {{/js_if}}
                            </div>
                        </div>
                    </li>
                    {{/js_if}}
                    {{/each}}
                </ul>
            </div>
        </form>
    </div>

    <script>
        var machineid = "{{machineid}}";

        //$("textarea.machinefield")
    </script>
</div>