-
Notifications
You must be signed in to change notification settings - Fork 5
/
undo-stack-view.html
70 lines (57 loc) · 1.37 KB
/
undo-stack-view.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!--
CUSTOM ELEMENT: undo-stack-view
BY: DM
This is a read-only view of the undo-stack array of a cut-object.
The array contains all the delta information, but we only care about
the human-readable "description" here.
It also shows the redo-stack.
-->
<link rel="import" href="bower_components/polymer/polymer.html">
<dom-module id="undo-stack-view">
<style>
.redo,
.undo{
background: rgba(106, 119, 130, 0.08);
margin-top: 2px;
}
.redo{
color: #1A64A5;
text-align: right;
}
:host{
max-height: 150px;
overflow: scroll;
cursor: default;
}
</style>
<template>
<template is="dom-repeat" items="[[redo_stack]]">
<div class="redo">([[item]])</div>
</template>
<template is="dom-repeat" items="{{_reversed_undo(undo_stack.splices)}}" >
<div class="undo">[[item]]</div>
</template>
</template>
<script>
"use strict";
Polymer({
is:'undo-stack-view',
properties: {
undo_stack: {
type: Array,
value: function(){return [];},
notify: true
},
redo_stack: {
type: Array,
value: function(){return [];},
notify: true
}
}, _reversed_undo: function(){
let arr = this.undo_stack.slice(0);
arr.reverse();
return arr;
}
});
</script>
</dom-module>