diff --git a/README.md b/README.md index 615d8e9..738bb48 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ position | | Sets a fixed position for the picker. Available values are `"top le inline | `false` | Views the picker inline. | [Plunker](https://embed.plnkr.co/5PhKOc) validate | `true` | Forces picker value between the range `minDate` and `maxDate`. | [Plunker](https://embed.plnkr.co/hFTyMV) autoclose | `true` | Closes the picker after selecting a date. | [Plunker](https://embed.plnkr.co/z7M6WK) +set-on-select | `false` | Updates picker model after selecting a date in each view. | [Plunker](https://embed.plnkr.co/hJRNcT) is-open | | Open/closes the picker when set to `true` or `false`. | [Plunker](https://embed.plnkr.co/7T4sbs) today | `false` | Highlights the current day. | [Plunker](https://embed.plnkr.co/YYbV4C) keyboard | `false` | Allows using the keyboard to navigate the picker. | [Plunker](https://embed.plnkr.co/OdUhHx) @@ -159,6 +160,7 @@ position | | Sets a fixed position for the picker. Available values are `"top le inline | `false` | Views the picker inline. validate | `true` | Forces picker value between the range `minDate` and `maxDate`. autoclose | `true` | Closes the picker after selecting a date. +set-on-select | `false` | Updates picker model after selecting a date in each view. today | `false` | Highlights the current day. keyboard | `false` | Allows using the keyboard to navigate the picker. show-header | `true` | Shows the header in the view. diff --git a/bower.json b/bower.json index d30f81c..81d5330 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-moment-picker", - "version": "0.9.9", + "version": "0.9.10", "authors": [ "Indri Muska " ], diff --git a/dist/angular-moment-picker.css b/dist/angular-moment-picker.css index c1a4e44..c88dd1d 100644 --- a/dist/angular-moment-picker.css +++ b/dist/angular-moment-picker.css @@ -1,4 +1,4 @@ -/*! Angular Moment Picker - v0.9.9 - http://indrimuska.github.io/angular-moment-picker - (c) 2015 Indri Muska - MIT */ +/*! Angular Moment Picker - v0.9.10 - http://indrimuska.github.io/angular-moment-picker - (c) 2015 Indri Muska - MIT */ .moment-picker { position: relative; display: block; diff --git a/dist/angular-moment-picker.js b/dist/angular-moment-picker.js index 92584e3..b42d7f6 100644 --- a/dist/angular-moment-picker.js +++ b/dist/angular-moment-picker.js @@ -1,4 +1,4 @@ -/*! Angular Moment Picker - v0.9.9 - http://indrimuska.github.io/angular-moment-picker - (c) 2015 Indri Muska - MIT */ +/*! Angular Moment Picker - v0.9.10 - http://indrimuska.github.io/angular-moment-picker - (c) 2015 Indri Muska - MIT */ /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -93,6 +93,7 @@ inline: false, validate: true, autoclose: true, + setOnSelect: false, today: false, keyboard: false, showHeader: true, @@ -173,6 +174,7 @@ inline: '@?', validate: '=?', autoclose: '=?', + setOnSelect: '=?', isOpen: '=?', today: '=?', keyboard: '=?', @@ -185,7 +187,7 @@ $transclude(function ($transElement) { // one-way binding attributes angular.forEach([ - 'locale', 'format', 'minView', 'maxView', 'startView', 'position', 'inline', 'validate', 'autoclose', 'today', + 'locale', 'format', 'minView', 'maxView', 'startView', 'position', 'inline', 'validate', 'autoclose', 'setOnSelect', 'today', 'keyboard', 'showHeader', 'leftArrow', 'rightArrow', 'additions' ], function (attr) { if (!angular.isDefined($scope[attr])) @@ -397,11 +399,17 @@ }, change: function (view) { var nextView = $scope.views.all.indexOf(view), minView = $scope.views.all.indexOf($scope.minView), maxView = $scope.views.all.indexOf($scope.maxView); - if (nextView < 0 || nextView > maxView) { + var update = function () { utility_1.setValue($scope.view.moment, $scope, $ctrl, $attrs); $scope.view.update(); if ($attrs['ngModel']) $ctrl.$commitViewValue(); + }; + if ($scope.setOnSelect) + update(); + if (nextView < 0 || nextView > maxView) { + if (!$scope.setOnSelect) + update(); if ($scope.autoclose) _this.$timeout($scope.view.close); } diff --git a/dist/angular-moment-picker.min.css b/dist/angular-moment-picker.min.css index af408a0..8c8dd6d 100644 --- a/dist/angular-moment-picker.min.css +++ b/dist/angular-moment-picker.min.css @@ -1,2 +1,2 @@ -/*! Angular Moment Picker - v0.9.9 - http://indrimuska.github.io/angular-moment-picker - (c) 2015 Indri Muska - MIT */ +/*! Angular Moment Picker - v0.9.10 - http://indrimuska.github.io/angular-moment-picker - (c) 2015 Indri Muska - MIT */ .moment-picker{position:relative;display:block}.moment-picker .moment-picker-input{cursor:pointer}.moment-picker .moment-picker-container{color:#404040;min-width:15em;background:#fff;padding:4px;border:1px solid #f0f3f4;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;position:absolute;top:100%;margin-top:4px;margin-left:-.5em;-webkit-box-shadow:0 2px 4px rgba(0,0,0,.075);-moz-box-shadow:0 2px 4px rgba(0,0,0,.075);box-shadow:0 2px 4px rgba(0,0,0,.075);z-index:5}.moment-picker .moment-picker-container:after,.moment-picker .moment-picker-container:before{content:"";display:block;width:0;height:0;border:8px solid transparent;border-top:none;position:absolute;top:-9px;left:15px}.moment-picker .moment-picker-container:before{border-bottom-color:#f0f3f4;border-width:9px}.moment-picker .moment-picker-container:after{border-bottom-color:#fff;margin-top:1px;margin-left:1px}.moment-picker .moment-picker-container.inline{position:relative;margin:0}.moment-picker .moment-picker-container.inline:after,.moment-picker .moment-picker-container.inline:before{content:none}.moment-picker.top .moment-picker-container{top:auto;bottom:100%;margin-top:auto;margin-bottom:4px}.moment-picker.top .moment-picker-container:after,.moment-picker.top .moment-picker-container:before{border:8px solid transparent;border-bottom:none;top:auto;bottom:-9px}.moment-picker.top .moment-picker-container:before{border-top-color:#f0f3f4;border-width:9px}.moment-picker.top .moment-picker-container:after{border-top-color:#fff;margin-top:auto;margin-bottom:1px}.moment-picker.right .moment-picker-container{right:0;margin-left:auto;margin-right:-.5em}.moment-picker.right .moment-picker-container:after,.moment-picker.right .moment-picker-container:before{left:auto;right:15px}.moment-picker.right .moment-picker-container:after{margin-left:auto;margin-right:1px}.moment-picker table{border-collapse:collapse;border-spacing:0;min-width:100%;table-layout:fixed}.moment-picker th{font-weight:700}.moment-picker th:first-child,.moment-picker th:last-child{width:2em}.moment-picker td,.moment-picker th{padding:0;text-align:center;min-width:2em;height:2em;text-shadow:0 1px 0 hsla(0,0%,100%,.9);cursor:pointer;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.moment-picker td:hover,.moment-picker th:hover{background-color:#fafbfb;background-image:-webkit-gradient(linear,left top,left bottom,from(#f0f3f4),to(#fafbfb));background-image:-webkit-linear-gradient(#f0f3f4,#fafbfb);background-image:-moz-linear-gradient(#f0f3f4,#fafbfb);background-image:-o-linear-gradient(#f0f3f4,#fafbfb);background-image:linear-gradient(#f0f3f4,#fafbfb)}.moment-picker td.disabled,.moment-picker td.disabled:hover,.moment-picker th.disabled,.moment-picker th.disabled:hover{color:#abbbc7;background:none;cursor:default}.moment-picker td.today{background:#e4eef5;color:#404040;text-shadow:0 1px 0 hsla(0,0%,100%,.9)}.moment-picker td.selected{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.3);border-color:#3ca0dd;background-color:#45b1e8;background-image:-webkit-gradient(linear,left top,left bottom,from(#45b1e8),to(#3097de));background-image:-webkit-linear-gradient(#45b1e8,#3097de);background-image:-moz-linear-gradient(#45b1e8,#3097de);background-image:-o-linear-gradient(#45b1e8,#3097de);background-image:linear-gradient(#45b1e8,#3097de)}.moment-picker td.highlighted{background-image:-webkit-radial-gradient(transparent,rgba(0,0,0,.15));background-image:-moz-radial-gradient(transparent,rgba(0,0,0,.15));background-image:-o-radial-gradient(transparent,rgba(0,0,0,.15));background-image:radial-gradient(transparent,rgba(0,0,0,.15))}.moment-picker .decade-view td,.moment-picker .year-view td{height:3.4em}.moment-picker .month-view .moment-picker-specific-views th{background:none;cursor:default}.moment-picker .month-view td{width:1.42857143em}.moment-picker .day-view td,.moment-picker .hour-view td{height:2.33333333em}.moment-picker .minute-view td{height:1.8em} \ No newline at end of file diff --git a/dist/angular-moment-picker.min.js b/dist/angular-moment-picker.min.js index 879eeff..5356ada 100644 --- a/dist/angular-moment-picker.min.js +++ b/dist/angular-moment-picker.min.js @@ -1,2 +1,2 @@ -/*! Angular Moment Picker - v0.9.9 - http://indrimuska.github.io/angular-moment-picker - (c) 2015 Indri Muska - MIT */ -!function(e){function t(n){if(i[n])return i[n].exports;var o=i[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var i={};return t.m=e,t.c=i,t.p="",t(0)}([function(e,t,i){i(8),e.exports=i(4)},function(e,t,i){"use strict";var n=i(2),o=i(3);t.KEYS={up:38,down:40,left:37,right:39,escape:27,enter:13},t.isValidMoment=function(e){return o.isMoment(e)&&e.isValid()},t.toValue=function(e,i,n){var o=e;return t.isValidMoment(e)||(o=t.toMoment(e,i,n)),t.momentToValue(o,i)},t.toMoment=function(e,i,n){var s=o(e,i,n);return t.isValidMoment(s)||(s=void 0),s},t.momentToValue=function(e,i){if(t.isValidMoment(e))return i?e.format(i):e.valueOf()},t.valueToMoment=function(e,t){var i;if(!e)return i;if(i=t.format?o(e,t.format,t.locale):o(e),t.model){var s=t.views.all.slice(0,t.views.all.indexOf(t.detectedMinView));n.forEach(s,function(e){var n=t.views.precisions[e];i[n](t.model[n]())})}return i},t.setValue=function(e,i,n,o){var s=t.isValidMoment(e)?e.clone():t.valueToMoment(e,i),a=t.momentToValue(s,i.format);t.updateMoment(i.model,s,i),t.updateMoment(n.$modelValue,s,i),o.ngModel!=o.momentPicker&&(i.value=a),o.ngModel&&(n.$setViewValue(a),n.$render())},t.updateMoment=function(e,i,o){if(t.isValidMoment(e)&&i){if(!e.isSame(i)){var s=o.views.all.slice(0,o.views.all.indexOf(o.detectedMaxView)+1);n.forEach(s,function(t){var n=o.views.precisions[t];e[n](i[n]())})}}else e=i;return e}},function(e,t){e.exports=angular},function(e,t){e.exports=moment},function(e,t){},function(e,t){e.exports='
'},function(e,t,i){"use strict";var n=i(2),o=i(3),s=i(7),a=i(13),r=i(1),l=i(5),c=function(){function e(e,t,i,c,m,d,u){var h=this;this.$timeout=e,this.$sce=t,this.$log=i,this.$window=c,this.provider=m,this.$compile=d,this.$templateCache=u,this.restrict="AE",this.require="?ngModel",this.transclude=!0,this.template=l,this.scope={value:"=?momentPicker",model:"=?ngModel",locale:"@?",format:"@?",minView:"@?",maxView:"@?",startView:"@?",minDate:"=?",maxDate:"=?",startDate:"=?",disabled:"=?disable",position:"@?",inline:"@?",validate:"=?",autoclose:"=?",isOpen:"=?",today:"=?",keyboard:"=?",showHeader:"=?",additions:"=?",change:"&?",selectable:"&?"},this.link=function(e,t,i,l,c){c(function(c){n.forEach(["locale","format","minView","maxView","startView","position","inline","validate","autoclose","today","keyboard","showHeader","leftArrow","rightArrow","additions"],function(t){n.isDefined(e[t])||(e[t]=h.provider[t]),n.isDefined(i[t])||(i[t]=e[t])}),i.ngModel||(l={}),e.limits={minDate:r.toMoment(e.minDate,e.format,e.locale),maxDate:r.toMoment(e.maxDate,e.format,e.locale),isAfterOrEqualMin:function(t,i){return!n.isDefined(e.limits.minDate)||t.isAfter(e.limits.minDate,i)||t.isSame(e.limits.minDate,i)},isBeforeOrEqualMax:function(t,i){return!n.isDefined(e.limits.maxDate)||t.isBefore(e.limits.maxDate,i)||t.isSame(e.limits.maxDate,i)},isSelectable:function(t,o){var s=!0;try{n.isFunction(e.selectable)&&i.selectable&&(s=e.selectable({date:t,type:o}))}catch(e){h.$log.error(e)}return e.limits.isAfterOrEqualMin(t,o)&&e.limits.isBeforeOrEqualMax(t,o)&&s},checkValue:function(){r.isValidMoment(l.$modelValue)&&e.validate&&(e.limits.isAfterOrEqualMin(l.$modelValue)||r.setValue(e.limits.minDate,e,l,i),e.limits.isBeforeOrEqualMax(l.$modelValue)||r.setValue(e.limits.maxDate,e,l,i))},checkView:function(){n.isDefined(e.view.moment)||(e.view.moment=o().locale(e.locale)),e.limits.isAfterOrEqualMin(e.view.moment)||(e.view.moment=e.limits.minDate.clone()),e.limits.isBeforeOrEqualMax(e.view.moment)||(e.view.moment=e.limits.maxDate.clone()),e.view.update(),e.view.render()}},e.views={all:["decade","year","month","day","hour","minute"],precisions:{decade:"year",year:"month",month:"date",day:"hour",hour:"minute",minute:"second"},formats:{decade:"Y{1,2}(?!Y)|YYYY|[Ll]{1,4}(?!T)",year:"M{1,4}(?![Mo])|Mo|Q",month:"[Dd]{1,4}(?![Ddo])|DDDo|[Dd]o|[Ww]{1,2}(?![Wwo])|[Ww]o|[Ee]|L{1,2}(?!T)|l{1,2}",day:"[Hh]{1,2}|LTS?",hour:"m{1,2}|[Ll]{3,4}|LT(?!S)",minute:"s{1,2}|S{1,}|X|LTS"},detectMinMax:function(){if(e.detectedMinView=e.detectedMaxView=void 0,e.format){var t,i;n.forEach(e.views.formats,function(o,s){var a=new RegExp("("+o+")(?![^[]*])","g");e.format.match(a)&&(n.isDefined(t)||(t=s),i=s)}),t=n.isDefined(t)?Math.max(0,e.views.all.indexOf(t)):0,i=n.isDefined(i)?Math.min(e.views.all.length-1,e.views.all.indexOf(i)):e.views.all.length-1,t>e.views.all.indexOf(e.minView)&&(e.minView=e.views.all[t]),i0&&n>r/2&&e.picker.addClass("top"),o+t.offsetWidth>a&&e.picker.addClass("right")}},keydown:function(t){var i=e.views[e.view.selected],n=e.views.precisions[e.view.selected].replace("date","day"),o=h.provider[n+"sStep"]||1,s=[r.KEYS.up,r.KEYS.left].indexOf(t.keyCode)>=0?"subtract":"add",a=function(t){var a=t?i.perLine:1,r=e.view.moment.clone()[s](o*a,n);e.limits.isSelectable(r,n)&&(e.view.moment=r,e.view.update(),e.view.render())};switch(t.keyCode){case r.KEYS.up:case r.KEYS.down:t.preventDefault(),e.view.isOpen?a(!0):e.view.open();break;case r.KEYS.left:case r.KEYS.right:if(!e.view.isOpen)break;t.preventDefault(),a();break;case r.KEYS.enter:if(!e.view.isOpen)break;e.view.change(n),t.preventDefault();break;case r.KEYS.escape:e.view.toggle()}},unit:function(){return"decade"==e.view.selected?10:1},precision:function(){return e.view.selected.replace("decade","year")},title:"",previous:{label:h.$sce.trustAsHtml(e.leftArrow),selectable:!0,set:function(){e.view.previous.selectable&&(e.view.moment.subtract(e.view.unit(),e.view.precision()),e.view.update(),e.view.render())}},next:{selectable:!0,label:h.$sce.trustAsHtml(e.rightArrow),set:function(){e.view.next.selectable&&(e.view.moment.add(e.view.unit(),e.view.precision()),e.view.update(),e.view.render())}},setParentView:function(){e.view.change(e.views.all[Math.max(0,e.views.all.indexOf(e.view.selected)-1)])},render:function(){var t=e.view.moment.clone().startOf(e.view.precision()).subtract(e.view.unit(),e.view.precision()),i=e.view.moment.clone().endOf(e.view.precision()).add(e.view.unit(),e.view.precision());e.view.previous.selectable=e.limits.isAfterOrEqualMin(t,e.view.precision()),e.view.previous.label=h.$sce.trustAsHtml(e.view.previous.selectable?e.leftArrow:" "),e.view.next.selectable=e.limits.isBeforeOrEqualMax(i,e.view.precision()),e.view.next.label=h.$sce.trustAsHtml(e.view.next.selectable?e.rightArrow:" "),e.view.title=e.views[e.view.selected].render()},change:function(t){var n=e.views.all.indexOf(t),o=e.views.all.indexOf(e.minView),s=e.views.all.indexOf(e.maxView);n<0||n>s?(r.setValue(e.view.moment,e,l,i),e.view.update(),i.ngModel&&l.$commitViewValue(),e.autoclose&&h.$timeout(e.view.close)):n>=o&&(e.view.selected=t)}},e.picker=n.element(t[0].querySelectorAll(".moment-picker")),t.after(e.picker),e.contents=n.element(e.picker[0].querySelectorAll(".moment-picker-contents")),e.container=n.element(e.picker[0].querySelectorAll(".moment-picker-container")),e.contents.append(t.append(c)),e.input="input"!=e.contents[0].tagName.toLowerCase()&&e.contents[0].querySelectorAll("input").length>0?n.element(e.contents[0].querySelectorAll("input")):n.element(e.contents[0]),e.input.addClass("moment-picker-input").attr("tabindex",0),(e.position||"").split(" ").forEach(function(t){return e.picker.addClass(t)}),h.$timeout(function(){n.forEach(e.additions||{},function(t,i){var o=n.element(e.container[0].querySelector(".moment-picker-addition."+i)),s=h.$templateCache.get(t),a=h.$compile(s)(e.$parent);o.append(a)})}),e.views.detectMinMax(),e.limits.checkView(),h.$timeout(function(){i.ngModel&&(!l.$modelValue&&e.value&&l.$setViewValue(e.value),l.$commitViewValue(),l.$render()),e.startDate?e.view.moment=r.toMoment(e.startDate,e.format,e.locale):r.isValidMoment(l.$modelValue)&&(e.view.moment=l.$modelValue.clone()),e.view.update(),e.view.render()}),i.ngModel&&(l.$parsers.push(function(t){return r.updateMoment(l.$modelValue,r.valueToMoment(t,e),e)||!0}),l.$formatters.push(function(t){return r.momentToValue(t,e.format)||""}),l.$viewChangeListeners.push(function(){i.ngModel!=i.momentPicker&&(e.value=l.$viewValue)}),l.$validators.minDate=function(t){return e.validate||!r.isValidMoment(t)||e.limits.isAfterOrEqualMin(t)},l.$validators.maxDate=function(t){return e.validate||!r.isValidMoment(t)||e.limits.isBeforeOrEqualMax(t)}),i.ngModel!=i.momentPicker&&e.$watch("value",function(t,n){t!==n&&r.setValue(t,e,l,i)}),e.$watch(function(){return r.momentToValue(l.$modelValue,e.format)},function(t,s){if(t!=s){var a=r.valueToMoment(t,e);if(r.setValue(a,e,l,i),e.limits.checkValue(),e.view.moment=(a||o().locale(e.locale)).clone(),e.view.update(),e.view.render(),n.isFunction(e.change)&&i.change){var c=r.valueToMoment(s,e);e.$evalAsync(function(){return e.change({newValue:a,oldValue:c})})}}}),e.$watch(function(){return l.$modelValue&&l.$modelValue.valueOf()},function(){var t=(r.isValidMoment(l.$modelValue)?l.$modelValue:o().locale(e.locale)).clone();t.isSame(e.view.moment)||(e.view.moment=t,e.view.update(),e.view.render())}),e.$watch("view.selected",function(){return e.view.render()}),e.$watchGroup(["minView","maxView"],function(){e.views.detectMinMax(),e.startView=e.views.all[Math.max(Math.min(e.views.all.indexOf(e.startView),e.views.all.indexOf(e.maxView)),e.views.all.indexOf(e.minView))],e.view.selected=e.startView}),e.$watchGroup([function(){return r.toValue(e.minDate,e.format,e.locale)},function(){return r.toValue(e.maxDate,e.format,e.locale)}],function(){n.forEach(["minDate","maxDate"],function(t){e.limits[t]=r.toMoment(e[t],e.format,e.locale)}),e.limits.checkValue(),e.limits.checkView(),e.view.render()}),e.$watch(function(){return r.toValue(e.startDate,e.format,e.locale)},function(t,i){t!=i&&(e.view.moment=r.valueToMoment(t,e),e.view.update(),e.view.render())}),i.$observe("locale",function(t){return e.locale=t}),e.$watch("locale",function(t,o){n.isDefined(o)&&t!=o&&(r.isValidMoment(l.$modelValue)&&r.setValue(l.$modelValue.locale(t),e,l,i),r.isValidMoment(e.view.moment)&&(e.view.moment=e.view.moment.locale(t)),r.isValidMoment(e.limits.minDate)&&(e.limits.minDate=e.limits.minDate.locale(t)),r.isValidMoment(e.limits.maxDate)&&(e.limits.maxDate=e.limits.maxDate.locale(t)),e.view.render())}),e.$watch("validate",e.limits.checkValue),e.$watch("isOpen",function(t){e.inline?e.view.isOpen=!0:n.isDefined(t)&&t!=e.view.isOpen&&e.view.toggle()});var m=function(t){t&&t.preventDefault(),e.input[0].focus()};e.input.on("focus click",function(){return e.$evalAsync(e.view.open)}).on("blur",function(){return e.$evalAsync(e.view.close)}).on("keydown",function(t){return e.keyboard&&e.$evalAsync(function(){return e.view.keydown(t)})}),e.contents.on("click",function(){return m()}),e.container.on("mousedown",function(e){return m(e)}),n.element(h.$window).on("resize scroll",e.view.position)})}}return e}();t.__esModule=!0,t.default=c},function(e,t){"use strict";t.getOffset=function(e){if(e){if(!e.getClientRects().length)return{top:0,left:0};var t=function(e){return null!=e&&e===e.window},i=function(e){return t(e)?e:9===e.nodeType&&e.defaultView},n=e.getBoundingClientRect();if(!n.width&&!n.height)return n;var o=e.ownerDocument,s=i(o),a=o.documentElement;return{top:n.top+s.pageYOffset-a.clientTop,left:n.left+s.pageXOffset-a.clientLeft}}}},function(e,t,i){"use strict";var n=i(2),o=i(9);t.Provider=o.default;var s=i(6);t.Directive=s.default,n.module("moment-picker",[]).provider("momentPicker",[function(){return new o.default}]).directive("momentPicker",["$timeout","$sce","$log","$window","momentPicker","$compile","$templateCache",function(e,t,i,n,o,a,r){return new s.default(e,t,i,n,o,a,r)}])},function(e,t,i){"use strict";var n=i(2),o=function(){function e(){this.settings={locale:"en",format:"L LTS",minView:"decade",maxView:"minute",startView:"year",inline:!1,validate:!0,autoclose:!0,today:!1,keyboard:!1,showHeader:!0,leftArrow:"←",rightArrow:"→",yearsFormat:"YYYY",monthsFormat:"MMM",daysFormat:"D",hoursFormat:"HH:[00]",hoursStart:0,hoursEnd:23,minutesStep:5,minutesStart:0,minutesEnd:59,secondsFormat:"ss",secondsStep:1,secondsStart:0,secondsEnd:59}}return e.prototype.options=function(e){return n.extend(this.settings,e),n.copy(this.settings)},e.prototype.$get=function(){return this.settings},e}();t.__esModule=!0,t.default=o},function(e,t,i){"use strict";var n=i(1),o=function(){function e(e,t,i){this.$scope=e,this.$ctrl=t,this.provider=i,this.perLine=4,this.rows={}}return e.prototype.render=function(){var e=this.$scope.view.moment.clone().startOf("day").hour(this.provider.hoursStart);this.rows={};for(var t=0;t<=this.provider.hoursEnd-this.provider.hoursStart;t++){var i=Math.floor(t/this.perLine),o=this.$scope.limits.isSelectable(e,"hour");this.rows[i]||(this.rows[i]=[]),this.rows[i].push({index:t,label:e.format(this.provider.hoursFormat),year:e.year(),month:e.month(),date:e.date(),hour:e.hour(),class:[this.$scope.keyboard&&e.isSame(this.$scope.view.moment,"hour")?"highlighted":"",o?n.isValidMoment(this.$ctrl.$modelValue)&&e.isSame(this.$ctrl.$modelValue,"hour")?"selected":"":"disabled"].join(" ").trim(),selectable:o}),e.add(1,"hours")}return this.$scope.view.moment.format("LL")},e.prototype.set=function(e){e.selectable&&(this.$scope.view.moment.year(e.year).month(e.month).date(e.date).hour(e.hour),this.$scope.view.update(),this.$scope.view.change("hour"))},e}();t.__esModule=!0,t.default=o},function(e,t,i){"use strict";var n=i(1),o=function(){function e(e,t,i){this.$scope=e,this.$ctrl=t,this.provider=i,this.perLine=4,this.rows={}}return e.prototype.render=function(){var e=this.$scope.view.moment.clone(),t=10*Math.floor(e.year()/10)-1;this.rows={},e.year(t);for(var i=0;i<12;i++){var o=Math.floor(i/this.perLine),s=this.$scope.limits.isSelectable(e,"year");this.rows[o]||(this.rows[o]=[]),this.rows[o].push({index:e.year(),label:e.format(this.provider.yearsFormat),year:e.year(),class:[this.$scope.keyboard&&e.isSame(this.$scope.view.moment,"year")?"highlighted":"",!s||[0,11].indexOf(i)>=0?"disabled":n.isValidMoment(this.$ctrl.$modelValue)&&e.isSame(this.$ctrl.$modelValue,"year")?"selected":""].join(" ").trim(),selectable:s}),e.add(1,"years")}return[e.subtract(2,"years").format("YYYY"),e.subtract(9,"years").format("YYYY")].reverse().join(" - ")},e.prototype.set=function(e){e.selectable&&(this.$scope.view.moment.year(e.year),this.$scope.view.update(),this.$scope.view.change("year"))},e}();t.__esModule=!0,t.default=o},function(e,t,i){"use strict";var n=i(2),o=i(3),s=i(1),a=function(){function e(e,t,i){this.$scope=e,this.$ctrl=t,this.provider=i,this.perLine=4,this.rows={}}return e.prototype.render=function(){var e=0,t=this.$scope.view.moment.clone().startOf("hour").minute(this.provider.minutesStart),i=this.provider.minutesFormat||o.localeData(this.$scope.locale).longDateFormat("LT").replace(/[aA]/,"").trim();this.rows={};for(var n=0;n<=this.provider.minutesEnd-this.provider.minutesStart;n+=this.provider.minutesStep){var a=Math.floor(e/this.perLine),r=this.$scope.limits.isSelectable(t,"minute");this.rows[a]||(this.rows[a]=[]),this.rows[a].push({index:t.minute(),label:t.format(i),year:t.year(),month:t.month(),date:t.date(),hour:t.hour(),minute:t.minute(),class:[this.$scope.keyboard&&t.isSame(this.$scope.view.moment,"minute")?"highlighted":"",r?s.isValidMoment(this.$ctrl.$modelValue)&&t.isSame(this.$ctrl.$modelValue,"minute")?"selected":"":"disabled"].join(" ").trim(),selectable:r}),e++,t.add(this.provider.minutesStep,"minutes")}return this.$scope.keyboard&&this.highlightClosest(),this.$scope.view.moment.clone().startOf("hour").format("lll")},e.prototype.set=function(e){e.selectable&&(this.$scope.view.moment.year(e.year).month(e.month).date(e.date).hour(e.hour).minute(e.minute),this.$scope.view.update(),this.$scope.view.change("minute"))},e.prototype.highlightClosest=function(){var e,t=this,i=[];n.forEach(this.rows,function(e){n.forEach(e,function(e){Math.abs(e.minute-t.$scope.view.moment.minute())Math.abs(i.minute-t.$scope.view.moment.minute())?1:0})[0],e&&e.minute-this.$scope.view.moment.minute()!=0&&(this.$scope.view.moment.year(e.year).month(e.month).date(e.date).hour(e.hour).minute(e.minute),this.$scope.view.update(),e.selectable&&(e.class=(e.class+" highlighted").trim()))},e}();t.__esModule=!0,t.default=a},function(e,t,i){"use strict";var n=i(11);t.DecadeView=n.default;var o=i(16);t.YearView=o.default;var s=i(15);t.MonthView=s.default;var a=i(10);t.DayView=a.default;var r=i(12);t.HourView=r.default;var l=i(14);t.MinuteView=l.default},function(e,t,i){"use strict";var n=i(2),o=i(1),s=function(){function e(e,t,i){this.$scope=e,this.$ctrl=t,this.provider=i,this.perLine=6,this.rows={}}return e.prototype.render=function(){var e=0,t=this.$scope.view.moment.clone().startOf("minute").second(this.provider.secondsStart);this.rows={};for(var i=0;i<=this.provider.secondsEnd-this.provider.secondsStart;i+=this.provider.secondsStep){var n=Math.floor(e/this.perLine),s=this.$scope.limits.isSelectable(t,"second");this.rows[n]||(this.rows[n]=[]),this.rows[n].push({index:t.second(),label:t.format(this.provider.secondsFormat),year:t.year(),month:t.month(),date:t.date(),hour:t.hour(),minute:t.minute(),second:t.second(),class:[this.$scope.keyboard&&t.isSame(this.$scope.view.moment,"second")?"highlighted":"",s?o.isValidMoment(this.$ctrl.$modelValue)&&t.isSame(this.$ctrl.$modelValue,"second")?"selected":"":"disabled"].join(" ").trim(),selectable:s}),e++,t.add(this.provider.secondsStep,"seconds")}return this.$scope.keyboard&&this.highlightClosest(),this.$scope.view.moment.clone().startOf("minute").format("lll")},e.prototype.set=function(e){e.selectable&&(this.$scope.view.moment.year(e.year).month(e.month).date(e.date).hour(e.hour).minute(e.minute).second(e.second),this.$scope.view.update(),this.$scope.view.change())},e.prototype.highlightClosest=function(){var e,t=this,i=[];n.forEach(this.rows,function(e){n.forEach(e,function(e){Math.abs(e.second-t.$scope.view.moment.second())Math.abs(i.second-t.$scope.view.moment.second())?1:0})[0],e&&e.second-this.$scope.view.moment.second()!=0&&(this.$scope.view.moment.year(e.year).month(e.month).date(e.date).hour(e.hour).minute(e.minute).second(e.second),this.$scope.view.update(),e.selectable&&(e.class=(e.class+" highlighted").trim()))},e}();t.__esModule=!0,t.default=s},function(e,t,i){"use strict";var n=i(2),o=i(3),s=i(1),a=function(){function e(e,t,i){this.$scope=e,this.$ctrl=t,this.provider=i,this.perLine=o.weekdays().length,this.rows=[]}return e.prototype.render=function(){var e=this,t=this.$scope.view.moment.month(),i=this.$scope.view.moment.clone().startOf("month").startOf("week").hour(12),a={},r=i.week(),l=r+5;this.rows=[];for(var c=r;c<=l;c++)a[c]=Array.apply(null,Array(this.perLine)).map(function(){var n=e.$scope.limits.isSelectable(i,"day"),o={index:i.date(),label:i.format(e.provider.daysFormat),year:i.year(),month:i.month(),date:i.date(),class:[e.$scope.keyboard&&i.isSame(e.$scope.view.moment,"day")?"highlighted":"",e.$scope.today&&i.isSame(new Date,"day")?"today":"",n&&i.month()==t?s.isValidMoment(e.$ctrl.$modelValue)&&i.isSame(e.$ctrl.$modelValue,"day")?"selected":"":"disabled"].join(" ").trim(),selectable:n};return i.add(1,"days"),o});return n.forEach(a,function(t){return e.rows.push(t)}),this.headers=o.weekdays().map(function(t,i){return o().locale(e.$scope.locale).startOf("week").add(i,"day").format("dd")}),this.$scope.view.moment.format("MMMM YYYY")},e.prototype.set=function(e){e.selectable&&(this.$scope.view.moment.year(e.year).month(e.month).date(e.date),this.$scope.view.update(),this.$scope.view.change("day"))},e}();t.__esModule=!0,t.default=a},function(e,t,i){"use strict";var n=i(3),o=i(1),s=function(){function e(e,t,i){this.$scope=e,this.$ctrl=t,this.provider=i,this.perLine=4,this.rows={}}return e.prototype.render=function(){var e=this,t=this.$scope.view.moment.clone().startOf("year"),i=n.monthsShort();return this.rows={},i.forEach(function(i,n){var s=Math.floor(n/e.perLine),a=e.$scope.limits.isSelectable(t,"month");e.rows[s]||(e.rows[s]=[]),e.rows[s].push({index:t.month(),label:t.format(e.provider.monthsFormat),year:t.year(),month:t.month(),class:[e.$scope.keyboard&&t.isSame(e.$scope.view.moment,"month")?"highlighted":"",a?o.isValidMoment(e.$ctrl.$modelValue)&&t.isSame(e.$ctrl.$modelValue,"month")?"selected":"":"disabled"].join(" ").trim(),selectable:a}),t.add(1,"months")}),this.$scope.view.moment.format("YYYY")},e.prototype.set=function(e){e.selectable&&(this.$scope.view.moment.year(e.year).month(e.month),this.$scope.view.update(),this.$scope.view.change("month"))},e}();t.__esModule=!0,t.default=s}]); \ No newline at end of file +/*! Angular Moment Picker - v0.9.10 - http://indrimuska.github.io/angular-moment-picker - (c) 2015 Indri Muska - MIT */ +!function(e){function t(n){if(i[n])return i[n].exports;var o=i[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var i={};return t.m=e,t.c=i,t.p="",t(0)}([function(e,t,i){i(8),e.exports=i(4)},function(e,t,i){"use strict";var n=i(2),o=i(3);t.KEYS={up:38,down:40,left:37,right:39,escape:27,enter:13},t.isValidMoment=function(e){return o.isMoment(e)&&e.isValid()},t.toValue=function(e,i,n){var o=e;return t.isValidMoment(e)||(o=t.toMoment(e,i,n)),t.momentToValue(o,i)},t.toMoment=function(e,i,n){var s=o(e,i,n);return t.isValidMoment(s)||(s=void 0),s},t.momentToValue=function(e,i){if(t.isValidMoment(e))return i?e.format(i):e.valueOf()},t.valueToMoment=function(e,t){var i;if(!e)return i;if(i=t.format?o(e,t.format,t.locale):o(e),t.model){var s=t.views.all.slice(0,t.views.all.indexOf(t.detectedMinView));n.forEach(s,function(e){var n=t.views.precisions[e];i[n](t.model[n]())})}return i},t.setValue=function(e,i,n,o){var s=t.isValidMoment(e)?e.clone():t.valueToMoment(e,i),a=t.momentToValue(s,i.format);t.updateMoment(i.model,s,i),t.updateMoment(n.$modelValue,s,i),o.ngModel!=o.momentPicker&&(i.value=a),o.ngModel&&(n.$setViewValue(a),n.$render())},t.updateMoment=function(e,i,o){if(t.isValidMoment(e)&&i){if(!e.isSame(i)){var s=o.views.all.slice(0,o.views.all.indexOf(o.detectedMaxView)+1);n.forEach(s,function(t){var n=o.views.precisions[t];e[n](i[n]())})}}else e=i;return e}},function(e,t){e.exports=angular},function(e,t){e.exports=moment},function(e,t){},function(e,t){e.exports='
'},function(e,t,i){"use strict";var n=i(2),o=i(3),s=i(7),a=i(13),r=i(1),l=i(5),c=function(){function e(e,t,i,c,m,d,u){var h=this;this.$timeout=e,this.$sce=t,this.$log=i,this.$window=c,this.provider=m,this.$compile=d,this.$templateCache=u,this.restrict="AE",this.require="?ngModel",this.transclude=!0,this.template=l,this.scope={value:"=?momentPicker",model:"=?ngModel",locale:"@?",format:"@?",minView:"@?",maxView:"@?",startView:"@?",minDate:"=?",maxDate:"=?",startDate:"=?",disabled:"=?disable",position:"@?",inline:"@?",validate:"=?",autoclose:"=?",setOnSelect:"=?",isOpen:"=?",today:"=?",keyboard:"=?",showHeader:"=?",additions:"=?",change:"&?",selectable:"&?"},this.link=function(e,t,i,l,c){c(function(c){n.forEach(["locale","format","minView","maxView","startView","position","inline","validate","autoclose","setOnSelect","today","keyboard","showHeader","leftArrow","rightArrow","additions"],function(t){n.isDefined(e[t])||(e[t]=h.provider[t]),n.isDefined(i[t])||(i[t]=e[t])}),i.ngModel||(l={}),e.limits={minDate:r.toMoment(e.minDate,e.format,e.locale),maxDate:r.toMoment(e.maxDate,e.format,e.locale),isAfterOrEqualMin:function(t,i){return!n.isDefined(e.limits.minDate)||t.isAfter(e.limits.minDate,i)||t.isSame(e.limits.minDate,i)},isBeforeOrEqualMax:function(t,i){return!n.isDefined(e.limits.maxDate)||t.isBefore(e.limits.maxDate,i)||t.isSame(e.limits.maxDate,i)},isSelectable:function(t,o){var s=!0;try{n.isFunction(e.selectable)&&i.selectable&&(s=e.selectable({date:t,type:o}))}catch(e){h.$log.error(e)}return e.limits.isAfterOrEqualMin(t,o)&&e.limits.isBeforeOrEqualMax(t,o)&&s},checkValue:function(){r.isValidMoment(l.$modelValue)&&e.validate&&(e.limits.isAfterOrEqualMin(l.$modelValue)||r.setValue(e.limits.minDate,e,l,i),e.limits.isBeforeOrEqualMax(l.$modelValue)||r.setValue(e.limits.maxDate,e,l,i))},checkView:function(){n.isDefined(e.view.moment)||(e.view.moment=o().locale(e.locale)),e.limits.isAfterOrEqualMin(e.view.moment)||(e.view.moment=e.limits.minDate.clone()),e.limits.isBeforeOrEqualMax(e.view.moment)||(e.view.moment=e.limits.maxDate.clone()),e.view.update(),e.view.render()}},e.views={all:["decade","year","month","day","hour","minute"],precisions:{decade:"year",year:"month",month:"date",day:"hour",hour:"minute",minute:"second"},formats:{decade:"Y{1,2}(?!Y)|YYYY|[Ll]{1,4}(?!T)",year:"M{1,4}(?![Mo])|Mo|Q",month:"[Dd]{1,4}(?![Ddo])|DDDo|[Dd]o|[Ww]{1,2}(?![Wwo])|[Ww]o|[Ee]|L{1,2}(?!T)|l{1,2}",day:"[Hh]{1,2}|LTS?",hour:"m{1,2}|[Ll]{3,4}|LT(?!S)",minute:"s{1,2}|S{1,}|X|LTS"},detectMinMax:function(){if(e.detectedMinView=e.detectedMaxView=void 0,e.format){var t,i;n.forEach(e.views.formats,function(o,s){var a=new RegExp("("+o+")(?![^[]*])","g");e.format.match(a)&&(n.isDefined(t)||(t=s),i=s)}),t=n.isDefined(t)?Math.max(0,e.views.all.indexOf(t)):0,i=n.isDefined(i)?Math.min(e.views.all.length-1,e.views.all.indexOf(i)):e.views.all.length-1,t>e.views.all.indexOf(e.minView)&&(e.minView=e.views.all[t]),i0&&n>r/2&&e.picker.addClass("top"),o+t.offsetWidth>a&&e.picker.addClass("right")}},keydown:function(t){var i=e.views[e.view.selected],n=e.views.precisions[e.view.selected].replace("date","day"),o=h.provider[n+"sStep"]||1,s=[r.KEYS.up,r.KEYS.left].indexOf(t.keyCode)>=0?"subtract":"add",a=function(t){var a=t?i.perLine:1,r=e.view.moment.clone()[s](o*a,n);e.limits.isSelectable(r,n)&&(e.view.moment=r,e.view.update(),e.view.render())};switch(t.keyCode){case r.KEYS.up:case r.KEYS.down:t.preventDefault(),e.view.isOpen?a(!0):e.view.open();break;case r.KEYS.left:case r.KEYS.right:if(!e.view.isOpen)break;t.preventDefault(),a();break;case r.KEYS.enter:if(!e.view.isOpen)break;e.view.change(n),t.preventDefault();break;case r.KEYS.escape:e.view.toggle()}},unit:function(){return"decade"==e.view.selected?10:1},precision:function(){return e.view.selected.replace("decade","year")},title:"",previous:{label:h.$sce.trustAsHtml(e.leftArrow),selectable:!0,set:function(){e.view.previous.selectable&&(e.view.moment.subtract(e.view.unit(),e.view.precision()),e.view.update(),e.view.render())}},next:{selectable:!0,label:h.$sce.trustAsHtml(e.rightArrow),set:function(){e.view.next.selectable&&(e.view.moment.add(e.view.unit(),e.view.precision()),e.view.update(),e.view.render())}},setParentView:function(){e.view.change(e.views.all[Math.max(0,e.views.all.indexOf(e.view.selected)-1)])},render:function(){var t=e.view.moment.clone().startOf(e.view.precision()).subtract(e.view.unit(),e.view.precision()),i=e.view.moment.clone().endOf(e.view.precision()).add(e.view.unit(),e.view.precision());e.view.previous.selectable=e.limits.isAfterOrEqualMin(t,e.view.precision()),e.view.previous.label=h.$sce.trustAsHtml(e.view.previous.selectable?e.leftArrow:" "),e.view.next.selectable=e.limits.isBeforeOrEqualMax(i,e.view.precision()),e.view.next.label=h.$sce.trustAsHtml(e.view.next.selectable?e.rightArrow:" "),e.view.title=e.views[e.view.selected].render()},change:function(t){var n=e.views.all.indexOf(t),o=e.views.all.indexOf(e.minView),s=e.views.all.indexOf(e.maxView),a=function(){r.setValue(e.view.moment,e,l,i),e.view.update(),i.ngModel&&l.$commitViewValue()};e.setOnSelect&&a(),n<0||n>s?(e.setOnSelect||a(),e.autoclose&&h.$timeout(e.view.close)):n>=o&&(e.view.selected=t)}},e.picker=n.element(t[0].querySelectorAll(".moment-picker")),t.after(e.picker),e.contents=n.element(e.picker[0].querySelectorAll(".moment-picker-contents")),e.container=n.element(e.picker[0].querySelectorAll(".moment-picker-container")),e.contents.append(t.append(c)),e.input="input"!=e.contents[0].tagName.toLowerCase()&&e.contents[0].querySelectorAll("input").length>0?n.element(e.contents[0].querySelectorAll("input")):n.element(e.contents[0]),e.input.addClass("moment-picker-input").attr("tabindex",0),(e.position||"").split(" ").forEach(function(t){return e.picker.addClass(t)}),h.$timeout(function(){n.forEach(e.additions||{},function(t,i){var o=n.element(e.container[0].querySelector(".moment-picker-addition."+i)),s=h.$templateCache.get(t),a=h.$compile(s)(e.$parent);o.append(a)})}),e.views.detectMinMax(),e.limits.checkView(),h.$timeout(function(){i.ngModel&&(!l.$modelValue&&e.value&&l.$setViewValue(e.value),l.$commitViewValue(),l.$render()),e.startDate?e.view.moment=r.toMoment(e.startDate,e.format,e.locale):r.isValidMoment(l.$modelValue)&&(e.view.moment=l.$modelValue.clone()),e.view.update(),e.view.render()}),i.ngModel&&(l.$parsers.push(function(t){return r.updateMoment(l.$modelValue,r.valueToMoment(t,e),e)||!0}),l.$formatters.push(function(t){return r.momentToValue(t,e.format)||""}),l.$viewChangeListeners.push(function(){i.ngModel!=i.momentPicker&&(e.value=l.$viewValue)}),l.$validators.minDate=function(t){return e.validate||!r.isValidMoment(t)||e.limits.isAfterOrEqualMin(t)},l.$validators.maxDate=function(t){return e.validate||!r.isValidMoment(t)||e.limits.isBeforeOrEqualMax(t)}),i.ngModel!=i.momentPicker&&e.$watch("value",function(t,n){t!==n&&r.setValue(t,e,l,i)}),e.$watch(function(){return r.momentToValue(l.$modelValue,e.format)},function(t,s){if(t!=s){var a=r.valueToMoment(t,e);if(r.setValue(a,e,l,i),e.limits.checkValue(),e.view.moment=(a||o().locale(e.locale)).clone(),e.view.update(),e.view.render(),n.isFunction(e.change)&&i.change){var c=r.valueToMoment(s,e);e.$evalAsync(function(){return e.change({newValue:a,oldValue:c})})}}}),e.$watch(function(){return l.$modelValue&&l.$modelValue.valueOf()},function(){var t=(r.isValidMoment(l.$modelValue)?l.$modelValue:o().locale(e.locale)).clone();t.isSame(e.view.moment)||(e.view.moment=t,e.view.update(),e.view.render())}),e.$watch("view.selected",function(){return e.view.render()}),e.$watchGroup(["minView","maxView"],function(){e.views.detectMinMax(),e.startView=e.views.all[Math.max(Math.min(e.views.all.indexOf(e.startView),e.views.all.indexOf(e.maxView)),e.views.all.indexOf(e.minView))],e.view.selected=e.startView}),e.$watchGroup([function(){return r.toValue(e.minDate,e.format,e.locale)},function(){return r.toValue(e.maxDate,e.format,e.locale)}],function(){n.forEach(["minDate","maxDate"],function(t){e.limits[t]=r.toMoment(e[t],e.format,e.locale)}),e.limits.checkValue(),e.limits.checkView(),e.view.render()}),e.$watch(function(){return r.toValue(e.startDate,e.format,e.locale)},function(t,i){t!=i&&(e.view.moment=r.valueToMoment(t,e),e.view.update(),e.view.render())}),i.$observe("locale",function(t){return e.locale=t}),e.$watch("locale",function(t,o){n.isDefined(o)&&t!=o&&(r.isValidMoment(l.$modelValue)&&r.setValue(l.$modelValue.locale(t),e,l,i),r.isValidMoment(e.view.moment)&&(e.view.moment=e.view.moment.locale(t)),r.isValidMoment(e.limits.minDate)&&(e.limits.minDate=e.limits.minDate.locale(t)),r.isValidMoment(e.limits.maxDate)&&(e.limits.maxDate=e.limits.maxDate.locale(t)),e.view.render())}),e.$watch("validate",e.limits.checkValue),e.$watch("isOpen",function(t){e.inline?e.view.isOpen=!0:n.isDefined(t)&&t!=e.view.isOpen&&e.view.toggle()});var m=function(t){t&&t.preventDefault(),e.input[0].focus()};e.input.on("focus click",function(){return e.$evalAsync(e.view.open)}).on("blur",function(){return e.$evalAsync(e.view.close)}).on("keydown",function(t){return e.keyboard&&e.$evalAsync(function(){return e.view.keydown(t)})}),e.contents.on("click",function(){return m()}),e.container.on("mousedown",function(e){return m(e)}),n.element(h.$window).on("resize scroll",e.view.position)})}}return e}();t.__esModule=!0,t.default=c},function(e,t){"use strict";t.getOffset=function(e){if(e){if(!e.getClientRects().length)return{top:0,left:0};var t=function(e){return null!=e&&e===e.window},i=function(e){return t(e)?e:9===e.nodeType&&e.defaultView},n=e.getBoundingClientRect();if(!n.width&&!n.height)return n;var o=e.ownerDocument,s=i(o),a=o.documentElement;return{top:n.top+s.pageYOffset-a.clientTop,left:n.left+s.pageXOffset-a.clientLeft}}}},function(e,t,i){"use strict";var n=i(2),o=i(9);t.Provider=o.default;var s=i(6);t.Directive=s.default,n.module("moment-picker",[]).provider("momentPicker",[function(){return new o.default}]).directive("momentPicker",["$timeout","$sce","$log","$window","momentPicker","$compile","$templateCache",function(e,t,i,n,o,a,r){return new s.default(e,t,i,n,o,a,r)}])},function(e,t,i){"use strict";var n=i(2),o=function(){function e(){this.settings={locale:"en",format:"L LTS",minView:"decade",maxView:"minute",startView:"year",inline:!1,validate:!0,autoclose:!0,setOnSelect:!1,today:!1,keyboard:!1,showHeader:!0,leftArrow:"←",rightArrow:"→",yearsFormat:"YYYY",monthsFormat:"MMM",daysFormat:"D",hoursFormat:"HH:[00]",hoursStart:0,hoursEnd:23,minutesStep:5,minutesStart:0,minutesEnd:59,secondsFormat:"ss",secondsStep:1,secondsStart:0,secondsEnd:59}}return e.prototype.options=function(e){return n.extend(this.settings,e),n.copy(this.settings)},e.prototype.$get=function(){return this.settings},e}();t.__esModule=!0,t.default=o},function(e,t,i){"use strict";var n=i(1),o=function(){function e(e,t,i){this.$scope=e,this.$ctrl=t,this.provider=i,this.perLine=4,this.rows={}}return e.prototype.render=function(){var e=this.$scope.view.moment.clone().startOf("day").hour(this.provider.hoursStart);this.rows={};for(var t=0;t<=this.provider.hoursEnd-this.provider.hoursStart;t++){var i=Math.floor(t/this.perLine),o=this.$scope.limits.isSelectable(e,"hour");this.rows[i]||(this.rows[i]=[]),this.rows[i].push({index:t,label:e.format(this.provider.hoursFormat),year:e.year(),month:e.month(),date:e.date(),hour:e.hour(),class:[this.$scope.keyboard&&e.isSame(this.$scope.view.moment,"hour")?"highlighted":"",o?n.isValidMoment(this.$ctrl.$modelValue)&&e.isSame(this.$ctrl.$modelValue,"hour")?"selected":"":"disabled"].join(" ").trim(),selectable:o}),e.add(1,"hours")}return this.$scope.view.moment.format("LL")},e.prototype.set=function(e){e.selectable&&(this.$scope.view.moment.year(e.year).month(e.month).date(e.date).hour(e.hour),this.$scope.view.update(),this.$scope.view.change("hour"))},e}();t.__esModule=!0,t.default=o},function(e,t,i){"use strict";var n=i(1),o=function(){function e(e,t,i){this.$scope=e,this.$ctrl=t,this.provider=i,this.perLine=4,this.rows={}}return e.prototype.render=function(){var e=this.$scope.view.moment.clone(),t=10*Math.floor(e.year()/10)-1;this.rows={},e.year(t);for(var i=0;i<12;i++){var o=Math.floor(i/this.perLine),s=this.$scope.limits.isSelectable(e,"year");this.rows[o]||(this.rows[o]=[]),this.rows[o].push({index:e.year(),label:e.format(this.provider.yearsFormat),year:e.year(),class:[this.$scope.keyboard&&e.isSame(this.$scope.view.moment,"year")?"highlighted":"",!s||[0,11].indexOf(i)>=0?"disabled":n.isValidMoment(this.$ctrl.$modelValue)&&e.isSame(this.$ctrl.$modelValue,"year")?"selected":""].join(" ").trim(),selectable:s}),e.add(1,"years")}return[e.subtract(2,"years").format("YYYY"),e.subtract(9,"years").format("YYYY")].reverse().join(" - ")},e.prototype.set=function(e){e.selectable&&(this.$scope.view.moment.year(e.year),this.$scope.view.update(),this.$scope.view.change("year"))},e}();t.__esModule=!0,t.default=o},function(e,t,i){"use strict";var n=i(2),o=i(3),s=i(1),a=function(){function e(e,t,i){this.$scope=e,this.$ctrl=t,this.provider=i,this.perLine=4,this.rows={}}return e.prototype.render=function(){var e=0,t=this.$scope.view.moment.clone().startOf("hour").minute(this.provider.minutesStart),i=this.provider.minutesFormat||o.localeData(this.$scope.locale).longDateFormat("LT").replace(/[aA]/,"").trim();this.rows={};for(var n=0;n<=this.provider.minutesEnd-this.provider.minutesStart;n+=this.provider.minutesStep){var a=Math.floor(e/this.perLine),r=this.$scope.limits.isSelectable(t,"minute");this.rows[a]||(this.rows[a]=[]),this.rows[a].push({index:t.minute(),label:t.format(i),year:t.year(),month:t.month(),date:t.date(),hour:t.hour(),minute:t.minute(),class:[this.$scope.keyboard&&t.isSame(this.$scope.view.moment,"minute")?"highlighted":"",r?s.isValidMoment(this.$ctrl.$modelValue)&&t.isSame(this.$ctrl.$modelValue,"minute")?"selected":"":"disabled"].join(" ").trim(),selectable:r}),e++,t.add(this.provider.minutesStep,"minutes")}return this.$scope.keyboard&&this.highlightClosest(),this.$scope.view.moment.clone().startOf("hour").format("lll")},e.prototype.set=function(e){e.selectable&&(this.$scope.view.moment.year(e.year).month(e.month).date(e.date).hour(e.hour).minute(e.minute),this.$scope.view.update(),this.$scope.view.change("minute"))},e.prototype.highlightClosest=function(){var e,t=this,i=[];n.forEach(this.rows,function(e){n.forEach(e,function(e){Math.abs(e.minute-t.$scope.view.moment.minute())Math.abs(i.minute-t.$scope.view.moment.minute())?1:0})[0],e&&e.minute-this.$scope.view.moment.minute()!=0&&(this.$scope.view.moment.year(e.year).month(e.month).date(e.date).hour(e.hour).minute(e.minute),this.$scope.view.update(),e.selectable&&(e.class=(e.class+" highlighted").trim()))},e}();t.__esModule=!0,t.default=a},function(e,t,i){"use strict";var n=i(11);t.DecadeView=n.default;var o=i(16);t.YearView=o.default;var s=i(15);t.MonthView=s.default;var a=i(10);t.DayView=a.default;var r=i(12);t.HourView=r.default;var l=i(14);t.MinuteView=l.default},function(e,t,i){"use strict";var n=i(2),o=i(1),s=function(){function e(e,t,i){this.$scope=e,this.$ctrl=t,this.provider=i,this.perLine=6,this.rows={}}return e.prototype.render=function(){var e=0,t=this.$scope.view.moment.clone().startOf("minute").second(this.provider.secondsStart);this.rows={};for(var i=0;i<=this.provider.secondsEnd-this.provider.secondsStart;i+=this.provider.secondsStep){var n=Math.floor(e/this.perLine),s=this.$scope.limits.isSelectable(t,"second");this.rows[n]||(this.rows[n]=[]),this.rows[n].push({index:t.second(),label:t.format(this.provider.secondsFormat),year:t.year(),month:t.month(),date:t.date(),hour:t.hour(),minute:t.minute(),second:t.second(),class:[this.$scope.keyboard&&t.isSame(this.$scope.view.moment,"second")?"highlighted":"",s?o.isValidMoment(this.$ctrl.$modelValue)&&t.isSame(this.$ctrl.$modelValue,"second")?"selected":"":"disabled"].join(" ").trim(),selectable:s}),e++,t.add(this.provider.secondsStep,"seconds")}return this.$scope.keyboard&&this.highlightClosest(),this.$scope.view.moment.clone().startOf("minute").format("lll")},e.prototype.set=function(e){e.selectable&&(this.$scope.view.moment.year(e.year).month(e.month).date(e.date).hour(e.hour).minute(e.minute).second(e.second),this.$scope.view.update(),this.$scope.view.change())},e.prototype.highlightClosest=function(){var e,t=this,i=[];n.forEach(this.rows,function(e){n.forEach(e,function(e){Math.abs(e.second-t.$scope.view.moment.second())Math.abs(i.second-t.$scope.view.moment.second())?1:0})[0],e&&e.second-this.$scope.view.moment.second()!=0&&(this.$scope.view.moment.year(e.year).month(e.month).date(e.date).hour(e.hour).minute(e.minute).second(e.second),this.$scope.view.update(),e.selectable&&(e.class=(e.class+" highlighted").trim()))},e}();t.__esModule=!0,t.default=s},function(e,t,i){"use strict";var n=i(2),o=i(3),s=i(1),a=function(){function e(e,t,i){this.$scope=e,this.$ctrl=t,this.provider=i,this.perLine=o.weekdays().length,this.rows=[]}return e.prototype.render=function(){var e=this,t=this.$scope.view.moment.month(),i=this.$scope.view.moment.clone().startOf("month").startOf("week").hour(12),a={},r=i.week(),l=r+5;this.rows=[];for(var c=r;c<=l;c++)a[c]=Array.apply(null,Array(this.perLine)).map(function(){var n=e.$scope.limits.isSelectable(i,"day"),o={index:i.date(),label:i.format(e.provider.daysFormat),year:i.year(),month:i.month(),date:i.date(),class:[e.$scope.keyboard&&i.isSame(e.$scope.view.moment,"day")?"highlighted":"",e.$scope.today&&i.isSame(new Date,"day")?"today":"",n&&i.month()==t?s.isValidMoment(e.$ctrl.$modelValue)&&i.isSame(e.$ctrl.$modelValue,"day")?"selected":"":"disabled"].join(" ").trim(),selectable:n};return i.add(1,"days"),o});return n.forEach(a,function(t){return e.rows.push(t)}),this.headers=o.weekdays().map(function(t,i){return o().locale(e.$scope.locale).startOf("week").add(i,"day").format("dd")}),this.$scope.view.moment.format("MMMM YYYY")},e.prototype.set=function(e){e.selectable&&(this.$scope.view.moment.year(e.year).month(e.month).date(e.date),this.$scope.view.update(),this.$scope.view.change("day"))},e}();t.__esModule=!0,t.default=a},function(e,t,i){"use strict";var n=i(3),o=i(1),s=function(){function e(e,t,i){this.$scope=e,this.$ctrl=t,this.provider=i,this.perLine=4,this.rows={}}return e.prototype.render=function(){var e=this,t=this.$scope.view.moment.clone().startOf("year"),i=n.monthsShort();return this.rows={},i.forEach(function(i,n){var s=Math.floor(n/e.perLine),a=e.$scope.limits.isSelectable(t,"month");e.rows[s]||(e.rows[s]=[]),e.rows[s].push({index:t.month(),label:t.format(e.provider.monthsFormat),year:t.year(),month:t.month(),class:[e.$scope.keyboard&&t.isSame(e.$scope.view.moment,"month")?"highlighted":"",a?o.isValidMoment(e.$ctrl.$modelValue)&&t.isSame(e.$ctrl.$modelValue,"month")?"selected":"":"disabled"].join(" ").trim(),selectable:a}),t.add(1,"months")}),this.$scope.view.moment.format("YYYY")},e.prototype.set=function(e){e.selectable&&(this.$scope.view.moment.year(e.year).month(e.month),this.$scope.view.update(),this.$scope.view.change("month"))},e}();t.__esModule=!0,t.default=s}]); \ No newline at end of file diff --git a/package.json b/package.json index 0e6c84a..ccb6f68 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-moment-picker", - "version": "0.9.9", + "version": "0.9.10", "description": "Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js", "main": "dist/angular-moment-picker.js", "repository": { diff --git a/src/definitions.d.ts b/src/definitions.d.ts index d925eed..3e581b0 100644 --- a/src/definitions.d.ts +++ b/src/definitions.d.ts @@ -24,6 +24,7 @@ export interface IDirectiveScope extends ng.IScope { inline?: boolean; validate?: boolean; autoclose?: boolean; + setOnSelect?: boolean; isOpen?: boolean; today?: boolean; keyboard?: boolean; diff --git a/src/directive.ts b/src/directive.ts index af7ca09..d1a985d 100644 --- a/src/directive.ts +++ b/src/directive.ts @@ -14,28 +14,29 @@ export default class Directive implements ng.IDirective { public transclude = true; public template = templateHtml; public scope = { - value: '=?momentPicker', - model: '=?ngModel', - locale: '@?', - format: '@?', - minView: '@?', - maxView: '@?', - startView: '@?', - minDate: '=?', - maxDate: '=?', - startDate: '=?', - disabled: '=?disable', - position: '@?', - inline: '@?', - validate: '=?', - autoclose: '=?', - isOpen: '=?', - today: '=?', - keyboard: '=?', - showHeader: '=?', - additions: '=?', - change: '&?', - selectable: '&?' + value: '=?momentPicker', + model: '=?ngModel', + locale: '@?', + format: '@?', + minView: '@?', + maxView: '@?', + startView: '@?', + minDate: '=?', + maxDate: '=?', + startDate: '=?', + disabled: '=?disable', + position: '@?', + inline: '@?', + validate: '=?', + autoclose: '=?', + setOnSelect: '=?', + isOpen: '=?', + today: '=?', + keyboard: '=?', + showHeader: '=?', + additions: '=?', + change: '&?', + selectable: '&?' }; constructor( @@ -51,7 +52,7 @@ export default class Directive implements ng.IDirective { $transclude(($transElement: ng.IAugmentedJQuery) => { // one-way binding attributes angular.forEach([ - 'locale', 'format', 'minView', 'maxView', 'startView', 'position', 'inline', 'validate', 'autoclose', 'today', + 'locale', 'format', 'minView', 'maxView', 'startView', 'position', 'inline', 'validate', 'autoclose', 'setOnSelect', 'today', 'keyboard', 'showHeader', 'leftArrow', 'rightArrow', 'additions' ], (attr: string) => { if (!angular.isDefined($scope[attr])) $scope[attr] = this.provider[attr]; @@ -261,11 +262,16 @@ export default class Directive implements ng.IDirective { let nextView = $scope.views.all.indexOf(view), minView = $scope.views.all.indexOf($scope.minView), maxView = $scope.views.all.indexOf($scope.maxView); - - if (nextView < 0 || nextView > maxView) { + + const update = () => { setValue($scope.view.moment, $scope, $ctrl, $attrs); $scope.view.update(); if ($attrs['ngModel']) $ctrl.$commitViewValue(); + }; + + if ($scope.setOnSelect) update(); + if (nextView < 0 || nextView > maxView) { + if (!$scope.setOnSelect) update(); if ($scope.autoclose) this.$timeout($scope.view.close); } else if (nextView >= minView) $scope.view.selected = view; } diff --git a/src/provider.ts b/src/provider.ts index ab52bdc..882a6e4 100644 --- a/src/provider.ts +++ b/src/provider.ts @@ -11,6 +11,7 @@ export interface IProviderOptions { inline?: boolean; validate?: boolean; autoclose?: boolean; + setOnSelect?: boolean; today?: boolean; keyboard?: boolean; showHeader?: boolean; @@ -54,6 +55,7 @@ export default class Provider implements angular.IServiceProvider { inline: false, validate: true, autoclose: true, + setOnSelect: false, today: false, keyboard: false, showHeader: true,