2
* Copyright (C) 2020 Apple Inc. All rights reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
7
* 1. Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* 2. Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
13
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
* THE POSSIBILITY OF SUCH DAMAGE.
26
WI.AnimationCollectionContentView = class AnimationCollectionContentView extends WI.CollectionContentView
28
constructor(representedObject)
30
console.assert(representedObject instanceof WI.AnimationCollection);
32
let contentPlaceholder = document.createElement("div");
34
let descriptionElement = contentPlaceholder.appendChild(document.createElement("div"));
35
descriptionElement.className = "description";
37
switch (representedObject.animationType) {
38
case WI.Animation.Type.WebAnimation:
39
descriptionElement.textContent = WI.UIString("Waiting for animations created by JavaScript.");
42
case WI.Animation.Type.CSSAnimation:
43
descriptionElement.textContent = WI.UIString("Waiting for animations created by CSS.");
46
case WI.Animation.Type.CSSTransition:
47
descriptionElement.textContent = WI.UIString("Waiting for transitions created by CSS.");
50
console.assert(descriptionElement.textContent);
52
super(representedObject, WI.AnimationContentView, contentPlaceholder);
54
this.selectionEnabled = true;
56
this.element.classList.add("animation-collection");
61
handleRefreshButtonClicked()
63
for (let subview of this.subviews) {
64
if (subview instanceof WI.AnimationContentView)
65
subview.handleRefreshButtonClicked();
71
contentViewAdded(contentView)
73
contentView.element.addEventListener("mouseenter", this._handleContentViewMouseEnter);
74
contentView.element.addEventListener("mouseleave", this._handleContentViewMouseLeave);
77
contentViewRemoved(contentView)
79
contentView.element.removeEventListener("mouseenter", this._handleContentViewMouseEnter);
80
contentView.element.removeEventListener("mouseleave", this._handleContentViewMouseLeave);
85
WI.domManager.hideDOMNodeHighlight();
92
_handleContentViewMouseEnter(event)
94
let contentView = WI.View.fromElement(event.target);
95
if (!(contentView instanceof WI.AnimationContentView))
98
let animation = contentView.representedObject;
99
animation.requestEffectTarget((node) => {
100
if (!node || !node.ownerDocument)
106
_handleContentViewMouseLeave(event)
108
WI.domManager.hideDOMNodeHighlight();