-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8704 from infor-design/NG1659-monthview-activedate
NG1659 - Monthview Add Day
- Loading branch information
Showing
2 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<div class="row"> | ||
<div class="twelve columns"> | ||
<p id="selected-date"></p><br> | ||
<button class="btn-primary" type="button" id="btn-add">Add Day</button> | ||
</div> | ||
</div> | ||
<div class="row top-padding"> | ||
<div class="twelve columns"> | ||
<div class="monthview" data-init="false"> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
<script> | ||
$('body').on('initialized', function() { | ||
var monthViewApi = null; | ||
var selectedDate = new Date(); | ||
var monthViewOptions = { | ||
inPage: true, | ||
inPageExpanded: true, | ||
showMonthYearPicker: false, | ||
showLegend: true, | ||
disable: { | ||
isEnable: false, // inverses the disable options | ||
attributes: [ | ||
{ name: 'id', value: 'monthview-id' }, | ||
{ name: 'data-automation-id', value: 'monthview-automation-id' } | ||
] | ||
}, | ||
} | ||
$('.monthview').monthview({ | ||
...monthViewOptions, | ||
day: selectedDate.getDate(), | ||
month: selectedDate.getMonth(), | ||
year: selectedDate.getFullYear(), | ||
activeDate: selectedDate | ||
}); | ||
|
||
monthViewApi = $('.monthview').data('monthview'); | ||
|
||
$('#selected-date').text(selectedDate); | ||
|
||
$('#btn-add').on('click', () => { | ||
selectedDate = monthViewApi.currentDate; | ||
selectedDate.setDate(selectedDate.getDate() + 1); | ||
var settings = { | ||
...monthViewOptions, | ||
day: selectedDate.getDate(), | ||
month: selectedDate.getMonth(), | ||
year: selectedDate.getFullYear(), | ||
activeDate: selectedDate, | ||
}; | ||
console.log(selectedDate.toDateString()); | ||
|
||
$('#selected-date').text(selectedDate); | ||
monthViewApi.updated(settings); | ||
}) | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters