Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(594)

Side by Side Diff: appengine/swarming/elements/res/imp/common/sort-toggle.html

Issue 2182693002: Add new botlist for swarming (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@app-wrapper
Patch Set: Adjust font and layout a bit more Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!--
2 Copyright 2016 The LUCI Authors. All rights reserved.
3 Use of this source code is governed under the Apache License, Version 2.0
4 that can be found in the LICENSE file.
5
6 This in an HTML Import-able file that contains the definition
7 of the following elements:
8
9 <sort-toggle>
10
11 Sort-toggle is a small ui widget that can be tapped to change the way
12 something is sorted. The preferred way to use this is to have multipe
13 of them created in dom-repeat. The parent then listens to the
14 sort_change event and sets the current property on all the sort-toggles
15 to keep them up to date.
16
17 Only one sort-toggle will be active in this way.
18
19 Properties:
20 // input
21 current: Object, the current sort-toggle that should be active. Is
22 The same format as the event.detail Object.
23 name: String, the name of the thing being sorted. To be used in the
24 fired event.
25
26 // output
27 direction: String, the direction of the sorting. "asc", "", "desc" for
28 ascending/nothing/descending.
29
30
31
32 Methods:
33 None.
34
35 Events:
36 sort_change: when a user has tapped this element. The details includes
37 name and direction.
38 -->
39
40 <link rel="import" href="/res/imp/bower_components/iron-icons/iron-icons.html">
41
42 <dom-module id="sort-toggle">
43 <template>
44 <style>
45 :host {
46 display: inline-block;
47 position: relative;
48 min-width: 20px;
49 min-height: 16px;
50 vertical-align: middle;
51 }
52 iron-icon {
53 position: absolute;
54 left: 0;
55 cursor: pointer;
56 }
57 .hidden {
58 visibility: hidden;
59 }
60 </style>
61
62 <span on-click="toggle">
63 <iron-icon
64 style="top:0"
65 class$="[[_hidden(direction,'asc')]]"
66 icon="icons:arrow-drop-down">
67 </iron-icon>
68 <iron-icon
69 style="bottom:0"
70 class$="[[_hidden(direction,'desc')]]"
71 icon="icons:arrow-drop-up">
72 </iron-icon>
73 </span>
74
75 </template>
76 <script>
77 Polymer({
78 is: "sort-toggle",
79 properties: {
jcgregorio 2016/08/01 14:08:06 nit: need blank line above.
80 current: {
81 type: Object,
82 observer: "_resetSort",
83 },
84 name: {
85 type: String,
86 observer: "_resetSort",
87 },
88
89 direction: {
90 type: String,
91 value: "",
92 notify: true,
93 },
94 },
95
96 toggle: function() {
97 if (this.direction === "asc") {
98 this.set("direction", "desc");
99 } else {
100 this.set("direction", "asc");
101 }
102 this.fire("sort_change", {direction: this.direction, name: this.name});
103 },
104
105 _hidden: function(num, compare) {
106 if (num === compare) {
107 return "hidden";
108 }
109 return "";
110 },
111
112 _resetSort: function() {
113 // Because of how Polymer inserts and moves elements around, we need to
114 // update the direction value if the name changes so the ascending sort
115 // by "os" doesn't become the ascending sort by "gpu" if a column gets
116 // added before "os", for example. Additionally, this makes sure that
117 // only one sort-toggle is active at a given time.
118 if (this.current && this.current.name === this.name) {
119 this.set("direction", this.current.direction);
120 } else {
121 this.set("direction", "");
122 }
123
jcgregorio 2016/08/01 14:08:06 nit: no blank line here.
124 },
125 });
126 </script>
127 </dom-module>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698