Skip to content

Commit

Permalink
Add options minTime/maxTime - needs doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsage committed Jun 9, 2015
1 parent e2bbc4b commit 8165402
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dev/index.html
Expand Up @@ -89,7 +89,7 @@ <h1>DateBox - Dev Page</h1>
</div>
<div class="ui-field-contain">
<label for="lang2">yep</label>
<input name="lang2" type="text" data-role="datebox" data-datebox-mode="flipbox" id="lang2" data-options='{"afterToday": true, "beforeToday":true, "notToday":true, "defaultValue":"2014-02-02", "whiteDates":["2014-02-02"]}' />
<input name="lang2" type="text" data-role="datebox" data-datebox-mode="timeflipbox" id="lang2" data-options='{"minTime": "6:00", "maxTime":"9:00"}' />

</div>
<div class="ui-field-contain">
Expand Down
18 changes: 16 additions & 2 deletions js/jqm-datebox.core.js
Expand Up @@ -11,7 +11,7 @@

// 3-jQueryMobileVersion
// Check Header for Build Date.
version: "3-1.4.5-06",
version: "3-1.4.5-07",

theme: false,
themeDefault: "a",
Expand Down Expand Up @@ -77,6 +77,8 @@
whiteDates: true,
minHour: false,
maxHour: false,
minTime: false,
maxTime: false,
maxDur: false,
minDur: false,
minuteStep: 1,
Expand Down Expand Up @@ -1382,7 +1384,7 @@
},
_check: function() {
// Check to see if a date is valid.
var td, year, month, date, i,
var td, year, month, date, i, tihm,
w = this,
o = this.options,
now = this.theDate;
Expand Down Expand Up @@ -1418,6 +1420,18 @@
now.setD( 3, o.maxHour );
}
}
if ( o.minTime !== false ) {
td = new w._date();
tihm = o.minTime.split(":");
td.setD( 3, tihm[0] ).setD( 4, tihm[1] );
if ( now < td ) { now = td; }
}
if ( o.maxTime !== false ) {
td = new w._date();
tihm = o.maxTime.split(":");
td.setD( 3, tihm[0] ).setD( 4, tihm[1] );
if ( now > td ) { now = td; }
}
if ( o.maxYear !== false ) {
td = new w._date( o.maxYear, 11, 31 );
if ( now > td ) { now = td; }
Expand Down

0 comments on commit 8165402

Please sign in to comment.