Skip to content

Commit 9246dac

Browse files
committed
Add close button to the date input directive
1 parent 24c3deb commit 9246dac

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

src/date-input.css

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

src/date-input.html

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

src/date-input.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ directive('dateInput', ['$document', '$timeout', function ($document, $timeout)
1414
minDate:'=?',
1515
maxDate:'=?',
1616
onChange: '&',
17+
onClose: '&?',
1718
placeholder: '@',
1819
clearText: '@',
1920
cssClass:'@',
@@ -71,7 +72,10 @@ directive('dateInput', ['$document', '$timeout', function ($document, $timeout)
7172
// Close edit popover
7273
scope.close = function () {
7374
scope.selected = '';
74-
scope.calendar_active = false;
75+
76+
if ( !!scope.onClose ) {
77+
scope.onClose();
78+
}
7579
}
7680

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

0 commit comments

Comments
 (0)