You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
2.2 KiB
JavaScript
53 lines
2.2 KiB
JavaScript
6 years ago
|
/*!
|
||
|
* * depend on
|
||
|
* /js/jquery-1.11.3.min.js, /public/js/bootstrap.min.js
|
||
|
* /js/ui.core.js,/js/ui.datepicker.js
|
||
|
* /css/ui.core.css,/css/ui.datepicker.css,/css/ui.theme.css
|
||
|
*/
|
||
|
var shade_html = "<style type=\"text/css\" media=\"screen and (max-width:767px)\">" +
|
||
|
".ui-datepicker,.ui-datepicker-title{font-size:18px!important;}" +
|
||
|
"</style>";
|
||
|
shade_html += "<div id=\"date_dialog\" class=\"date_dialog modal fade\" role=\"dialog\" aria-hidden=\"true\" style=\"padding-top: 100px;\"><div id=\"date_inline\"></div></div>";
|
||
|
$(function() {
|
||
|
// var min_date = $("#starting_date").data("min-date");
|
||
|
// min_date = min_date ? min_date : 3;
|
||
|
min_date = 3;
|
||
|
if (screen.width >= 768){
|
||
|
$("#starting_date").removeAttr("data-target");
|
||
|
$("#starting_date").datepicker({
|
||
|
showAnim: "fadeIn",
|
||
|
duration: 0,
|
||
|
minDate: min_date,
|
||
|
maxDate: "2y",
|
||
|
dateFormat: "mm/dd/yy",
|
||
|
numberOfMonths: 2
|
||
|
});
|
||
|
$("#ui-datepicker-div,.ui-datepicker,.ui-datepicker-title").css({"font-size":"12px"});
|
||
|
} else {
|
||
|
$("body").append(shade_html);
|
||
|
$("#starting_date").attr({"data-target":"#date_dialog", "data-toggle":"modal"});
|
||
|
$('#date_dialog').on('show.bs.modal', function () {
|
||
|
$("#date_inline").datepicker({
|
||
|
showAnim: "fadeIn",
|
||
|
duration: 0,
|
||
|
minDate: min_date,
|
||
|
maxDate: "2y",
|
||
|
dateFormat: "mm/dd/yy",
|
||
|
numberOfMonths: 1,
|
||
|
onSelect: function (dateText, inst) {
|
||
|
setTimeout(function(){
|
||
|
$("#starting_date").val(dateText);
|
||
|
$('#date_dialog').modal('hide');
|
||
|
},500);
|
||
|
}
|
||
|
});
|
||
|
var width = ($(window).width() - 306) / 2;
|
||
|
$(".ui-datepicker").css({"width":"306px","z-index":9999,left:0,"margin-left":width+"px","margin-right":"auto","font-size":"18px"});
|
||
|
}).on('hide.bs.modal', function () {
|
||
|
var currentDate = $( "#date_inline" ).datepicker( "getDate" );
|
||
|
var dateText = $.datepicker.formatDate("mm/dd/yy", currentDate);
|
||
|
$("#starting_date").val(dateText);
|
||
|
});
|
||
|
}
|
||
|
})
|