marquex
2015-08-24 1f5ec14c3c4d092d45b50cb9623e28292c950003
1
2
3
4
5
6
/*
react-datetime v1.2.1
https://github.com/arqex/react-datetime
MIT: https://github.com/arqex/react-datetime/raw/master/LICENSE
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require(void 0),require(void 0)):"function"==typeof define&&define.amd?define([,],e):"object"==typeof exports?exports.Datetime=e(require(void 0),require(void 0)):t.Datetime=e(t.React,t.moment)}(this,function(t,e){return function(t){function e(n){if(s[n])return s[n].exports;var a=s[n]={exports:{},id:n,loaded:!1};return t[n].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var s={};return e.m=t,e.c=s,e.p="",e(0)}([function(t,e,s){"use strict";var n=s(3),a=s(2),r=s(4),o=s(6),i=s(1),u=s(7),c=s(5),l=a.PropTypes,p=a.createClass({mixins:[s(8)],viewComponents:{days:r,months:o,years:i,time:u},propTypes:{onBlur:l.func,onChange:l.func,locale:l.string,input:l.bool,inputProps:l.object,viewMode:l.oneOf(["years","months","days","time"]),isValidDate:l.func,minDate:l.object,maxDate:l.object},getDefaultProps:function(){var t=function(){};return{className:"",defaultValue:"",viewMode:"days",inputProps:{},input:!0,onBlur:t,onChange:t,timeFormat:!0,dateFormat:!0}},getInitialState:function(){var t=this.getStateFromProps(this.props);return t.open=!this.props.input,t.currentView=this.props.dateFormat?this.props.viewMode:"time",t},getStateFromProps:function(t){var e,s,n=this.getFormats(t),a=t.value||t.defaultValue;return a&&"string"==typeof a?e=this.localMoment(a,n.datetime):a&&(e=this.localMoment(a)),e&&!e.isValid()&&(e=null),s=e?e.clone().startOf("month"):this.localMoment().startOf("month"),{inputFormat:n.datetime,viewDate:s,selectedDate:e,inputValue:e?e.format(n.datetime):a||""}},getFormats:function(t){var e={date:t.dateFormat||"",time:t.timeFormat||""},s=this.localMoment(t.date).localeData();return e.date===!0&&(e.date=s.longDateFormat("L")),e.time===!0&&(e.time=s.longDateFormat("LT")),e.datetime=e.date&&e.time?e.date+" "+e.time:e.date||e.time,e},componentWillReceiveProps:function(t){var e=this.getFormats(t),s={};t.value&&(s=this.getStateFromProps(t)),e.datetime!==this.getFormats(this.props).datetime&&(s.inputFormat=e.datetime),this.setState(s)},onInputChange:function(t){var e=null==t.target?t:t.target.value,s=this.localMoment(e,this.state.inputFormat),n={inputValue:e};return s.isValid()&&!this.props.value?(n.selectedDate=s,n.viewDate=s.clone().startOf("month")):n.selectedDate=null,this.setState(n,function(){return this.props.onChange(s.isValid()?s:this.state.inputValue)})},showView:function(t){var e=this;return function(s){e.setState({currentView:t})}},setDate:function(t){var e=this,s={month:"days",year:"months"};return function(n){e.setState({viewDate:e.state.viewDate.clone()[t](parseInt(n.target.getAttribute("data-value"))).startOf(t),currentView:s[t]})}},addTime:function(t,e,s){return this.updateTime("add",t,e,s)},subtractTime:function(t,e,s){return this.updateTime("subtract",t,e,s)},updateTime:function(t,e,s,n){var a=this;return function(){var r={},o=n?"selectedDate":"viewDate";r[o]=a.state[o].clone()[t](e,s),a.setState(r)}},allowedSetTime:["hours","minutes","seconds","milliseconds"],setTime:function(t,e){var s,n=this.allowedSetTime.indexOf(t)+1,a=this.state,r=(a.selectedDate||a.viewDate).clone();for(r[t](e);n<this.allowedSetTime.length;n++)s=this.allowedSetTime[n],r[s](r[s]());this.props.value||this.setState({selectedDate:r,inputValue:r.format(a.inputFormat)}),this.props.onChange(r)},updateSelectedDate:function(t){var e,s=t.target,n=0,a=this.state.viewDate,r=this.state.selectedDate||a;-1!=s.className.indexOf("new")?n=1:-1!=s.className.indexOf("old")&&(n=-1),e=a.clone().month(a.month()+n).date(parseInt(s.getAttribute("data-value"))).hours(r.hours()).minutes(r.minutes()).seconds(r.seconds()).milliseconds(r.milliseconds()),this.props.value||this.setState({selectedDate:e,viewDate:e.clone().startOf("month"),inputValue:e.format(this.state.inputFormat)}),this.props.onChange(e)},openCalendar:function(){this.setState({open:!0})},handleClickOutside:function(){this.props.input&&this.state.open&&(this.setState({open:!1}),this.props.onBlur(this.state.selectedDate||this.state.inputValue))},localMoment:function(t,e){var s=c(t,e);return this.props.locale&&s.locale(this.props.locale),s},componentProps:{fromProps:["value","isValidDate","renderDay","renderMonth","renderYear"],fromState:["viewDate","selectedDate"],fromThis:["setDate","setTime","showView","addTime","subtractTime","updateSelectedDate","localMoment"]},getComponentProps:function(){var t=this,e=this.getFormats(this.props),s={dateFormat:e.date,timeFormat:e.time};return this.componentProps.fromProps.forEach(function(e){s[e]=t.props[e]}),this.componentProps.fromState.forEach(function(e){s[e]=t.state[e]}),this.componentProps.fromThis.forEach(function(e){s[e]=t[e]}),s},render:function(){var t=this.viewComponents[this.state.currentView],e=a.DOM,s="rdt "+this.props.className,r=[];return this.props.input?r=[e.input(n({key:"i",type:"text",className:"form-control",onFocus:this.openCalendar,onChange:this.onInputChange,value:this.state.inputValue},this.props.inputProps))]:s+=" rdtStatic",this.state.open&&(s+=" rdtOpen"),e.div({className:s},r.concat(e.div({key:"dt",className:"rdtPicker"},a.createElement(t,this.getComponentProps()))))}});p.moment=c,t.exports=p},function(t,e,s){"use strict";var n=s(2),a=n.DOM,r=n.createClass({render:function(){var t=10*parseInt(this.props.viewDate.year()/10,10);return a.div({className:"rdtYears"},[a.table({key:"a"},a.thead({},a.tr({},[a.th({key:"prev",className:"prev"},a.button({onClick:this.props.subtractTime(10,"years"),type:"button"},"‹")),a.th({key:"year",className:"switch",onClick:this.props.showView("years"),colSpan:2},t+"-"+(t+9)),a.th({key:"next",className:"next"},a.button({onClick:this.props.addTime(10,"years"),type:"button"},"›"))]))),a.table({key:"years"},a.tbody({},this.renderYears(t)))])},renderYears:function(t){var e,s,n=[],r=-1,o=[],i=this.props.renderYear||this.renderYear,u=this.props.selectedDate;for(t--;11>r;)e="year",-1===r|10===r&&(e+=" old"),u&&u.year()===t&&(e+=" active"),s={key:t,"data-value":t,className:e,onClick:this.props.setDate("year")},n.push(i(s,t,u&&u.clone())),4==n.length&&(o.push(a.tr({key:r},n)),n=[]),t++,r++;return o},renderYear:function(t,e,s){return a.td(t,e)}});t.exports=r},function(e,s){e.exports=t},function(t,e){"use strict";function s(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function n(t){var e=Object.getOwnPropertyNames(t);return Object.getOwnPropertySymbols&&(e=e.concat(Object.getOwnPropertySymbols(t))),e.filter(function(e){return a.call(t,e)})}var a=Object.prototype.propertyIsEnumerable;t.exports=Object.assign||function(t,e){for(var a,r,o=s(t),i=1;i<arguments.length;i++){a=arguments[i],r=n(Object(a));for(var u=0;u<r.length;u++)o[r[u]]=a[r[u]]}return o}},function(t,e,s){var n=s(2),a=s(5),r=n.DOM,o=n.createClass({render:function(){var t,e=this.renderFooter(),s=this.props.viewDate,n=s.localeData();return t=[r.thead({key:"th"},[r.tr({key:"h"},[r.th({key:"p",className:"prev"},r.button({onClick:this.props.subtractTime(1,"months"),type:"button"},"‹")),r.th({key:"s",className:"switch",onClick:this.props.showView("months"),colSpan:5,"data-value":this.props.viewDate.month()},n.months(s)+" "+s.year()),r.th({key:"n",className:"next"},r.button({onClick:this.props.addTime(1,"months"),type:"button"},"›"))]),r.tr({key:"d"},this.getDaysOfWeek(n).map(function(t){return r.th({key:t,className:"dow"},t)}))]),r.tbody({key:"tb"},this.renderDays())],e&&t.push(e),r.div({className:"rdtDays"},r.table({},t))},getDaysOfWeek:function(t){var e=t._weekdaysMin,s=t.firstDayOfWeek(),n=[],a=0;return e.forEach(function(t){n[(7+a++-s)%7]=t}),n},renderDays:function(){var t,e,s,n,o=this.props.viewDate,i=this.props.selectedDate&&this.props.selectedDate.clone(),u=o.clone().subtract(1,"months"),c=o.year(),l=o.month(),p=(this.props.minDate,this.props.maxDate,[]),d=[],h=this.props.renderDay||this.renderDay,m=this.props.isValidDate||this.isValidDate;u.date(u.daysInMonth()).startOf("week");for(var f=u.clone().add(42,"d");u.isBefore(f);)t="day",n=u.clone(),u.year()<c||u.month()<l?t+=" old":(u.year()>c||u.month()>l)&&(t+=" new"),i&&u.isSame({y:i.year(),M:i.month(),d:i.date()})&&(t+=" active"),u.isSame(a(),"day")&&(t+=" today"),e=!m(n,i),e&&(t+=" disabled"),s={key:u.format("M_D"),"data-value":u.date(),className:t},e||(s.onClick=this.props.updateSelectedDate),d.push(h(s,n,i)),7==d.length&&(p.push(r.tr({key:u.format("M_D")},d)),d=[]),u.add(1,"d");return p},renderDay:function(t,e,s){return r.td(t,e.date())},renderFooter:function(){if(!this.props.timeFormat)return"";var t=this.props.selectedDate||this.props.viewDate;return r.tfoot({key:"tf"},r.tr({},r.td({onClick:this.props.showView("time"),colSpan:7,className:"timeToggle"},t.format(this.props.timeFormat))))},isValidDate:function(){return 1}});t.exports=o},function(t,s){t.exports=e},function(t,e,s){"use strict";var n=s(2),a=(s(5),n.DOM),r=n.createClass({render:function(){return a.div({className:"rdtMonths"},[a.table({key:"a"},a.thead({},a.tr({},[a.th({key:"prev",className:"prev"},a.button({onClick:this.props.subtractTime(1,"years"),type:"button"},"‹")),a.th({key:"year",className:"switch",onClick:this.props.showView("years"),colSpan:2,"data-value":this.props.viewDate.year()},this.props.viewDate.year()),a.th({key:"next",className:"next"},a.button({onClick:this.props.addTime(1,"years"),type:"button"},"›"))]))),a.table({key:"months"},a.tbody({key:"b"},this.renderMonths()))])},renderMonths:function(){for(var t,e,s=this.props.selectedDate,n=this.props.viewDate.month(),r=this.props.viewDate.year(),o=[],i=0,u=[],c=this.props.renderMonth||this.renderMonth;12>i;)t="month",s&&i===n&&r===s.year()&&(t+=" active"),e={key:i,"data-value":i,className:t,onClick:this.props.setDate("month")},u.push(c(e,i,r,s&&s.clone())),4==u.length&&(o.push(a.tr({key:n+"_"+o.length},u)),u=[]),i++;return o},renderMonth:function(t,e,s,n){return a.td(t,this.props.viewDate.localeData()._monthsShort[e])}});t.exports=r},function(t,e,s){"use strict";var n=s(2),a=n.DOM,r=n.createClass({getInitialState:function(){return this.calculateState(this.props)},calculateState:function(t){var e=t.selectedDate||t.viewDate,s=t.timeFormat,n=[];return(-1!=s.indexOf("H")||-1!=s.indexOf("h"))&&(n.push("hours"),-1!=s.indexOf("m")&&(n.push("minutes"),-1!=s.indexOf("s")&&n.push("seconds"))),{hours:e.format("H"),minutes:e.format("mm"),seconds:e.format("ss"),milliseconds:e.format("SSS"),counters:n}},renderCounter:function(t){return a.div({key:t,className:"rdtCounter"},[a.button({key:"up",className:"btn",onMouseDown:this.onStartClicking("increase",t),type:"button"},"▲"),a.div({key:"c",className:"rdtCount"},this.state[t]),a.button({key:"do",className:"btn",onMouseDown:this.onStartClicking("decrease",t),type:"button"},"▼")])},render:function(){var t=this,e=[];return this.state.counters.forEach(function(s){e.length&&e.push(a.div({key:"sep"+e.length,className:"rdtCounterSeparator"},":")),e.push(t.renderCounter(s))}),3==this.state.counters.length&&-1!=this.props.timeFormat.indexOf("S")&&(e.push(a.div({className:"rdtCounterSeparator",key:"sep5"},":")),e.push(a.div({className:"rdtCounter rdtMilli",key:"m"},a.input({value:this.state.milliseconds,type:"text",onChange:this.updateMilli})))),a.div({className:"rdtTime"},a.table({},[this.renderHeader(),a.tbody({key:"b"},a.tr({},a.td({},a.div({className:"rdtCounters"},e))))]))},componentWillReceiveProps:function(t,e){this.setState(this.calculateState(t))},updateMilli:function(t){var e=parseInt(t.target.value);e==t.target.value&&e>=0&&1e3>e&&(this.props.setTime("milliseconds",e),this.setState({milliseconds:e}))},renderHeader:function(){if(!this.props.dateFormat)return"";var t=this.props.selectedDate||this.props.viewDate;return a.thead({key:"h"},a.tr({},a.th({className:"switch",colSpan:4,onClick:this.props.showView("days")},t.format(this.props.dateFormat))))},onStartClicking:function(t,e){{var s=this;this.state[e]}return function(){var n={};n[e]=s[t](e),s.setState(n),s.timer=setTimeout(function(){s.increaseTimer=setInterval(function(){n[e]=s[t](e),s.setState(n)},70)},500),s.mouseUpListener=function(){clearTimeout(s.timer),clearInterval(s.increaseTimer),s.props.setTime(e,s.state[e]),document.body.removeEventListener("mouseup",s.mouseUpListener)},document.body.addEventListener("mouseup",s.mouseUpListener)}},maxValues:{hours:23,minutes:59,seconds:59,milliseconds:999},padValues:{hours:1,minutes:2,seconds:2,milliseconds:3},increase:function(t){var e=parseInt(this.state[t])+1;return e>this.maxValues[t]&&(e=0),this.pad(t,e)},decrease:function(t){var e=parseInt(this.state[t])-1;return 0>e&&(e=this.maxValues[t]),this.pad(t,e)},pad:function(t,e){for(var s=e+"";s.length<this.padValues[t];)s="0"+s;return s}});t.exports=r},function(t,e,s){var n,a,r;!function(o,i){a=[s(2)],n=i,r="function"==typeof n?n.apply(e,a):n,!(void 0!==r&&(t.exports=r))}(this,function(t){"use strict";var e=[],s=[],n="ignore-react-onclickoutside",a=function(t,e){return t===e?!0:t.correspondingElement?t.correspondingElement.classList.contains(n):t.classList.contains(n)};return{componentDidMount:function(){if(!this.handleClickOutside)throw new Error("Component lacks a handleClickOutside(event) function for processing outside click events.");var n=this.__outsideClickHandler=function(t,e){return function(s){for(var n=s.target,r=!1;n.parentNode;){if(r=a(n,t))return;n=n.parentNode}e(s)}}(t.findDOMNode(this),this.handleClickOutside),r=e.length;e.push(this),s[r]=n,this.props.disableOnClickOutside||this.enableOnClickOutside()},componentWillUnmount:function(){this.disableOnClickOutside(),this.__outsideClickHandler=!1;var t=e.indexOf(this);t>-1&&s[t]&&(s.splice(t,1),e.splice(t,1))},enableOnClickOutside:function(){var t=this.__outsideClickHandler;document.addEventListener("mousedown",t),document.addEventListener("touchstart",t)},disableOnClickOutside:function(t){var t=this.__outsideClickHandler;document.removeEventListener("mousedown",t),document.removeEventListener("touchstart",t)}}})}])});