9
9
*/
10
10
11
11
angular . module ( 'ui.calendar' , [ ] )
12
- . constant ( 'uiCalendarConfig' , { } )
13
- . controller ( 'uiCalendarCtrl' , [ '$scope' , '$timeout' , '$locale' , function ( $scope , $timeout , $locale ) {
12
+ . constant ( 'uiCalendarConfig' , { calendars : { } } )
13
+ . controller ( 'uiCalendarCtrl' , [ '$scope' ,
14
+ '$timeout' ,
15
+ '$locale' , function (
16
+ $scope ,
17
+ $timeout ,
18
+ $locale ) {
14
19
15
20
var sourceSerialId = 1 ,
16
21
eventSerialId = 1 ,
@@ -198,6 +203,7 @@ angular.module('ui.calendar', [])
198
203
199
204
var sources = scope . eventSources ,
200
205
sourcesChanged = false ,
206
+ calendar ,
201
207
eventSourcesWatcher = controller . changeWatcher ( sources , controller . sourcesFingerprint ) ,
202
208
eventsWatcher = controller . changeWatcher ( controller . allEvents , controller . eventsFingerprint ) ,
203
209
options = null ;
@@ -210,9 +216,10 @@ angular.module('ui.calendar', [])
210
216
211
217
var localeFullCalendarConfig = controller . getLocaleConfig ( fullCalendarConfig ) ;
212
218
angular . extend ( localeFullCalendarConfig , fullCalendarConfig ) ;
213
-
214
219
options = { eventSources : sources } ;
215
220
angular . extend ( options , localeFullCalendarConfig ) ;
221
+ //remove calendars from options
222
+ options . calendars = null ;
216
223
217
224
var options2 = { } ;
218
225
for ( var o in options ) {
@@ -224,44 +231,44 @@ angular.module('ui.calendar', [])
224
231
}
225
232
226
233
scope . destroy = function ( ) {
227
- if ( scope . calendar && scope . calendar . fullCalendar ) {
228
- scope . calendar . fullCalendar ( 'destroy' ) ;
234
+ if ( calendar && calendar . fullCalendar ) {
235
+ calendar . fullCalendar ( 'destroy' ) ;
229
236
}
230
237
if ( attrs . calendar ) {
231
- scope . calendar = scope . $parent [ attrs . calendar ] = $ ( elm ) . html ( '' ) ;
238
+ calendar = uiCalendarConfig . calendars [ attrs . calendar ] = $ ( elm ) . html ( '' ) ;
232
239
} else {
233
- scope . calendar = $ ( elm ) . html ( '' ) ;
240
+ calendar = $ ( elm ) . html ( '' ) ;
234
241
}
235
242
} ;
236
243
237
244
scope . init = function ( ) {
238
- scope . calendar . fullCalendar ( options ) ;
245
+ calendar . fullCalendar ( options ) ;
239
246
} ;
240
247
241
248
eventSourcesWatcher . onAdded = function ( source ) {
242
- scope . calendar . fullCalendar ( 'addEventSource' , source ) ;
249
+ calendar . fullCalendar ( 'addEventSource' , source ) ;
243
250
sourcesChanged = true ;
244
251
} ;
245
252
246
253
eventSourcesWatcher . onRemoved = function ( source ) {
247
- scope . calendar . fullCalendar ( 'removeEventSource' , source ) ;
254
+ calendar . fullCalendar ( 'removeEventSource' , source ) ;
248
255
sourcesChanged = true ;
249
256
} ;
250
257
251
258
eventsWatcher . onAdded = function ( event ) {
252
- scope . calendar . fullCalendar ( 'renderEvent' , event ) ;
259
+ calendar . fullCalendar ( 'renderEvent' , event ) ;
253
260
} ;
254
261
255
262
eventsWatcher . onRemoved = function ( event ) {
256
- scope . calendar . fullCalendar ( 'removeEvents' , function ( e ) {
263
+ calendar . fullCalendar ( 'removeEvents' , function ( e ) {
257
264
return e . _id === event . _id ;
258
265
} ) ;
259
266
} ;
260
267
261
268
eventsWatcher . onChanged = function ( event ) {
262
269
event . _start = $ . fullCalendar . moment ( event . start ) ;
263
270
event . _end = $ . fullCalendar . moment ( event . end ) ;
264
- scope . calendar . fullCalendar ( 'updateEvent' , event ) ;
271
+ calendar . fullCalendar ( 'updateEvent' , event ) ;
265
272
} ;
266
273
267
274
eventSourcesWatcher . subscribe ( scope ) ;
0 commit comments