Skip to content

Commit

Permalink
bug fix for moth range in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
timkeane committed Jan 15, 2016
1 parent 9325662 commit 4160681
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 39 deletions.
15 changes: 11 additions & 4 deletions src/main/js/nyc/collapsible-month-range.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,17 @@ nyc.MonthRangePicker.prototype = {
(year > options.minYear && year < options.maxYear)
){
var min = this.firstOfMonth(month, year), max = this.lastOfMonth(month, year);
this.minDates.push(min);
this.appendOpt(this.min, min);
this.maxDates.push(max);
this.appendOpt(this.max, max);
if (
(year >- options.minYear && month >= options.minMonth) &&
(year <= options.maxYear && month <= options.maxMonth)
){
this.minDates.push(min);
this.appendOpt(this.min, min);
}
if ((year == options.maxYear && month <= options.maxMonth) || year < options.maxYear){
this.maxDates.push(max);
this.appendOpt(this.max, max);
}
}
}
}
Expand Down
70 changes: 35 additions & 35 deletions src/test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,46 +81,46 @@
<!-- tests -->
<script src="js/setup-teardown.js"></script>

<script src="js/nyc/nyc.js"></script>
<script src="js/nyc/util.js"></script>
<script src="js/nyc/content.js"></script>
<script src="js/nyc/dialog.js"></script>
<script src="js/nyc/lang.js"></script>
<script src="js/nyc/collapsible.js"></script>
<!-- <script src="js/nyc/nyc.js"></script> -->
<!-- <script src="js/nyc/util.js"></script> -->
<!-- <script src="js/nyc/content.js"></script> -->
<!-- <script src="js/nyc/dialog.js"></script> -->
<!-- <script src="js/nyc/lang.js"></script> -->
<!-- <script src="js/nyc/collapsible.js"></script> -->
<script src="js/nyc/collapsible-month-range.js"></script>
<script src="js/nyc/collapsible-radio.js"></script>
<script src="js/nyc/geocoder.js"></script>
<script src="js/nyc/legend.js"></script>
<script src="js/nyc/locationmgr.js"></script>
<script src="js/nyc/share.js"></script>
<script src="js/nyc/zoomsearch.js"></script>
<!-- <script src="js/nyc/collapsible-radio.js"></script> -->
<!-- <script src="js/nyc/geocoder.js"></script> -->
<!-- <script src="js/nyc/legend.js"></script> -->
<!-- <script src="js/nyc/locationmgr.js"></script> -->
<!-- <script src="js/nyc/share.js"></script> -->
<!-- <script src="js/nyc/zoomsearch.js"></script> -->

<script src="js/nyc/leaf/zoomsearch.js"></script>
<script src="js/nyc/leaf/locate.js"></script>
<script src="js/nyc/leaf/locator.js"></script>
<!-- <script src="js/nyc/leaf/zoomsearch.js"></script> -->
<!-- <script src="js/nyc/leaf/locate.js"></script> -->
<!-- <script src="js/nyc/leaf/locator.js"></script> -->

<script src="js/nyc/carto/carto.js"></script>
<script src="js/nyc/carto/heatsymbolizer.js"></script>
<script src="js/nyc/carto/jenkssymbolizer.js"></script>
<script src="js/nyc/carto/view.js"></script>
<script src="js/nyc/carto/sqlview.js"></script>
<script src="js/nyc/carto/chart.js"></script>
<script src="js/nyc/carto/popup.js"></script>
<!-- <script src="js/nyc/carto/carto.js"></script> -->
<!-- <script src="js/nyc/carto/heatsymbolizer.js"></script> -->
<!-- <script src="js/nyc/carto/jenkssymbolizer.js"></script> -->
<!-- <script src="js/nyc/carto/view.js"></script> -->
<!-- <script src="js/nyc/carto/sqlview.js"></script> -->
<!-- <script src="js/nyc/carto/chart.js"></script> -->
<!-- <script src="js/nyc/carto/popup.js"></script> -->

<script src="js/nyc/ol/draw.js"></script>
<script src="js/nyc/ol/featuretip.js"></script>
<script src="js/nyc/ol/geoserver/getfeature.js"></script>
<script src="js/nyc/ol/source/arcgiscache.js"></script>
<script src="js/nyc/ol/source/decorating.js"></script>
<script src="js/nyc/ol/source/filteringandsorting.js"></script>
<script src="js/nyc/ol/layer/baselayer.js"></script>
<script src="js/nyc/ol/layer/grayscale.js"></script>
<!-- <script src="js/nyc/ol/draw.js"></script> -->
<!-- <script src="js/nyc/ol/featuretip.js"></script> -->
<!-- <script src="js/nyc/ol/geoserver/getfeature.js"></script> -->
<!-- <script src="js/nyc/ol/source/arcgiscache.js"></script> -->
<!-- <script src="js/nyc/ol/source/decorating.js"></script> -->
<!-- <script src="js/nyc/ol/source/filteringandsorting.js"></script> -->
<!-- <script src="js/nyc/ol/layer/baselayer.js"></script> -->
<!-- <script src="js/nyc/ol/layer/grayscale.js"></script> -->

<script src="js/nyc/directions.js"></script>
<script src="js/nyc/ol/locate.js"></script>
<script src="js/nyc/ol/locator.js"></script>
<script src="js/nyc/ol/popup.js"></script>
<script src="js/nyc/ol/featuretip.js"></script>
<!-- <script src="js/nyc/directions.js"></script> -->
<!-- <script src="js/nyc/ol/locate.js"></script> -->
<!-- <script src="js/nyc/ol/locator.js"></script> -->
<!-- <script src="js/nyc/ol/popup.js"></script> -->
<!-- <script src="js/nyc/ol/featuretip.js"></script> -->

</body>
</html>
46 changes: 46 additions & 0 deletions src/test/js/nyc/collapsible-month-range.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,52 @@ QUnit.test('constructor', function(assert){
div.remove();
});

QUnit.test('constructor 2', function(assert){
assert.expect(4);

var div = $('<div id="test-div"><div>stuff</div></div>');
$('body').append(div);

var dateRange = new nyc.MonthRangePicker({
target: div,
title: 'Date Range',
minMonth: 0,
minYear: 2015,
maxMonth: 10,
maxYear: 2015
});

var selects = $('#test-div select');

assert.equal(selects.length, 2);

assert.ok(selects.get(0) === dateRange.min.get(0));
assert.ok(selects.get(1) === dateRange.max.get(0));

// assert.equal(dateRange.min.children().length, 28);
// assert.equal(dateRange.max.children().length, 28);
//
console.warn(dateRange.min.children().first().get(0));
console.warn(dateRange.max.children().last().get(0));

console.log(dateRange.minDates);
console.log(dateRange.maxDates);

console.info(dateRange.val());

assert.deepEqual(dateRange.val(), {
start: dateRange.localeDate('2015-11-01'),
end: dateRange.localeDate('2015-11-30')
});

// assert.equal(
// dateRange.localeDate('2013-06-01').toLocaleDateString() + ' - ' +
// dateRange.localeDate('2013-06-30').toLocaleDateString(),
// dateRange.currentVal.html()
// );
div.remove();
});

QUnit.test('firstOfMonth', function(assert){
assert.expect(12);

Expand Down

0 comments on commit 4160681

Please sign in to comment.