jtsage / jtsage-datebox

A multi-mode date and time picker for Bootstrap (3&4), jQueryMobile, Foundation, Bulma, FomanticUI, and UIKit (or others)
http://datebox.jtsage.dev/
Other
474 stars 166 forks source link

Upgrading to v5.1.0 jqm minDays, maxDays and year #468

Closed gregh3269 closed 5 years ago

gregh3269 commented 5 years ago

Trying out JTSage-DateBox-5.1.0 (jqm)

<input name="visitDate" type="text" value="20/05/19" data-role="datebox" data-options='{"mode": "calbox", "useFocus":true, "overrideDateFormat": "%d/%m/%y", "minDays" : 4.0, "maxDays" : 0.0, "disabledState": "disabled" }' readonly="readonly" />

I get the calendar to pop, but nothing is selectable, if I remove "minDays" : 4.0, "maxDays" : 0.0 it works.

Are there any other changes I need to make?

(Year is OK)

jtsage commented 5 years ago

Curiously, if you remove either one of minDays or maxDays, there is also a selectable set. The logic is bad here (my fault). And indeed, in version 4, these options were not exclusive.

Give me a couple hours to figure out how to fix this, because you should be able to do exactly what you want to.

~j

gregh3269 commented 5 years ago

Yes, the logic seems incorrect now. If I just use minDays it selects everything except for the minimum days. I took a look at the code and there seems some logic missing, its failing the maxDays ie not checking its within the minDays window.

for (itt = 0; itt < badChecks.length && !done; itt++) {
                if (w._newDateCheck[badChecks[itt]].call(w, testDate)) {
                    returnObject.bad = true;
                    returnObject.good = false;
                    returnObject.failrule = badChecks[itt];
                    done = true;
                }
            }
jtsage commented 5 years ago

Yeah - minDays and maxDays can't be truly separate checks - and that is solely down to the fact that I wish to keep allowing negative values for these. (If I didn't, it's trivial to just ignore everything before/after today). At any rate, commit coming at you in about 5 min. I tested through a couple times, looks like it responds exactly like version 4.

jtsage commented 5 years ago

Huh. that last bit is only partially true. It doesn't work in 5.1.0 because the check is flipped. Stupid double negatives.

jtsage commented 5 years ago

Re Version 5.1.1, SHA: df7153a30ca96dfada0b8ad300e879cf7b63a9b6

gregh3269 commented 5 years ago

Great, looks good. I will I upgrade rest of my pickers now.

Thanks!

gregh3269 commented 5 years ago

Sorry, one more question, in the source I spotted

"ui-btn-" + data.theme,

Where does the data.theme come from?

jtsage commented 5 years ago

It's a placeholder variable.

It's in the function:

_cal_ThemeDate = function( testDate, dispMonth ) { ... } source

At a glance,

[ "selected",     "theme_cal_Selected" ],
[ "today" ,       "theme_cal_Today" ],
[ "highDates",    "theme_cal_DateHigh" ],
[ "highDatesAlt", "theme_cal_DateHighAlt" ],
[ "highDatesRec", "theme_cal_DateHighRec" ],
[ "highDays",     "theme_cal_DayHigh" ]

With the outlier of "theme_cal_OutOfBounds" where appropriate, and "theme_cal_Default" if none of them apply.

jtsage commented 5 years ago

Pretty much the old theme system, while it worked, was incredibly poorly named / thought out.

A full list of the new option names are here:

https://datebox.jtsage.dev/themes/

They do work pretty much the same as they used to.

Also, you can ignore the bit on that page about icons - icons for the jQM build work like they always have, as they are built into jQM itself.

gregh3269 commented 5 years ago

So if I had "themeHeader" : "b" before what would the new value be (if any)?

eg for the header I used to get (theme b, blue colour): ui-header ui-bar-b

now I get (no colour): ui-header ui-bar-inherit

gregh3269 commented 5 years ago

OK, from https://datebox.jtsage.dev/themes/ : theme_headerTheme

Thanks (again)

jtsage commented 5 years ago

Looks like it is "theme_headerTheme"

This may also be helpful, as it's the "defaults" for the jQM build source

jtsage commented 5 years ago

Fix pushed to release, SHA: df7153a30ca96dfada0b8ad300e879cf7b63a9b6 (5.1.1)

(already superseded by 5.1.2, but adding here for historical purposes.)

Closing issue, if this comes back, or I missed something, feel free to re-open.