-
Notifications
You must be signed in to change notification settings - Fork 167
/
Copy pathindex.js
172 lines (148 loc) · 3.91 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
var app = angular.module('app', ['ui.bootstrap', 'ui.bootstrap.datetimepicker']);
app.controller('MyController', ['$scope', function($scope) {
var that = this;
// date picker
this.picker1 = {
date: new Date('2015-03-01T00:00:00Z'),
datepickerOptions: {
showWeeks: false,
startingDay: 1,
dateDisabled: function(data) {
return (data.mode === 'day' && (new Date().toDateString() == data.date.toDateString()));
}
}
};
// time picker
this.picker2 = {
date: new Date('2015-03-01T12:30:00Z'),
timepickerOptions: {
readonlyInput: false,
showMeridian: false
}
};
// date and time picker
this.picker3 = {
date: new Date()
};
// min date picker
this.picker4 = {
date: new Date(),
datepickerOptions: {
maxDate: null
}
};
// max date picker
this.picker5 = {
date: new Date(),
datepickerOptions: {
minDate: null
}
};
// set date for max picker, 10 days in future
this.picker5.date.setDate(this.picker5.date.getDate() + 10);
// global config picker
this.picker6 = {
date: new Date()
};
// dropdown up picker
this.picker7 = {
date: new Date()
};
// view mode picker
this.picker8 = {
date: new Date(),
datepickerOptions: {
mode: 'year',
minMode: 'year',
maxMode: 'year'
}
};
// dropdown up picker
this.picker9 = {
date: null
};
// min time picker
this.picker10 = {
date: new Date('2016-03-01T09:00:00Z'),
timepickerOptions: {
max: null
}
};
// max time picker
this.picker11 = {
date: new Date('2016-03-01T10:00:00Z'),
timepickerOptions: {
min: null
}
};
// button bar
this.picker12 = {
date: new Date(),
buttonBar: {
show: true,
now: {
show: true,
text: 'Now!'
},
today: {
show: true,
text: 'Today!'
},
clear: {
show: false,
text: 'Wipe'
},
date: {
show: true,
text: 'Date'
},
time: {
show: true,
text: 'Time'
},
close: {
show: true,
text: 'Shut'
},
cancel: {
show: true,
text: 'Cancel'
}
}
};
// when closed picker
this.picker13 = {
date: new Date(),
closed: function(args) {
that.closedArgs = args;
}
};
// saveAs - ISO
this.picker14 = {
date: new Date().toISOString()
}
this.openCalendar = function(e, picker) {
that[picker].open = true;
};
// watch min and max dates to calculate difference
var unwatchMinMaxValues = $scope.$watch(function() {
return [that.picker4, that.picker5, that.picker10, that.picker11];
}, function() {
// min max dates
that.picker4.datepickerOptions.maxDate = that.picker5.date;
that.picker5.datepickerOptions.minDate = that.picker4.date;
if (that.picker4.date && that.picker5.date) {
var diff = that.picker4.date.getTime() - that.picker5.date.getTime();
that.dayRange = Math.round(Math.abs(diff/(1000*60*60*24)))
} else {
that.dayRange = 'n/a';
}
// min max times
that.picker10.timepickerOptions.max = that.picker11.date;
that.picker11.timepickerOptions.min = that.picker10.date;
}, true);
// destroy watcher
$scope.$on('$destroy', function() {
unwatchMinMaxValues();
});
}]);