Просмотр исходного кода

make slot_event_overlap test even better

Adam Shaw 12 лет назад
Родитель
Сommit
b7f96ba79a
1 измененных файлов с 22 добавлено и 0 удалено
  1. 22 0
      tests/slot_event_overlap.html

+ 22 - 0
tests/slot_event_overlap.html

@@ -98,8 +98,18 @@
 	}
 
 	function _testOverlap(el, allowOverlap, isRTL) {
+
 		var events = el.find('.fc-event');
 
+		var cell = el.find('.fc-slot0 td');
+		var cellLeft = Math.round(cell.offset().left);
+		var cellWidth = Math.round(cell.outerWidth());
+
+		if (!events.length) { // json events probably couldn't load
+			console.log('need to run this from a real web server');
+			return false;
+		}
+
 		for (var i=0; i<events.length; i++) {
 
 			var event = $(events[i]);
@@ -109,6 +119,16 @@
 			var width = Math.floor(event.outerWidth());
 			var height = Math.floor(event.outerHeight());
 
+			if (left < cellLeft || left + width > cellLeft + cellWidth) {
+				console.log('event is out of bounds', event[0]);
+				return false;
+			}
+
+			if (width < 10 || height < 10) {
+				console.log('event is suprisingly small', event[0]);
+				return false;
+			}
+
 			if (allowOverlap) {
 				width /= 2; // make sure nothing overlaps the first half of the event
 				if (isRTL) {
@@ -160,6 +180,8 @@
 		return true;
 	}
 
+	// TODO: add tests for viewing events in week-mode also
+
 </script>
 <style>