@@ -119,6 +119,7 @@ function Calendar( element, options )
119119 element . find ( 'resource' ) . each ( function ( i , element ) {
120120 t . resources [ $ ( this ) . attr ( 'id' ) ] = new Resource ( $ ( this ) , t . options . insert_policy ) ;
121121 } ) ;
122+ t . resources [ 'unassigned_event_resource' ] = new Resource ( $ ( '#unassigned_event_resource' ) , function ( ) { } ) ;
122123
123124 t . initialize_events = function ( ) {
124125 t . eventmanager = new rc_EventManager ( t . options . retrieve ,
@@ -197,7 +198,7 @@ function Calendar( element, options )
197198 } ) ;
198199
199200 // let the application do any required post-render cleanup:
200- t . options . postcalrender ( ) ;
201+ t . options . postcalrender ( t ) ;
201202 }
202203
203204 t . view_week = function ( date , resources )
@@ -219,7 +220,8 @@ function Calendar( element, options )
219220 }
220221
221222 // find new parent if the date has changed
222- if ( date_changed ) {
223+ // not a valid operation if the event is in the unassigned resource
224+ if ( date_changed && "unassigned_event_resource" != evt . attr . resource ) {
223225 $ ( '#' + evt . attr . resource + ' > .rc_day_target' ) . each ( function ( ) {
224226 if ( evt . attr . date == $ ( this ) . attr ( 'data-date' ) ) {
225227 evt . attr . parent = $ ( this ) . attr ( 'id' ) ;
@@ -273,11 +275,14 @@ function Calendar( element, options )
273275 handles : 's' ,
274276
275277 stop : function ( event , ui ) {
276- var snapheight = ~ ~ ( ui . size . height / t . options . intervalpixels ) ;
278+ var snapheight = ~ ~ ( ( ui . size . height + ( t . options . intervalpixels / 2 ) ) / t . options . intervalpixels ) ;
277279 var total_mins = snapheight * t . options . interval ;
278280
279281 evt . attr . duration = total_mins - ( evt . attr . prep_time + evt . attr . cleanup_time ) ;
280282 ui . helper . css ( 'height' , snapheight * t . options . intervalpixels - 2 + 'px' ) ;
283+ t . view_week_render_event ( evt ) ;
284+ t . options . persist ( evt ) ;
285+
281286 }
282287 } )
283288 }
@@ -293,6 +298,9 @@ function Calendar( element, options )
293298 return false ; // this is a fix for form submit callback
294299 }
295300
301+ //
302+ // External Events Initialization
303+ //
296304 t . external_events_init = function ( events ) {
297305 for ( var event = 0 ; event < events . length ; event ++ )
298306 {
@@ -549,6 +557,9 @@ function Resource( resource_element, insert_policy ) {
549557 // This test can be as complex as you like, but should at least
550558 // perform basic sanity checking such as ensuring that (for example)
551559 // a room can accommodate all of the attendees for a meeting
560+
561+ // [TODO - fix this so that Resources do not have to specify validation]
562+
552563 t . attr . validateFn = window [ resource_element . attr ( 'data-validate' ) ] ;
553564 t . attr . validateParams = $ . parseJSON ( resource_element . attr ( 'data-params' ) ) ;
554565
@@ -574,7 +585,7 @@ function Resource( resource_element, insert_policy ) {
574585 // false: unable to add the event
575586 //
576587 t . addEvent = function ( event , no_confirm ) {
577- if ( reason = t . attr . validateFn ( event . attr , t . attr . validateParams ) ) {
588+ if ( $ . isFunction ( t . attr . validateFn ) && ( reason = t . attr . validateFn ( event . attr , t . attr . validateParams ) ) ) {
578589 rc_notify ( 'Unable to add the event' , 'The ' + reason + ' requirement was not met' , 'error' ) ;
579590 return false ;
580591 }
@@ -608,10 +619,8 @@ function Resource( resource_element, insert_policy ) {
608619 return t . eventpool [ date ] ;
609620 }
610621
611- //t.findCollisions = function( event )
612-
613622 return t ;
614- }
623+ }
615624
616625} ( jQuery ) )
617626
0 commit comments