Socket
Socket
Sign inDemoInstall

datepair.js

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datepair.js - npm Package Compare versions

Comparing version 0.4.16 to 0.4.17

2

bower.json
{
"name": "datepair.js",
"version": "0.4.16",
"version": "0.4.17",
"main": ["dist/datepair.js", "dist/jquery.datepair.js"],

@@ -5,0 +5,0 @@ "ignore": [

/*!
* datepair.js v0.4.16 - A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.
* Copyright (c) 2018 Jon Thornton - http://jonthornton.github.com/Datepair.js
* datepair.js v0.4.17 - A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.
* Copyright (c) 2021 Jon Thornton - http://jonthornton.github.com/Datepair.js
* License: MIT

@@ -13,6 +13,6 @@ */

var jq = window.Zepto || window.jQuery;
function simpleExtend(obj1, obj2) {
var out = obj2 || {};
for (var i in obj1) {

@@ -23,6 +23,6 @@ if (!(i in out)) {

}
return out;
}
// IE's custom event support is totally borked.

@@ -39,3 +39,3 @@ // Use jQuery if possible

}
// el.classList not supported by < IE10

@@ -50,3 +50,3 @@ // use jQuery if available

}
function Datepair(container, options) {

@@ -63,3 +63,3 @@ this.dateDelta = null;

anchor: 'start',
// defaults for jquery-timepicker; override when using other input widgets

@@ -75,3 +75,3 @@ parseTime: function(input){

},
// defaults for bootstrap datepicker; override when using other input widgets

@@ -85,6 +85,6 @@ parseDate: function(input){

};
this.container = container;
this.settings = simpleExtend(this._defaults, options);
this.startDateInput = this.container.querySelector('.'+this.settings.startClass+'.'+this.settings.dateClass);

@@ -94,13 +94,13 @@ this.endDateInput = this.container.querySelector('.'+this.settings.endClass+'.'+this.settings.dateClass);

this.endTimeInput = this.container.querySelector('.'+this.settings.endClass+'.'+this.settings.timeClass);
// initialize date and time deltas
this.refresh();
// init starts here
this._bindChangeHandler();
}
Datepair.prototype = {
constructor: Datepair,
option: function(key, value)

@@ -110,13 +110,13 @@ {

this.settings = simpleExtend(this.settings, key);
} else if (typeof key == 'string' && typeof value != 'undefined') {
this.settings[key] = value;
} else if (typeof key == 'string') {
return this.settings[key];
}
this._updateEndMintime();
},
getTimeDiff: function()

@@ -130,6 +130,6 @@ {

}
return delta;
},
refresh: function()

@@ -153,3 +153,3 @@ {

},
remove: function()

@@ -159,3 +159,3 @@ {

},
_bindChangeHandler: function(){

@@ -171,3 +171,3 @@ // addEventListener doesn't work with synthetic "change" events

},
_unbindChangeHandler: function(){

@@ -180,3 +180,3 @@ if (jq) {

},
// This function will be called when passing 'this' to addEventListener

@@ -187,3 +187,3 @@ handleEvent: function(e){

this._unbindChangeHandler();
if (hasClass(e.target, this.settings.dateClass)) {

@@ -196,3 +196,3 @@ if (e.target.value != '') {

}
} else if (hasClass(e.target, this.settings.timeClass)) {

@@ -205,3 +205,3 @@ if (e.target.value != '') {

}
this._validateRanges();

@@ -211,3 +211,3 @@ this._updateEndMintime();

},
_dateChanged: function(target){

@@ -217,6 +217,6 @@ if (!this.startDateInput || !this.endDateInput) {

}
var startDate = this.settings.parseDate(this.startDateInput);
var endDate = this.settings.parseDate(this.endDateInput);
if (!startDate || !endDate) {

@@ -227,3 +227,3 @@ if (this.settings.defaultDateDelta !== null) {

this.settings.updateDate(this.endDateInput, newEnd);
} else if (endDate) {

@@ -233,3 +233,3 @@ var newStart = new Date(endDate.getTime() - this.settings.defaultDateDelta * _ONE_DAY);

}
this.dateDelta = this.settings.defaultDateDelta * _ONE_DAY;

@@ -239,6 +239,11 @@ } else {

}
return;
}
if (Math.abs(endDate.getFullYear() - startDate.getFullYear()) > 1000) {
console.log('here')
return;
}
if (this.settings.anchor == 'start' && hasClass(target, this.settings.startClass)) {

@@ -261,3 +266,3 @@ var newDate = new Date(startDate.getTime() + this.dateDelta);

},
_timeChanged: function(target){

@@ -267,10 +272,10 @@ if (!this.startTimeInput || !this.endTimeInput) {

}
var startTime = this.settings.parseTime(this.startTimeInput);
var endTime = this.settings.parseTime(this.endTimeInput);
if (!startTime || !endTime) {
if (this.settings.defaultTimeDelta !== null) {
this.timeDelta = this.settings.defaultTimeDelta;
if (startTime) {

@@ -286,6 +291,6 @@ endTime = this._setTimeAndReturn(this.endTimeInput, new Date(startTime.getTime() + this.settings.defaultTimeDelta));

}
return;
}
if (this.settings.anchor == 'start' && hasClass(target, this.settings.startClass)) {

@@ -299,3 +304,3 @@ endTime = this._setTimeAndReturn(this.endTimeInput, new Date(startTime.getTime() + this.timeDelta));

this._doMidnightRollover(startTime, endTime);
var startDate, endDate;

@@ -306,3 +311,3 @@ if (this.startDateInput && this.endDateInput) {

}
if ((+startDate == +endDate) && (endTime < startTime)) {

@@ -318,6 +323,6 @@ var thisInput = hasClass(target, this.settings.endClass) ? this.endTimeInput : this.startTimeInput;

}
},
_setTimeAndReturn: function(input, newTime) {

@@ -327,3 +332,3 @@ this.settings.updateTime(input, newTime);

},
_doMidnightRollover: function(startTime, endTime) {

@@ -333,3 +338,3 @@ if (!this.startDateInput || !this.endDateInput) {

}
var endDate = this.settings.parseDate(this.endDateInput);

@@ -339,3 +344,3 @@ var startDate = this.settings.parseDate(this.startDateInput);

var offset = (endTime < startTime) ? _ONE_DAY : -1 * _ONE_DAY;
if (this.dateDelta !== null

@@ -346,3 +351,3 @@ && this.dateDelta + this.timeDelta <= _ONE_DAY

&& ((newDelta >= 0 && this.timeDelta < 0) || (newDelta < 0 && this.timeDelta >= 0))) {
if (this.settings.anchor == 'start') {

@@ -358,6 +363,6 @@ this.settings.updateDate(this.endDateInput, new Date(endDate.getTime() + offset));

},
_updateEndMintime: function(){
if (typeof this.settings.setMinTime != 'function') return;
var baseTime = null;

@@ -367,6 +372,6 @@ if (this.settings.anchor == 'start' && (!this.dateDelta || this.dateDelta < _ONE_DAY || (this.timeDelta && this.dateDelta + this.timeDelta < _ONE_DAY))) {

}
this.settings.setMinTime(this.endTimeInput, baseTime);
},
_validateRanges: function(){

@@ -377,3 +382,3 @@ if (this.startTimeInput && this.endTimeInput && this.timeDelta === null) {

}
if (this.startDateInput && this.endDateInput && this.dateDelta === null) {

@@ -383,3 +388,3 @@ triggerSimpleCustomEvent(this.container, 'rangeIncomplete');

}
// due to the fact that times can wrap around, any time-only pair will be considered valid

@@ -396,2 +401,2 @@ if (!this.startDateInput || !this.endDateInput || this.dateDelta + this.timeDelta >= 0) {

}(window, document));
}(window, document));
/*!
* datepair.js v0.4.16 - A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.
* datepair.js v0.4.17 - A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.
* Copyright (c) 2018 Jon Thornton - http://jonthornton.github.com/Datepair.js

@@ -4,0 +4,0 @@ * License: MIT

/*!
* datepair.js v0.4.16 - A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.
* Copyright (c) 2018 Jon Thornton - http://jonthornton.github.com/Datepair.js
* datepair.js v0.4.17 - A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.
* Copyright (c) 2021 Jon Thornton - http://jonthornton.github.com/Datepair.js
* License: MIT

@@ -51,2 +51,2 @@ */

}(window.Zepto || window.jQuery));
}(window.Zepto || window.jQuery));
/*!
* datepair.js v0.4.16 - A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.
* datepair.js v0.4.17 - A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.
* Copyright (c) 2018 Jon Thornton - http://jonthornton.github.com/Datepair.js

@@ -4,0 +4,0 @@ * License: MIT

@@ -5,3 +5,3 @@ {

"homepage": "http://jonthornton.github.com/Datepair.js",
"version": "0.4.16",
"version": "0.4.17",
"main": "dist/datepair.js",

@@ -8,0 +8,0 @@ "author": {

@@ -212,2 +212,7 @@ var _ONE_DAY = 86400000;

if (Math.abs(endDate.getFullYear() - startDate.getFullYear()) > 1000) {
console.log('here')
return;
}
if (this.settings.anchor == 'start' && hasClass(target, this.settings.startClass)) {

@@ -214,0 +219,0 @@ var newDate = new Date(startDate.getTime() + this.dateDelta);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc