Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selected date is going on the top in the datepicker on popup for firefox #27

Open
minivetsystem opened this issue Mar 15, 2018 · 0 comments

Comments

@minivetsystem
Copy link

Hello,
I'm applying the anypicker on a textbox into a popup. So there is current date is showing by default php code. So selected date should work, as it is working in chrome. But in firefox it is scrolling once like the image below
firefox

Here is my code

//Set date time picker
var curFullDate = new Date();
var curYear = curFullDate.getFullYear();
if (userAgent !== "") { //Firefox
var monthArr = [
"January",
"Febary",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
];
var curMonth = curFullDate.getMonth();
curMonth = monthArr[curMonth];
} else {
var curMonth = curFullDate.getMonth() + 1;
}
console.log(curMonth);
var curDate = curFullDate.getDate();
var curHours = curFullDate.getHours();
var curAP = (curHours > 12) ? "PM" : "AM";
if (userAgent === "") {
curHours = (curHours > 12) ? curHours - 12 : curHours;
}
curHours = (curHours > 9) ? curHours : "0" + curHours;
var curMinutes = curFullDate.getMinutes();
var curSeconds = curFullDate.getSeconds();
curMinutes = (curMinutes > 9) ? curMinutes : "0" + curMinutes;

                                if (userAgent !== "") { //Firefox
                                    //"October 13, 1975 11:13:00"
                                    var curFormat = curMonth + " " + curDate + ", " + curYear + " " + curHours + ":" + curMinutes + ":" + curSeconds;
                                } else {
                                    var curFormat = curYear + "-" + curMonth + "-" + curDate + " " + curHours + ":" + curMinutes + " " + curAP;
                                }
                                
                                //console.log(curFormat);
                                var minDate = new Date(curFormat);
                                var maxDate = new Date(curFormat);
                                maxDate.setFullYear(maxDate.getFullYear() + 5);
                                //console.log(minDate);
                                //console.log(maxDate);
                                var selectedDate = new Date(curFormat);
                                
                                var settings = {
                                    dateTimeFormat: "Y-MM-dd HH:mm",
                                    minValue: minDate,
                                    maxValue: maxDate,
                                    //selectedDate: selectedDate
                                };
                                
                                $("#popupContent #addOfferForm").find("input[name=\"start_date\"]").applyDateTimePicker(settings);

Here is the applyDateTimePicker function

$.fn.applyDateTimePicker = function(data) {
var minDate =new Date();
var maxDate = new Date();
var theme = "Default", userAgent = navigator.userAgent;

if (userAgent.match(/Android|Silk/i)) {
    theme = "Android";
}
else if (userAgent.match(/iPhone|iPad|iPod/i)) {
    theme = "iOS";
}
else if (userAgent.match(/IEMobile/i)) {
    theme = "Android";//"Windows";
}

minDate.setFullYear(minDate.getFullYear() - 118);

var settings = {
    mode: "datetime",
    inputDateTimeFormat: "Y-MM-dd hh:mm AA",
    dateTimeFormat: "Y-MM-dd hh:mm AA",
    theme: theme,  // "Defaualt", "iOS", "Android", "Windows",
    minValue: minDate,
    maxValue: maxDate,

    headerTitle: {
        markup: "<span class='ap-header__title'>" + DATEPICKER_HEADER_TITLE + "</span>",
        type: "Text",
        contentBehaviour: "Dynamic", // Static or Dynamic
        format: "" // DateTime Format
    },

    i18n: {
        headerTitle: DATEPICKER_HEADER_TITLE,
        setButton: DATEPICKER_SET_BUTTON,
        cancelButton: DATEPICKER_CANCEL_BUTTON,
        dateSwitch: DATEPICKER_DATE_TAB,
        timeSwitch: DATEPICKER_TIME_TAB
    }
};

if (data && data !== undefined && typeof data === "object") {
    // Merge data into settings
    $.extend( settings, data );
}

this.AnyPicker(settings);

};

Please try to give me solution as soon as possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant