├── .repo-rt ├── README.md ├── css └── ui.daterangepicker.css ├── index.html └── js ├── date.js ├── daterangepicker.jQuery.compressed.js └── daterangepicker.jQuery.js /.repo-rt: -------------------------------------------------------------------------------- 1 | RETIRED 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | :warning: This project is archived and the repository is no longer maintained. 2 | 3 | # jQuery-UI-Date-Range-Picker 4 | A range picker built on top of jQuery UI's Datepicker Control 5 | -------------------------------------------------------------------------------- /css/ui.daterangepicker.css: -------------------------------------------------------------------------------- 1 | /*styles for jquery ui daterangepicker plugin */ 2 | 3 | .ui-daterangepickercontain { 4 | position: absolute; 5 | z-index: 999; 6 | } 7 | .ui-daterangepickercontain .ui-daterangepicker { 8 | float: left; 9 | padding: 5px !important; 10 | width: auto; 11 | display: inline; 12 | background-image: none !important; 13 | clear: left; 14 | } 15 | .ui-daterangepicker ul, .ui-daterangepicker .ranges, .ui-daterangepicker .range-start, .ui-daterangepicker .range-end { 16 | float: left; 17 | padding: 0; 18 | margin: 0; 19 | } 20 | .ui-daterangepicker .ranges { 21 | width: auto; 22 | position: relative; 23 | padding: 5px 5px 40px 0; 24 | margin-left: 10px; 25 | } 26 | .ui-daterangepicker .range-start, .ui-daterangepicker .range-end { 27 | margin-left: 5px; 28 | } 29 | .ui-daterangepicker button.btnDone { 30 | margin: 0 5px 5px 0; 31 | position: absolute; 32 | bottom: 0; 33 | right: 0; 34 | clear: both; 35 | cursor: pointer; 36 | font-size: 1.1em; 37 | } 38 | .ui-daterangepicker ul { 39 | width: 17.6em; 40 | background: none; 41 | border: 0; 42 | } 43 | .ui-daterangepicker li { 44 | list-style: none; 45 | padding: 1px; 46 | cursor: pointer; 47 | margin: 1px 0; 48 | } 49 | .ui-daterangepicker li.ui-state-hover, .ui-daterangepicker li.ui-state-active { 50 | padding: 0; 51 | } 52 | .ui-daterangepicker li.preset_0 { 53 | margin-top: 1.5em !important; 54 | } 55 | .ui-daterangepicker .ui-widget-content a { 56 | text-decoration: none !important; 57 | } 58 | .ui-daterangepicker li a { 59 | font-weight: normal; 60 | margin: .3em .5em; 61 | display: block; 62 | } 63 | .ui-daterangepicker li span { 64 | float: right; 65 | margin: .3em .2em; 66 | } 67 | .ui-daterangepicker .title-start, .ui-daterangepicker .title-end { 68 | display: block; 69 | margin: 0 0 .2em; 70 | font-size: 1em; 71 | padding: 0 4px 2px; 72 | } 73 | .ui-daterangepicker .ui-datepicker-inline { 74 | font-size: 1em; 75 | } 76 | .ui-daterangepicker-arrows { 77 | padding: 2px; 78 | width: 204px; 79 | position: relative; 80 | } 81 | .ui-daterangepicker-arrows input.ui-rangepicker-input { 82 | width: 158px; 83 | margin: 0 2px 0 20px; 84 | padding: 2px; 85 | height: 1.1em; 86 | } 87 | .ui-daterangepicker-arrows .ui-daterangepicker-prev, .ui-daterangepicker-arrows .ui-daterangepicker-next { 88 | position: absolute; 89 | top: 2px; 90 | padding: 1px; 91 | } 92 | .ui-daterangepicker-arrows .ui-daterangepicker-prev { 93 | left: 2px; 94 | } 95 | .ui-daterangepicker-arrows .ui-daterangepicker-next { 96 | right: 2px; 97 | } 98 | .ui-daterangepicker-arrows .ui-daterangepicker-prev:hover, 99 | .ui-daterangepicker-arrows .ui-daterangepicker-next:hover, 100 | .ui-daterangepicker-arrows .ui-daterangepicker-prev:focus, 101 | .ui-daterangepicker-arrows .ui-daterangepicker-next:focus { 102 | padding: 0; 103 | } 104 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Themeroller-Ready jQuery UI Range Picker 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 34 | 35 | 36 |

Default Rangepicker

37 |
38 | 39 |
40 | 41 |

2 inputs Rangepicker

42 |
43 | 44 | 45 |
46 | 47 |

Rangepicker with arrows

48 |
49 | 50 |
51 | 52 |

Rangepicker opening to the right

53 |
54 | 55 |
56 | 57 |

Rangepicker with contraints

58 |
59 | 60 |
61 | 62 | 63 | -------------------------------------------------------------------------------- /js/date.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Version: 1.0 Alpha-1 3 | * Build Date: 13-Nov-2007 4 | * Copyright (c) 2006-2007, Coolite Inc. (http://www.coolite.com/). All rights reserved. 5 | * License: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/. 6 | * Website: http://www.datejs.com/ or http://www.coolite.com/datejs/ 7 | */ 8 | Date.CultureInfo={name:"en-US",englishName:"English (United States)",nativeName:"English (United States)",dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbreviatedDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],shortestDayNames:["Su","Mo","Tu","We","Th","Fr","Sa"],firstLetterDayNames:["S","M","T","W","T","F","S"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],abbreviatedMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],amDesignator:"AM",pmDesignator:"PM",firstDayOfWeek:0,twoDigitYearMax:2029,dateElementOrder:"mdy",formatPatterns:{shortDate:"M/d/yyyy",longDate:"dddd, MMMM dd, yyyy",shortTime:"h:mm tt",longTime:"h:mm:ss tt",fullDateTime:"dddd, MMMM dd, yyyy h:mm:ss tt",sortableDateTime:"yyyy-MM-ddTHH:mm:ss",universalSortableDateTime:"yyyy-MM-dd HH:mm:ssZ",rfc1123:"ddd, dd MMM yyyy HH:mm:ss GMT",monthDay:"MMMM dd",yearMonth:"MMMM, yyyy"},regexPatterns:{jan:/^jan(uary)?/i,feb:/^feb(ruary)?/i,mar:/^mar(ch)?/i,apr:/^apr(il)?/i,may:/^may/i,jun:/^jun(e)?/i,jul:/^jul(y)?/i,aug:/^aug(ust)?/i,sep:/^sep(t(ember)?)?/i,oct:/^oct(ober)?/i,nov:/^nov(ember)?/i,dec:/^dec(ember)?/i,sun:/^su(n(day)?)?/i,mon:/^mo(n(day)?)?/i,tue:/^tu(e(s(day)?)?)?/i,wed:/^we(d(nesday)?)?/i,thu:/^th(u(r(s(day)?)?)?)?/i,fri:/^fr(i(day)?)?/i,sat:/^sa(t(urday)?)?/i,future:/^next/i,past:/^last|past|prev(ious)?/i,add:/^(\+|after|from)/i,subtract:/^(\-|before|ago)/i,yesterday:/^yesterday/i,today:/^t(oday)?/i,tomorrow:/^tomorrow/i,now:/^n(ow)?/i,millisecond:/^ms|milli(second)?s?/i,second:/^sec(ond)?s?/i,minute:/^min(ute)?s?/i,hour:/^h(ou)?rs?/i,week:/^w(ee)?k/i,month:/^m(o(nth)?s?)?/i,day:/^d(ays?)?/i,year:/^y((ea)?rs?)?/i,shortMeridian:/^(a|p)/i,longMeridian:/^(a\.?m?\.?|p\.?m?\.?)/i,timezone:/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\s*(\+|\-)\s*\d\d\d\d?)|gmt)/i,ordinalSuffix:/^\s*(st|nd|rd|th)/i,timeContext:/^\s*(\:|a|p)/i},abbreviatedTimeZoneStandard:{GMT:"-000",EST:"-0400",CST:"-0500",MST:"-0600",PST:"-0700"},abbreviatedTimeZoneDST:{GMT:"-000",EDT:"-0500",CDT:"-0600",MDT:"-0700",PDT:"-0800"}}; 9 | Date.getMonthNumberFromName=function(name){var n=Date.CultureInfo.monthNames,m=Date.CultureInfo.abbreviatedMonthNames,s=name.toLowerCase();for(var i=0;idate)?1:(this=start.getTime()&&t<=end.getTime();};Date.prototype.addMilliseconds=function(value){this.setMilliseconds(this.getMilliseconds()+value);return this;};Date.prototype.addSeconds=function(value){return this.addMilliseconds(value*1000);};Date.prototype.addMinutes=function(value){return this.addMilliseconds(value*60000);};Date.prototype.addHours=function(value){return this.addMilliseconds(value*3600000);};Date.prototype.addDays=function(value){return this.addMilliseconds(value*86400000);};Date.prototype.addWeeks=function(value){return this.addMilliseconds(value*604800000);};Date.prototype.addMonths=function(value){var n=this.getDate();this.setDate(1);this.setMonth(this.getMonth()+value);this.setDate(Math.min(n,this.getDaysInMonth()));return this;};Date.prototype.addYears=function(value){return this.addMonths(value*12);};Date.prototype.add=function(config){if(typeof config=="number"){this._orient=config;return this;} 14 | var x=config;if(x.millisecond||x.milliseconds){this.addMilliseconds(x.millisecond||x.milliseconds);} 15 | if(x.second||x.seconds){this.addSeconds(x.second||x.seconds);} 16 | if(x.minute||x.minutes){this.addMinutes(x.minute||x.minutes);} 17 | if(x.hour||x.hours){this.addHours(x.hour||x.hours);} 18 | if(x.month||x.months){this.addMonths(x.month||x.months);} 19 | if(x.year||x.years){this.addYears(x.year||x.years);} 20 | if(x.day||x.days){this.addDays(x.day||x.days);} 21 | return this;};Date._validate=function(value,min,max,name){if(typeof value!="number"){throw new TypeError(value+" is not a Number.");}else if(valuemax){throw new RangeError(value+" is not a valid value for "+name+".");} 22 | return true;};Date.validateMillisecond=function(n){return Date._validate(n,0,999,"milliseconds");};Date.validateSecond=function(n){return Date._validate(n,0,59,"seconds");};Date.validateMinute=function(n){return Date._validate(n,0,59,"minutes");};Date.validateHour=function(n){return Date._validate(n,0,23,"hours");};Date.validateDay=function(n,year,month){return Date._validate(n,1,Date.getDaysInMonth(year,month),"days");};Date.validateMonth=function(n){return Date._validate(n,0,11,"months");};Date.validateYear=function(n){return Date._validate(n,1,9999,"seconds");};Date.prototype.set=function(config){var x=config;if(!x.millisecond&&x.millisecond!==0){x.millisecond=-1;} 23 | if(!x.second&&x.second!==0){x.second=-1;} 24 | if(!x.minute&&x.minute!==0){x.minute=-1;} 25 | if(!x.hour&&x.hour!==0){x.hour=-1;} 26 | if(!x.day&&x.day!==0){x.day=-1;} 27 | if(!x.month&&x.month!==0){x.month=-1;} 28 | if(!x.year&&x.year!==0){x.year=-1;} 29 | if(x.millisecond!=-1&&Date.validateMillisecond(x.millisecond)){this.addMilliseconds(x.millisecond-this.getMilliseconds());} 30 | if(x.second!=-1&&Date.validateSecond(x.second)){this.addSeconds(x.second-this.getSeconds());} 31 | if(x.minute!=-1&&Date.validateMinute(x.minute)){this.addMinutes(x.minute-this.getMinutes());} 32 | if(x.hour!=-1&&Date.validateHour(x.hour)){this.addHours(x.hour-this.getHours());} 33 | if(x.month!==-1&&Date.validateMonth(x.month)){this.addMonths(x.month-this.getMonth());} 34 | if(x.year!=-1&&Date.validateYear(x.year)){this.addYears(x.year-this.getFullYear());} 35 | if(x.day!=-1&&Date.validateDay(x.day,this.getFullYear(),this.getMonth())){this.addDays(x.day-this.getDate());} 36 | if(x.timezone){this.setTimezone(x.timezone);} 37 | if(x.timezoneOffset){this.setTimezoneOffset(x.timezoneOffset);} 38 | return this;};Date.prototype.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);return this;};Date.prototype.isLeapYear=function(){var y=this.getFullYear();return(((y%4===0)&&(y%100!==0))||(y%400===0));};Date.prototype.isWeekday=function(){return!(this.is().sat()||this.is().sun());};Date.prototype.getDaysInMonth=function(){return Date.getDaysInMonth(this.getFullYear(),this.getMonth());};Date.prototype.moveToFirstDayOfMonth=function(){return this.set({day:1});};Date.prototype.moveToLastDayOfMonth=function(){return this.set({day:this.getDaysInMonth()});};Date.prototype.moveToDayOfWeek=function(day,orient){var diff=(day-this.getDay()+7*(orient||+1))%7;return this.addDays((diff===0)?diff+=7*(orient||+1):diff);};Date.prototype.moveToMonth=function(month,orient){var diff=(month-this.getMonth()+12*(orient||+1))%12;return this.addMonths((diff===0)?diff+=12*(orient||+1):diff);};Date.prototype.getDayOfYear=function(){return Math.floor((this-new Date(this.getFullYear(),0,1))/86400000);};Date.prototype.getWeekOfYear=function(firstDayOfWeek){var y=this.getFullYear(),m=this.getMonth(),d=this.getDate();var dow=firstDayOfWeek||Date.CultureInfo.firstDayOfWeek;var offset=7+1-new Date(y,0,1).getDay();if(offset==8){offset=1;} 39 | var daynum=((Date.UTC(y,m,d,0,0,0)-Date.UTC(y,0,1,0,0,0))/86400000)+1;var w=Math.floor((daynum-offset+7)/7);if(w===dow){y--;var prevOffset=7+1-new Date(y,0,1).getDay();if(prevOffset==2||prevOffset==8){w=53;}else{w=52;}} 40 | return w;};Date.prototype.isDST=function(){return this.toString().match(/(E|C|M|P)(S|D)T/)[2]=="D";};Date.prototype.getTimezone=function(){return Date.getTimezoneAbbreviation(this.getUTCOffset,this.isDST());};Date.prototype.setTimezoneOffset=function(s){var here=this.getTimezoneOffset(),there=Number(s)*-6/10;this.addMinutes(there-here);return this;};Date.prototype.setTimezone=function(s){return this.setTimezoneOffset(Date.getTimezoneOffset(s));};Date.prototype.getUTCOffset=function(){var n=this.getTimezoneOffset()*-10/6,r;if(n<0){r=(n-10000).toString();return r[0]+r.substr(2);}else{r=(n+10000).toString();return"+"+r.substr(1);}};Date.prototype.getDayName=function(abbrev){return abbrev?Date.CultureInfo.abbreviatedDayNames[this.getDay()]:Date.CultureInfo.dayNames[this.getDay()];};Date.prototype.getMonthName=function(abbrev){return abbrev?Date.CultureInfo.abbreviatedMonthNames[this.getMonth()]:Date.CultureInfo.monthNames[this.getMonth()];};Date.prototype._toString=Date.prototype.toString;Date.prototype.toString=function(format){var self=this;var p=function p(s){return(s.toString().length==1)?"0"+s:s;};return format?format.replace(/dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?/g,function(format){switch(format){case"hh":return p(self.getHours()<13?self.getHours():(self.getHours()-12));case"h":return self.getHours()<13?self.getHours():(self.getHours()-12);case"HH":return p(self.getHours());case"H":return self.getHours();case"mm":return p(self.getMinutes());case"m":return self.getMinutes();case"ss":return p(self.getSeconds());case"s":return self.getSeconds();case"yyyy":return self.getFullYear();case"yy":return self.getFullYear().toString().substring(2,4);case"dddd":return self.getDayName();case"ddd":return self.getDayName(true);case"dd":return p(self.getDate());case"d":return self.getDate().toString();case"MMMM":return self.getMonthName();case"MMM":return self.getMonthName(true);case"MM":return p((self.getMonth()+1));case"M":return self.getMonth()+1;case"t":return self.getHours()<12?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case"tt":return self.getHours()<12?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case"zzz":case"zz":case"z":return"";}}):this._toString();}; 41 | Date.now=function(){return new Date();};Date.today=function(){return Date.now().clearTime();};Date.prototype._orient=+1;Date.prototype.next=function(){this._orient=+1;return this;};Date.prototype.last=Date.prototype.prev=Date.prototype.previous=function(){this._orient=-1;return this;};Date.prototype._is=false;Date.prototype.is=function(){this._is=true;return this;};Number.prototype._dateElement="day";Number.prototype.fromNow=function(){var c={};c[this._dateElement]=this;return Date.now().add(c);};Number.prototype.ago=function(){var c={};c[this._dateElement]=this*-1;return Date.now().add(c);};(function(){var $D=Date.prototype,$N=Number.prototype;var dx=("sunday monday tuesday wednesday thursday friday saturday").split(/\s/),mx=("january february march april may june july august september october november december").split(/\s/),px=("Millisecond Second Minute Hour Day Week Month Year").split(/\s/),de;var df=function(n){return function(){if(this._is){this._is=false;return this.getDay()==n;} 42 | return this.moveToDayOfWeek(n,this._orient);};};for(var i=0;i0&&!last){try{q=d.call(this,r[1]);}catch(ex){last=true;}}else{last=true;} 70 | if(!last&&q[1].length===0){last=true;} 71 | if(!last){var qx=[];for(var j=0;j0){rx[0]=rx[0].concat(p[0]);rx[1]=p[1];}} 73 | if(rx[1].length1){args=Array.prototype.slice.call(arguments);}else if(arguments[0]instanceof Array){args=arguments[0];} 80 | if(args){for(var i=0,px=args.shift();i2)?n:(n+(((n+2000)Date.getDaysInMonth(this.year,this.month)){throw new RangeError(this.day+" is not a valid value for days.");} 84 | var r=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second);if(this.timezone){r.set({timezone:this.timezone});}else if(this.timezoneOffset){r.set({timezoneOffset:this.timezoneOffset});} 85 | return r;},finish:function(x){x=(x instanceof Array)?flattenAndCompact(x):[x];if(x.length===0){return null;} 86 | for(var i=0;i t2) ? 1 : 0; 187 | }; 188 | 189 | this.equals = function (time) { 190 | return (this.compareTo(time) === 0); 191 | }; 192 | 193 | this.add = function (time) { 194 | return (time === null) ? this : this.addSeconds(time.getTotalMilliseconds() / 1000); 195 | }; 196 | 197 | this.subtract = function (time) { 198 | return (time === null) ? this : this.addSeconds(-time.getTotalMilliseconds() / 1000); 199 | }; 200 | 201 | this.addDays = function (n) { 202 | return new TimeSpan(this.getTotalMilliseconds() + (n * 86400000)); 203 | }; 204 | 205 | this.addHours = function (n) { 206 | return new TimeSpan(this.getTotalMilliseconds() + (n * 3600000)); 207 | }; 208 | 209 | this.addMinutes = function (n) { 210 | return new TimeSpan(this.getTotalMilliseconds() + (n * 60000)); 211 | }; 212 | 213 | this.addSeconds = function (n) { 214 | return new TimeSpan(this.getTotalMilliseconds() + (n * 1000)); 215 | }; 216 | 217 | this.addMilliseconds = function (n) { 218 | return new TimeSpan(this.getTotalMilliseconds() + n); 219 | }; 220 | 221 | this.get12HourHour = function () { 222 | return (this.getHours() > 12) ? this.getHours() - 12 : (this.getHours() === 0) ? 12 : this.getHours(); 223 | }; 224 | 225 | this.getDesignator = function () { 226 | return (this.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; 227 | }; 228 | 229 | this.toString = function (format) { 230 | this._toString = function () { 231 | if (this.getDays() !== null && this.getDays() > 0) { 232 | return this.getDays() + "." + this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); 233 | } 234 | else { 235 | return this.getHours() + ":" + this.p(this.getMinutes()) + ":" + this.p(this.getSeconds()); 236 | } 237 | }; 238 | 239 | this.p = function (s) { 240 | return (s.toString().length < 2) ? "0" + s : s; 241 | }; 242 | 243 | var me = this; 244 | 245 | return format ? format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, 246 | function (format) { 247 | switch (format) { 248 | case "d": 249 | return me.getDays(); 250 | case "dd": 251 | return me.p(me.getDays()); 252 | case "H": 253 | return me.getHours(); 254 | case "HH": 255 | return me.p(me.getHours()); 256 | case "h": 257 | return me.get12HourHour(); 258 | case "hh": 259 | return me.p(me.get12HourHour()); 260 | case "m": 261 | return me.getMinutes(); 262 | case "mm": 263 | return me.p(me.getMinutes()); 264 | case "s": 265 | return me.getSeconds(); 266 | case "ss": 267 | return me.p(me.getSeconds()); 268 | case "t": 269 | return ((me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator).substring(0, 1); 270 | case "tt": 271 | return (me.getHours() < 12) ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; 272 | } 273 | } 274 | ) : this._toString(); 275 | }; 276 | return this; 277 | }; 278 | 279 | /** 280 | * Gets the time of day for this date instances. 281 | * @return {TimeSpan} TimeSpan 282 | */ 283 | Date.prototype.getTimeOfDay = function () { 284 | return new TimeSpan(0, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds()); 285 | }; 286 | 287 | /* 288 | * TimePeriod(startDate, endDate); 289 | * TimePeriod(years, months, days, hours, minutes, seconds, milliseconds); 290 | */ 291 | var TimePeriod = function (years, months, days, hours, minutes, seconds, milliseconds) { 292 | var attrs = "years months days hours minutes seconds milliseconds".split(/\s+/); 293 | 294 | var gFn = function (attr) { 295 | return function () { 296 | return this[attr]; 297 | }; 298 | }; 299 | 300 | var sFn = function (attr) { 301 | return function (val) { 302 | this[attr] = val; 303 | return this; 304 | }; 305 | }; 306 | 307 | for (var i = 0; i < attrs.length ; i++) { 308 | var $a = attrs[i], $b = $a.slice(0, 1).toUpperCase() + $a.slice(1); 309 | TimePeriod.prototype[$a] = 0; 310 | TimePeriod.prototype["get" + $b] = gFn($a); 311 | TimePeriod.prototype["set" + $b] = sFn($a); 312 | } 313 | 314 | if (arguments.length == 7) { 315 | this.years = years; 316 | this.months = months; 317 | this.setDays(days); 318 | this.setHours(hours); 319 | this.setMinutes(minutes); 320 | this.setSeconds(seconds); 321 | this.setMilliseconds(milliseconds); 322 | } else if (arguments.length == 2 && arguments[0] instanceof Date && arguments[1] instanceof Date) { 323 | // startDate and endDate as arguments 324 | 325 | var d1 = years.clone(); 326 | var d2 = months.clone(); 327 | 328 | var temp = d1.clone(); 329 | var orient = (d1 > d2) ? -1 : +1; 330 | 331 | this.years = d2.getFullYear() - d1.getFullYear(); 332 | temp.addYears(this.years); 333 | 334 | if (orient == +1) { 335 | if (temp > d2) { 336 | if (this.years !== 0) { 337 | this.years--; 338 | } 339 | } 340 | } else { 341 | if (temp < d2) { 342 | if (this.years !== 0) { 343 | this.years++; 344 | } 345 | } 346 | } 347 | 348 | d1.addYears(this.years); 349 | 350 | if (orient == +1) { 351 | while (d1 < d2 && d1.clone().addDays(Date.getDaysInMonth(d1.getYear(), d1.getMonth()) ) < d2) { 352 | d1.addMonths(1); 353 | this.months++; 354 | } 355 | } 356 | else { 357 | while (d1 > d2 && d1.clone().addDays(-d1.getDaysInMonth()) > d2) { 358 | d1.addMonths(-1); 359 | this.months--; 360 | } 361 | } 362 | 363 | var diff = d2 - d1; 364 | 365 | if (diff !== 0) { 366 | var ts = new TimeSpan(diff); 367 | this.setDays(ts.getDays()); 368 | this.setHours(ts.getHours()); 369 | this.setMinutes(ts.getMinutes()); 370 | this.setSeconds(ts.getSeconds()); 371 | this.setMilliseconds(ts.getMilliseconds()); 372 | } 373 | } 374 | return this; 375 | }; -------------------------------------------------------------------------------- /js/daterangepicker.jQuery.compressed.js: -------------------------------------------------------------------------------- 1 | (function(a){a.fn.daterangepicker=function(s){var d=a(this);var e=a.extend({presetRanges:[{text:"Today",dateStart:"today",dateEnd:"today"},{text:"Last 7 days",dateStart:"today-7days",dateEnd:"today"},{text:"Month to date",dateStart:function(){return Date.parse("today").moveToFirstDayOfMonth()},dateEnd:"today"},{text:"Year to date",dateStart:function(){var w=Date.parse("today");w.setMonth(0);w.setDate(1);return w},dateEnd:"today"},{text:"The previous Month",dateStart:function(){return Date.parse("1 month ago").moveToFirstDayOfMonth()},dateEnd:function(){return Date.parse("1 month ago").moveToLastDayOfMonth()}}],presets:{specificDate:"Specific Date",allDatesBefore:"All Dates Before",allDatesAfter:"All Dates After",dateRange:"Date Range"},rangeStartTitle:"Start date",rangeEndTitle:"End date",nextLinkText:"Next",prevLinkText:"Prev",target:d,doneButtonText:"Done",earliestDate:Date.parse("-15years"),latestDate:Date.parse("+15years"),constrainDates:false,rangeSplitter:"-",dateFormat:"m/d/yy",closeOnSelect:true,arrows:false,appendTo:"body",onClose:function(){},onOpen:function(){},onChange:function(){},datepickerOptions:null},s);var g={onSelect:function(A,z){var y=j.find(".range-start");var B=j.find(".range-end");if(j.find(".ui-daterangepicker-specificDate").is(".ui-state-active")){B.datepicker("setDate",y.datepicker("getDate"))}a(this).trigger("constrainOtherPicker");var x=b(y.datepicker("getDate"));var w=b(B.datepicker("getDate"));if(d.length==2){d.eq(0).val(x);d.eq(1).val(w)}else{d.val((x!=w)?x+" "+e.rangeSplitter+" "+w:x)}if(e.closeOnSelect){if(!j.find("li.ui-state-active").is(".ui-daterangepicker-dateRange")&&!j.is(":animated")){k()}a(this).trigger("constrainOtherPicker");e.onChange()}},defaultDate:+0};d.bind("change",e.onChange);e.datepickerOptions=(s)?a.extend(g,s.datepickerOptions):g;var m,l=Date.parse("today");var o,i;if(d.size()==2){o=Date.parse(d.eq(0).val());i=Date.parse(d.eq(1).val());if(o==null){o=i}if(i==null){i=o}}else{o=Date.parse(d.val().split(e.rangeSplitter)[0]);i=Date.parse(d.val().split(e.rangeSplitter)[1]);if(i==null){i=o}}if(o!=null){m=o}if(i!=null){l=i}var j=a('
');var u=(function(){var y=a('
    ').appendTo(j);a.each(e.presetRanges,function(){a('
  • '+this.text+"
  • ").data("dateStart",this.dateStart).data("dateEnd",this.dateEnd).appendTo(y)});var w=0;a.each(e.presets,function(x,z){a('
  • '+z+"
  • ").appendTo(y);w++});y.find("li").hover(function(){a(this).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover")}).click(function(){j.find(".ui-state-active").removeClass("ui-state-active");a(this).addClass("ui-state-active");q(a(this),j,n,f);return false});return y})();function b(y){if(!y.getDate()){return""}var x=y.getDate();var A=y.getMonth();var z=y.getFullYear();A++;var w=e.dateFormat;return a.datepicker.formatDate(w,y)}a.fn.restoreDateFromData=function(){if(a(this).data("saveDate")){a(this).datepicker("setDate",a(this).data("saveDate")).removeData("saveDate")}return this};a.fn.saveDateToData=function(){if(!a(this).data("saveDate")){a(this).data("saveDate",a(this).datepicker("getDate"))}return this};function t(){if(j.data("state")=="closed"){v();j.fadeIn(300).data("state","open");e.onOpen()}}function k(){if(j.data("state")=="open"){j.fadeOut(300).data("state","closed");e.onClose()}}function c(){if(j.data("state")=="open"){k()}else{t()}}function v(){var w=p||d;var A=w.offset(),y="left",z=A.left,x=a(window).width()-z-w.outerWidth();if(z>x){y="right",z=x}j.parent().css(y,z).css("top",A.top+w.outerHeight())}function q(z,y,A,w){if(z.is(".ui-daterangepicker-specificDate")){w.hide();A.show();y.find(".title-start").text(e.presets.specificDate);y.find(".range-start").restoreDateFromData().css("opacity",1).show(400);y.find(".range-end").restoreDateFromData().css("opacity",0).hide(400);setTimeout(function(){w.fadeIn()},400)}else{if(z.is(".ui-daterangepicker-allDatesBefore")){w.hide();A.show();y.find(".title-end").text(e.presets.allDatesBefore);y.find(".range-start").saveDateToData().datepicker("setDate",e.earliestDate).css("opacity",0).hide(400);y.find(".range-end").restoreDateFromData().css("opacity",1).show(400);setTimeout(function(){w.fadeIn()},400)}else{if(z.is(".ui-daterangepicker-allDatesAfter")){w.hide();A.show();y.find(".title-start").text(e.presets.allDatesAfter);y.find(".range-start").restoreDateFromData().css("opacity",1).show(400);y.find(".range-end").saveDateToData().datepicker("setDate",e.latestDate).css("opacity",0).hide(400);setTimeout(function(){w.fadeIn()},400)}else{if(z.is(".ui-daterangepicker-dateRange")){w.hide();A.show();y.find(".title-start").text(e.rangeStartTitle);y.find(".title-end").text(e.rangeEndTitle);y.find(".range-start").restoreDateFromData().css("opacity",1).show(400);y.find(".range-end").restoreDateFromData().css("opacity",1).show(400);setTimeout(function(){w.fadeIn()},400)}else{w.hide();y.find(".range-start, .range-end").css("opacity",0).hide(400,function(){A.hide()});var B=(typeof z.data("dateStart")=="string")?Date.parse(z.data("dateStart")):z.data("dateStart")();var x=(typeof z.data("dateEnd")=="string")?Date.parse(z.data("dateEnd")):z.data("dateEnd")();y.find(".range-start").datepicker("setDate",B).find(".ui-datepicker-current-day").trigger("click");y.find(".range-end").datepicker("setDate",x).find(".ui-datepicker-current-day").trigger("click")}}}}return false}var n=a('
    Start Date
    End Date
    ').appendTo(j);n.find(".range-start, .range-end").datepicker(e.datepickerOptions);n.find(".range-start").datepicker("setDate",m);n.find(".range-end").datepicker("setDate",l);n.find(".range-start, .range-end").bind("constrainOtherPicker",function(){if(e.constrainDates){if(a(this).is(".range-start")){j.find(".range-end").datepicker("option","minDate",a(this).datepicker("getDate"))}else{j.find(".range-start").datepicker("option","maxDate",a(this).datepicker("getDate"))}}}).trigger("constrainOtherPicker");var f=a('").click(function(){j.find(".ui-datepicker-current-day").trigger("click");k()}).hover(function(){a(this).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover")}).appendTo(n);a(this).click(function(){c();return false});n.hide().find(".range-start, .range-end, .btnDone").hide();j.data("state","closed");n.find(".ui-datepicker").css("display","block");a(e.appendTo).append(j);j.wrap('
    ');if(e.arrows&&d.size()==1){var h=a(''+e.prevLinkText+"");var r=a(''+e.nextLinkText+"");a(this).addClass("ui-rangepicker-input ui-widget-content").wrap('
    ').before(h).before(r).parent().find("a").click(function(){var x=n.find(".range-start").datepicker("getDate");var w=n.find(".range-end").datepicker("getDate");var y=Math.abs(new TimeSpan(x-w).getTotalMilliseconds())+86400000;if(a(this).is(".ui-daterangepicker-prev")){y=-y}n.find(".range-start, .range-end ").each(function(){var z=a(this).datepicker("getDate");if(z==null){return false}a(this).datepicker("setDate",z.add({milliseconds:y})).find(".ui-datepicker-current-day").trigger("click")});return false}).hover(function(){a(this).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover")});var p=d.parent()}a(document).click(function(){if(j.is(":visible")){k()}});j.click(function(){return false}).hide();return this}})(jQuery); -------------------------------------------------------------------------------- /js/daterangepicker.jQuery.js: -------------------------------------------------------------------------------- 1 | (function ($) { 2 | 3 | /** 4 | * -------------------------------------------------------------------- 5 | * jQuery-Plugin "daterangepicker.jQuery.js" 6 | * by Scott Jehl, scott@filamentgroup.com 7 | * reference article: http://www.filamentgroup.com/lab/update_date_range_picker_with_jquery_ui/ 8 | * demo page: http://www.filamentgroup.com/examples/daterangepicker/ 9 | * 10 | * Copyright (c) 2010 Filament Group, Inc 11 | * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses. 12 | * 13 | * Dependencies: jquery, jquery UI datepicker, date.js, jQuery UI CSS Framework 14 | 15 | * 12.15.2010 Made some fixes to resolve breaking changes introduced by jQuery UI 1.8.7 16 | * -------------------------------------------------------------------- 17 | */ 18 | $.fn.daterangepicker = function(settings){ 19 | var rangeInput = $(this); 20 | 21 | //defaults 22 | var options = $.extend({ 23 | presetRanges: [ 24 | {text: 'Today', dateStart: 'today', dateEnd: 'today' }, 25 | {text: 'Last 7 days', dateStart: 'today-7days', dateEnd: 'today' }, 26 | {text: 'Month to date', dateStart: function(){ return Date.parse('today').moveToFirstDayOfMonth(); }, dateEnd: 'today' }, 27 | {text: 'Year to date', dateStart: function(){ var x= Date.parse('today'); x.setMonth(0); x.setDate(1); return x; }, dateEnd: 'today' }, 28 | //extras: 29 | {text: 'The previous Month', dateStart: function(){ return Date.parse('1 month ago').moveToFirstDayOfMonth(); }, dateEnd: function(){ return Date.parse('1 month ago').moveToLastDayOfMonth(); } } 30 | //{text: 'Tomorrow', dateStart: 'Tomorrow', dateEnd: 'Tomorrow' }, 31 | //{text: 'Ad Campaign', dateStart: '03/07/08', dateEnd: 'Today' }, 32 | //{text: 'Last 30 Days', dateStart: 'Today-30', dateEnd: 'Today' }, 33 | //{text: 'Next 30 Days', dateStart: 'Today', dateEnd: 'Today+30' }, 34 | //{text: 'Our Ad Campaign', dateStart: '03/07/08', dateEnd: '07/08/08' } 35 | ], 36 | //presetRanges: array of objects for each menu preset. 37 | //Each obj must have text, dateStart, dateEnd. dateStart, dateEnd accept date.js string or a function which returns a date object 38 | presets: { 39 | specificDate: 'Specific Date', 40 | allDatesBefore: 'All Dates Before', 41 | allDatesAfter: 'All Dates After', 42 | dateRange: 'Date Range' 43 | }, 44 | rangeStartTitle: 'Start date', 45 | rangeEndTitle: 'End date', 46 | nextLinkText: 'Next', 47 | prevLinkText: 'Prev', 48 | target: rangeInput, 49 | doneButtonText: 'Done', 50 | earliestDate: Date.parse('-15years'), //earliest date allowed 51 | latestDate: Date.parse('+15years'), //latest date allowed 52 | constrainDates: false, 53 | rangeSplitter: '-', //string to use between dates in single input 54 | dateFormat: 'm/d/yy', // date formatting. Available formats: http://docs.jquery.com/UI/Datepicker/%24.datepicker.formatDate 55 | closeOnSelect: true, //if a complete selection is made, close the menu 56 | arrows: false, 57 | appendTo: 'body', 58 | onClose: function(){}, 59 | onOpen: function(){}, 60 | onChange: function(){}, 61 | datepickerOptions: null //object containing native UI datepicker API options 62 | }, settings); 63 | 64 | 65 | 66 | //custom datepicker options, extended by options 67 | var datepickerOptions = { 68 | onSelect: function(dateText, inst) { 69 | var range_start = rp.find('.range-start'); 70 | var range_end = rp.find('.range-end'); 71 | 72 | if(rp.find('.ui-daterangepicker-specificDate').is('.ui-state-active')){ 73 | range_end.datepicker('setDate', range_start.datepicker('getDate') ); 74 | } 75 | 76 | $(this).trigger('constrainOtherPicker'); 77 | 78 | var rangeA = fDate( range_start.datepicker('getDate') ); 79 | var rangeB = fDate( range_end.datepicker('getDate') ); 80 | 81 | //send back to input or inputs 82 | if(rangeInput.length == 2){ 83 | rangeInput.eq(0).val(rangeA); 84 | rangeInput.eq(1).val(rangeB); 85 | } 86 | else{ 87 | rangeInput.val((rangeA != rangeB) ? rangeA+' '+ options.rangeSplitter +' '+rangeB : rangeA); 88 | } 89 | //if closeOnSelect is true 90 | if(options.closeOnSelect){ 91 | if(!rp.find('li.ui-state-active').is('.ui-daterangepicker-dateRange') && !rp.is(':animated') ){ 92 | hideRP(); 93 | } 94 | 95 | $(this).trigger('constrainOtherPicker'); 96 | 97 | options.onChange(); 98 | } 99 | }, 100 | defaultDate: +0 101 | }; 102 | 103 | //change event fires both when a calendar is updated or a change event on the input is triggered 104 | rangeInput.bind('change', options.onChange); 105 | 106 | //datepicker options from options 107 | options.datepickerOptions = (settings) ? $.extend(datepickerOptions, settings.datepickerOptions) : datepickerOptions; 108 | 109 | //Capture Dates from input(s) 110 | var inputDateA, inputDateB = Date.parse('today'); 111 | var inputDateAtemp, inputDateBtemp; 112 | if(rangeInput.size() == 2){ 113 | inputDateAtemp = Date.parse( rangeInput.eq(0).val() ); 114 | inputDateBtemp = Date.parse( rangeInput.eq(1).val() ); 115 | if(inputDateAtemp == null){inputDateAtemp = inputDateBtemp;} 116 | if(inputDateBtemp == null){inputDateBtemp = inputDateAtemp;} 117 | } 118 | else { 119 | inputDateAtemp = Date.parse( rangeInput.val().split(options.rangeSplitter)[0] ); 120 | inputDateBtemp = Date.parse( rangeInput.val().split(options.rangeSplitter)[1] ); 121 | if(inputDateBtemp == null){inputDateBtemp = inputDateAtemp;} //if one date, set both 122 | } 123 | if(inputDateAtemp != null){inputDateA = inputDateAtemp;} 124 | if(inputDateBtemp != null){inputDateB = inputDateBtemp;} 125 | 126 | 127 | //build picker and 128 | var rp = $('
    '); 129 | var rpPresets = (function(){ 130 | var ul = $('
      ').appendTo(rp); 131 | $.each(options.presetRanges,function(){ 132 | $('
    • '+ this.text +'
    • ') 133 | .data('dateStart', this.dateStart) 134 | .data('dateEnd', this.dateEnd) 135 | .appendTo(ul); 136 | }); 137 | var x=0; 138 | $.each(options.presets, function(key, value) { 139 | $('
    • '+ value +'
    • ') 140 | .appendTo(ul); 141 | x++; 142 | }); 143 | 144 | ul.find('li').hover( 145 | function(){ 146 | $(this).addClass('ui-state-hover'); 147 | }, 148 | function(){ 149 | $(this).removeClass('ui-state-hover'); 150 | }) 151 | .click(function(){ 152 | rp.find('.ui-state-active').removeClass('ui-state-active'); 153 | $(this).addClass('ui-state-active'); 154 | clickActions($(this),rp, rpPickers, doneBtn); 155 | return false; 156 | }); 157 | return ul; 158 | })(); 159 | 160 | //function to format a date string 161 | function fDate(date){ 162 | if(!date.getDate()){return '';} 163 | var day = date.getDate(); 164 | var month = date.getMonth(); 165 | var year = date.getFullYear(); 166 | month++; // adjust javascript month 167 | var dateFormat = options.dateFormat; 168 | return $.datepicker.formatDate( dateFormat, date ); 169 | } 170 | 171 | 172 | $.fn.restoreDateFromData = function(){ 173 | if($(this).data('saveDate')){ 174 | $(this).datepicker('setDate', $(this).data('saveDate')).removeData('saveDate'); 175 | } 176 | return this; 177 | }; 178 | $.fn.saveDateToData = function(){ 179 | if(!$(this).data('saveDate')){ 180 | $(this).data('saveDate', $(this).datepicker('getDate') ); 181 | } 182 | return this; 183 | }; 184 | 185 | //show, hide, or toggle rangepicker 186 | function showRP(){ 187 | if(rp.data('state') == 'closed'){ 188 | positionRP(); 189 | rp.fadeIn(300).data('state', 'open'); 190 | options.onOpen(); 191 | } 192 | } 193 | function hideRP(){ 194 | if(rp.data('state') == 'open'){ 195 | rp.fadeOut(300).data('state', 'closed'); 196 | options.onClose(); 197 | } 198 | } 199 | function toggleRP(){ 200 | if( rp.data('state') == 'open' ){ hideRP(); } 201 | else { showRP(); } 202 | } 203 | function positionRP(){ 204 | var relEl = riContain || rangeInput; //if arrows, use parent for offsets 205 | var riOffset = relEl.offset(), 206 | side = 'left', 207 | val = riOffset.left, 208 | offRight = $(window).width() - val - relEl.outerWidth(); 209 | 210 | if(val > offRight){ 211 | side = 'right', val = offRight; 212 | } 213 | 214 | rp.parent().css(side, val).css('top', riOffset.top + relEl.outerHeight()); 215 | } 216 | 217 | 218 | 219 | //preset menu click events 220 | function clickActions(el, rp, rpPickers, doneBtn){ 221 | 222 | if(el.is('.ui-daterangepicker-specificDate')){ 223 | //Specific Date (show the "start" calendar) 224 | doneBtn.hide(); 225 | rpPickers.show(); 226 | rp.find('.title-start').text( options.presets.specificDate ); 227 | rp.find('.range-start').restoreDateFromData().css('opacity',1).show(400); 228 | rp.find('.range-end').restoreDateFromData().css('opacity',0).hide(400); 229 | setTimeout(function(){doneBtn.fadeIn();}, 400); 230 | } 231 | else if(el.is('.ui-daterangepicker-allDatesBefore')){ 232 | //All dates before specific date (show the "end" calendar and set the "start" calendar to the earliest date) 233 | doneBtn.hide(); 234 | rpPickers.show(); 235 | rp.find('.title-end').text( options.presets.allDatesBefore ); 236 | rp.find('.range-start').saveDateToData().datepicker('setDate', options.earliestDate).css('opacity',0).hide(400); 237 | rp.find('.range-end').restoreDateFromData().css('opacity',1).show(400); 238 | setTimeout(function(){doneBtn.fadeIn();}, 400); 239 | } 240 | else if(el.is('.ui-daterangepicker-allDatesAfter')){ 241 | //All dates after specific date (show the "start" calendar and set the "end" calendar to the latest date) 242 | doneBtn.hide(); 243 | rpPickers.show(); 244 | rp.find('.title-start').text( options.presets.allDatesAfter ); 245 | rp.find('.range-start').restoreDateFromData().css('opacity',1).show(400); 246 | rp.find('.range-end').saveDateToData().datepicker('setDate', options.latestDate).css('opacity',0).hide(400); 247 | setTimeout(function(){doneBtn.fadeIn();}, 400); 248 | } 249 | else if(el.is('.ui-daterangepicker-dateRange')){ 250 | //Specific Date range (show both calendars) 251 | doneBtn.hide(); 252 | rpPickers.show(); 253 | rp.find('.title-start').text(options.rangeStartTitle); 254 | rp.find('.title-end').text(options.rangeEndTitle); 255 | rp.find('.range-start').restoreDateFromData().css('opacity',1).show(400); 256 | rp.find('.range-end').restoreDateFromData().css('opacity',1).show(400); 257 | setTimeout(function(){doneBtn.fadeIn();}, 400); 258 | } 259 | else { 260 | //custom date range specified in the options (no calendars shown) 261 | doneBtn.hide(); 262 | rp.find('.range-start, .range-end').css('opacity',0).hide(400, function(){ 263 | rpPickers.hide(); 264 | }); 265 | var dateStart = (typeof el.data('dateStart') == 'string') ? Date.parse(el.data('dateStart')) : el.data('dateStart')(); 266 | var dateEnd = (typeof el.data('dateEnd') == 'string') ? Date.parse(el.data('dateEnd')) : el.data('dateEnd')(); 267 | rp.find('.range-start').datepicker('setDate', dateStart).find('.ui-datepicker-current-day').trigger('click'); 268 | rp.find('.range-end').datepicker('setDate', dateEnd).find('.ui-datepicker-current-day').trigger('click'); 269 | } 270 | 271 | return false; 272 | } 273 | 274 | 275 | //picker divs 276 | var rpPickers = $('
      Start Date
      End Date
      ').appendTo(rp); 277 | rpPickers.find('.range-start, .range-end') 278 | .datepicker(options.datepickerOptions); 279 | 280 | 281 | rpPickers.find('.range-start').datepicker('setDate', inputDateA); 282 | rpPickers.find('.range-end').datepicker('setDate', inputDateB); 283 | 284 | rpPickers.find('.range-start, .range-end') 285 | .bind('constrainOtherPicker', function(){ 286 | if(options.constrainDates){ 287 | //constrain dates 288 | if($(this).is('.range-start')){ 289 | rp.find('.range-end').datepicker( "option", "minDate", $(this).datepicker('getDate')); 290 | } 291 | else{ 292 | rp.find('.range-start').datepicker( "option", "maxDate", $(this).datepicker('getDate')); 293 | } 294 | } 295 | }) 296 | .trigger('constrainOtherPicker'); 297 | 298 | var doneBtn = $('') 299 | .click(function(){ 300 | rp.find('.ui-datepicker-current-day').trigger('click'); 301 | hideRP(); 302 | }) 303 | .hover( 304 | function(){ 305 | $(this).addClass('ui-state-hover'); 306 | }, 307 | function(){ 308 | $(this).removeClass('ui-state-hover'); 309 | } 310 | ) 311 | .appendTo(rpPickers); 312 | 313 | 314 | 315 | 316 | //inputs toggle rangepicker visibility 317 | $(this).click(function(){ 318 | toggleRP(); 319 | return false; 320 | }); 321 | //hide em all 322 | rpPickers.hide().find('.range-start, .range-end, .btnDone').hide(); 323 | 324 | rp.data('state', 'closed'); 325 | 326 | //Fixed for jQuery UI 1.8.7 - Calendars are hidden otherwise! 327 | rpPickers.find('.ui-datepicker').css("display","block"); 328 | 329 | //inject rp 330 | $(options.appendTo).append(rp); 331 | 332 | //wrap and position 333 | rp.wrap('
      '); 334 | 335 | //add arrows (only available on one input) 336 | if(options.arrows && rangeInput.size()==1){ 337 | var prevLink = $(''+ options.prevLinkText +''); 338 | var nextLink = $(''+ options.nextLinkText +''); 339 | 340 | $(this) 341 | .addClass('ui-rangepicker-input ui-widget-content') 342 | .wrap('
      ') 343 | .before( prevLink ) 344 | .before( nextLink ) 345 | .parent().find('a').click(function(){ 346 | var dateA = rpPickers.find('.range-start').datepicker('getDate'); 347 | var dateB = rpPickers.find('.range-end').datepicker('getDate'); 348 | var diff = Math.abs( new TimeSpan(dateA - dateB).getTotalMilliseconds() ) + 86400000; //difference plus one day 349 | if($(this).is('.ui-daterangepicker-prev')){ diff = -diff; } 350 | 351 | rpPickers.find('.range-start, .range-end ').each(function(){ 352 | var thisDate = $(this).datepicker( "getDate"); 353 | if(thisDate == null){return false;} 354 | $(this).datepicker( "setDate", thisDate.add({milliseconds: diff}) ).find('.ui-datepicker-current-day').trigger('click'); 355 | }); 356 | return false; 357 | }) 358 | .hover( 359 | function(){ 360 | $(this).addClass('ui-state-hover'); 361 | }, 362 | function(){ 363 | $(this).removeClass('ui-state-hover'); 364 | }); 365 | 366 | var riContain = rangeInput.parent(); 367 | } 368 | 369 | 370 | $(document).click(function(){ 371 | if (rp.is(':visible')) { 372 | hideRP(); 373 | } 374 | }); 375 | 376 | rp.click(function(){return false;}).hide(); 377 | return this; 378 | } 379 | 380 | })(jQuery); 381 | --------------------------------------------------------------------------------