|
1 | 1 | /* |
2 | 2 | @author : Maelig GOHIN For ARCA-Computing - www.arca-computing.fr |
3 | | - @version: 2.0.10 |
| 3 | + @version: 2.0.11 |
4 | 4 |
|
5 | 5 | @description: MultipleDatePicker is an Angular directive to show a simple calendar allowing user to select multiple dates. |
6 | 6 | Css style can be changed by editing less or css stylesheet. |
|
195 | 195 | }; |
196 | 196 |
|
197 | 197 | /*scope functions*/ |
198 | | - scope.$watch('ngModel', function () { |
199 | | - scope.generate(); |
200 | | - }, true); |
201 | | - |
202 | | - scope.$watch('month', function () { |
203 | | - scope.generate(); |
204 | | - }, true); |
205 | | - |
206 | | - scope.$watch('highlightDays', function () { |
207 | | - scope.generate(); |
208 | | - }, true); |
209 | | - |
210 | | - scope.$watch('weekDaysOff', function () { |
211 | | - scope.generate(); |
212 | | - }, true); |
213 | | - |
214 | | - scope.$watch('allDaysOff', function () { |
215 | | - scope.generate(); |
216 | | - }, true); |
217 | | - |
218 | | - scope.$watch('daysAllowed', function () { |
219 | | - scope.generate(); |
220 | | - }, true); |
221 | | - |
222 | | - scope.$watch(function () { |
223 | | - return moment.locale(); |
224 | | - }, function () { |
225 | | - scope.daysOfWeek = getDaysOfWeek(); |
226 | | - scope.monthToDisplay = getMonthYearToDisplay(); |
227 | | - }, true); |
228 | | - |
| 198 | + var watches = []; |
| 199 | + watches.push( |
| 200 | + scope.$watch('ngModel', function () { |
| 201 | + scope.generate(); |
| 202 | + }, true) |
| 203 | + ); |
| 204 | + |
| 205 | + watches.push( |
| 206 | + scope.$watch('month', function () { |
| 207 | + scope.generate(); |
| 208 | + }, true) |
| 209 | + ); |
| 210 | + |
| 211 | + watches.push( |
| 212 | + scope.$watch('highlightDays', function () { |
| 213 | + scope.generate(); |
| 214 | + }, true) |
| 215 | + ); |
| 216 | + |
| 217 | + watches.push( |
| 218 | + scope.$watch('weekDaysOff', function () { |
| 219 | + scope.generate(); |
| 220 | + }, true) |
| 221 | + ); |
| 222 | + |
| 223 | + watches.push( |
| 224 | + scope.$watch('allDaysOff', function () { |
| 225 | + scope.generate(); |
| 226 | + }, true) |
| 227 | + ); |
| 228 | + |
| 229 | + watches.push( |
| 230 | + scope.$watch('daysAllowed', function () { |
| 231 | + scope.generate(); |
| 232 | + }, true) |
| 233 | + ); |
| 234 | + |
| 235 | + watches.push( |
| 236 | + scope.$watch('disableDaysBefore', function () { |
| 237 | + scope.generate(); |
| 238 | + }, true) |
| 239 | + ); |
| 240 | + |
| 241 | + watches.push( |
| 242 | + scope.$watch('disableDaysAfter', function () { |
| 243 | + scope.generate(); |
| 244 | + }, true) |
| 245 | + ); |
| 246 | + |
| 247 | + watches.push( |
| 248 | + scope.$watch(function () { |
| 249 | + return moment.locale(); |
| 250 | + }, function () { |
| 251 | + scope.daysOfWeek = getDaysOfWeek(); |
| 252 | + scope.monthToDisplay = getMonthYearToDisplay(); |
| 253 | + }, true) |
| 254 | + ); |
| 255 | + |
| 256 | + scope.$on('destroy', function () { |
| 257 | + for(var i = 0; i < watches.length; i++){ |
| 258 | + watches[i](); |
| 259 | + } |
| 260 | + }); |
229 | 261 | //default values |
230 | 262 | scope.month = scope.month || moment().startOf('day'); |
231 | 263 | scope.days = []; |
|
266 | 298 | } else { |
267 | 299 | var idx = -1; |
268 | 300 | for (var i = 0; i < scope.ngModel.length; ++i) { |
269 | | - if (scope.ngModel[i].isSame(day.date,'day')) { |
| 301 | + if (scope.ngModel[i].isSame(day.date, 'day')) { |
270 | 302 | idx = i; |
271 | 303 | break; |
272 | 304 | } |
|
0 commit comments