|
44 | 44 | ' <mdc-datetime-picker-calendar date="picker.currentDate" picker="picker" class="dtp-picker-calendar" ng-show="picker.currentView === picker.VIEWS.DATE"></mdc-datetime-picker-calendar>' + |
45 | 45 | ' <div class="dtp-picker-datetime" ng-cloak ng-if="picker.currentView !== picker.VIEWS.DATE">' + |
46 | 46 | ' <div class="dtp-actual-meridien">' + |
47 | | - ' <div class="left p20">' + |
| 47 | + ' <div ng-if="picker.params.shortTime" class="left p20">' + |
48 | 48 | ' <a id="time-periods-am" href="#" mdc-dtp-noclick class="dtp-meridien-am" ng-class="{selected: picker.meridien == \'AM\'}" ng-click="picker.selectAM()">{{picker.params.amText}}</a>' + |
49 | 49 | ' </div>' + |
50 | 50 | ' <div ng-show="!picker.timeMode" class="dtp-actual-time p60">{{picker.currentNearest5Minute().format(picker.params.shortTime ? "hh:mm" : "HH:mm")}}</div>' + |
51 | | - ' <div class="right p20">' + |
| 51 | + ' <div ng-if="picker.params.shortTime" class="right p20">' + |
52 | 52 | ' <a id="time-periods-pm" href="#" mdc-dtp-noclick class="dtp-meridien-pm" ng-class="{selected: picker.meridien == \'PM\'}" ng-click="picker.selectPM()">{{picker.params.pmText}}</a>' + |
53 | 53 | ' </div>' + |
54 | 54 | ' <div class="clearfix"></div>' + |
|
486 | 486 | }, |
487 | 487 | isHourAvailable: function (hour) { |
488 | 488 | var _date = moment(this.currentDate); |
489 | | - _date.hour(this.convertHours(hour)).minute(0).second(0); |
| 489 | + if (this.params.shortTime) { |
| 490 | + _date.hour(this.convertHours(hour)).minute(0).second(0); |
| 491 | + } else { |
| 492 | + _date.hour(hour).minute(0).second(0); |
| 493 | + } |
490 | 494 | return this.isAfterMinDate(_date, true, false) && this.isBeforeMaxDate(_date, true, false); |
491 | 495 | }, |
492 | 496 | isMinuteAvailable: function (minute) { |
|
842 | 846 |
|
843 | 847 | var template = |
844 | 848 | '<div class="dtp-picker-clock"><span ng-if="!points || points.length < 1"> </span>' + |
845 | | - '<div ng-repeat="point in points" class="dtp-picker-time" ng-style="point.style">' + |
| 849 | + '<div ng-repeat="point in points" class="dtp-picker-time noselect" ng-style="point.style">' + |
846 | 850 | ' <a href="#" id="time-{{mode}}-{{point.display}}" mdc-dtp-noclick ng-class="{selected: point.value===currentValue}" class="dtp-select-hour" ng-click="setTime(point.value)" ng-if="pointAvailable(point)">{{point.display}}</a>' + |
847 | 851 | ' <a href="#" mdc-dtp-noclick class="disabled dtp-select-hour" ng-if="!pointAvailable(point)">{{point.display}}</a>' + |
848 | 852 | '</div>' + |
| 853 | + '<div ng-if="points24.length" ng-repeat="point24 in points24" class="dtp-picker-time noselect" ng-style="point24.style">' + |
| 854 | + ' <a href="#" id="time-24hours-{{point24.display}}" mdc-dtp-noclick ng-class="{selected: point24.value===currentValue}" class="dtp-select-hour" ng-click="setTime(point24.value)" ng-if="pointAvailable(point24)">{{point24.display}}</a>' + |
| 855 | + ' <a href="#" mdc-dtp-noclick class="disabled dtp-select-hour" ng-if="!pointAvailable(point24)">{{point24.display}}</a>' + |
| 856 | + '</div>' + |
849 | 857 | '<div class="dtp-hand dtp-hour-hand"></div>' + |
850 | 858 | '<div class="dtp-hand dtp-minute-hand"></div>' + |
851 | 859 | '<div class="dtp-clock-center"></div>' + |
|
878 | 886 | var mT = parseInt(css(clock, 'marginTop').replace('px', '')) || 0; |
879 | 887 |
|
880 | 888 | var r = (clockWidth / 2); |
881 | | - var j = r / 1.2; //??? |
882 | | - |
| 889 | + var j = r / 1.2; // radius for low number |
| 890 | + |
883 | 891 | var points = []; |
884 | 892 |
|
885 | 893 | for (var h = 0; h < 12; ++h) { |
|
902 | 910 | if (picker.params.shortTime) { |
903 | 911 | hour.display = (h === 0) ? 12 : h; |
904 | 912 | } else { |
905 | | - hour.display = picker.isPM() ? h + 12 : h; |
| 913 | + hour.display = h; |
906 | 914 | } |
907 | 915 | } |
908 | 916 |
|
909 | | - |
910 | 917 | points.push(hour); |
911 | 918 | } |
912 | | - |
913 | 919 | scope.points = points; |
| 920 | + |
| 921 | + if (!picker.params.shortTime && !minuteMode) { |
| 922 | + var points24 = []; |
| 923 | + |
| 924 | + var j24 = r / 1.8; // radius for high number |
| 925 | + for (var h24 = 12; h24 < 24; ++h24) { |
| 926 | + var x24 = j24 * Math.sin(Math.PI * 2 * (h24 / 12)); |
| 927 | + var y24 = j24 * Math.cos(Math.PI * 2 * (h24 / 12)); |
| 928 | + var left24 = (r + x24 + pL / 2) - (pL + mL); |
| 929 | + var top24 = (r - y24 - mT / 2) - (pT + mT); |
| 930 | + |
| 931 | + var hour24 = { |
| 932 | + left: left24, |
| 933 | + top: top24, |
| 934 | + value: h24, |
| 935 | + style: {'margin-left': left24 + 'px', 'margin-top': top24 + 'px'} |
| 936 | + }; |
| 937 | + |
| 938 | + hour24.display = h24; |
| 939 | + |
| 940 | + points24.push(hour24); |
| 941 | + } |
| 942 | + scope.points24 = points24; |
| 943 | + } |
| 944 | + |
914 | 945 | scope.mode = attrs.mode; |
915 | 946 | setCurrentValue(); |
916 | 947 | clock.css('height', clockWidth + 'px'); |
917 | 948 |
|
918 | 949 | var clockCenter = element[0].querySelector('.dtp-clock-center'); |
919 | 950 | var centerWidth = (clockCenter.offsetWidth / 2) || 7.5, |
920 | 951 | centerHeight = (clockCenter.offsetHeight / 2) || 7.5; |
921 | | - var _hL = r / 1.8; |
| 952 | + var _hL = r / (picker.params.shortTime ? 1.8 : 2.3); |
922 | 953 | var _mL = r / 1.5; |
923 | 954 |
|
924 | 955 | angular.element(element[0].querySelector('.dtp-hour-hand')).css({ |
|
963 | 994 |
|
964 | 995 | var setCurrentValue = function () { |
965 | 996 | var date = picker.currentNearest5Minute(); |
966 | | - scope.currentValue = minuteMode ? date.minute() : (date.hour() % 12); |
| 997 | + var nbH = picker.params.shortTime ? 12 : 24; |
| 998 | + scope.currentValue = minuteMode ? date.minute() : (date.hour() % nbH); |
967 | 999 | }; |
968 | 1000 |
|
969 | 1001 | scope.$watch(function () { |
|
974 | 1006 | animateHands(); |
975 | 1007 | }); |
976 | 1008 |
|
977 | | - |
978 | | - var setDisplayPoints = function (isPM, points) { |
979 | | - for (var i = 0; i < points.length; i++) { |
980 | | - points[i].display = i; |
981 | | - if (isPM) { |
982 | | - points[i].display += 12; |
983 | | - } |
984 | | - } |
985 | | - return points; |
986 | | - }; |
987 | | - |
988 | | - if (!picker.params.shortTime) { |
989 | | - scope.$watch('picker.meridien', function () { |
990 | | - if (!minuteMode) { |
991 | | - if (scope.points) { |
992 | | - var points = setDisplayPoints(picker.isPM(), angular.copy(scope.points)); |
993 | | - scope.points = points; |
994 | | - } |
995 | | - } |
996 | | - }); |
997 | | - } |
998 | | - |
999 | | - |
1000 | 1009 | scope.setTime = function (val) { |
1001 | 1010 | if (val === scope.currentValue) { |
1002 | 1011 | picker.ok(); |
1003 | 1012 | } |
1004 | 1013 |
|
1005 | 1014 | if (!minuteMode) { |
1006 | | - picker.currentDate.hour(picker.isPM() ? (val + 12) : val); |
| 1015 | + if (picker.params.shortTime) { |
| 1016 | + picker.currentDate.hour(picker.isPM() ? (val + 12) : val); |
| 1017 | + } else { |
| 1018 | + picker.currentDate.hour(val); |
| 1019 | + } |
| 1020 | + |
1007 | 1021 | } else { |
1008 | 1022 | picker.currentDate.minute(val); |
1009 | 1023 | } |
|
0 commit comments