Skip to content

Commit 816985b

Browse files
committed
Add close button to the datetime input directive
1 parent c37b0ff commit 816985b

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

src/datetime-input.css

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,3 +369,44 @@
369369
.datetime-input.datetime .clear-button:hover::before {
370370
background: #ddd;
371371
}
372+
373+
374+
/**
375+
* Close button
376+
*/
377+
.datetime-input.datetime .close-button {
378+
position: absolute;
379+
z-index: 5;
380+
left: -1px;
381+
cursor: pointer;
382+
outline: none;
383+
border-top: 1px solid #aaa;
384+
border-left: 1px solid #aaa;
385+
border-bottom: 1px solid #aaa;
386+
color: #777;
387+
width: 25%;
388+
height: auto;
389+
margin-top: 10px;
390+
font-size: 1.5em;
391+
line-height: 2em;
392+
box-sizing: border-box;
393+
background-color: #efefef;
394+
transition: background-color 0.25s ease-out;
395+
}
396+
.datetime-input.datetime .close-button::before {
397+
content: "";
398+
position: absolute;
399+
right: -0.5em;
400+
top: -1px;
401+
width: 1em;
402+
height: 2em;
403+
background: #efefef;
404+
border-top: 1px solid #aaa;
405+
border-right: 1px solid #aaa;
406+
transition: background 0.25s ease-out;
407+
transform: skewX(-26deg);
408+
}
409+
.datetime-input.datetime .close-button:hover,
410+
.datetime-input.datetime .close-button:hover::before {
411+
background: #ddd;
412+
}

src/datetime-input.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,8 @@
6464
<div class="clear-button" ng-if="!!datetime">
6565
<div ng-click="update()" ng-bind="clearText || 'Clear'"></div>
6666
</div>
67+
<div class="close-button">
68+
<div ng-click="close()">Close</div>
69+
</div>
6770
</div>
6871
</div>

src/datetime-input.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ directive('datetimeInput', ['$document', '$timeout', function ($document, $timeo
1818
minuteStep:'=?',
1919
secondStep:'=?',
2020
onChange: '&',
21+
onClose: '&?',
2122
placeholder: '@',
2223
clearText: '@',
2324
cssClass:'@',
@@ -75,6 +76,10 @@ directive('datetimeInput', ['$document', '$timeout', function ($document, $timeo
7576
scope.close = function () {
7677
scope.selected = '';
7778
scope.calendar_active = false;
79+
80+
if ( !!scope.onClose ) {
81+
scope.onClose();
82+
}
7883
}
7984

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

0 commit comments

Comments
 (0)