99 startdate : new moment ( ) . valueOf ( ) ,
1010 render : 'view_week' ,
1111 render_event : 'view_week_render_event' ,
12- get_time_offset : function ( evt , ui ) { return ui . offset . top - evt . target . offsetTop ; } ,
12+ get_time_offset : function ( evt , ui ) { return ui . offset . top + $ ( evt . target ) . parent ( ) . scrollTop ( ) - evt . target . offsetTop ; } ,
1313
1414 // persistent event storage accessor functions
1515 // (override with application functions in rc_calendar constructor call)
1616 persist : function ( evt ) { } ,
1717 retrieve : function ( ) { return [ ] } ,
1818 remove : function ( ) { } ,
1919
20+ // default insert_policy is simple - allow overlaps:
21+ insert_policy : function ( event_list , evt ) { event_list [ evt . attr . id ] = evt ; } ,
22+
2023 min_time : '07:00' , // 7am
2124 max_time : '20:00' , // 8pm
2225 interval : 20 , // minutes
@@ -112,7 +115,7 @@ function Calendar( element, options )
112115 //
113116 t . resources = [ ] ;
114117 element . find ( 'resource' ) . each ( function ( i , element ) {
115- t . resources [ $ ( this ) . attr ( 'id' ) ] = new Resource ( $ ( this ) , 'localtest' ) ;
118+ t . resources [ $ ( this ) . attr ( 'id' ) ] = new Resource ( $ ( this ) , t . options . insert_policy ) ;
116119 } ) ;
117120
118121 t . initialize_events = function ( ) {
@@ -240,6 +243,12 @@ function Calendar( element, options )
240243 helper : 'clone' ,
241244 zIndex : 9999 ,
242245 /* drag : function( event, ui ){
246+
247+ // [TODO]
248+ // Update Time in helper during drag
249+ // Add "next week, previous week" drag zones?
250+ //
251+
243252 var time_offset = t.options.get_time_offset( event, ui );
244253 var start_time = nearest_time( time_offset );
245254 ui.helper.find(".rc_event_head").text(start_time);
@@ -498,8 +507,16 @@ function rc_EventManager( retrieve_events, save_event, delete_event, resources,
498507// 3: live Ajax + localStorage for offline working
499508
500509
510+ //
511+ // [TODO] - register per-day availability times for each resource
512+ // This accommodates different open/close times on different days, or
513+ // worker shifts, or holiday/vacation times.
514+ //
515+ // Implement regular hours function, and specific overrides
516+ //
517+
501518
502- function Resource ( resource_element , init_mode ) {
519+ function Resource ( resource_element , insert_policy ) {
503520 var t = this ;
504521
505522 //
@@ -509,6 +526,7 @@ function Resource( resource_element, init_mode ) {
509526 t . eventpool = { } ;
510527
511528 t . id = resource_element . attr ( 'id' ) ;
529+ t . insert_policy = insert_policy ;
512530 t . attr = $ . parseJSON ( resource_element . attr ( 'data-attr' ) ) ;
513531
514532 //
@@ -547,15 +565,14 @@ function Resource( resource_element, init_mode ) {
547565 }
548566 else {
549567
550- // [TODO - add in policy code for overlapping events, locked events]
551-
552-
553-
554568 if ( "undefined" == typeof ( t . eventpool [ event . attr . date ] ) ) {
555569 t . eventpool [ event . attr . date ] = [ ] ;
556570 }
557571
558- t . eventpool [ event . attr . date ] [ event . attr . id ] = event ;
572+ //
573+ // Policy code for overlapping events, locked events
574+ //
575+ t . insert_policy ( t . eventpool [ event . attr . date ] , event ) ;
559576
560577 if ( undefined == no_confirm ) {
561578 var formatted_date = new moment ( event . attr . date ) . format ( "dddd, Do MMM YYYY" ) ;
0 commit comments