Browse Source

un-unit-tested bugfixes for 1.2.1

Adam Shaw 16 năm trước cách đây
mục cha
commit
d181c7af2e
4 tập tin đã thay đổi với 55 bổ sung22 xóa
  1. 1 0
      docs/index.txt
  2. 1 0
      docs/templates/layout.html
  3. 41 21
      fullcalendar/fullcalendar.js
  4. 12 1
      fullcalendar/gcal.js

+ 1 - 0
docs/index.txt

@@ -398,6 +398,7 @@ when creating a custom event source:
       * **h** - 01 through 12 (hour, leading zeros)
       * **H** - 00 through 23 (hour, military time and leading zeros)
       * **i** - 00 to 59 (minute, leading zeros)
+      * **c** - 2009-06-07T05:28:21Z (ISO8601)
       
    **$.fullCalendar.parseDate(string)**
       Parse a string and return a javascript Date object. The string may be

+ 1 - 0
docs/templates/layout.html

@@ -13,3 +13,4 @@
 {% block body %}{% endblock %}
 
 <? end_content() ?>
+<? fullcalendar_side() ?>

+ 41 - 21
fullcalendar/fullcalendar.js

@@ -230,13 +230,9 @@
 			
 				addEventSource: function(src) {
 					eventSources.push(src);
-					if (options.loading) {
-						options.loading(true);
-					}
+					pushLoading();
 					fetchEventSource(src, function() {
-						if (options.loading) {
-							options.loading(false);
-						}
+						popLoading();
 						clearEventElements();
 						renderEvents();
 					});
@@ -974,17 +970,13 @@
 					var queued = eventSources.length;
 					var sourceDone = function() {
 						if (--queued == 0) {
-							if (options.loading) {
-								options.loading(false);
-							}
+							popLoading();
 							if (callback) {
 								callback(events);
 							}
 						}
 					};
-					if (options.loading) {
-						options.loading(true);
-					}
+					pushLoading();
 					for (var i=0; i<eventSources.length; i++) {
 						fetchEventSource(eventSources[i], sourceDone);
 					}
@@ -1027,6 +1019,25 @@
 			}
 			
 			
+			//
+			// methods for reporting loading state
+			//
+			
+			var loadingLevel = 0;
+			
+			function pushLoading() {
+				if (!loadingLevel++ && options.loading) {
+					options.loading(true);
+				}
+			}
+			
+			function popLoading() {
+				if (!--loadingLevel && options.loading) {
+					options.loading(false);
+				}
+			}
+			
+			
 			
 			
 			
@@ -1037,26 +1048,33 @@
 			//
 			/*******************************************************************/
 		
-			var e = this;
+			var e = $(this);
+			var _e = this;
 			var resizeID = 0;
 			$(window).resize(function() {   // re-render table on window resize
 				if (!ignoreResizes) {
 					var rid = ++resizeID;   // add a delay
 					setTimeout(function() {
 						if (rid == resizeID) {
-							// if the month width changed
-							if (monthElement.width() != monthElementWidth) {
-								clearEventElements();
-								setCellSizes();
-								_renderEvents();
-								if (options.resize) options.resize.call(e);
+							// if calendar is visible
+							if (e.css('display') != 'none') {
+								// if the month width changed
+								if (monthElement.width() != monthElementWidth) {
+									clearEventElements();
+									setCellSizes();
+									_renderEvents();
+									if (options.resize) options.resize.call(_e);
+								}
 							}
 						}
 					}, 200);
 				}
 			});
 		
-			render(); // let's begin...
+			// let's begin...
+			if (e.css('display') != 'none') {
+				render();
+			}
 			
 			
 			
@@ -1088,7 +1106,9 @@
 		event.start = $.fullCalendar.parseDate(event.start);
 		event._start = cloneDate(event.start);
 		event.end = $.fullCalendar.parseDate(event.end);
-		if (!event.end) event.end = addDays(cloneDate(event.start), 1);
+		if (!event.end || event.end <= event.start) {
+			event.end = addDays(cloneDate(event.start), 1);
+		}
 		return event;
 	}
 	

+ 12 - 1
fullcalendar/gcal.js

@@ -37,6 +37,17 @@
 								if (link.type == 'text/html') url = link.href;
 							});
 							var showTime = entry['gd$when'][0]['startTime'].indexOf('T') != -1;
+							var classNames = [];
+							if (showTime) {
+								classNames.push('nobg');
+							}
+							if (options.className) {
+								if (typeof options.className == 'string') {
+									classNames.push(options.className);
+								}else{
+									classNames = classNames.concat(options.className);
+								}
+							}
 							events.push({
 								id: entry['gCal$uid']['value'],
 								url: url,
@@ -46,7 +57,7 @@
 								location: entry['gd$where'][0]['valueString'],
 								description: entry['content']['$t'],
 								showTime: showTime,
-								className: [showTime ? 'nobg' : null, options.className],
+								className: classNames,
 								draggable: draggable
 							});
 						});