<?php
defined('C5_EXECUTE') or die("Access Denied.");
?>

<div data-search="express_entries" class="ccm-ui">
    <?php View::element('express/entries/search', array('controller' => $searchController, 'selectMode' => true)) ?>
</div>

<script type="text/javascript">
    $(function () {
        $('div[data-search=express_entries]').concreteAjaxSearch({
            result: <?=$result?>,
            onUpdateResults: function(concreteSearch) {
                concreteSearch.$element.on('mouseover', 'tr[data-entity-id]', function(e) {
                    e.stopPropagation();
                    $(this).addClass('ccm-search-select-hover');
                });
                concreteSearch.$element.on('mouseout', 'tr[data-entity-id]', function(e) {
                    e.stopPropagation();
                    $(this).removeClass('ccm-search-select-hover');
                });

                concreteSearch.$element.unbind('click.expressEntries');
                concreteSearch.$element.on('click.expressEntries', 'tr[data-entity-id]', function(e) {
                    e.stopPropagation();
                    ConcreteEvent.publish('SelectExpressEntry', {
                        exEntryID: $(this).attr('data-entity-id'),
                        event: e
                    });
                    return false;
                });
            }

        });
    });
</script>