Adam Shaw 11 лет назад
Родитель
Сommit
fcf579bcb5

+ 8 - 1
src/common/TimeGrid.events.js

@@ -145,7 +145,14 @@ $.extend(TimeGrid.prototype, {
 		}
 
 		return '<a class="' + classes.join(' ') + '"' +
-			(skinCss ? ' style="' + skinCss + '"' : '') +
+			(event.url ?
+				' href="' + htmlEscape(event.url) + '"' :
+				''
+				) +
+			(skinCss ?
+				' style="' + skinCss + '"' :
+				''
+				) +
 			'>' +
 				'<div class="fc-content">' +
 					(timeText ?

+ 21 - 0
tests/automated/DayGrid-events.js

@@ -34,4 +34,25 @@ describe('DayGrid event rendering', function() {
 		expect(row0event1.offset().top).toBeLessThan(row0event2.offset().top);
 		expect(row1event1.offset().top).toBeLessThan(row1event2.offset().top);
 	});
+
+	it('renders an event with no url with no <a> href', function() {
+		options.events = [ {
+			title: 'event1',
+			start: '2014-08-01'
+		} ];
+		$('#cal').fullCalendar(options);
+		var seg = $('.fc-event');
+		expect(seg).not.toHaveAttr('href');
+	});
+
+	it('renders an event with a url with an <a> href', function() {
+		options.events = [ {
+			title: 'event1',
+			start: '2014-08-01',
+			url: 'http://google.com/'
+		} ];
+		$('#cal').fullCalendar(options);
+		var seg = $('.fc-event');
+		expect(seg).toHaveAttr('href');
+	});
 });

+ 21 - 0
tests/automated/TimeGrid-events.js

@@ -46,4 +46,25 @@ describe('TimeGrid event rendering', function() {
 		expect(seg2.find('.fc-time')).not.toBeInDOM();
 	});
 
+	it('renders an event with no url with no <a> href', function() {
+		options.events = [ {
+			title: 'event1',
+			start: '2014-08-18T02:00:00'
+		} ];
+		$('#cal').fullCalendar(options);
+		var seg = $('.fc-event');
+		expect(seg).not.toHaveAttr('href');
+	});
+
+	it('renders an event with a url with an <a> href', function() {
+		options.events = [ {
+			title: 'event1',
+			start: '2014-08-18T02:00:00',
+			url: 'http://google.com/'
+		} ];
+		$('#cal').fullCalendar(options);
+		var seg = $('.fc-event');
+		expect(seg).toHaveAttr('href');
+	});
+
 });