Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updating gh-pages with the 0.5 release.

  • Loading branch information...
commit 71626fcbe55b8dad501f56f317584f10b57cd6de 1 parent 690b17a
@ChiperSoft authored
View
1,571 build/kalendae.js
@@ -1,1571 +0,0 @@
-/********************************************************************
- * Kalendae, a framework agnostic javascript date picker *
- * Copyright(c) 2012 Jarvis Badgley (chipersoft@gmail.com) *
- * http://github.com/ChiperSoft/Kalendae *
- * Version 0.2 *
- ********************************************************************/
-
-(function (undefined) {
-
-var today;
-
-var Kalendae = function (targetElement, options) {
- //if the first argument isn't an element and isn't a string, assume that it is the options object
- if (!(targetElement instanceof Element || typeof targetElement === 'string')) options = targetElement;
-
- var self = this,
- classes = self.classes,
- opts = self.settings = util.merge(self.defaults, {attachTo:targetElement}, options || {}),
- $container = self.container = util.make('div', {'class':classes.container}),
- calendars = self.calendars = [],
- startDay = moment().day(opts.weekStart),
- vsd,
- columnHeaders = [],
- $cal,
- $title,
- $caption,
- $header,
- $days, dayNodes = [],
- $span,
- i = 0,
- j = opts.months;
-
- if (util.isIE8()) util.addClassName($container, 'ie8');
-
- //generate the column headers (Su, Mo, Tu, etc)
- i = 7;
- while (i--) {
- columnHeaders.push( startDay.format('ddd').substr(0,opts.columnHeaderLength) );
- startDay.add('days',1);
- }
-
- //setup publish/subscribe and apply any subscriptions passed in settings
- MinPubSub(self);
- if (typeof opts.subscribe === 'object') {
- for (i in opts.subscribe) if (opts.subscribe.hasOwnProperty(i)) {
- self.subscribe(i, opts.subscribe[i]);
- }
- }
-
- //process default selected dates
- self._sel = [];
- if (!!opts.selected) self.setSelected(opts.selected, false);
-
- //set the view month
- if (!!opts.viewStartDate) {
- vsd = moment(opts.viewStartDate, opts.format);
- } else if (self._sel.length > 0) {
- vsd = moment(self._sel[0]);
- } else {
- vsd = moment();
- }
- self.viewStartDate = vsd.date(1);
-
- var viewDelta = ({
- 'past' : opts.months-1,
- 'today-past' : opts.months-1,
- 'any' : opts.months>2?Math.floor(opts.months/2):0,
- 'today-future' : 0,
- 'future' : 0
- })[this.settings.direction];
-
-
- if (viewDelta && moment().month()==moment(self.viewStartDate).month()){
- self.viewStartDate = moment(self.viewStartDate).subtract({M:viewDelta}).date(1);
- }
-
-
- if (typeof opts.blackout === 'function') {
- self.blackout = opts.blackout;
- } else if (!!opts.blackout) {
- var bdates = parseDates(opts.blackout, opts.parseSplitDelimiter);
- self.blackout = function (input) {
- input = moment(input).yearDay();
- if (input < 1 || !self._sel || self._sel.length < 1) return false;
- var i = bdates.length;
- while (i--) if (bdates[i].yearDay() === input) return true;
- return false;
- }
- } else {
- self.blackout = function () {return false;}
- }
-
-
- self.direction = self.directions[opts.direction] ? self.directions[opts.direction] : self.directions['any'];
-
-
- //for the total months setting, generate N calendar views and add them to the container
- j = Math.max(opts.months,1);
- while (j--) {
- $cal = util.make('div', {'class':classes.calendar}, $container);
-
- $cal.setAttribute('data-cal-index', j);
- if (opts.months > 1) {
- if (j == Math.max(opts.months-1,1)) util.addClassName($cal, classes.monthFirst);
- else if (j === 0) util.addClassName($cal, classes.monthLast);
- else util.addClassName($cal, classes.monthMiddle);
- }
-
- //title bar
- $title = util.make('div', {'class':classes.title}, $cal);
- util.make('a', {'class':classes.previousYear}, $title); //previous button
- util.make('a', {'class':classes.previousMonth}, $title); //previous button
- util.make('a', {'class':classes.nextYear}, $title); //next button
- util.make('a', {'class':classes.nextMonth}, $title); //next button
- $caption = util.make('span', {'class':classes.caption}, $title); //title caption
-
- //column headers
- $header = util.make('div', {'class':classes.header}, $cal);
- i = 0;
- do {
- $span = util.make('span', {}, $header);
- $span.innerHTML = columnHeaders[i];
- } while (++i < 7)
-
- //individual day cells
- $days = util.make('div', {'class':classes.days}, $cal);
- i = 0;
- dayNodes = [];
- while (i++ < 42) {
- dayNodes.push(util.make('span', {}, $days));
- }
-
- //store each calendar view for easy redrawing
- calendars.push({
- caption:$caption,
- days:dayNodes
- });
-
- if (j) util.make('div', {'class':classes.monthSeparator}, $container);
- }
-
- self.draw();
-
- util.addEvent($container, 'mousedown', function (event, target) {
- var clickedDate;
- if (util.hasClassName(target, classes.nextMonth)) {
- //NEXT MONTH BUTTON
- if (!self.disableNext && self.publish('view-changed', self, ['next-month']) !== false) {
- self.viewStartDate.add('months',1);
- self.draw();
- }
- return false;
-
- } else if (util.hasClassName(target, classes.previousMonth)) {
- //PREVIOUS MONTH BUTTON
- if (!self.disablePreviousMonth && self.publish('view-changed', self, ['previous-month']) !== false) {
- self.viewStartDate.subtract('months',1);
- self.draw();
- }
- return false;
-
- } else if (util.hasClassName(target, classes.nextYear)) {
- //NEXT MONTH BUTTON
- if (!self.disableNext && self.publish('view-changed', self, ['next-year']) !== false) {
- self.viewStartDate.add('years',1);
- self.draw();
- }
- return false;
-
- } else if (util.hasClassName(target, classes.previousYear)) {
- //PREVIOUS MONTH BUTTON
- if (!self.disablePreviousMonth && self.publish('view-changed', self, ['previous-year']) !== false) {
- self.viewStartDate.subtract('years',1);
- self.draw();
- }
- return false;
-
-
-
- } else if (util.hasClassName(target.parentNode, classes.days) && util.hasClassName(target, classes.dayActive) && (clickedDate = target.getAttribute('data-date'))) {
- //DAY CLICK
- clickedDate = moment(clickedDate, opts.dayAttributeFormat).hours(12);
- if (self.publish('date-clicked', self, [clickedDate]) !== false) {
-
- switch (opts.mode) {
- case 'multiple':
- if (!self.addSelected(clickedDate)) self.removeSelected(clickedDate);
- break;
- case 'range':
- self.addSelected(clickedDate);
- break;
- case 'single':
- /* falls through */
- default:
- self.addSelected(clickedDate);
- break;
- }
-
- }
- return false;
-
- }
- return false;
- });
-
-
- if (!!(opts.attachTo = util.$(opts.attachTo))) {
- opts.attachTo.appendChild($container);
- }
-
-};
-
-Kalendae.prototype = {
- defaults : {
- attachTo: null, /* the element to attach the root container to. can be string or DOMElement */
- months: 1, /* total number of months to display side by side */
- weekStart: 0, /* day to use for the start of the week. 0 is Sunday */
- direction: 'any', /* past, today-past, any, today-future, future */
- directionScrolling: true, /* if a direction other than any is defined, prevent scrolling out of range */
- viewStartDate: null, /* date in the month to display. When multiple months, this is the left most */
- blackout: null, /* array of dates, or function to be passed a date */
- selected: null, /* dates already selected. can be string, date, or array of strings or dates. */
- mode: 'single', /* single, multiple, range */
- format: null, /* string used for parsing dates. */
- subscribe: null, /* object containing events to subscribe to */
-
- columnHeaderLength: 2, /* number of characters to show in the column headers */
- titleFormat: 'MMMM, YYYY', /* format mask for month titles. See momentjs.com for rules */
- dayNumberFormat: 'D', /* format mask for individual days */
- dayAttributeFormat: 'YYYY-MM-DD', /* format mask for the data-date attribute set on every span */
- parseSplitDelimiter: /,\s*|\s+-\s+/, /* regex to use for splitting multiple dates from a passed string */
- rangeDelimiter: ' - ', /* string to use between dates when outputting in range mode */
- multipleDelimiter: ', ', /* string to use between dates when outputting in multiple mode */
-
- dateClassMap: {}
- },
- classes : {
- container :'kalendae',
- calendar :'k-calendar',
- monthFirst :'k-first-month',
- monthMiddle :'k-middle-month',
- monthLast :'k-last-month',
- title :'k-title',
- previousMonth :'k-btn-previous-month',
- nextMonth :'k-btn-next-month',
- previousYear :'k-btn-previous-year',
- nextYear :'k-btn-next-year',
- caption :'k-caption',
- header :'k-header',
- days :'k-days',
- dayOutOfMonth :'k-out-of-month',
- dayActive :'k-active',
- daySelected :'k-selected',
- dayInRange :'k-range',
- dayToday :'k-today',
- monthSeparator :'k-separator',
- disablePreviousMonth :'k-disable-previous-month-btn',
- disableNextMonth :'k-disable-next-month-btn',
- disablePreviousYear :'k-disable-previous-year-btn',
- disableNextYear :'k-disable-next-year-btn'
- },
-
- disablePreviousMonth: false,
- disableNextMonth: false,
- disablePreviousYear: false,
- disableNextYear: false,
-
- directions: {
- 'past' :function (date) {return moment(date).yearDay() >= today.yearDay();},
- 'today-past' :function (date) {return moment(date).yearDay() > today.yearDay();},
- 'any' :function (date) {return false;},
- 'today-future' :function (date) {return moment(date).yearDay() < today.yearDay();},
- 'future' :function (date) {return moment(date).yearDay() <= today.yearDay();}
- },
-
- getSelectedAsDates : function () {
- var out = [];
- var i=0, c = this._sel.length;
- for (;i<c;i++) {
- out.push(this._sel[i].nativeDate());
- }
- return out;
- },
-
- getSelectedAsText : function (format) {
- var out = [];
- var i=0, c = this._sel.length;
- for (;i<c;i++) {
- out.push(this._sel[i].format(format || this.settings.format || 'YYYY-MM-DD'))
- }
- return out;
- },
-
- getSelectedRaw : function () {
- var out = [];
- var i=0, c = this._sel.length;
- for (;i<c;i++) {
- out.push(moment(this._sel[i]))
- }
- return out;
- },
-
- getSelected : function (format) {
- var sel = this.getSelectedAsText(format);
- switch (this.settings.mode) {
- case 'range':
- sel.splice(2); //shouldn't be more than two, but lets just make sure.
- return sel.join(this.settings.rangeDelimiter);
-
- case 'multiple':
- return sel.join(this.settings.multipleDelimiter);
-
- case 'single':
- /* falls through */
- default:
- return sel[0];
- }
- },
-
- isSelected : function (input) {
- input = moment(input).yearDay();
- if (input < 1 || !this._sel || this._sel.length < 1) return false;
-
- switch (this.settings.mode) {
- case 'range':
- var a = this._sel[0] ? this._sel[0].yearDay() : 0,
- b = this._sel[1] ? this._sel[1].yearDay() : 0;
-
- if (a === input || b === input) return 1;
- if (!a || !b) return 0;
-
- if ((input > a && input < b) || (a<b && input < a && input > b)) return -1;
- return false;
-
- case 'multiple':
- var i = this._sel.length;
- while (i--) {
- if (this._sel[i].yearDay() === input) {
- return true;
- }
- }
- return false;
-
-
- case 'single':
- /* falls through */
- default:
- return (this._sel[0] && (this._sel[0].yearDay() === input));
- }
-
- return false;
- },
-
- setSelected : function (input, draw) {
- this._sel = parseDates(input, this.settings.parseSplitDelimiter, this.settings.format);
- this._sel.sort(function (a,b) {return a.yearDay() - b.yearDay();});
-
- if (draw !== false) this.draw();
- },
-
- addSelected : function (date, draw) {
- date = moment(date).hours(12);
- switch (this.settings.mode) {
- case 'multiple':
- if (!this.isSelected(date)) this._sel.push(date);
- else return false;
- break;
- case 'range':
-
- if (this._sel.length !== 1) this._sel = [date];
- else {
- if (date.yearDay() > this._sel[0].yearDay()) this._sel[1] = date;
- else this._sel = [date, this._sel[0]];
- }
- break;
- case 'single':
- /* falls through */
- default:
- this._sel = [date];
- break;
- }
- this._sel.sort(function (a,b) {return a.yearDay() - b.yearDay();});
- this.publish('change', this);
- if (draw !== false) this.draw();
- return true;
- },
-
- removeSelected : function (date, draw) {
- date = moment(date).yearDay();
- var i = this._sel.length;
- while (i--) {
- if (this._sel[i].yearDay() === date) {
- this._sel.splice(i,1);
- this.publish('change', this);
- if (draw !== false) this.draw();
- return true;
- }
- }
- return false;
- },
-
- draw : function draw() {
- // return;
- var month = moment(this.viewStartDate).hours(12), //force middle of the day to avoid any weird date shifts
- day,
- classes = this.classes,
- cal,
- $span,
- klass,
- i=0, c,
- j=0, k,
- s,
- dateString,
- opts = this.settings;
-
- c = this.calendars.length;
-
- do {
- day = moment(month).date(1);
- day.day( day.day() < this.settings.weekStart ? this.settings.weekStart-7 : this.settings.weekStart);
- //if the first day of the month is less than our week start, back up a week
-
- cal = this.calendars[i];
- cal.caption.innerHTML = month.format(this.settings.titleFormat);
- j = 0;
- do {
- $span = cal.days[j];
-
- klass = [];
-
- s = this.isSelected(day);
-
- if (s) klass.push(({'-1':classes.dayInRange,'1':classes.daySelected, 'true':classes.daySelected})[s]);
-
- if (day.month() != month.month()) klass.push(classes.dayOutOfMonth);
- else if (!(this.blackout(day) || this.direction(day)) || s>0) klass.push(classes.dayActive);
-
- if (day.yearDay() === today.yearDay()) klass.push(classes.dayToday);
-
- dateString = day.format(this.settings.dayAttributeFormat);
- if (opts.dateClassMap[dateString]) klass.push(opts.dateClassMap[dateString]);
-
- $span.innerHTML = day.format(opts.dayNumberFormat);
- $span.className = klass.join(' ');
- $span.setAttribute('data-date', dateString);
-
-
- day.add('days',1);
- } while (++j < 42);
- month.add('months',1);
- } while (++i < c);
-
- if (opts.directionScrolling) {
- var diff = -(moment().diff(month, 'months'));
- if (opts.direction==='today-past' || opts.direction==='past') {
-
- if (diff <= 0) {
- this.disableNextMonth = false;
- util.removeClassName(this.container, classes.disableNextMonth);
- } else {
- this.disableNextMonth = true;
- util.addClassName(this.container, classes.disableNextMonth);
- }
-
- } else if (opts.direction==='today-future' || opts.direction==='future') {
-
- if (diff > opts.months) {
- this.disablePreviousMonth = false;
- util.removeClassName(this.container, classes.disablePreviousMonth);
- } else {
- this.disablePreviousMonth = true;
- util.addClassName(this.container, classes.disablePreviousMonth);
- }
-
- }
-
-
- if (opts.direction==='today-past' || opts.direction==='past') {
- if (month.add({Y:1}).diff(moment(), 'years') < 0) {
- this.disableNextYear = false;
- util.removeClassName(this.container, classes.disableNextYear);
- } else {
- this.disableNextYear = true;
- util.addClassName(this.container, classes.disableNextYear);
- }
-
- } else if (opts.direction==='today-future' || opts.direction==='future') {
- if (month.subtract({Y:1}).diff(moment(), 'years') > 0) {
- this.disablePreviousYear = false;
- util.removeClassName(this.container, classes.disablePreviousYear);
- } else {
- this.disablePreviousYear = true;
- util.addClassName(this.container, classes.disablePreviousYear);
- }
-
- }
-
- }
- }
-}
-
-var parseDates = function (input, delimiter, format) {
- var output = [];
-
- if (typeof input === 'string') {
- input = input.split(delimiter);
- } else if (!util.isArray(input)) {
- input = [input];
- }
-
- var c = input.length;
- i = 0;
- do {
- if (input[i]) output.push( moment(input[i], format).hours(12) );
- } while (++i < c);
-
- return output;
-}
-
-
-
-window.Kalendae = Kalendae;
-
-var util = Kalendae.util = {
-
- isIE8: function() {
- return !!( (/msie 8./i).test(navigator.appVersion) && !(/opera/i).test(navigator.userAgent) && window.ActiveXObject && XDomainRequest && !window.msPerformance );
- },
-
-// ELEMENT FUNCTIONS
-
- $: function (elem) {
- return (typeof elem == 'string') ? document.getElementById(elem) : elem;
- },
-
- $$: function (selector) {
- return document.querySelectorAll(selector);
- },
-
- make: function (tagName, attributes, attach) {
- var k, e = document.createElement(tagName);
- if (!!attributes) for (k in attributes) if (attributes.hasOwnProperty(k)) e.setAttribute(k, attributes[k]);
- if (!!attach) attach.appendChild(e);
- return e;
- },
-
- // Returns true if the DOM element is visible, false if it's hidden.
- // Checks if display is anything other than none.
- isVisible: function (elem) {
- // shamelessly copied from jQuery
- return elem.offsetWidth > 0 || elem.offsetHeight > 0;
- },
-
- getStyle: function (elem, styleProp) {
- var y;
- if (elem.currentStyle) {
- y = elem.currentStyle[styleProp];
- } else if (window.getComputedStyle) {
- y = window.getComputedStyle(elem, null)[styleProp];
- }
- return y;
- },
-
- domReady:function (f){/in/.test(document.readyState) ? setTimeout(function() {util.domReady(f);},9) : f()},
-
- // Adds a listener callback to a DOM element which is fired on a specified
- // event. Callback is sent the event object and the element that triggered the event
- addEvent: function (elem, eventName, callback) {
- var listener = function (event) {
- event = event || window.event;
- var target = event.target || event.srcElement;
- var block = callback.apply(elem, [event, target]);
- if (block === false) {
- if (!!event.preventDefault) event.preventDefault();
- else {
- event.returnValue = false;
- event.cancelBubble = true;
- }
- }
- return block;
- };
- if (elem.attachEvent) { // IE only. The "on" is mandatory.
- elem.attachEvent("on" + eventName, listener);
- } else { // Other browsers.
- elem.addEventListener(eventName, listener, false);
- }
- return listener;
- },
-
- // Removes a listener callback from a DOM element which is fired on a specified
- // event.
- removeEvent: function (elem, event, listener) {
- if (elem.detachEvent) { // IE only. The "on" is mandatory.
- elem.detachEvent("on" + event, listener);
- } else { // Other browsers.
- elem.removeEventListener(event, listener, false);
- }
- },
-
- hasClassName: function(elem, className) { //copied and modified from Prototype.js
- if (!(elem = util.$(elem))) return false;
- var eClassName = elem.className;
- return (eClassName.length > 0 && (eClassName == className || new RegExp("(^|\\s)" + className + "(\\s|$)").test(eClassName)));
- },
-
- addClassName: function(elem, className) { //copied and modified from Prototype.js
- if (!(elem = util.$(elem))) return;
- if (!util.hasClassName(elem, className)) elem.className += (elem.className ? ' ' : '') + className;
- },
-
- removeClassName: function(elem, className) { //copied and modified from Prototype.js
- if (!(elem = util.$(elem))) return;
- elem.className = util.trimString(elem.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' '));
- },
-
- isFixed: function (elem) {
- do {
- if (util.getStyle(elem, 'position') === 'fixed') return true;
- } while ((elem = elem.offsetParent));
- return false;
- },
-
- getPosition: function (elem, isInner) {
- var x = elem.offsetLeft,
- y = elem.offsetTop,
- r = {};
-
- if (!isInner) {
- while ((elem = elem.offsetParent)) {
- x += elem.offsetLeft;
- y += elem.offsetTop;
- }
- }
-
- r[0] = r.left = x;
- r[1] = r.top = y;
- return r;
- },
-
- getHeight: function (elem) {
- return elem.offsetHeight || elem.scrollHeight;
- },
-
- getWidth: function (elem) {
- return elem.offsetWidth || elem.scrollWidth;
- },
-
-
-// TEXT FUNCTIONS
-
- trimString: function (input) {
- return input.replace(/^\s+/, '').replace(/\s+$/, '');
- },
-
-
-// OBJECT FUNCTIONS
-
- merge: function () {
- /* Combines multiple objects into one.
- * Syntax: util.extend([true], object1, object2, ... objectN)
- * If first argument is true, function will merge recursively.
- */
-
- var deep = (arguments[0]===true),
- d = {},
- i = deep?1:0;
-
- var _c = function (a, b) {
- if (typeof b !== 'object') return;
- for (var k in b) if (b.hasOwnProperty(k)) {
- //if property is an object or array, merge the contents instead of overwriting, if extend() was called as such
- if (deep && typeof a[k] === 'object' && typeof b[k] === 'object') _update(a[k], b[k]);
- else a[k] = b[k];
- }
- return a;
- }
-
- for (; i < arguments.length; i++) {
- _c(d, arguments[i]);
- }
- return d;
- },
-
- isArray: function (array) {
- return !(
- !array ||
- (!array.length || array.length === 0) ||
- typeof array !== 'object' ||
- !array.constructor ||
- array.nodeType ||
- array.item
- );
- }
-};
-
-
-//auto-initializaiton code
-Kalendae.util.domReady(function () {
- var els = util.$$('.auto-kal'),
- i = els.length,
- e;
-
- while (i--) {
- e = els[i];
- if (e.tagName === 'INPUT') {
- //if element is an input, bind a popup calendar to the input.
- new Kalendae.Input(e);
- } else {
- //otherwise, insert a flat calendar into the element.
- new Kalendae({attachTo:e});
- }
-
- }
-});
-
-Kalendae.Input = function (targetElement, options) {
- var $input = this.input = util.$(targetElement),
- overwriteInput;
-
- if (!$input || $input.tagName !== 'INPUT') throw "First argument for Kalendae.Input must be an <input> element or a valid element id.";
-
- var self = this,
- classes = self.classes
- opts = self.settings = util.merge(self.defaults, options);
-
- //force attachment to the body
- opts.attachTo = window.document.body;
-
- //if no override provided, use the input's contents
- if (!opts.selected) opts.selected = $input.value;
- else overwriteInput = true;
-
- //call our parent constructor
- Kalendae.call(self, opts);
-
- //create the close button
- if (opts.closeButton) {
- var $closeButton = util.make('a', {'class':classes.closeButton}, self.container)
- util.addEvent($closeButton, 'click', function () {
- $input.blur();
- });
- }
-
- if (overwriteInput) $input.value = self.getSelected();
-
- var $container = self.container,
- noclose = false;
-
- $container.style.display = 'none';
- util.addClassName($container, classes.positioned);
-
- util.addEvent($container, 'mousedown', function (event, target) {
- noclose = true; //IE8 doesn't obey event blocking when it comes to focusing, so we have to do this shit.
- });
- util.addEvent(window.document, 'mousedown', function (event, target) {
- noclose = false;
- });
-
- util.addEvent($input, 'focus', function () {
- self.setSelected(this.value);
- self.show();
- });
-
- util.addEvent($input, 'blur', function () {
- if (noclose) {
- noclose = false;
- $input.focus();
- }
- else self.hide();
- });
- util.addEvent($input, 'keyup', function (event) {
- self.setSelected(this.value);
- });
-
- self.subscribe('change', function () {
- $input.value = self.getSelected();
- });
-
-};
-
-Kalendae.Input.prototype = util.merge(Kalendae.prototype, {
- defaults : util.merge(Kalendae.prototype.defaults, {
- format: 'MM/DD/YYYY',
- side: 'bottom',
- closeButton: true,
- offsetLeft: 0,
- offsetTop: 0
- }),
- classes : util.merge(Kalendae.prototype.classes, {
- positioned : 'k-floating',
- closeButton: 'k-btn-close'
- }),
-
- show : function () {
- var $container = this.container,
- style = $container.style,
- $input = this.input,
- pos = util.getPosition($input);
-
- style.display = '';
- switch (opts.side) {
- case 'left':
- style.left = (pos.left - util.getWidth($container) + this.settings.offsetLeft) + 'px';
- style.top = (pos.top + this.settings.offsetTop) + 'px';
- break;
- case 'right':
- style.left = (pos.left + util.getWidth($input)) + 'px';
- style.top = (pos.top + this.settings.offsetTop) + 'px';
- break;
- case 'top':
- style.left = (pos.left + this.settings.offsetLeft) + 'px';
- style.top = (pos.top - util.getHeight($container) + this.settings.offsetTop) + 'px';
- break;
- case 'bottom':
- /* falls through */
- default:
- style.left = (pos.left + this.settings.offsetLeft) + 'px';
- style.top = (pos.top + util.getHeight($input) + this.settings.offsetTop) + 'px';
- break;
- }
-
- style.position = util.isFixed($input) ? 'fixed' : 'absolute';
-
- },
-
- hide : function () {
- this.container.style.display = 'none';
- }
-
-});
-
-
-/*!
-* MinPubSub, modified for use on Kalendae
-* Copyright(c) 2011 Daniel Lamb <daniellmb.com>
-* https://github.com/daniellmb/MinPubSub
-* MIT Licensed
-*/
-
-var MinPubSub = function(d){
-
- if (!d) d = this;
-
- // the topic/subscription hash
- var cache = d.c_ || {}; //check for "c_" cache for unit testing
-
- d.publish = function(/* String */ topic, /* Object */ target, /* Array? */ args){
- // summary:
- // Publish some data on a named topic.
- // topic: String
- // The channel to publish on
- // args: Array?
- // The data to publish. Each array item is converted into an ordered
- // arguments on the subscribed functions.
- //
- // example:
- // Publish stuff on '/some/topic'. Anything subscribed will be called
- // with a function signature like: function(a,b,c){ ... }
- //
- // publish("/some/topic", ["a","b","c"]);
-
- var subs = cache[topic],
- len = subs ? subs.length : 0,
- r;
-
- //can change loop or reverse array if the order matters
- while(len--){
- r = subs[len].apply(target, args || []);
- if (typeof r === 'boolean') return r;
- }
- };
-
- d.subscribe = function(/* String */ topic, /* Function */ callback, /* Boolean */ topPriority){
- // summary:
- // Register a callback on a named topic.
- // topic: String
- // The channel to subscribe to
- // callback: Function
- // The handler event. Anytime something is publish'ed on a
- // subscribed channel, the callback will be called with the
- // published array as ordered arguments.
- //
- // returns: Array
- // A handle which can be used to unsubscribe this particular subscription.
- //
- // example:
- // subscribe("/some/topic", function(a, b, c){ /* handle data */ });
-
- if(!cache[topic]){
- cache[topic] = [];
- }
- if (topPriority)
- cache[topic].push(callback);
- else
- cache[topic].unshift(callback);
- return [topic, callback]; // Array
- };
-
- d.unsubscribe = function(/* Array */ handle){
- // summary:
- // Disconnect a subscribed function for a topic.
- // handle: Array
- // The return value from a subscribe call.
- // example:
- // var handle = subscribe("/some/topic", function(){});
- // unsubscribe(handle);
-
- var subs = cache[handle[0]],
- callback = handle[1],
- len = subs ? subs.length : 0;
-
- while(len--){
- if(subs[len] === callback){
- subs.splice(len, 1);
- }
- }
- };
-
-};// Moment.js
-// Altered slightly for use in Kalendae.js
-//
-// (c) 2011 Tim Wood
-// Moment.js is freely distributable under the terms of the MIT license.
-//
-// Version 1.3.0
-
-var moment = Kalendae.moment = (function (Date, undefined) {
-
- var moment,
- round = Math.round,
- languages = {},
- hasModule = (typeof module !== 'undefined'),
- paramsToParse = 'months|monthsShort|monthsParse|weekdays|weekdaysShort|longDateFormat|calendar|relativeTime|ordinal|meridiem'.split('|'),
- i,
- charactersToReplace = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?|ZZ?|LT|LL?L?L?)/g,
- nonuppercaseLetters = /[^A-Z]/g,
- timezoneRegex = /\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g,
- tokenCharacters = /(\\)?(MM?M?M?|dd?d?d|DD?D?D?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|ZZ?|T)/g,
- inputCharacters = /(\\)?([0-9]+|([a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+|([\+\-]\d\d:?\d\d))/gi,
- timezoneParseRegex = /([\+\-]|\d\d)/gi,
- VERSION = "1.3.0",
- shortcuts = 'Month|Date|Hours|Minutes|Seconds|Milliseconds'.split('|');
-
- // Moment prototype object
- function Moment(date) {
- this._d = date;
- }
-
- // left zero fill a number
- // see http://jsperf.com/left-zero-filling for performance comparison
- function leftZeroFill(number, targetLength) {
- var output = number + '';
- while (output.length < targetLength) {
- output = '0' + output;
- }
- return output;
- }
-
- // helper function for _.addTime and _.subtractTime
- function dateAddRemove(date, _input, adding, val) {
- var isString = (typeof _input === 'string'),
- input = isString ? {} : _input,
- ms, d, M, currentDate;
- if (isString && val) {
- input[_input] = val;
- }
- ms = (input.ms || input.milliseconds || 0) +
- (input.s || input.seconds || 0) * 1e3 + // 1000
- (input.m || input.minutes || 0) * 6e4 + // 1000 * 60
- (input.h || input.hours || 0) * 36e5; // 1000 * 60 * 60
- d = (input.d || input.days || 0) +
- (input.w || input.weeks || 0) * 7;
- M = (input.M || input.months || 0) +
- (input.y || input.years || 0) * 12;
- if (ms) {
- date.setTime(+date + ms * adding);
- }
- if (d) {
- date.setDate(date.getDate() + d * adding);
- }
- if (M) {
- currentDate = date.getDate();
- date.setDate(1);
- date.setMonth(date.getMonth() + M * adding);
- date.setDate(Math.min(new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate(), currentDate));
- }
- return date;
- }
-
- // check if is an array
- function isArray(input) {
- return Object.prototype.toString.call(input) === '[object Array]';
- }
-
- // convert an array to a date.
- // the array should mirror the parameters below
- // note: all values past the year are optional and will default to the lowest possible value.
- // [year, month, day , hour, minute, second, millisecond]
- function dateFromArray(input) {
- return new Date(input[0], input[1] || 0, input[2] || 1, input[3] || 0, input[4] || 0, input[5] || 0, input[6] || 0);
- }
-
- // format date using native date object
- function formatDate(date, inputString) {
- var m = new Moment(date),
- currentMonth = m.month(),
- currentDate = m.date(),
- currentYear = m.year(),
- currentDay = m.day(),
- currentHours = m.hours(),
- currentMinutes = m.minutes(),
- currentSeconds = m.seconds(),
- currentZone = m.zone(),
- ordinal = moment.ordinal,
- meridiem = moment.meridiem;
- // check if the character is a format
- // return formatted string or non string.
- //
- // uses switch/case instead of an object of named functions (like http://phpjs.org/functions/date:380)
- // for minification and performance
- // see http://jsperf.com/object-of-functions-vs-switch for performance comparison
- function replaceFunction(input) {
- // create a couple variables to be used later inside one of the cases.
- var a, b;
- switch (input) {
- // MONTH
- case 'M' :
- return currentMonth + 1;
- case 'Mo' :
- return (currentMonth + 1) + ordinal(currentMonth + 1);
- case 'MM' :
- return leftZeroFill(currentMonth + 1, 2);
- case 'MMM' :
- return moment.monthsShort[currentMonth];
- case 'MMMM' :
- return moment.months[currentMonth];
- // DAY OF MONTH
- case 'D' :
- return currentDate;
- case 'Do' :
- return currentDate + ordinal(currentDate);
- case 'DD' :
- return leftZeroFill(currentDate, 2);
- // DAY OF YEAR
- case 'DDD' :
- a = new Date(currentYear, currentMonth, currentDate);
- b = new Date(currentYear, 0, 1);
- return ~~ (((a - b) / 864e5) + 1.5);
- case 'DDDo' :
- a = replaceFunction('DDD');
- return a + ordinal(a);
- case 'DDDD' :
- return leftZeroFill(replaceFunction('DDD'), 3);
- // WEEKDAY
- case 'd' :
- return currentDay;
- case 'do' :
- return currentDay + ordinal(currentDay);
- case 'ddd' :
- return moment.weekdaysShort[currentDay];
- case 'dddd' :
- return moment.weekdays[currentDay];
- // WEEK OF YEAR
- case 'w' :
- a = new Date(currentYear, currentMonth, currentDate - currentDay + 5);
- b = new Date(a.getFullYear(), 0, 4);
- return ~~ ((a - b) / 864e5 / 7 + 1.5);
- case 'wo' :
- a = replaceFunction('w');
- return a + ordinal(a);
- case 'ww' :
- return leftZeroFill(replaceFunction('w'), 2);
- // YEAR
- case 'YY' :
- return leftZeroFill(currentYear % 100, 2);
- case 'YYYY' :
- return currentYear;
- // AM / PM
- case 'a' :
- return currentHours > 11 ? meridiem.pm : meridiem.am;
- case 'A' :
- return currentHours > 11 ? meridiem.PM : meridiem.AM;
- // 24 HOUR
- case 'H' :
- return currentHours;
- case 'HH' :
- return leftZeroFill(currentHours, 2);
- // 12 HOUR
- case 'h' :
- return currentHours % 12 || 12;
- case 'hh' :
- return leftZeroFill(currentHours % 12 || 12, 2);
- // MINUTE
- case 'm' :
- return currentMinutes;
- case 'mm' :
- return leftZeroFill(currentMinutes, 2);
- // SECOND
- case 's' :
- return currentSeconds;
- case 'ss' :
- return leftZeroFill(currentSeconds, 2);
- // TIMEZONE
- case 'zz' :
- // depreciating 'zz' fall through to 'z'
- case 'z' :
- return (date.toString().match(timezoneRegex) || [''])[0].replace(nonuppercaseLetters, '');
- case 'Z' :
- return (currentZone > 0 ? '+' : '-') + leftZeroFill(~~(Math.abs(currentZone) / 60), 2) + ':' + leftZeroFill(~~(Math.abs(currentZone) % 60), 2);
- case 'ZZ' :
- return (currentZone > 0 ? '+' : '-') + leftZeroFill(~~(10 * Math.abs(currentZone) / 6), 4);
- // LONG DATES
- case 'L' :
- case 'LL' :
- case 'LLL' :
- case 'LLLL' :
- case 'LT' :
- return formatDate(date, moment.longDateFormat[input]);
- // DEFAULT
- default :
- return input.replace(/(^\[)|(\\)|\]$/g, "");
- }
- }
- return inputString.replace(charactersToReplace, replaceFunction);
- }
-
- // date from string and format string
- function makeDateFromStringAndFormat(string, format) {
- var inArray = [0, 0, 1, 0, 0, 0, 0],
- timezoneHours = 0,
- timezoneMinutes = 0,
- isUsingUTC = false,
- inputParts = string.match(inputCharacters),
- formatParts = format.match(tokenCharacters),
- i,
- isPm;
-
- // function to convert string input to date
- function addTime(format, input) {
- var a;
- switch (format) {
- // MONTH
- case 'M' :
- // fall through to MM
- case 'MM' :
- inArray[1] = ~~input - 1;
- break;
- case 'MMM' :
- // fall through to MMMM
- case 'MMMM' :
- for (a = 0; a < 12; a++) {
- if (moment.monthsParse[a].test(input)) {
- inArray[1] = a;
- break;
- }
- }
- break;
- // DAY OF MONTH
- case 'D' :
- // fall through to DDDD
- case 'DD' :
- // fall through to DDDD
- case 'DDD' :
- // fall through to DDDD
- case 'DDDD' :
- inArray[2] = ~~input;
- break;
- // YEAR
- case 'YY' :
- input = ~~input;
- inArray[0] = input + (input > 70 ? 1900 : 2000);
- break;
- case 'YYYY' :
- inArray[0] = ~~Math.abs(input);
- break;
- // AM / PM
- case 'a' :
- // fall through to A
- case 'A' :
- isPm = (input.toLowerCase() === 'pm');
- break;
- // 24 HOUR
- case 'H' :
- // fall through to hh
- case 'HH' :
- // fall through to hh
- case 'h' :
- // fall through to hh
- case 'hh' :
- inArray[3] = ~~input;
- break;
- // MINUTE
- case 'm' :
- // fall through to mm
- case 'mm' :
- inArray[4] = ~~input;
- break;
- // SECOND
- case 's' :
- // fall through to ss
- case 'ss' :
- inArray[5] = ~~input;
- break;
- // TIMEZONE
- case 'Z' :
- // fall through to ZZ
- case 'ZZ' :
- isUsingUTC = true;
- a = input.match(timezoneParseRegex);
- if (a[1]) {
- timezoneHours = ~~a[1];
- }
- if (a[2]) {
- timezoneMinutes = ~~a[2];
- }
- // reverse offsets
- if (a[0] === '-') {
- timezoneHours = -timezoneHours;
- timezoneMinutes = -timezoneMinutes;
- }
- break;
- }
- }
- for (i = 0; i < formatParts.length; i++) {
- addTime(formatParts[i], inputParts[i]);
- }
- // handle am pm
- if (isPm && inArray[3] < 12) {
- inArray[3] += 12;
- }
- // if is 12 am, change hours to 0
- if (isPm === false && inArray[3] === 12) {
- inArray[3] = 0;
- }
- // handle timezone
- inArray[3] += timezoneHours;
- inArray[4] += timezoneMinutes;
- // return
- return isUsingUTC ? new Date(Date.UTC.apply({}, inArray)) : dateFromArray(inArray);
- }
-
- // compare two arrays, return the number of differences
- function compareArrays(array1, array2) {
- var len = Math.min(array1.length, array2.length),
- lengthDiff = Math.abs(array1.length - array2.length),
- diffs = 0,
- i;
- for (i = 0; i < len; i++) {
- if (~~array1[i] !== ~~array2[i]) {
- diffs++;
- }
- }
- return diffs + lengthDiff;
- }
-
- // date from string and array of format strings
- function makeDateFromStringAndArray(string, formats) {
- var output,
- inputParts = string.match(inputCharacters),
- scores = [],
- scoreToBeat = 99,
- i,
- curDate,
- curScore;
- for (i = 0; i < formats.length; i++) {
- curDate = makeDateFromStringAndFormat(string, formats[i]);
- curScore = compareArrays(inputParts, formatDate(curDate, formats[i]).match(inputCharacters));
- if (curScore < scoreToBeat) {
- scoreToBeat = curScore;
- output = curDate;
- }
- }
- return output;
- }
-
- moment = function (input, format) {
- if (input === null) {
- return null;
- }
- var date;
- // parse UnderscoreDate object
- if (input && input._d instanceof Date) {
- date = new Date(+input._d);
- // parse string and format
- } else if (format) {
- if (isArray(format)) {
- date = makeDateFromStringAndArray(input, format);
- } else {
- date = makeDateFromStringAndFormat(input, format);
- }
- // parse everything else
- } else {
- date = input === undefined ? new Date() :
- input instanceof Date ? input :
- isArray(input) ? dateFromArray(input) :
- new Date(input);
- }
- return new Moment(date);
- };
-
- // version number
- moment.version = VERSION;
-
- // language switching and caching
- moment.lang = function (key, values) {
- var i,
- param,
- req,
- parse = [];
- if (values) {
- for (i = 0; i < 12; i++) {
- parse[i] = new RegExp('^' + values.months[i] + '|^' + values.monthsShort[i].replace('.', ''), 'i');
- }
- values.monthsParse = values.monthsParse || parse;
- languages[key] = values;
- }
- if (languages[key]) {
- for (i = 0; i < paramsToParse.length; i++) {
- param = paramsToParse[i];
- moment[param] = languages[key][param] || moment[param];
- }
- } else {
- if (hasModule) {
- req = require('./lang/' + key);
- moment.lang(key, req);
- }
- }
- };
-
- // set default language
- moment.lang('en', {
- months : "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
- monthsShort : "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),
- weekdays : "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
- weekdaysShort : "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),
- longDateFormat : {
- LT : "h:mm A",
- L : "MM/DD/YYYY",
- LL : "MMMM D YYYY",
- LLL : "MMMM D YYYY LT",
- LLLL : "dddd, MMMM D YYYY LT"
- },
- meridiem : {
- AM : 'AM',
- am : 'am',
- PM : 'PM',
- pm : 'pm'
- },
- calendar : {
- sameDay : '[Today at] LT',
- nextDay : '[Tomorrow at] LT',
- nextWeek : 'dddd [at] LT',
- lastDay : '[Yesterday at] LT',
- lastWeek : '[last] dddd [at] LT',
- sameElse : 'L'
- },
- relativeTime : {
- future : "in %s",
- past : "%s ago",
- s : "a few seconds",
- m : "a minute",
- mm : "%d minutes",
- h : "an hour",
- hh : "%d hours",
- d : "a day",
- dd : "%d days",
- M : "a month",
- MM : "%d months",
- y : "a year",
- yy : "%d years"
- },
- ordinal : function (number) {
- var b = number % 10;
- return (~~ (number % 100 / 10) === 1) ? 'th' :
- (b === 1) ? 'st' :
- (b === 2) ? 'nd' :
- (b === 3) ? 'rd' : 'th';
- }
- });
-
- // helper function for _date.from() and _date.fromNow()
- function substituteTimeAgo(string, number, withoutSuffix) {
- var rt = moment.relativeTime[string];
- return (typeof rt === 'function') ?
- rt(number || 1, !!withoutSuffix, string) :
- rt.replace(/%d/i, number || 1);
- }
-
- function relativeTime(milliseconds, withoutSuffix) {
- var seconds = round(Math.abs(milliseconds) / 1000),
- minutes = round(seconds / 60),
- hours = round(minutes / 60),
- days = round(hours / 24),
- years = round(days / 365),
- args = seconds < 45 && ['s', seconds] ||
- minutes === 1 && ['m'] ||
- minutes < 45 && ['mm', minutes] ||
- hours === 1 && ['h'] ||
- hours < 22 && ['hh', hours] ||
- days === 1 && ['d'] ||
- days <= 25 && ['dd', days] ||
- days <= 45 && ['M'] ||
- days < 345 && ['MM', round(days / 30)] ||
- years === 1 && ['y'] || ['yy', years];
- args[2] = withoutSuffix;
- return substituteTimeAgo.apply({}, args);
- }
-
- // shortcut for prototype
- moment.fn = Moment.prototype = {
-
- clone : function () {
- return moment(this);
- },
-
- valueOf : function () {
- return +this._d;
- },
-
- nativeDate : function () {
- return this._d;
- },
-
- toString : function () {
- return this._d.toString();
- },
-
- toDate : function () {
- return this._d;
- },
-
- format : function (inputString) {
- return formatDate(this._d, inputString);
- },
-
- add : function (input, val) {
- this._d = dateAddRemove(this._d, input, 1, val);
- return this;
- },
-
- subtract : function (input, val) {
- this._d = dateAddRemove(this._d, input, -1, val);
- return this;
- },
-
- diff : function (input, val, asFloat) {
- var inputMoment = moment(input),
- diff = this._d - inputMoment._d,
- year = this.year() - inputMoment.year(),
- month = this.month() - inputMoment.month(),
- day = this.day() - inputMoment.day(),
- output;
- if (val === 'months') {
- output = year * 12 + month + day / 30;
- } else if (val === 'years') {
- output = year + month / 12;
- } else {
- output = val === 'seconds' ? diff / 1e3 : // 1000
- val === 'minutes' ? diff / 6e4 : // 1000 * 60
- val === 'hours' ? diff / 36e5 : // 1000 * 60 * 60
- val === 'days' ? diff / 864e5 : // 1000 * 60 * 60 * 24
- val === 'weeks' ? diff / 6048e5 : // 1000 * 60 * 60 * 24 * 7
- val === 'days' ? diff / 3600 : diff;
- }
- return asFloat ? output : round(output);
- },
-
- from : function (time, withoutSuffix) {
- var difference = this.diff(time),
- rel = moment.relativeTime,
- output = relativeTime(difference, withoutSuffix);
- return withoutSuffix ? output : (difference <= 0 ? rel.past : rel.future).replace(/%s/i, output);
- },
-
- fromNow : function (withoutSuffix) {
- return this.from(moment(), withoutSuffix);
- },
-
- calendar : function () {
- var today = moment(),
- todayAtZeroHour = moment([today.year(), today.month(), today.date()]),
- diff = this.diff(todayAtZeroHour, 'days', true),
- calendar = moment.calendar,
- allElse = calendar.sameElse,
- format = diff < -6 ? allElse :
- diff < -1 ? calendar.lastWeek :
- diff < 0 ? calendar.lastDay :
- diff < 1 ? calendar.sameDay :
- diff < 2 ? calendar.nextDay :
- diff < 7 ? calendar.nextWeek : allElse;
- return this.format(typeof format === 'function' ? format.apply(this) : format);
- },
-
- isLeapYear : function () {
- var year = this.year();
- return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
- },
-
- isDST : function () {
- return this.zone() !== moment([this.year()]).zone();
- },
-
- day : function (input) {
- var day = this._d.getDay();
- return (typeof input === 'undefined') ? day :
- this.add({ d : input - day });
- }
- };
-
- // helper for adding shortcuts
- function makeShortcut(name, key) {
- moment.fn[name] = function (input) {
- if (typeof input !== 'undefined') {
- this._d['set' + key](input);
- return this;
- } else {
- return this._d['get' + key]();
- }
- };
- }
-
- // loop through and add shortcuts (Month, Date, Hours, Minutes, Seconds, Milliseconds)
- for (i = 0; i < shortcuts.length; i ++) {
- makeShortcut(shortcuts[i].toLowerCase(), shortcuts[i]);
- }
-
- // add shortcut for year (uses different syntax than the getter/setter 'year' == 'FullYear')
- makeShortcut('year', 'FullYear');
-
- // add shortcut for timezone offset (no setter)
- moment.fn.zone = function () {
- return this._d.getTimezoneOffset();
- };
-
- return moment;
-})(Date);
-
-
-//function to reset the date object to 00:00 GMT
-moment.fn.stripTime = function () {
- this._d = new Date(Math.floor(this._d.valueOf() / 86400000) * 86400000);
- return this;
-}
-
-
-//function to get the total number of days since the epoch.
-moment.fn.yearDay = function (input) {
- var yearday = Math.floor(this._d / 86400000);
- return (typeof input === 'undefined') ? yearday :
- this.add({ d : input - yearday });
-}
-
-today = moment().stripTime();
-
-if (typeof jQuery !== 'undefined') {
- jQuery.fn.kalendae = function (options) {
- this.each(function (i, e) {
- if (e.tagName === 'INPUT') {
- //if element is an input, bind a popup calendar to the input.
- $(e).data('kalendae', new Kalendae.Input(e, options));
- } else {
- //otherwise, insert a flat calendar into the element.
- $(e).data('kalendae', new Kalendae($.extend({}, {attachTo:e}, options)));
- }
- });
- return this;
- }
-}
-
-
-})();
View
48 build/kalendae.min.js
@@ -1,48 +0,0 @@
-/********************************************************************
- * Kalendae, a framework agnostic javascript date picker *
- * Copyright(c) 2012 Jarvis Badgley (chipersoft@gmail.com) *
- * http://github.com/ChiperSoft/Kalendae *
- * Version 0.2 *
- ********************************************************************/
-
-(function(){var l,o=function(a,c){a instanceof Element||"string"===typeof a||(c=a);var b=this,d=b.classes,f=b.settings=e.merge(b.defaults,{attachTo:a},c||{}),q=b.container=e.make("div",{"class":d.container}),o=b.calendars=[],j=h().day(f.weekStart),m,p=[],g,k,y;g=[];var l;k=0;m=f.months;e.isIE8()&&e.addClassName(q,"ie8");for(k=7;k--;)p.push(j.format("ddd").substr(0,f.columnHeaderLength)),j.add("days",1);A(b);if("object"===typeof f.subscribe)for(k in f.subscribe)f.subscribe.hasOwnProperty(k)&&b.subscribe(k,
-f.subscribe[k]);b._sel=[];f.selected&&b.setSelected(f.selected,!1);m=f.viewStartDate?h(f.viewStartDate,f.format):0<b._sel.length?h(b._sel[0]):h();b.viewStartDate=m.date(1);if((m={past:f.months-1,"today-past":f.months-1,any:2<f.months?Math.floor(f.months/2):0,"today-future":0,future:0}[this.settings.direction])&&h().month()==h(b.viewStartDate).month())b.viewStartDate=h(b.viewStartDate).subtract({M:m}).date(1);if("function"===typeof f.blackout)b.blackout=f.blackout;else if(f.blackout){var u=z(f.blackout,
-f.parseSplitDelimiter);b.blackout=function(a){a=h(a).yearDay();if(1>a||!b._sel||1>b._sel.length)return!1;for(var c=u.length;c--;)if(u[c].yearDay()===a)return!0;return!1}}else b.blackout=function(){return!1};b.direction=b.directions[f.direction]?b.directions[f.direction]:b.directions.any;for(m=Math.max(f.months,1);m--;){g=e.make("div",{"class":d.calendar},q);g.setAttribute("data-cal-index",m);1<f.months&&(m==Math.max(f.months-1,1)?e.addClassName(g,d.monthFirst):0===m?e.addClassName(g,d.monthLast):
-e.addClassName(g,d.monthMiddle));k=e.make("div",{"class":d.title},g);e.make("a",{"class":d.previousYear},k);e.make("a",{"class":d.previousMonth},k);e.make("a",{"class":d.nextYear},k);e.make("a",{"class":d.nextMonth},k);j=e.make("span",{"class":d.caption},k);y=e.make("div",{"class":d.header},g);k=0;do l=e.make("span",{},y),l.innerHTML=p[k];while(7>++k);y=e.make("div",{"class":d.days},g);k=0;for(g=[];42>k++;)g.push(e.make("span",{},y));o.push({caption:j,days:g});m&&e.make("div",{"class":d.monthSeparator},
-q)}b.draw();e.addEvent(q,"mousedown",function(a,c){var g;if(e.hasClassName(c,d.nextMonth))!b.disableNext&&!1!==b.publish("view-changed",b,["next-month"])&&(b.viewStartDate.add("months",1),b.draw());else if(e.hasClassName(c,d.previousMonth))!b.disablePreviousMonth&&!1!==b.publish("view-changed",b,["previous-month"])&&(b.viewStartDate.subtract("months",1),b.draw());else if(e.hasClassName(c,d.nextYear))!b.disableNext&&!1!==b.publish("view-changed",b,["next-year"])&&(b.viewStartDate.add("years",1),b.draw());
-else if(e.hasClassName(c,d.previousYear))!b.disablePreviousMonth&&!1!==b.publish("view-changed",b,["previous-year"])&&(b.viewStartDate.subtract("years",1),b.draw());else if(e.hasClassName(c.parentNode,d.days)&&e.hasClassName(c,d.dayActive)&&(g=c.getAttribute("data-date")))if(g=h(g,f.dayAttributeFormat).hours(12),!1!==b.publish("date-clicked",b,[g]))switch(f.mode){case "multiple":b.addSelected(g)||b.removeSelected(g);break;case "range":b.addSelected(g);break;default:b.addSelected(g)}return!1});(f.attachTo=
-e.$(f.attachTo))&&f.attachTo.appendChild(q)};o.prototype={defaults:{attachTo:null,months:1,weekStart:0,direction:"any",directionScrolling:!0,viewStartDate:null,blackout:null,selected:null,mode:"single",format:null,subscribe:null,columnHeaderLength:2,titleFormat:"MMMM, YYYY",dayNumberFormat:"D",dayAttributeFormat:"YYYY-MM-DD",parseSplitDelimiter:/,\s*|\s+-\s+/,rangeDelimiter:" - ",multipleDelimiter:", ",dateClassMap:{}},classes:{container:"kalendae",calendar:"k-calendar",monthFirst:"k-first-month",
-monthMiddle:"k-middle-month",monthLast:"k-last-month",title:"k-title",previousMonth:"k-btn-previous-month",nextMonth:"k-btn-next-month",previousYear:"k-btn-previous-year",nextYear:"k-btn-next-year",caption:"k-caption",header:"k-header",days:"k-days",dayOutOfMonth:"k-out-of-month",dayActive:"k-active",daySelected:"k-selected",dayInRange:"k-range",dayToday:"k-today",monthSeparator:"k-separator",disablePreviousMonth:"k-disable-previous-month-btn",disableNextMonth:"k-disable-next-month-btn",disablePreviousYear:"k-disable-previous-year-btn",
-disableNextYear:"k-disable-next-year-btn"},disablePreviousMonth:!1,disableNextMonth:!1,disablePreviousYear:!1,disableNextYear:!1,directions:{past:function(a){return h(a).yearDay()>=l.yearDay()},"today-past":function(a){return h(a).yearDay()>l.yearDay()},any:function(){return!1},"today-future":function(a){return h(a).yearDay()<l.yearDay()},future:function(a){return h(a).yearDay()<=l.yearDay()}},getSelectedAsDates:function(){for(var a=[],c=0,b=this._sel.length;c<b;c++)a.push(this._sel[c].nativeDate());
-return a},getSelectedAsText:function(a){for(var c=[],b=0,d=this._sel.length;b<d;b++)c.push(this._sel[b].format(a||this.settings.format||"YYYY-MM-DD"));return c},getSelectedRaw:function(){for(var a=[],c=0,b=this._sel.length;c<b;c++)a.push(h(this._sel[c]));return a},getSelected:function(a){a=this.getSelectedAsText(a);switch(this.settings.mode){case "range":return a.splice(2),a.join(this.settings.rangeDelimiter);case "multiple":return a.join(this.settings.multipleDelimiter);default:return a[0]}},isSelected:function(a){a=
-h(a).yearDay();if(1>a||!this._sel||1>this._sel.length)return!1;switch(this.settings.mode){case "range":var c=this._sel[0]?this._sel[0].yearDay():0,b=this._sel[1]?this._sel[1].yearDay():0;return c===a||b===a?1:!c||!b?0:a>c&&a<b||c<b&&a<c&&a>b?-1:!1;case "multiple":for(c=this._sel.length;c--;)if(this._sel[c].yearDay()===a)return!0;return!1;default:return this._sel[0]&&this._sel[0].yearDay()===a}},setSelected:function(a,c){this._sel=z(a,this.settings.parseSplitDelimiter,this.settings.format);this._sel.sort(function(a,
-c){return a.yearDay()-c.yearDay()});!1!==c&&this.draw()},addSelected:function(a,c){a=h(a).hours(12);switch(this.settings.mode){case "multiple":if(this.isSelected(a))return!1;this._sel.push(a);break;case "range":1!==this._sel.length?this._sel=[a]:a.yearDay()>this._sel[0].yearDay()?this._sel[1]=a:this._sel=[a,this._sel[0]];break;default:this._sel=[a]}this._sel.sort(function(a,c){return a.yearDay()-c.yearDay()});this.publish("change",this);!1!==c&&this.draw();return!0},removeSelected:function(a,c){for(var a=
-h(a).yearDay(),b=this._sel.length;b--;)if(this._sel[b].yearDay()===a)return this._sel.splice(b,1),this.publish("change",this),!1!==c&&this.draw(),!0;return!1},draw:function(){var a=h(this.viewStartDate).hours(12),c,b=this.classes,d,f,q,o=0,j,m=0,p,g=this.settings;j=this.calendars.length;do{c=h(a).date(1);c.day(c.day()<this.settings.weekStart?this.settings.weekStart-7:this.settings.weekStart);d=this.calendars[o];d.caption.innerHTML=a.format(this.settings.titleFormat);m=0;do f=d.days[m],q=[],(p=this.isSelected(c))&&
-q.push({"-1":b.dayInRange,1:b.daySelected,"true":b.daySelected}[p]),c.month()!=a.month()?q.push(b.dayOutOfMonth):(!this.blackout(c)&&!this.direction(c)||0<p)&&q.push(b.dayActive),c.yearDay()===l.yearDay()&&q.push(b.dayToday),p=c.format(this.settings.dayAttributeFormat),g.dateClassMap[p]&&q.push(g.dateClassMap[p]),f.innerHTML=c.format(g.dayNumberFormat),f.className=q.join(" "),f.setAttribute("data-date",p),c.add("days",1);while(42>++m);a.add("months",1)}while(++o<j);if(g.directionScrolling){c=-h().diff(a,
-"months");if("today-past"===g.direction||"past"===g.direction)0>=c?(this.disableNextMonth=!1,e.removeClassName(this.container,b.disableNextMonth)):(this.disableNextMonth=!0,e.addClassName(this.container,b.disableNextMonth));else if("today-future"===g.direction||"future"===g.direction)c>g.months?(this.disablePreviousMonth=!1,e.removeClassName(this.container,b.disablePreviousMonth)):(this.disablePreviousMonth=!0,e.addClassName(this.container,b.disablePreviousMonth));if("today-past"===g.direction||"past"===
-g.direction)0>a.add({Y:1}).diff(h(),"years")?(this.disableNextYear=!1,e.removeClassName(this.container,b.disableNextYear)):(this.disableNextYear=!0,e.addClassName(this.container,b.disableNextYear));else if("today-future"===g.direction||"future"===g.direction)0<a.subtract({Y:1}).diff(h(),"years")?(this.disablePreviousYear=!1,e.removeClassName(this.container,b.disablePreviousYear)):(this.disablePreviousYear=!0,e.addClassName(this.container,b.disablePreviousYear))}}};var z=function(a,c,b){var d=[];"string"===
-typeof a?a=a.split(c):e.isArray(a)||(a=[a]);c=a.length;i=0;do a[i]&&d.push(h(a[i],b).hours(12));while(++i<c);return d};window.Kalendae=o;var e=o.util={isIE8:function(){return!(!/msie 8./i.test(navigator.appVersion)||/opera/i.test(navigator.userAgent)||!window.ActiveXObject||!XDomainRequest||window.msPerformance)},$:function(a){return"string"==typeof a?document.getElementById(a):a},$$:function(a){return document.querySelectorAll(a)},make:function(a,c,b){var d,a=document.createElement(a);if(c)for(d in c)c.hasOwnProperty(d)&&
-a.setAttribute(d,c[d]);b&&b.appendChild(a);return a},isVisible:function(a){return 0<a.offsetWidth||0<a.offsetHeight},getStyle:function(a,c){var b;a.currentStyle?b=a.currentStyle[c]:window.getComputedStyle&&(b=window.getComputedStyle(a,null)[c]);return b},domReady:function(a){/in/.test(document.readyState)?setTimeout(function(){e.domReady(a)},9):a()},addEvent:function(a,c,b){var d=function(c){var c=c||window.event,d=b.apply(a,[c,c.target||c.srcElement]);!1===d&&(c.preventDefault?c.preventDefault():
-(c.returnValue=!1,c.cancelBubble=!0));return d};a.attachEvent?a.attachEvent("on"+c,d):a.addEventListener(c,d,!1);return d},removeEvent:function(a,c,b){a.detachEvent?a.detachEvent("on"+c,b):a.removeEventListener(c,b,!1)},hasClassName:function(a,c){if(!(a=e.$(a)))return!1;var b=a.className;return 0<b.length&&(b==c||RegExp("(^|\\s)"+c+"(\\s|$)").test(b))},addClassName:function(a,c){if((a=e.$(a))&&!e.hasClassName(a,c))a.className+=(a.className?" ":"")+c},removeClassName:function(a,c){if(a=e.$(a))a.className=
-e.trimString(a.className.replace(RegExp("(^|\\s+)"+c+"(\\s+|$)")," "))},isFixed:function(a){do if("fixed"===e.getStyle(a,"position"))return!0;while(a=a.offsetParent);return!1},getPosition:function(a,c){var b=a.offsetLeft,d=a.offsetTop,f={};if(!c)for(;a=a.offsetParent;)b+=a.offsetLeft,d+=a.offsetTop;f[0]=f.left=b;f[1]=f.top=d;return f},getHeight:function(a){return a.offsetHeight||a.scrollHeight},getWidth:function(a){return a.offsetWidth||a.scrollWidth},trimString:function(a){return a.replace(/^\s+/,
-"").replace(/\s+$/,"")},merge:function(){for(var a=!0===arguments[0],c={},b=a?1:0;b<arguments.length;b++){var d=c,f=arguments[b];if("object"===typeof f){var e=void 0;for(e in f)f.hasOwnProperty(e)&&(a&&"object"===typeof d[e]&&"object"===typeof f[e]?_update(d[e],f[e]):d[e]=f[e])}}return c},isArray:function(a){return!(!a||!a.length||0===a.length||"object"!==typeof a||!a.constructor||a.nodeType||a.item)}};o.util.domReady(function(){for(var a=e.$$(".auto-kal"),c=a.length,b;c--;)b=a[c],"INPUT"===b.tagName?
-new o.Input(b):new o({attachTo:b})});o.Input=function(a,c){var b=this.input=e.$(a),d;if(!b||"INPUT"!==b.tagName)throw"First argument for Kalendae.Input must be an <input> element or a valid element id.";var f=this,h=f.classes;opts=f.settings=e.merge(f.defaults,c);opts.attachTo=window.document.body;opts.selected?d=!0:opts.selected=b.value;o.call(f,opts);if(opts.closeButton){var l=e.make("a",{"class":h.closeButton},f.container);e.addEvent(l,"click",function(){b.blur()})}d&&(b.value=f.getSelected());
-d=f.container;var j=!1;d.style.display="none";e.addClassName(d,h.positioned);e.addEvent(d,"mousedown",function(){j=true});e.addEvent(window.document,"mousedown",function(){j=false});e.addEvent(b,"focus",function(){f.setSelected(this.value);f.show()});e.addEvent(b,"blur",function(){if(j){j=false;b.focus()}else f.hide()});e.addEvent(b,"keyup",function(){f.setSelected(this.value)});f.subscribe("change",function(){b.value=f.getSelected()})};o.Input.prototype=e.merge(o.prototype,{defaults:e.merge(o.prototype.defaults,
-{format:"MM/DD/YYYY",side:"bottom",closeButton:!0,offsetLeft:0,offsetTop:0}),classes:e.merge(o.prototype.classes,{positioned:"k-floating",closeButton:"k-btn-close"}),show:function(){var a=this.container,c=a.style,b=this.input,d=e.getPosition(b);c.display="";switch(opts.side){case "left":c.left=d.left-e.getWidth(a)+this.settings.offsetLeft+"px";c.top=d.top+this.settings.offsetTop+"px";break;case "right":c.left=d.left+e.getWidth(b)+"px";c.top=d.top+this.settings.offsetTop+"px";break;case "top":c.left=
-d.left+this.settings.offsetLeft+"px";c.top=d.top-e.getHeight(a)+this.settings.offsetTop+"px";break;default:c.left=d.left+this.settings.offsetLeft+"px",c.top=d.top+e.getHeight(b)+this.settings.offsetTop+"px"}c.position=e.isFixed(b)?"fixed":"absolute"},hide:function(){this.container.style.display="none"}});var A=function(a){a||(a=this);var c=a.c_||{};a.publish=function(a,d,f){for(var e=(a=c[a])?a.length:0,h;e--;)if(h=a[e].apply(d,f||[]),"boolean"===typeof h)return h};a.subscribe=function(a,d,e){c[a]||
-(c[a]=[]);e?c[a].push(d):c[a].unshift(d);return[a,d]};a.unsubscribe=function(a){for(var d=c[a[0]],a=a[1],e=d?d.length:0;e--;)d[e]===a&&d.splice(e,1)}},h=o.moment=function(a,c){function b(a){this._d=a}function d(a,b){for(var c=a+"";c.length<b;)c="0"+c;return c}function e(b,c,d,f){var g="string"===typeof c,n=g?{}:c;g&&f&&(n[c]=f);c=(n.ms||n.milliseconds||0)+1E3*(n.s||n.seconds||0)+6E4*(n.m||n.minutes||0)+36E5*(n.h||n.hours||0);f=(n.d||n.days||0)+7*(n.w||n.weeks||0);n=(n.M||n.months||0)+12*(n.y||n.years||
-0);c&&b.setTime(+b+c*d);f&&b.setDate(b.getDate()+f*d);n&&(c=b.getDate(),b.setDate(1),b.setMonth(b.getMonth()+n*d),b.setDate(Math.min((new a(b.getFullYear(),b.getMonth()+1,0)).getDate(),c)));return b}function h(b){return new a(b[0],b[1]||0,b[2]||1,b[3]||0,b[4]||0,b[5]||0,b[6]||0)}function o(c,e){function f(b){var e;switch(b){case "M":return h+1;case "Mo":return h+1+l(h+1);case "MM":return d(h+1,2);case "MMM":return g.monthsShort[h];case "MMMM":return g.months[h];case "D":return n;case "Do":return n+
-l(n);case "DD":return d(n,2);case "DDD":return b=new a(k,h,n),e=new a(k,0,1),~~((b-e)/864E5+1.5);case "DDDo":return b=f("DDD"),b+l(b);case "DDDD":return d(f("DDD"),3);case "d":return r;case "do":return r+l(r);case "ddd":return g.weekdaysShort[r];case "dddd":return g.weekdays[r];case "w":return b=new a(k,h,n-r+5),e=new a(b.getFullYear(),0,4),~~((b-e)/864E5/7+1.5);case "wo":return b=f("w"),b+l(b);case "ww":return d(f("w"),2);case "YY":return d(k%100,2);case "YYYY":return k;case "a":return 11<w?j.pm:
-j.am;case "A":return 11<w?j.PM:j.AM;case "H":return w;case "HH":return d(w,2);case "h":return w%12||12;case "hh":return d(w%12||12,2);case "m":return m;case "mm":return d(m,2);case "s":return D;case "ss":return d(D,2);case "zz":case "z":return(c.toString().match(F)||[""])[0].replace(E,"");case "Z":return(0<t?"+":"-")+d(~~(Math.abs(t)/60),2)+":"+d(~~(Math.abs(t)%60),2);case "ZZ":return(0<t?"+":"-")+d(~~(10*Math.abs(t)/6),4);case "L":case "LL":case "LLL":case "LLLL":case "LT":return o(c,g.longDateFormat[b]);
-default:return b.replace(/(^\[)|(\\)|\]$/g,"")}}var s=new b(c),h=s.month(),n=s.date(),k=s.year(),r=s.day(),w=s.hours(),m=s.minutes(),D=s.seconds(),t=s.zone(),l=g.ordinal,j=g.meridiem;return e.replace(A,f)}function j(b,c){var d=[0,0,1,0,0,0,0],e=0,f=0,n=!1,k=b.match(B),r=c.match(G),o,l;for(o=0;o<r.length;o++){var j=k[o],m=void 0;switch(r[o]){case "M":case "MM":d[1]=~~j-1;break;case "MMM":case "MMMM":for(m=0;12>m;m++)if(g.monthsParse[m].test(j)){d[1]=m;break}break;case "D":case "DD":case "DDD":case "DDDD":d[2]=
-~~j;break;case "YY":j=~~j;d[0]=j+(70<j?1900:2E3);break;case "YYYY":d[0]=~~Math.abs(j);break;case "a":case "A":l="pm"===j.toLowerCase();break;case "H":case "HH":case "h":case "hh":d[3]=~~j;break;case "m":case "mm":d[4]=~~j;break;case "s":case "ss":d[5]=~~j;break;case "Z":case "ZZ":n=!0,m=j.match(H),m[1]&&(e=~~m[1]),m[2]&&(f=~~m[2]),"-"===m[0]&&(e=-e,f=-f)}}l&&12>d[3]&&(d[3]+=12);!1===l&&12===d[3]&&(d[3]=0);d[3]+=e;d[4]+=f;return n?new a(a.UTC.apply({},d)):h(d)}function m(a,b,c){var d=g.relativeTime[a];
-return"function"===typeof d?d(b||1,!!c,a):d.replace(/%d/i,b||1)}function p(a,b){g.fn[a]=function(a){return"undefined"!==typeof a?(this._d["set"+b](a),this):this._d["get"+b]()}}var g,k=Math.round,l={},z="undefined"!==typeof module,u="months,monthsShort,monthsParse,weekdays,weekdaysShort,longDateFormat,calendar,relativeTime,ordinal,meridiem".split(","),v,A=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?|ZZ?|LT|LL?L?L?)/g,E=/[^A-Z]/g,F=/\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g,
-G=/(\\)?(MM?M?M?|dd?d?d|DD?D?D?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|ZZ?|T)/g,B=/(\\)?([0-9]+|([a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+|([\+\-]\d\d:?\d\d))/gi,H=/([\+\-]|\d\d)/gi,C="Month,Date,Hours,Minutes,Seconds,Milliseconds".split(",");g=function(d,e){if(null===d)return null;var f;if(d&&d._d instanceof a)f=new a(+d._d);else if(e)if("[object Array]"===Object.prototype.toString.call(e)){var g=d.match(B),k=99,n,m,l;for(n=0;n<e.length;n++){m=j(d,e[n]);l=g;for(var p=o(m,e[n]).match(B),u=Math.min(l.length,
-p.length),v=Math.abs(l.length-p.length),t=0,x=void 0,x=0;x<u;x++)~~l[x]!==~~p[x]&&t++;l=t+v;l<k&&(k=l,f=m)}}else f=j(d,e);else f=d===c?new a:d instanceof a?d:"[object Array]"===Object.prototype.toString.call(d)?h(d):new a(d);return new b(f)};g.version="1.3.0";g.lang=function(a,b){var c,d;d=[];if(b){for(c=0;12>c;c++)d[c]=RegExp("^"+b.months[c]+"|^"+b.monthsShort[c].replace(".",""),"i");b.monthsParse=b.monthsParse||d;l[a]=b}if(l[a])for(c=0;c<u.length;c++)d=u[c],g[d]=l[a][d]||g[d];else z&&(c=require("./lang/"+
-a),g.lang(a,c))};g.lang("en",{months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(","),longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},meridiem:{AM:"AM",am:"am",PM:"PM",pm:"pm"},calendar:{sameDay:"[Today at] LT",
-nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[last] dddd [at] LT",sameElse:"L"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"}});g.fn=b.prototype={clone:function(){return g(this)},valueOf:function(){return+this._d},
-nativeDate:function(){return this._d},toString:function(){return this._d.toString()},toDate:function(){return this._d},format:function(a){return o(this._d,a)},add:function(a,b){this._d=e(this._d,a,1,b);return this},subtract:function(a,b){this._d=e(this._d,a,-1,b);return this},diff:function(a,b,c){var d=g(a),a=this._d-d._d,e=this.year()-d.year(),f=this.month()-d.month(),d=this.day()-d.day(),b="months"===b?12*e+f+d/30:"years"===b?e+f/12:"seconds"===b?a/1E3:"minutes"===b?a/6E4:"hours"===b?a/36E5:"days"===
-b?a/864E5:"weeks"===b?a/6048E5:"days"===b?a/3600:a;return c?b:k(b)},from:function(a,b){var c=this.diff(a),d=g.relativeTime,e;e=k(Math.abs(c)/1E3);var f=k(e/60),h=k(f/60),j=k(h/24),l=k(j/365);e=45>e&&["s",e]||1===f&&["m"]||45>f&&["mm",f]||1===h&&["h"]||22>h&&["hh",h]||1===j&&["d"]||25>=j&&["dd",j]||45>=j&&["M"]||345>j&&["MM",k(j/30)]||1===l&&["y"]||["yy",l];e[2]=b;e=m.apply({},e);return b?e:(0>=c?d.past:d.future).replace(/%s/i,e)},fromNow:function(a){return this.from(g(),a)},calendar:function(){var a=
-g(),a=this.diff(g([a.year(),a.month(),a.date()]),"days",!0),b=g.calendar,c=b.sameElse,a=-6>a?c:-1>a?b.lastWeek:0>a?b.lastDay:1>a?b.sameDay:2>a?b.nextDay:7>a?b.nextWeek:c;return this.format("function"===typeof a?a.apply(this):a)},isLeapYear:function(){var a=this.year();return 0===a%4&&0!==a%100||0===a%400},isDST:function(){return this.zone()!==g([this.year()]).zone()},day:function(a){var b=this._d.getDay();return"undefined"===typeof a?b:this.add({d:a-b})}};for(v=0;v<C.length;v++)p(C[v].toLowerCase(),
-C[v]);p("year","FullYear");g.fn.zone=function(){return this._d.getTimezoneOffset()};return g}(Date);h.fn.stripTime=function(){this._d=new Date(864E5*Math.floor(this._d.valueOf()/864E5));return this};h.fn.yearDay=function(a){var c=Math.floor(this._d/864E5);return"undefined"===typeof a?c:this.add({d:a-c})};l=h().stripTime();"undefined"!==typeof jQuery&&(jQuery.fn.kalendae=function(a){this.each(function(c,b){"INPUT"===b.tagName?$(b).data("kalendae",new o.Input(b,a)):$(b).data("kalendae",new o($.extend({},
-{attachTo:b},a)))});return this})})();
View
75 build/kalendae.standalone.min.js
@@ -0,0 +1,75 @@
+/********************************************************************
+ * Kalendae, a framework agnostic javascript date picker *
+ * Copyright(c) 2013 Jarvis Badgley (chipersoft@gmail.com) *
+ * http://github.com/ChiperSoft/Kalendae *
+ * Version 0.5.0 *
+ ********************************************************************/
+
+(function(ja){var w,l,r=function(a,b){if("function"===typeof document.addEventListener||d.isIE8()){var e=!1;try{e=a instanceof Element}catch(n){e=!!a&&1===e.nodeType}e||"string"===typeof a||(b=a);var f=this,g=f.classes,k=f.settings=d.merge(f.defaults,{attachTo:a},b||{}),e=f.container=d.make("div",{"class":g.container}),r=f.calendars=[],p=l().day(k.weekStart),u,v=[],m,q,B,w;m=[];var D;q=0;u=k.months;d.isIE8()&&d.addClassName(e,"ie8");for(q=7;q--;)v.push(p.format(k.columnHeaderFormat)),p.add("days",
+1);F(f);if("object"===typeof k.subscribe)for(q in k.subscribe)k.subscribe.hasOwnProperty(q)&&f.subscribe(q,k.subscribe[q]);f._sel=[];k.selected&&f.setSelected(k.selected,!1);u=k.viewStartDate?l(k.viewStartDate,k.format):0<f._sel.length?l(f._sel[0]):l();f.viewStartDate=u.date(1);(u={past:k.months-1,"today-past":k.months-1,any:2<k.months?Math.floor(k.months/2):0,"today-future":0,future:0}[this.settings.direction])&&l().month()==l(f.viewStartDate).month()&&(f.viewStartDate=l(f.viewStartDate).subtract({M:u}).date(1));
+if("function"===typeof k.blackout)f.blackout=k.blackout;else if(k.blackout){var C=z(k.blackout,k.parseSplitDelimiter,k.format);f.blackout=function(a){a=l(a).startOf("day").yearDay();if(1>a||!f._sel)return!1;for(var e=C.length;e--;)if(C[e].startOf("day").yearDay()===a)return!0;return!1}}else f.blackout=function(){return!1};f.direction=f.directions[k.direction]?f.directions[k.direction]:f.directions.any;for(u=Math.max(k.months,1);u--;){m=d.make("div",{"class":g.calendar},e);m.setAttribute("data-cal-index",
+u);1<k.months&&(u==Math.max(k.months-1,1)?d.addClassName(m,g.monthFirst):0===u?d.addClassName(m,g.monthLast):d.addClassName(m,g.monthMiddle));q=d.make("div",{"class":g.title},m);k.useYearNav||d.addClassName(q,g.disableYearNav);d.make("a",{"class":g.previousYear},q);d.make("a",{"class":g.previousMonth},q);d.make("a",{"class":g.nextYear},q);d.make("a",{"class":g.nextMonth},q);p=d.make("span",{"class":g.caption},q);B=d.make("div",{"class":g.header},m);q=0;do D=d.make("span",{},B),D.innerHTML=v[q];while(7>
+++q);B=d.make("div",{"class":g.days},m);q=0;m=[];do"week"==k.mode?(0===q%7&&(w=d.make("div",{"class":g.week+" clearfix"},B),m.push(w)),d.make("span",{},w)):m.push(d.make("span",{},B));while(42>++q);r.push({caption:p,days:m});u&&d.make("div",{"class":g.monthSeparator},e)}f.draw();d.addEvent(e,"mousedown",function(a,e){var b;if(d.hasClassName(e,g.nextMonth))f.disableNext||!1===f.publish("view-changed",f,["next-month"])||(f.viewStartDate.add("months",1),f.draw());else if(d.hasClassName(e,g.previousMonth))f.disablePreviousMonth||
+!1===f.publish("view-changed",f,["previous-month"])||(f.viewStartDate.subtract("months",1),f.draw());else if(d.hasClassName(e,g.nextYear))f.disableNext||!1===f.publish("view-changed",f,["next-year"])||(f.viewStartDate.add("years",1),f.draw());else if(d.hasClassName(e,g.previousYear))f.disablePreviousMonth||!1===f.publish("view-changed",f,["previous-year"])||(f.viewStartDate.subtract("years",1),f.draw());else if((d.hasClassName(e.parentNode,g.days)||d.hasClassName(e.parentNode,g.week))&&d.hasClassName(e,
+g.dayActive)&&(b=e.getAttribute("data-date"))){if(b=l(b,k.dayAttributeFormat).hours(12),!1!==f.publish("date-clicked",f,[b]))switch(k.mode){case "multiple":f.addSelected(b)||f.removeSelected(b);break;case "range":f.addSelected(b);break;case "week":f.weekSelected(b);break;default:f.addSelected(b)}}else d.hasClassName(e.parentNode,g.week)&&(b=e.getAttribute("data-date"))&&(b=l(b,k.dayAttributeFormat).hours(12),!1!==f.publish("date-clicked",f,[b])&&"week"==k.mode&&f.weekSelected(b));return!1});(k.attachTo=
+d.$(k.attachTo))&&k.attachTo.appendChild(e)}};r.prototype={defaults:{attachTo:null,months:1,weekStart:0,direction:"any",directionScrolling:!0,viewStartDate:null,blackout:null,selected:null,mode:"single",dayOutOfMonthClickable:!1,format:null,subscribe:null,columnHeaderFormat:"dd",titleFormat:"MMMM, YYYY",dayNumberFormat:"D",dayAttributeFormat:"YYYY-MM-DD",parseSplitDelimiter:/,\s*|\s+-\s+/,rangeDelimiter:" - ",multipleDelimiter:", ",useYearNav:!0,dateClassMap:{}},classes:{container:"kalendae",calendar:"k-calendar",
+monthFirst:"k-first-month",monthMiddle:"k-middle-month",monthLast:"k-last-month",title:"k-title",previousMonth:"k-btn-previous-month",nextMonth:"k-btn-next-month",previousYear:"k-btn-previous-year",nextYear:"k-btn-next-year",caption:"k-caption",header:"k-header",days:"k-days",week:"k-week",dayOutOfMonth:"k-out-of-month",dayInMonth:"k-in-month",dayActive:"k-active",daySelected:"k-selected",dayInRange:"k-range",dayToday:"k-today",monthSeparator:"k-separator",disablePreviousMonth:"k-disable-previous-month-btn",
+disableNextMonth:"k-disable-next-month-btn",disablePreviousYear:"k-disable-previous-year-btn",disableNextYear:"k-disable-next-year-btn",disableYearNav:"k-disable-year-nav"},disablePreviousMonth:!1,disableNextMonth:!1,disablePreviousYear:!1,disableNextYear:!1,directions:{past:function(a){return l(a).startOf("day").yearDay()>=w.yearDay()},"today-past":function(a){return l(a).startOf("day").yearDay()>w.yearDay()},any:function(a){return!1},"today-future":function(a){return l(a).startOf("day").yearDay()<
+w.yearDay()},future:function(a){return l(a).startOf("day").yearDay()<=w.yearDay()}},getSelectedAsDates:function(){for(var a=[],b=0,e=this._sel.length;b<e;b++)a.push(this._sel[b].toDate());return a},getSelectedAsText:function(a){for(var b=[],e=0,d=this._sel.length;e<d;e++)b.push(this._sel[e].format(a||this.settings.format||"YYYY-MM-DD"));return b},getSelectedRaw:function(){for(var a=[],b=0,e=this._sel.length;b<e;b++)a.push(l(this._sel[b]));return a},getSelected:function(a){a=this.getSelectedAsText(a);
+switch(this.settings.mode){case "week":case "range":return a.splice(2),a.join(this.settings.rangeDelimiter);case "multiple":return a.join(this.settings.multipleDelimiter);default:return a[0]||null}},isSelected:function(a){a=l(a).startOf("day").yearDay();if(1>a||!this._sel||1>this._sel.length)return!1;switch(this.settings.mode){case "week":case "range":var b=this._sel[0]?this._sel[0].startOf("day").yearDay():0,e=this._sel[1]?this._sel[1].startOf("day").yearDay():0;return b===a||e===a?1:b&&e?a>b&&a<
+e||b<e&&a<b&&a>e?-1:!1:0;case "multiple":for(b=this._sel.length;b--;)if(this._sel[b].startOf("day").yearDay()===a)return!0;return!1;default:return this._sel[0]&&this._sel[0].startOf("day").yearDay()===a}},setSelected:function(a,b){var e,d=z(a,this.settings.parseSplitDelimiter,this.settings.format),f=z(this.getSelected(),this.settings.parseSplitDelimiter,this.settings.format);for(e=f.length;e--;)this.removeSelected(f[e],!1);for(e=d.length;e--;)this.addSelected(d[e],!1);!1!==b&&(d[0]&&(this.viewStartDate=
+l(d[0],this.settings.format)),this.draw())},addSelected:function(a,b){a=l(a,this.settings.format).hours(12);this.settings.dayOutOfMonthClickable&&"range"!==this.settings.mode&&this.makeSelectedDateVisible(a);switch(this.settings.mode){case "multiple":if(this.isSelected(a))return!1;this._sel.push(a);break;case "range":1!==this._sel.length?this._sel=[a]:a.startOf("day").yearDay()>this._sel[0].startOf("day").yearDay()?this._sel[1]=a:this._sel=[a,this._sel[0]];break;default:this._sel=[a]}this._sel.sort(function(a,
+b){return a.startOf("day").yearDay()-b.startOf("day").yearDay()});this.publish("change",this,[a]);!1!==b&&this.draw();return!0},weekSelected:function(a){var b=a.toDate(),e=l(b).startOf("week"),b=l(b).endOf("week").subtract("day",1);this._sel=[e,b];this.publish("change",this,[a.day()]);this.draw()},makeSelectedDateVisible:function(a){outOfViewMonth=l(a).date("1").diff(this.viewStartDate,"months");0>outOfViewMonth?this.viewStartDate.subtract("months",1):0<outOfViewMonth&&outOfViewMonth>=this.settings.months&&
+this.viewStartDate.add("months",1)},removeSelected:function(a,b){a=l(a,this.settings.format).hours(12);for(var e=this._sel.length;e--;)if(this._sel[e].startOf("day").yearDay()===a.startOf("day").yearDay())return this._sel.splice(e,1),this.publish("change",this,[a]),!1!==b&&this.draw(),!0;return!1},draw:function(){var a=l(this.viewStartDate).startOf("day").hours(12),b,e=this.classes,n,f,g,k=0,r,p=0,u,v,m=this.settings;r=this.calendars.length;do{b=l(a).date(1);b.day(b.day()<this.settings.weekStart?
+this.settings.weekStart-7:this.settings.weekStart);n=this.calendars[k];n.caption.innerHTML=a.format(this.settings.titleFormat);u=p=0;do"week"==m.mode?(0===p%7&&0!==p&&u++,f=n.days[u].childNodes[p%7]):f=n.days[p],g=[],(v=this.isSelected(b))&&g.push({"-1":e.dayInRange,1:e.daySelected,"true":e.daySelected}[v]),b.month()!=a.month()?g.push(e.dayOutOfMonth):g.push(e.dayInMonth),(!(this.blackout(b)||this.direction(b)||b.month()!=a.month()&&!1===m.dayOutOfMonthClickable)||0<v)&&g.push(e.dayActive),b.startOf("day").yearDay()===
+w.yearDay()&&g.push(e.dayToday),v=b.format(this.settings.dayAttributeFormat),m.dateClassMap[v]&&g.push(m.dateClassMap[v]),f.innerHTML=b.format(m.dayNumberFormat),f.className=g.join(" "),f.setAttribute("data-date",v),b.add("days",1);while(42>++p);a.add("months",1)}while(++k<r);if(m.directionScrolling){b=l().startOf("day").hours(12);a=a.diff(b,"months",!0);if("today-past"===m.direction||"past"===m.direction)0>=a?(this.disableNextMonth=!1,d.removeClassName(this.container,e.disableNextMonth)):(this.disableNextMonth=
+!0,d.addClassName(this.container,e.disableNextMonth));else if("today-future"===m.direction||"future"===m.direction)a>m.months?(this.disablePreviousMonth=!1,d.removeClassName(this.container,e.disablePreviousMonth)):(this.disablePreviousMonth=!0,d.addClassName(this.container,e.disablePreviousMonth));if("today-past"===m.direction||"past"===m.direction)-11>=a?(this.disableNextYear=!1,d.removeClassName(this.container,e.disableNextYear)):(this.disableNextYear=!0,d.addClassName(this.container,e.disableNextYear));
+else if("today-future"===m.direction||"future"===m.direction)a>11+m.months?(this.disablePreviousYear=!1,d.removeClassName(this.container,e.disablePreviousYear)):(this.disablePreviousYear=!0,d.addClassName(this.container,e.disablePreviousYear))}}};var z=function(a,b,e){var n=[];"string"===typeof a?a=a.split(b):d.isArray(a)||(a=[a]);b=a.length;var f=0,g;do a[f]&&(g=l(a[f],e).hours(12),g.isValid()&&n.push(g));while(++f<b);return n};window.Kalendae=r;var d=r.util={isIE8:function(){return!(!/msie 8./i.test(navigator.appVersion)||
+/opera/i.test(navigator.userAgent)||!window.ActiveXObject||!XDomainRequest||window.msPerformance)},$:function(a){return"string"==typeof a?document.getElementById(a):a},$$:function(a){return document.querySelectorAll(a)},make:function(a,b,e){var d;a=document.createElement(a);if(b)for(d in b)b.hasOwnProperty(d)&&a.setAttribute(d,b[d]);e&&e.appendChild(a);return a},isVisible:function(a){return 0<a.offsetWidth||0<a.offsetHeight},getStyle:function(a,b){var e;a.currentStyle?e=a.currentStyle[b]:window.getComputedStyle&&
+(e=(e=window.getComputedStyle(a,null))?e[b]:"");return e},domReady:function(a){var b=document.readyState;"complete"===b||"interactive"===b?a():setTimeout(function(){d.domReady(a)},9)},addEvent:function(a,b,e){var d=function(b){b=b||window.event;var d=e.apply(a,[b,b.target||b.srcElement]);!1===d&&(b.preventDefault?b.preventDefault():(b.returnValue=!1,b.cancelBubble=!0));return d};a.attachEvent?a.attachEvent("on"+b,d):a.addEventListener(b,d,!1);return d},removeEvent:function(a,b,e){a.detachEvent?a.detachEvent("on"+
+b,e):a.removeEventListener(b,e,!1)},fireEvent:function(a,b){if(document.createEvent){var e=document.createEvent("HTMLEvents");e.initEvent(b,!1,!0);a.dispatchEvent(e)}else if(document.createEventObject)a.fireEvent("on"+b);else if("function"==typeof a["on"+b])a["on"+b]()},hasClassName:function(a,b){if(!(a=d.$(a)))return!1;var e=a.className;return 0<e.length&&(e==b||RegExp("(^|\\s)"+b+"(\\s|$)").test(e))},addClassName:function(a,b){(a=d.$(a))&&!d.hasClassName(a,b)&&(a.className+=(a.className?" ":"")+
+b)},removeClassName:function(a,b){if(a=d.$(a))a.className=d.trimString(a.className.replace(RegExp("(^|\\s+)"+b+"(\\s+|$)")," "))},isFixed:function(a){do if("fixed"===d.getStyle(a,"position"))return!0;while(a=a.offsetParent);return!1},scrollContainer:function(a){do{var b=d.getStyle(a,"overflow");if("auto"===b||"scroll"===b)return a}while((a=a.parentNode)&&a!=window.document.body);return null},getPosition:function(a,b){var e=a.offsetLeft,d=a.offsetTop,f={};if(!b)for(;a=a.offsetParent;)e+=a.offsetLeft,
+d+=a.offsetTop;f[0]=f.left=e;f[1]=f.top=d;return f},getHeight:function(a){return a.offsetHeight||a.scrollHeight},getWidth:function(a){return a.offsetWidth||a.scrollWidth},trimString:function(a){return a.replace(/^\s+/,"").replace(/\s+$/,"")},merge:function(){for(var a=!0===arguments[0],b={},e=a?1:0;e<arguments.length;e++){var d=b,f=arguments[e];if("object"===typeof f){var g=void 0;for(g in f)f.hasOwnProperty(g)&&(a&&"object"===typeof d[g]&&"object"===typeof f[g]?_update(d[g],f[g]):d[g]=f[g])}}return b},
+isArray:function(a){return"[object Array]"==Object.prototype.toString.call(a)}};"function"===typeof document.addEventListener&&r.util.domReady(function(){for(var a=d.$$(".auto-kal"),b=a.length,e,n;b--;)e=a[b],n=e.getAttribute("data-kal"),n=null==n||""==n?{}:(new Function("return {"+n+"};"))(),"INPUT"===e.tagName?new r.Input(e,n):new r(d.merge(n,{attachTo:e}))});r.Input=function(a,b){if("function"===typeof document.addEventListener||d.isIE8()){var e=this.input=d.$(a),n,f,g=!1;if(!e||"INPUT"!==e.tagName)throw"First argument for Kalendae.Input must be an <input> element or a valid element id.";
+var k=this,l=k.classes;f=k.settings=d.merge(k.defaults,b);this._events={};f.attachTo=window.document.body;f.selected?n=!0:f.selected=e.value;r.call(k,f);f.closeButton&&(f=d.make("a",{"class":l.closeButton},k.container),d.addEvent(f,"click",function(){e.blur()}));n&&(e.value=k.getSelected());n=k.container;var p=!1;n.style.display="none";d.addClassName(n,l.positioned);this._events.containerMouseDown=d.addEvent(n,"mousedown",function(a,b){p=!0});this._events.documentMousedown=d.addEvent(window.document,
+"mousedown",function(a,b){p=!1});this._events.inputFocus=d.addEvent(e,"focus",function(){g=!0;k.setSelected(this.value);g=!1;k.show()});this._events.inputBlur=d.addEvent(e,"blur",function(){p&&d.isIE8()?(p=!1,e.focus()):k.hide()});this._events.inputKeyup=d.addEvent(e,"keyup",function(a){g=!0;k.setSelected(this.value);g=!1});(l=d.scrollContainer(e))&&d.addEvent(l,"scroll",function(a){e.blur()});k.subscribe("change",function(){g||(e.value=k.getSelected(),d.fireEvent(e,"change"))})}};r.Input.prototype=
+d.merge(r.prototype,{defaults:d.merge(r.prototype.defaults,{format:"MM/DD/YYYY",side:"bottom",closeButton:!0,offsetLeft:0,offsetTop:0}),classes:d.merge(r.prototype.classes,{positioned:"k-floating",closeButton:"k-btn-close"}),show:function(){var a=this.container,b=a.style,e=this.input,n=d.getPosition(e),f=d.scrollContainer(e),f=f?f.scrollTop:0,g=this.settings;b.display="";switch(g.side){case "left":b.left=n.left-d.getWidth(a)+g.offsetLeft+"px";b.top=n.top+g.offsetTop-f+"px";break;case "right":b.left=
+n.left+d.getWidth(e)+"px";b.top=n.top+g.offsetTop-f+"px";break;case "top":b.left=n.left+g.offsetLeft+"px";b.top=n.top-d.getHeight(a)+g.offsetTop-f+"px";break;default:b.left=n.left+g.offsetLeft+"px",b.top=n.top+d.getHeight(e)+g.offsetTop-f+"px"}b.position=d.isFixed(e)?"fixed":"absolute";this.publish("show",this)},hide:function(){this.container.style.display="none";this.publish("hide",this)},destroy:function(){var a=this.container,b=this.input;d.removeEvent(a,"mousedown",this._events.containerMousedown);
+d.removeEvent(window.document,"mousedown",this._events.documentMousedown);d.removeEvent(b,"focus",this._events.inputFocus);d.removeEvent(b,"blur",this._events.inputBlur);d.removeEvent(b,"keyup",this._events.inputKeyup);a.remove()}});var F=function(a){a||(a=this);var b=a.c_||{};a.publish=function(a,d,f){for(var g=(a=b[a])?a.length:0,k;g--;)if(k=a[g].apply(d,f||[]),"boolean"===typeof k)return k};a.subscribe=function(a,d,f){b[a]||(b[a]=[]);f?b[a].push(d):b[a].unshift(d);return[a,d]};a.unsubscribe=function(a){var d=
+b[a[0]];a=a[1];for(var f=d?d.length:0;f--;)d[f]===a&&d.splice(f,1)}};(function(a){function b(c,s){return function(a){return p(c.call(this,a),s)}}function e(c,s){return function(a){return this.lang().ordinal(c.call(this,a),s)}}function d(){}function f(c){k(this,c)}function g(c){var s=c.years||c.year||c.y||0,a=c.months||c.month||c.M||0,b=c.weeks||c.week||c.w||0,e=c.days||c.day||c.d||0,d=c.hours||c.hour||c.h||0,f=c.minutes||c.minute||c.m||0,h=c.seconds||c.second||c.s||0,g=c.milliseconds||c.millisecond||
+c.ms||0;this._input=c;this._milliseconds=g+1E3*h+6E4*f+36E5*d;this._days=e+7*b;this._months=a+12*s;this._data={};this._bubble()}function k(c,s){for(var a in s)s.hasOwnProperty(a)&&(c[a]=s[a]);return c}function l(c){return 0>c?Math.ceil(c):Math.floor(c)}function p(c,s){for(var a=c+"";a.length<s;)a="0"+a;return a}function r(c,s,a,b){var e=s._milliseconds,d=s._days;s=s._months;var f,g;e&&c._d.setTime(+c._d+e*a);if(d||s)f=c.minute(),g=c.hour();d&&c.date(c.date()+d*a);s&&c.month(c.month()+s*a);e&&!b&&
+h.updateOffset(c);if(d||s)c.minute(f),c.hour(g)}function v(c,s){var a=Math.min(c.length,s.length),b=Math.abs(c.length-s.length),e=0,d;for(d=0;d<a;d++)~~c[d]!==~~s[d]&&e++;return e+b}function m(c){return c?V[c]||c.toLowerCase().replace(/(.)s$/,"$1"):c}function q(c){if(!c)return h.fn._lang;if(!A[c]&&M)try{require("./lang/"+c)}catch(a){return h.fn._lang}return A[c]}function w(c){var a=c.match(N),b,e;b=0;for(e=a.length;b<e;b++)a[b]=x[a[b]]?x[a[b]]:a[b].match(/\[.*\]/)?a[b].replace(/^\[|\]$/g,""):a[b].replace(/\\/g,
+"");return function(d){var f="";for(b=0;b<e;b++)f+=a[b]instanceof Function?a[b].call(d,c):a[b];return f}}function z(c,a){function b(a){return c.lang().longDateFormat(a)||a}for(var e=5;e--&&O.test(a);)a=a.replace(O,b);H[a]||(H[a]=w(a));return H[a](c)}function D(c,a){switch(c){case "DDDD":return W;case "YYYY":return X;case "YYYYY":return Y;case "S":case "SS":case "SSS":case "DDD":return Z;case "MMM":case "MMMM":case "dd":case "ddd":case "dddd":return aa;case "a":case "A":return q(a._l)._meridiemParse;
+case "X":return ba;case "Z":case "ZZ":return I;case "T":return ca;case "MM":case "DD":case "YY":case "HH":case "hh":case "mm":case "ss":case "M":case "D":case "d":case "H":case "h":case "m":case "s":return da;default:return RegExp(c.replace("\\",""))}}function C(c){c=((I.exec(c)||[])[0]+"").match(ea)||["-",0,0];var a=+(60*c[1])+~~c[2];return"+"===c[0]?-a:a}function L(c){var a,b=[];if(!c._d){for(a=0;7>a;a++)c._a[a]=b[a]=null==c._a[a]?2===a?1:0:c._a[a];b[3]+=~~((c._tzm||0)/60);b[4]+=~~((c._tzm||0)%
+60);a=new Date(0);c._useUTC?(a.setUTCFullYear(b[0],b[1],b[2]),a.setUTCHours(b[3],b[4],b[5],b[6])):(a.setFullYear(b[0],b[1],b[2]),a.setHours(b[3],b[4],b[5],b[6]));c._d=a}}function G(c){var a=c._f.match(N),b=c._i,e,d;c._a=[];for(e=0;e<a.length;e++)if((d=(D(a[e],c).exec(b)||[])[0])&&(b=b.slice(b.indexOf(d)+d.length)),x[a[e]]){var f=c,h=void 0,g=f._a;switch(a[e]){case "M":case "MM":g[1]=null==d?0:~~d-1;break;case "MMM":case "MMMM":h=q(f._l).monthsParse(d);null!=h?g[1]=h:f._isValid=!1;break;case "D":case "DD":case "DDD":case "DDDD":null!=
+d&&(g[2]=~~d);break;case "YY":g[0]=~~d+(68<~~d?1900:2E3);break;case "YYYY":case "YYYYY":g[0]=~~d;break;case "a":case "A":f._isPm=q(f._l).isPM(d);break;case "H":case "HH":case "h":case "hh":g[3]=~~d;break;case "m":case "mm":g[4]=~~d;break;case "s":case "ss":g[5]=~~d;break;case "S":case "SS":case "SSS":g[6]=~~(1E3*("0."+d));break;case "X":f._d=new Date(1E3*parseFloat(d));break;case "Z":case "ZZ":f._useUTC=!0,f._tzm=C(d)}null==d&&(f._isValid=!1)}b&&(c._il=b);c._isPm&&12>c._a[3]&&(c._a[3]+=12);!1===c._isPm&&
+12===c._a[3]&&(c._a[3]=0);L(c)}function F(c,a,b,d,e){return e.relativeTime(a||1,!!b,c,d)}function E(c,a,b){a=b-a;b-=c.day();b>a&&(b-=7);b<a-7&&(b+=7);c=h(c).add("d",b);return{week:Math.ceil(c.dayOfYear()/7),year:c.year()}}function P(c){var b=c._i,d=c._f;if(null===b||""===b)return null;"string"===typeof b&&(c._i=b=q().preparse(b));if(h.isMoment(b))c=k({},b),c._d=new Date(+b._d);else if(d)if("[object Array]"===Object.prototype.toString.call(d)){var b=c,e,g,l=99,m;for(m=0;m<b._f.length;m++)e=k({},b),
+e._f=b._f[m],G(e),d=new f(e),e=v(e._a,d.toArray()),d._il&&(e+=d._il.length),e<l&&(l=e,g=d);k(b,g)}else G(c);else if(g=c,b=g._i,d=fa.exec(b),b===a)g._d=new Date;else if(d)g._d=new Date(+d[1]);else if("string"===typeof b)if(b=g._i,d=ga.exec(b)){g._f="YYYY-MM-DD"+(d[2]||" ");for(d=0;4>d;d++)if(Q[d][1].exec(b)){g._f+=Q[d][0];break}I.exec(b)&&(g._f+=" Z");G(g)}else g._d=new Date(b);else"[object Array]"===Object.prototype.toString.call(b)?(g._a=b.slice(0),L(g)):g._d=b instanceof Date?new Date(+b):new Date(b);
+return new f(c)}function R(c,a){h.fn[c]=h.fn[c+"s"]=function(c){var b=this._isUTC?"UTC":"";return null!=c?(this._d["set"+b+a](c),h.updateOffset(this),this):this._d["get"+b+a]()}}function ha(c){h.duration.fn[c]=function(){return this._data[c]}}function S(c,a){h.duration.fn["as"+c]=function(){return+this/a}}for(var h,y=Math.round,t,A={},M="undefined"!==typeof module&&module.exports,fa=/^\/?Date\((\-?\d+)/i,ia=/(\-)?(\d*)?\.?(\d+)\:(\d+)\:(\d+)\.?(\d{3})?/,N=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/g,
+O=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,da=/\d\d?/,Z=/\d{1,3}/,W=/\d{3}/,X=/\d{1,4}/,Y=/[+\-]?\d{1,6}/,aa=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,I=/Z|[\+\-]\d\d:?\d\d/i,ca=/T/i,ba=/[\+\-]?\d+(\.\d{1,3})?/,ga=/^\s*\d{4}-\d\d-\d\d((T| )(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,Q=[["HH:mm:ss.S",/(T| )\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],
+ea=/([\+\-]|\d\d)/gi,J=["Date","Hours","Minutes","Seconds","Milliseconds"],K={Milliseconds:1,Seconds:1E3,Minutes:6E4,Hours:36E5,Days:864E5,Months:2592E6,Years:31536E6},V={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",w:"week",M:"month",y:"year"},H={},T="DDD w W M D d".split(" "),U="MDHhmswW".split(""),x={M:function(){return this.month()+1},MMM:function(c){return this.lang().monthsShort(this,c)},MMMM:function(c){return this.lang().months(this,c)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},
+d:function(){return this.day()},dd:function(c){return this.lang().weekdaysMin(this,c)},ddd:function(c){return this.lang().weekdaysShort(this,c)},dddd:function(c){return this.lang().weekdays(this,c)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return p(this.year()%100,2)},YYYY:function(){return p(this.year(),4)},YYYYY:function(){return p(this.year(),5)},gg:function(){return p(this.weekYear()%100,2)},gggg:function(){return this.weekYear()},ggggg:function(){return p(this.weekYear(),
+5)},GG:function(){return p(this.isoWeekYear()%100,2)},GGGG:function(){return this.isoWeekYear()},GGGGG:function(){return p(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},
+S:function(){return~~(this.milliseconds()/100)},SS:function(){return p(~~(this.milliseconds()/10),2)},SSS:function(){return p(this.milliseconds(),3)},Z:function(){var c=-this.zone(),a="+";0>c&&(c=-c,a="-");return a+p(~~(c/60),2)+":"+p(~~c%60,2)},ZZ:function(){var c=-this.zone(),a="+";0>c&&(c=-c,a="-");return a+p(~~(10*c/6),4)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()}};T.length;)t=T.pop(),x[t+"o"]=e(x[t],t);for(;U.length;)t=U.pop(),
+x[t+t]=b(x[t],2);x.DDDD=b(x.DDD,3);d.prototype={set:function(c){var a,b;for(b in c)a=c[b],"function"===typeof a?this[b]=a:this["_"+b]=a},_months:"January February March April May June July August September October November December".split(" "),months:function(c){return this._months[c.month()]},_monthsShort:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),monthsShort:function(c){return this._monthsShort[c.month()]},monthsParse:function(c){var a,b;this._monthsParse||(this._monthsParse=[]);
+for(a=0;12>a;a++)if(this._monthsParse[a]||(b=h([2E3,a]),b="^"+this.months(b,"")+"|^"+this.monthsShort(b,""),this._monthsParse[a]=RegExp(b.replace(".",""),"i")),this._monthsParse[a].test(c))return a},_weekdays:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),weekdays:function(c){return this._weekdays[c.day()]},_weekdaysShort:"Sun Mon Tue Wed Thu Fri Sat".split(" "),weekdaysShort:function(c){return this._weekdaysShort[c.day()]},_weekdaysMin:"Su Mo Tu We Th Fr Sa".split(" "),weekdaysMin:function(c){return this._weekdaysMin[c.day()]},
+weekdaysParse:function(c){var a,b;this._weekdaysParse||(this._weekdaysParse=[]);for(a=0;7>a;a++)if(this._weekdaysParse[a]||(b=h([2E3,1]).day(a),b="^"+this.weekdays(b,"")+"|^"+this.weekdaysShort(b,"")+"|^"+this.weekdaysMin(b,""),this._weekdaysParse[a]=RegExp(b.replace(".",""),"i")),this._weekdaysParse[a].test(c))return a},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},longDateFormat:function(c){var a=this._longDateFormat[c];!a&&this._longDateFormat[c.toUpperCase()]&&
+(a=this._longDateFormat[c.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(c){return c.slice(1)}),this._longDateFormat[c]=a);return a},isPM:function(c){return"p"===(c+"").toLowerCase()[0]},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(c,a,b){return 11<c?b?"pm":"PM":b?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(c,a){var b=this._calendar[c];return"function"===
+typeof b?b.apply(a):b},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(c,a,b,d){var e=this._relativeTime[b];return"function"===typeof e?e(c,a,b,d):e.replace(/%d/i,c)},pastFuture:function(c,a){var b=this._relativeTime[0<c?"future":"past"];return"function"===typeof b?b(a):b.replace(/%s/i,a)},ordinal:function(c){return this._ordinal.replace("%d",
+c)},_ordinal:"%d",preparse:function(c){return c},postformat:function(c){return c},week:function(c){return E(c,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6}};h=function(c,a,b){return P({_i:c,_f:a,_l:b,_isUTC:!1})};h.utc=function(c,a,b){return P({_useUTC:!0,_isUTC:!0,_l:b,_i:c,_f:a})};h.unix=function(c){return h(1E3*c)};h.duration=function(c,a){var b=h.isDuration(c),d="number"===typeof c,e=b?c._input:d?{}:c,f=ia.exec(c);d?a?e[a]=c:e.milliseconds=c:f&&(d="-"===f[1]?-1:1,e={y:0,d:~~f[2]*d,
+h:~~f[3]*d,m:~~f[4]*d,s:~~f[5]*d,ms:~~f[6]*d});f=new g(e);b&&c.hasOwnProperty("_lang")&&(f._lang=c._lang);return f};h.version="2.1.0";h.defaultFormat="YYYY-MM-DDTHH:mm:ssZ";h.updateOffset=function(){};h.lang=function(c,a){if(!c)return h.fn._lang._abbr;a?(a.abbr=c,A[c]||(A[c]=new d),A[c].set(a)):A[c]||q(c);h.duration.fn._lang=h.fn._lang=q(c)};h.langData=function(c){c&&c._lang&&c._lang._abbr&&(c=c._lang._abbr);return q(c)};h.isMoment=function(c){return c instanceof f};h.isDuration=function(c){return c instanceof
+g};h.fn=f.prototype={clone:function(){return h(this)},valueOf:function(){return+this._d+6E4*(this._offset||0)},unix:function(){return Math.floor(+this/1E3)},toString:function(){return this.format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){return z(h(this).utc(),"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},toArray:function(){return[this.year(),this.month(),this.date(),this.hours(),this.minutes(),this.seconds(),this.milliseconds()]},
+isValid:function(){null==this._isValid&&(this._isValid=this._a?!v(this._a,(this._isUTC?h.utc(this._a):h(this._a)).toArray()):!isNaN(this._d.getTime()));return!!this._isValid},utc:function(){return this.zone(0)},local:function(){this.zone(0);this._isUTC=!1;return this},format:function(c){c=z(this,c||h.defaultFormat);return this.lang().postformat(c)},add:function(c,a){var b;b="string"===typeof c?h.duration(+a,c):h.duration(c,a);r(this,b,1);return this},subtract:function(c,a){var b;b="string"===typeof c?
+h.duration(+a,c):h.duration(c,a);r(this,b,-1);return this},diff:function(c,a,b){c=this._isUTC?h(c).zone(this._offset||0):h(c).local();var d=6E4*(this.zone()-c.zone()),e;a=m(a);"year"===a||"month"===a?(e=432E5*(this.daysInMonth()+c.daysInMonth()),d=12*(this.year()-c.year())+(this.month()-c.month()),d+=(this-h(this).startOf("month")-(c-h(c).startOf("month")))/e,d-=6E4*(this.zone()-h(this).startOf("month").zone()-(c.zone()-h(c).startOf("month").zone()))/e,"year"===a&&(d/=12)):(e=this-c,d="second"===
+a?e/1E3:"minute"===a?e/6E4:"hour"===a?e/36E5:"day"===a?(e-d)/864E5:"week"===a?(e-d)/6048E5:e);return b?d:l(d)},from:function(c,a){return h.duration(this.diff(c)).lang(this.lang()._abbr).humanize(!a)},fromNow:function(c){return this.from(h(),c)},calendar:function(){var c=this.diff(h().startOf("day"),"days",!0),c=-6>c?"sameElse":-1>c?"lastWeek":0>c?"lastDay":1>c?"sameDay":2>c?"nextDay":7>c?"nextWeek":"sameElse";return this.format(this.lang().calendar(c,this))},isLeapYear:function(){var c=this.year();
+return 0===c%4&&0!==c%100||0===c%400},isDST:function(){return this.zone()<this.clone().month(0).zone()||this.zone()<this.clone().month(5).zone()},day:function(c){var a=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=c?"string"===typeof c&&(c=this.lang().weekdaysParse(c),"number"!==typeof c)?this:this.add({d:c-a}):a},month:function(a){var b=this._isUTC?"UTC":"",d;if(null!=a){if("string"===typeof a&&(a=this.lang().monthsParse(a),"number"!==typeof a))return this;d=this.date();this.date(1);
+this._d["set"+b+"Month"](a);this.date(Math.min(d,this.daysInMonth()));h.updateOffset(this);return this}return this._d["get"+b+"Month"]()},startOf:function(a){a=m(a);switch(a){case "year":this.month(0);case "month":this.date(1);case "week":case "day":this.hours(0);case "hour":this.minutes(0);case "minute":this.seconds(0);case "second":this.milliseconds(0)}"week"===a&&this.weekday(0);return this},endOf:function(a){return this.startOf(a).add(a,1).subtract("ms",1)},isAfter:function(a,b){b="