Commit c118c2d5 authored by Sebastian's avatar Sebastian
Browse files

HTML Support

close #42
parent 3921df38
......@@ -354,6 +354,11 @@ Appointment summary, defaults to empty string.
Appointment description
#### htmlDescription([_String_ htmlDescription])
Some calendar apps may support HTML descriptions. Like in emails, supported HTML tags and styling is limited.
#### location([_String_ location])
Appointment location
......
......@@ -34,6 +34,7 @@ var ICalEvent = function(_data, calendar) {
summary: '',
location: null,
description: null,
htmlDescription: null,
organizer: null,
attendees: [],
alarms: [],
......@@ -421,6 +422,23 @@ var ICalEvent = function(_data, calendar) {
};
/**
* Set/Get the event's HTML description
*
* @param {String} description
* @since 0.2.8
* @returns {ICalEvent|String}
*/
this.htmlDescription = function(htmlDescription) {
if(htmlDescription === undefined) {
return data.htmlDescription;
}
data.htmlDescription = htmlDescription ? htmlDescription.toString() : null;
return this;
};
/**
* Set/Get the event's organizer
*
......@@ -735,6 +753,11 @@ var ICalEvent = function(_data, calendar) {
g += 'DESCRIPTION:' + tools.escape(data.description) + '\r\n';
}
// HTML DESCRIPTION
if(data.htmlDescription) {
g += 'X-ALT-DESC;FMTTYPE=text/html:' + tools.escape(data.htmlDescription) + '\r\n';
}
// ORGANIZER
if(data.organizer) {
g += 'ORGANIZER;CN="' + tools.escape(data.organizer.name) + '":mailto:' + tools.escape(data.organizer.email) + '\r\n';
......
......@@ -1125,6 +1125,36 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
});
});
describe('htmlDescription()', function() {
it('setter should return this', function() {
var e = ical().createEvent();
assert.deepEqual(e, e.htmlDescription(null));
assert.deepEqual(e, e.htmlDescription('I don\'t need a description. I\'m far to awesome for descriptions…'));
});
it('getter should return value', function() {
var e = ical().createEvent();
assert.equal(e.htmlDescription(), null);
e.htmlDescription('<marquee>I\'m the best HTML tag in this universe!</marquee>');
assert.equal(e.htmlDescription(), '<marquee>I\'m the best HTML tag in this universe!</marquee>');
e.htmlDescription(null);
assert.equal(e.htmlDescription(), null);
});
it('should change something', function() {
var cal = ical(),
event = cal.createEvent({
start: new Date(),
end: new Date(new Date().getTime() + 3600000),
summary: 'Example Event'
}),
str = cal.toString();
event.htmlDescription('<marquee>I\'m the best HTML tag in this universe!</marquee>');
assert.ok(str !== cal.toString());
});
});
describe('organizer()', function() {
it('setter should return this', function() {
var e = ical().createEvent();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment