Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #6758 from KevinGrandon/bug-807906
Browse files Browse the repository at this point in the history
Bug 807906 - Improve template generation
  • Loading branch information
lightsofapollo committed Nov 30, 2012
2 parents 494364a + 64e6316 commit c50f18c
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 86 deletions.
26 changes: 11 additions & 15 deletions apps/calendar/js/templates/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,20 @@

var Account = Calendar.Template.create({
provider: function() {
return [
'<li class="', this.h('name'), '">',
'<a data-provider="', this.h('name'), '" href="/create-account/', this.h('name'), '">',
this.l10n('name', 'preset-'),
'</a>',
'</li>'
].join('');
return '<li class="' + this.h('name') + '">' +
'<a data-provider="' + this.h('name') + '" href="/create-account/' + this.h('name') + '">' +
this.l10n('name', 'preset-') +
'</a>' +
'</li>';
},

account: function() {
return [
'<li id="account-', this.h('id'), '">',
'<a href="/update-account/', this.h('id'), '">',
'<span class="preset">', this.l10n('preset', 'preset-'), '</span>',
'<span class="user">', this.h('user'), '</span>',
'</a>',
'</li>'
].join('');
return '<li id="account-' + this.h('id') + '">' +
'<a href="/update-account/' + this.h('id') + '">' +
'<span class="preset">' + this.l10n('preset', 'preset-') + '</span>' +
'<span class="user">' + this.h('user') + '</span>' +
'</a>' +
'</li>';
}
});

Expand Down
24 changes: 11 additions & 13 deletions apps/calendar/js/templates/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

var Cal = Calendar.Template.create({
item: function() {
return [
'<li id="calendar-', this.h('_id'), '">',
'<div class="calendar-id-', this.h('_id'), ' calendar-color"></div>',
'<label>',
'<span class="name">', this.h('name'), '</span>',
'<input ',
'value="', this.h('_id'), '" ',
'type="checkbox" ',
this.bool('localDisplayed', 'checked'), ' />',
'<span></span>',
'</label>',
'</li>'
].join('');
return '<li id="calendar-' + this.h('_id') + '">' +
'<div class="calendar-id-' + this.h('_id') + ' calendar-color"></div>' +
'<label>' +
'<span class="name">' + this.h('name') + '</span>' +
'<input ' +
'value="' + this.h('_id') + '" ' +
'type="checkbox" ' +
this.bool('localDisplayed', 'checked') + ' />' +
'<span></span>' +
'</label>' +
'</li>';
}
});

Expand Down
40 changes: 18 additions & 22 deletions apps/calendar/js/templates/day.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,32 @@

var Day = Calendar.Template.create({
hour: function() {
return [
'<section class="hour hour-', this.h('hour'), ' ', this.h('classes'), ' calendar-display">',
'<h4>',
'<span class="display-hour ', this.h('hour'), '">', this.h('displayHour'), '</span>',
'</h4>',
return '<section class="hour hour-' + this.h('hour') + ' ' + this.h('classes') + ' calendar-display">' +
'<h4>' +
'<span class="display-hour ' + this.h('hour') + '">' + this.h('displayHour') + '</span>' +
'</h4>' +
/** has no semantic value - re-evaluate */
'<div class="events">', this.s('items'), '</div>',
'</section>'
].join('');
'<div class="events">' + this.s('items') + '</div>' +
'</section>';
},

attendee: function() {
return '<span class="attendee">' + this.h('value') + '</span>';
},

event: function() {
return [
'<section class="event calendar-id-', this.h('calendarId'), ' ' +
'calendar-display" data-id="', this.h('busytimeId'), '">',
'<div class="container calendar-id-', this.h('calendarId'), ' calendar-color">',
'<h5>', this.h('title'), '</h5>',
'<span class="details">',
'<span class="location">',
this.h('location'),
'</span>',
this.s('attendees'),
'</span>',
'</div>',
'</section>'
].join('');
return '<section class="event calendar-id-' + this.h('calendarId') + ' ' +
'calendar-display" data-id="' + this.h('busytimeId') + '">' +
'<div class="container calendar-id-' + this.h('calendarId') + ' calendar-color">' +
'<h5>' + this.h('title') + '</h5>' +
'<span class="details">' +
'<span class="location">' +
this.h('location') +
'</span>' +
this.s('attendees') +
'</span>' +
'</div>' +
'</section>';
}
});

Expand Down
38 changes: 15 additions & 23 deletions apps/calendar/js/templates/month.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,30 @@
},

weekDaysHeader: function() {
return [
'<header id="month-days">',
'<ol role="row">',
this.s('value'),
'</ol>',
'</header>'
].join('');
return '<header id="month-days">' +
'<ol role="row">' +
this.s('value') +
'</ol>' +
'</header>';
},

weekDaysHeaderDay: function() {
return [
'<li data-l10n-id="weekday-', this.h('day'), '-short">',
this.h('dayName'),
'</li>'
].join('');
return '<li data-l10n-id="weekday-' + this.h('day') + '-short">' +
this.h('dayName') +
'</li>';
},

week: function() {
return [
'<ol role="row">',
this.s('value'),
'</ol>'
].join('');
return '<ol role="row">' +
this.s('value') +
'</ol>';
},

day: function() {
return [
'<li id="', this.s('id'), '" data-date="', this.s('dateString'), '" class="', this.s('state'), '">',
'<span class="day">', this.h('date'), '</span>',
'<div class="busy-indicator">', this.s('busy'), '</div>',
'</li>'
].join('');
return '<li id="' + this.s('id') + '" data-date="' + this.s('dateString') + '" class="' + this.s('state') + '">' +
'<span class="day">' + this.h('date') + '</span>' +
'<div class="busy-indicator">' + this.s('busy') + '</div>' +
'</li>';
}
});

Expand Down
22 changes: 9 additions & 13 deletions apps/calendar/js/templates/week.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,18 @@
},

hour: function() {
return [
'<ol class="hour-', this.h('hour'), ' events">',
this.s('items'),
'</ol>'
].join('');
return '<ol class="hour-' + this.h('hour') + ' events">' +
this.s('items') +
'</ol>';
},

event: function() {
return [
'<li class="event" data-id="', this.h('busytimeId'), '">',
'<div class="container calendar-id-', this.h('calendarId'), ' ' +
'calendar-display calendar-color">',
this.h('title'),
'</div>',
'</li>'
].join('');
return '<li class="event" data-id="' + this.h('busytimeId') + '">' +
'<div class="container calendar-id-' + this.h('calendarId') + ' ' +
'calendar-display calendar-color">' +
this.h('title') +
'</div>' +
'</li>';
}
});

Expand Down

0 comments on commit c50f18c

Please sign in to comment.