blob: fba8537f88b974450109c394af8fc7649a19b213 [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="/base/units/time_stamp.html">
<link rel="import" href="/model/compound_event_selection_state.html">
<link rel="import" href="/model/event_set.html">
<link rel="import" href="/model/timed_event.html">
<script>
'use strict';
tr.exportTo('tr.model', function() {
var CompoundEventSelectionState = tr.model.CompoundEventSelectionState;
function InteractionRecord(title, colorId, start, duration) {
tr.model.TimedEvent.call(this, start);
this.title = title;
this.colorId = colorId;
this.duration = duration;
this.args = {};
this.associatedEvents = new tr.model.EventSet();
}
InteractionRecord.prototype = {
__proto__: tr.model.TimedEvent.prototype,
get subSlices() {
return [];
},
get userFriendlyName() {
return this.title + ' interaction at ' +
tr.b.units.TimeStamp.format(this.start);
},
computeCompoundEvenSelectionState: function(selection) {
var cess = CompoundEventSelectionState.NOT_SELECTED;
if (selection.contains(this))
cess |= CompoundEventSelectionState.EVENT_SELECTED;
if (this.associatedEvents.intersectionIsEmpty(selection))
return cess;
var allContained = this.associatedEvents.every(function(event) {
return selection.contains(event);
});
if (allContained)
cess |= CompoundEventSelectionState.ALL_ASSOCIATED_EVENTS_SELECTED;
else
cess |= CompoundEventSelectionState.SOME_ASSOCIATED_EVENTS_SELECTED;
return cess;
}
};
tr.model.EventRegistry.register(
InteractionRecord,
{
name: 'interaction',
pluralName: 'interactions',
singleViewElementName: 'tr-ui-a-single-interaction-record-sub-view',
multiViewElementName: 'tr-ui-a-multi-interaction-record-sub-view'
});
return {
InteractionRecord: InteractionRecord
};
});
</script>