Skip to content

Commit c37b0ff

Browse files
committed
Add close button to the time input directive
1 parent 9246dac commit c37b0ff

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

src/time-input.css

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,44 @@
256256
.datetime-input.time .clear-button:hover::before {
257257
background: #ddd;
258258
}
259+
260+
261+
/**
262+
* Close button
263+
*/
264+
.datetime-input.time .close-button {
265+
position: absolute;
266+
z-index: 5;
267+
left: -1px;
268+
cursor: pointer;
269+
outline: none;
270+
border-top: 1px solid #aaa;
271+
border-left: 1px solid #aaa;
272+
border-bottom: 1px solid #aaa;
273+
color: #777;
274+
width: 25%;
275+
height: auto;
276+
margin-top: 10px;
277+
font-size: 1.5em;
278+
line-height: 2em;
279+
box-sizing: border-box;
280+
background-color: #efefef;
281+
transition: background-color 0.25s ease-out;
282+
}
283+
.datetime-input.time .close-button::before {
284+
content: "";
285+
position: absolute;
286+
right: -0.5em;
287+
top: -1px;
288+
width: 1em;
289+
height: 2em;
290+
background: #efefef;
291+
border-top: 1px solid #aaa;
292+
border-right: 1px solid #aaa;
293+
transition: background 0.25s ease-out;
294+
transform: skewX(-26deg);
295+
}
296+
.datetime-input.time .close-button:hover,
297+
.datetime-input.time .close-button:hover::before {
298+
background: #ddd;
299+
}

src/time-input.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,8 @@
3535
<div class="clear-button" ng-if="!!time">
3636
<div ng-click="update()" ng-bind="clearText || 'Clear'"></div>
3737
</div>
38+
<div class="close-button">
39+
<div ng-click="close()">Close</div>
40+
</div>
3841
</div>
3942
</div>

src/time-input.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ directive('timeInput', ['$document', '$timeout', function ($document, $timeout)
1717
minuteStep : '=?',
1818
secondStep : '=?',
1919
onChange: '&',
20+
onClose: '&?',
2021
placeholder: '@',
2122
clearText: '@',
2223
cssClass:'@',
@@ -66,6 +67,10 @@ directive('timeInput', ['$document', '$timeout', function ($document, $timeout)
6667
// Close edit popover
6768
scope.close = function () {
6869
scope.selected = '';
70+
71+
if ( !!scope.onClose ) {
72+
scope.onClose();
73+
}
6974
}
7075

7176
// Bind click events outside directive to close edit popover

0 commit comments

Comments
 (0)