<?js
var data = obj;
var self = this;
?>
<dt class="<?js= (data.stability && data.stability !== 'stable') ? 'unstable' : '' ?>">
    <div class="nameContainer<?js if (data.inherited) { ?> inherited<?js } ?>">
        <?js if (data.stability || kind !== 'class') { ?>
        <h4 class="name" id="<?js= id ?>">
            <?js= data.attribs + (kind === 'class' ? 'new ' : '') + (data.scope === 'static' ? longname : name) + (kind !== 'event' ? data.signature : '') ?>
            <?js if (data.inherited || data.inherits) { ?>
                <span class="inherited"><?js= this.linkto(data.inherits, 'inherited') ?></span>
            <?js } ?>
            <?js= this.partial('stability.tmpl', data) ?>
        </h4>
        <?js if (data.meta) {?>
        <div class="tag-source">
            <?js= self.linkto(meta.filename) ?>, <?js= self.linkto(meta.filename, 'line ' + meta.lineno, null, 'line' + meta.lineno) ?>
        </div>
        <?js } ?>
        <?js } ?>
    </div>
    <?js if (data.summary) { ?>
    <p class="summary"><?js= summary ?></p>
    <?js } ?>
</dt>
<dd class="<?js= (data.stability && data.stability !== 'stable') ? 'unstable' : '' ?>">

    <?js if (data.description) { ?>
    <div class="description">
        <?js= data.description ?>
    </div>
    <?js } ?>

    <?js if (kind === 'event' && data.type && data.type.names) {?>
        <h5>Type:</h5>
        <ul>
            <li>
                <?js= self.partial('type.tmpl', data.type.names) ?>
            </li>
        </ul>
    <?js } ?>

    <?js if (data['this']) { ?>
        <h5>This:</h5>
        <ul><li><?js= this.linkto(data['this'], data['this']) ?></li></ul>
    <?js } ?>

    <?js if (data.stability || kind !== 'class') { ?>
    <?js if (data.params && params.length) { ?>
        <?js= this.partial('params.tmpl', params) ?>
    <?js } ?>
    <?js } ?>

    <?js= this.partial('details.tmpl', data) ?>

    <?js if (data.fires && fires.length) { ?>
    <h5>Fires:</h5>
    <ul><?js fires.forEach(function(f) {
            var parts = f.split(/#?event:/);
            var type = parts.pop();
            var eventClassName = parts[0];
            parts = type.split(' ');
            type = parts.shift();
            var description = parts.length ? parts.join(' ') : '';
            var eventDoclet = self.find({longname: f})[0];
            if (eventDoclet && !description && eventDoclet.description) {
              description = eventDoclet.description.replace(/<[^>]*>/g, '');
            }
        ?>
        <li class="<?js= (eventDoclet || data).stability !== 'stable' ? 'unstable' : '' ?>">
            <code><?js= eventClassName ? self.linkto(f, type) : type ?></code>
            <?js if (eventClassName) {
              var eventClass = self.find({longname: eventClassName})[0];
              if (eventClass) { ?>
                (<?js= self.linkto(eventClass.longname) ?>)
              <?js } ?>
            <?js } ?>
            <?js= self.partial('stability.tmpl', eventDoclet || (data.stability ? data : {stability: 'experimental'})) ?>
            <?js if (description) { ?> -
            <?js= description ?>
            <?js } ?>
        </li>
    <?js }); ?></ul>
    <?js } ?>

    <?js if (data.listens && listens.length) { ?>
    <h5>Listens to Events:</h5>
    <ul><?js listens.forEach(function(f) { ?>
        <li><?js= self.linkto(f) ?></li>
    <?js }); ?></ul>
    <?js } ?>

    <?js if (data.listeners && listeners.length) { ?>
    <h5>Listeners of This Event:</h5>
    <ul><?js listeners.forEach(function(f) { ?>
        <li><?js= self.linkto(f) ?></li>
    <?js }); ?></ul>
    <?js } ?>

    <?js if (data.exceptions && exceptions.length) { ?>
    <h5>Throws:</h5>
    <?js if (exceptions.length > 1) { ?><ul><?js
        exceptions.forEach(function(r) { ?>
            <li><?js= self.partial('exceptions.tmpl', r) ?></li>
        <?js });
    ?></ul><?js } else {
        exceptions.forEach(function(r) { ?>
            <?js= self.partial('exceptions.tmpl', r) ?>
        <?js });
    } } ?>

    <?js if (data.returns && returns.length) { ?>
    <?js if (returns.length > 1) { ?><h5>Returns:</h5><?js } ?>
    <?js= self.partial('returns.tmpl', data.returns) ?>
    <?js } ?>

    <?js if (data.examples && examples.length) { ?>
        <h5>Example<?js= examples.length > 1? 's':'' ?></h5>
        <?js= this.partial('examples.tmpl', examples) ?>
    <?js } ?>
</dd>
