Use camelCase for naming
Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
parent
c3c34890ce
commit
fd49fe6915
@ -155,7 +155,7 @@ function FakeEventSource() {
|
|||||||
FakeEventSource.prototype = {
|
FakeEventSource.prototype = {
|
||||||
_init: function() {
|
_init: function() {
|
||||||
|
|
||||||
this._fake_tasks = [];
|
this._fakeTasks = [];
|
||||||
|
|
||||||
// Generate fake events
|
// Generate fake events
|
||||||
//
|
//
|
||||||
@ -170,7 +170,7 @@ FakeEventSource.prototype = {
|
|||||||
let t = new Date(now.getTime() - n * 4 * 86400 * 1000);
|
let t = new Date(now.getTime() - n * 4 * 86400 * 1000);
|
||||||
t.setHours(10);
|
t.setHours(10);
|
||||||
summary = '10-oclock pow-wow (n=' + n + ')';
|
summary = '10-oclock pow-wow (n=' + n + ')';
|
||||||
this._fake_tasks.push(new CalendarTask(t, summary));
|
this._fakeTasks.push(new CalendarTask(t, summary));
|
||||||
}
|
}
|
||||||
|
|
||||||
// '11-oclock thing' is an event occuring every three days at 11am
|
// '11-oclock thing' is an event occuring every three days at 11am
|
||||||
@ -178,7 +178,7 @@ FakeEventSource.prototype = {
|
|||||||
let t = new Date(now.getTime() + n * 3 * 86400 * 1000);
|
let t = new Date(now.getTime() + n * 3 * 86400 * 1000);
|
||||||
t.setHours(11);
|
t.setHours(11);
|
||||||
summary = '11-oclock thing (n=' + n + ')';
|
summary = '11-oclock thing (n=' + n + ')';
|
||||||
this._fake_tasks.push(new CalendarTask(t, summary));
|
this._fakeTasks.push(new CalendarTask(t, summary));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 'Weekly Meeting' is an event occuring every seven days at 1:45pm (two days displaced)
|
// 'Weekly Meeting' is an event occuring every seven days at 1:45pm (two days displaced)
|
||||||
@ -187,24 +187,24 @@ FakeEventSource.prototype = {
|
|||||||
t.setHours(13);
|
t.setHours(13);
|
||||||
t.setMinutes(45);
|
t.setMinutes(45);
|
||||||
summary = 'Weekly Meeting (n=' + n + ')';
|
summary = 'Weekly Meeting (n=' + n + ')';
|
||||||
this._fake_tasks.push(new CalendarTask(t, summary));
|
this._fakeTasks.push(new CalendarTask(t, summary));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 'Get Married' is an event that actually reflects reality (Dec 4, 2010) :-)
|
// 'Get Married' is an event that actually reflects reality (Dec 4, 2010) :-)
|
||||||
this._fake_tasks.push(new CalendarTask(new Date(2010, 11, 4, 16, 0), 'Get Married'));
|
this._fakeTasks.push(new CalendarTask(new Date(2010, 11, 4, 16, 0), 'Get Married'));
|
||||||
|
|
||||||
// ditto for 'NE Patriots vs NY Jets'
|
// ditto for 'NE Patriots vs NY Jets'
|
||||||
this._fake_tasks.push(new CalendarTask(new Date(2010, 11, 6, 20, 30), 'NE Patriots vs NY Jets'));
|
this._fakeTasks.push(new CalendarTask(new Date(2010, 11, 6, 20, 30), 'NE Patriots vs NY Jets'));
|
||||||
|
|
||||||
// An event for tomorrow @6:30pm that is added/removed every five
|
// An event for tomorrow @6:30pm that is added/removed every five
|
||||||
// seconds (to check that the ::changed signal works)
|
// seconds (to check that the ::changed signal works)
|
||||||
let transient_event_date = new Date(now.getTime() + 86400*1000);
|
let transientEventDate = new Date(now.getTime() + 86400*1000);
|
||||||
transient_event_date.setHours(18);
|
transientEventDate.setHours(18);
|
||||||
transient_event_date.setMinutes(30);
|
transientEventDate.setMinutes(30);
|
||||||
transient_event_date.setSeconds(0);
|
transientEventDate.setSeconds(0);
|
||||||
Mainloop.timeout_add(5000, Lang.bind(this, this._updateTransientEvent));
|
Mainloop.timeout_add(5000, Lang.bind(this, this._updateTransientEvent));
|
||||||
this._includeTransientEvent = false;
|
this._includeTransientEvent = false;
|
||||||
this._transientEvent = new CalendarTask(transient_event_date, 'A Transient Event');
|
this._transientEvent = new CalendarTask(transientEventDate, 'A Transient Event');
|
||||||
this._transientEventCounter = 1;
|
this._transientEventCounter = 1;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -220,8 +220,8 @@ FakeEventSource.prototype = {
|
|||||||
let result = [];
|
let result = [];
|
||||||
//log('begin:' + begin);
|
//log('begin:' + begin);
|
||||||
//log('end: ' + end);
|
//log('end: ' + end);
|
||||||
for(let n = 0; n < this._fake_tasks.length; n++) {
|
for(let n = 0; n < this._fakeTasks.length; n++) {
|
||||||
let task = this._fake_tasks[n];
|
let task = this._fakeTasks[n];
|
||||||
if (task.date >= begin && task.date <= end) {
|
if (task.date >= begin && task.date <= end) {
|
||||||
result.push(task);
|
result.push(task);
|
||||||
}
|
}
|
||||||
@ -263,11 +263,11 @@ function Calendar(eventSource, eventList) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Calendar.prototype = {
|
Calendar.prototype = {
|
||||||
_init: function(event_source, event_list) {
|
_init: function(eventSource, eventList) {
|
||||||
this._event_source = event_source;
|
this._eventSource = eventSource;
|
||||||
this._event_list = event_list;
|
this._eventList = eventList;
|
||||||
|
|
||||||
this._event_source.connect('changed', Lang.bind(this, this._update));
|
this._eventSource.connect('changed', Lang.bind(this, this._update));
|
||||||
|
|
||||||
// FIXME: This is actually the fallback method for GTK+ for the week start;
|
// FIXME: This is actually the fallback method for GTK+ for the week start;
|
||||||
// GTK+ by preference uses nl_langinfo (NL_TIME_FIRST_WEEKDAY). We probably
|
// GTK+ by preference uses nl_langinfo (NL_TIME_FIRST_WEEKDAY). We probably
|
||||||
@ -305,7 +305,7 @@ Calendar.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start off with the current date
|
// Start off with the current date
|
||||||
this.selected_date = new Date();
|
this.selectedDate = new Date();
|
||||||
|
|
||||||
this.actor = new St.Table({ homogeneous: false,
|
this.actor = new St.Table({ homogeneous: false,
|
||||||
style_class: 'calendar',
|
style_class: 'calendar',
|
||||||
@ -320,10 +320,10 @@ Calendar.prototype = {
|
|||||||
|
|
||||||
// Sets the calendar to show a specific date
|
// Sets the calendar to show a specific date
|
||||||
setDate: function(date) {
|
setDate: function(date) {
|
||||||
if (!_sameDay(date, this.selected_date)) {
|
if (!_sameDay(date, this.selectedDate)) {
|
||||||
this.selected_date = date;
|
this.selectedDate = date;
|
||||||
this._update();
|
this._update();
|
||||||
this.emit('selected-date-changed', new Date(this.selected_date));
|
this.emit('selected-date-changed', new Date(this.selectedDate));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -354,14 +354,14 @@ Calendar.prototype = {
|
|||||||
// We need to figure out the abbreviated localized names for the days of the week;
|
// We need to figure out the abbreviated localized names for the days of the week;
|
||||||
// we do this by just getting the next 7 days starting from right now and then putting
|
// we do this by just getting the next 7 days starting from right now and then putting
|
||||||
// them in the right cell in the table. It doesn't matter if we add them in order
|
// them in the right cell in the table. It doesn't matter if we add them in order
|
||||||
let iter = new Date(this.selected_date);
|
let iter = new Date(this.selectedDate);
|
||||||
iter.setSeconds(0); // Leap second protection. Hah!
|
iter.setSeconds(0); // Leap second protection. Hah!
|
||||||
iter.setHours(12);
|
iter.setHours(12);
|
||||||
for (let i = 0; i < 7; i++) {
|
for (let i = 0; i < 7; i++) {
|
||||||
// Could use iter.toLocaleFormat('%a') but that normally gives three characters
|
// Could use iter.toLocaleFormat('%a') but that normally gives three characters
|
||||||
// and we want, ideally, a single character for e.g. S M T W T F S
|
// and we want, ideally, a single character for e.g. S M T W T F S
|
||||||
let custom_day_abbrev = _getCalendarDayAbbreviation(iter.getDay());
|
let customDayAbbrev = _getCalendarDayAbbreviation(iter.getDay());
|
||||||
let label = new St.Label({ text: custom_day_abbrev });
|
let label = new St.Label({ text: customDayAbbrev });
|
||||||
label.style_class = 'calendar-day-base calendar-day-heading';
|
label.style_class = 'calendar-day-base calendar-day-heading';
|
||||||
this.actor.add(label,
|
this.actor.add(label,
|
||||||
{ row: 1,
|
{ row: 1,
|
||||||
@ -400,25 +400,25 @@ Calendar.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_onPrevMonthButtonClicked: function() {
|
_onPrevMonthButtonClicked: function() {
|
||||||
let new_date = new Date(this.selected_date);
|
let newDate = new Date(this.selectedDate);
|
||||||
if (new_date.getMonth() == 0) {
|
if (newDate.getMonth() == 0) {
|
||||||
new_date.setMonth(11);
|
newDate.setMonth(11);
|
||||||
new_date.setFullYear(new_date.getFullYear() - 1);
|
newDate.setFullYear(newDate.getFullYear() - 1);
|
||||||
} else {
|
} else {
|
||||||
new_date.setMonth(new_date.getMonth() - 1);
|
newDate.setMonth(newDate.getMonth() - 1);
|
||||||
}
|
}
|
||||||
this.setDate(new_date);
|
this.setDate(newDate);
|
||||||
},
|
},
|
||||||
|
|
||||||
_onNextMonthButtonClicked: function() {
|
_onNextMonthButtonClicked: function() {
|
||||||
let new_date = new Date(this.selected_date);
|
let newDate = new Date(this.selectedDate);
|
||||||
if (new_date.getMonth() == 11) {
|
if (newDate.getMonth() == 11) {
|
||||||
new_date.setMonth(0);
|
newDate.setMonth(0);
|
||||||
new_date.setFullYear(new_date.getFullYear() + 1);
|
newDate.setFullYear(newDate.getFullYear() + 1);
|
||||||
} else {
|
} else {
|
||||||
new_date.setMonth(new_date.getMonth() + 1);
|
newDate.setMonth(newDate.getMonth() + 1);
|
||||||
}
|
}
|
||||||
this.setDate(new_date);
|
this.setDate(newDate);
|
||||||
},
|
},
|
||||||
|
|
||||||
_onSettingsChange: function() {
|
_onSettingsChange: function() {
|
||||||
@ -428,7 +428,7 @@ Calendar.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_update: function() {
|
_update: function() {
|
||||||
this._dateLabel.text = this.selected_date.toLocaleFormat(this._headerFormat);
|
this._dateLabel.text = this.selectedDate.toLocaleFormat(this._headerFormat);
|
||||||
|
|
||||||
// Remove everything but the topBox and the weekday labels
|
// Remove everything but the topBox and the weekday labels
|
||||||
let children = this.actor.get_children();
|
let children = this.actor.get_children();
|
||||||
@ -436,7 +436,7 @@ Calendar.prototype = {
|
|||||||
children[i].destroy();
|
children[i].destroy();
|
||||||
|
|
||||||
// Start at the beginning of the week before the start of the month
|
// Start at the beginning of the week before the start of the month
|
||||||
let iter = new Date(this.selected_date);
|
let iter = new Date(this.selectedDate);
|
||||||
iter.setDate(1);
|
iter.setDate(1);
|
||||||
iter.setSeconds(0);
|
iter.setSeconds(0);
|
||||||
iter.setHours(12);
|
iter.setHours(12);
|
||||||
@ -451,31 +451,31 @@ Calendar.prototype = {
|
|||||||
|
|
||||||
let iterStr = iter.toUTCString();
|
let iterStr = iter.toUTCString();
|
||||||
button.connect('clicked', Lang.bind(this, function() {
|
button.connect('clicked', Lang.bind(this, function() {
|
||||||
let newly_selected_date = new Date(iterStr);
|
let newly_selectedDate = new Date(iterStr);
|
||||||
this.setDate(newly_selected_date);
|
this.setDate(newly_selectedDate);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let style_class;
|
let styleClass;
|
||||||
let has_tasks;
|
let hasTasks;
|
||||||
has_tasks = this._event_source.hasTasks(iter);
|
hasTasks = this._eventSource.hasTasks(iter);
|
||||||
style_class = 'calendar-day-base calendar-day';
|
styleClass = 'calendar-day-base calendar-day';
|
||||||
if (_isWorkDay(iter))
|
if (_isWorkDay(iter))
|
||||||
style_class += ' calendar-work-day'
|
styleClass += ' calendar-work-day'
|
||||||
else
|
else
|
||||||
style_class += ' calendar-nonwork-day'
|
styleClass += ' calendar-nonwork-day'
|
||||||
|
|
||||||
if (_sameDay(now, iter))
|
if (_sameDay(now, iter))
|
||||||
style_class += ' calendar-today';
|
styleClass += ' calendar-today';
|
||||||
else if (iter.getMonth() != this.selected_date.getMonth())
|
else if (iter.getMonth() != this.selectedDate.getMonth())
|
||||||
style_class += ' calendar-other-month-day';
|
styleClass += ' calendar-other-month-day';
|
||||||
|
|
||||||
if (_sameDay(this.selected_date, iter))
|
if (_sameDay(this.selectedDate, iter))
|
||||||
button.add_style_pseudo_class('active');
|
button.add_style_pseudo_class('active');
|
||||||
|
|
||||||
if (has_tasks)
|
if (hasTasks)
|
||||||
style_class += ' calendar-day-with-events'
|
styleClass += ' calendar-day-with-events'
|
||||||
|
|
||||||
button.style_class = style_class;
|
button.style_class = styleClass;
|
||||||
|
|
||||||
let offsetCols = this._useWeekdate ? 1 : 0;
|
let offsetCols = this._useWeekdate ? 1 : 0;
|
||||||
this.actor.add(button,
|
this.actor.add(button,
|
||||||
@ -491,21 +491,21 @@ Calendar.prototype = {
|
|||||||
iter.setTime(iter.getTime() + MSECS_IN_DAY);
|
iter.setTime(iter.getTime() + MSECS_IN_DAY);
|
||||||
if (iter.getDay() == this._weekStart) {
|
if (iter.getDay() == this._weekStart) {
|
||||||
// We stop on the first "first day of the week" after the month we are displaying
|
// We stop on the first "first day of the week" after the month we are displaying
|
||||||
if (iter.getMonth() > this.selected_date.getMonth() || iter.getYear() > this.selected_date.getYear())
|
if (iter.getMonth() > this.selectedDate.getMonth() || iter.getYear() > this.selectedDate.getYear())
|
||||||
break;
|
break;
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the event list widget
|
// update the event list widget
|
||||||
if (now.getDate() == this.selected_date.getDate() &&
|
if (now.getDate() == this.selectedDate.getDate() &&
|
||||||
now.getMonth() == this.selected_date.getMonth() &&
|
now.getMonth() == this.selectedDate.getMonth() &&
|
||||||
now.getFullYear() == this.selected_date.getFullYear()) {
|
now.getFullYear() == this.selectedDate.getFullYear()) {
|
||||||
// Today - show: Today, Tomorrow and This Week
|
// Today - show: Today, Tomorrow and This Week
|
||||||
this._event_list.showToday();
|
this._eventList.showToday();
|
||||||
} else {
|
} else {
|
||||||
// Not Today - show only events from that day
|
// Not Today - show only events from that day
|
||||||
this._event_list.showOtherDay(this.selected_date);
|
this._eventList.showOtherDay(this.selectedDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -514,14 +514,14 @@ Signals.addSignalMethods(Calendar.prototype);
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
function EventsList(event_source) {
|
function EventsList(eventSource) {
|
||||||
this._init(event_source);
|
this._init(eventSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventsList.prototype = {
|
EventsList.prototype = {
|
||||||
_init: function(event_source) {
|
_init: function(eventSource) {
|
||||||
this.actor = new St.BoxLayout({ vertical: true, style_class: 'events-header-vbox'});
|
this.actor = new St.BoxLayout({ vertical: true, style_class: 'events-header-vbox'});
|
||||||
this._event_source = event_source;
|
this._eventSource = eventSource;
|
||||||
},
|
},
|
||||||
|
|
||||||
_addEvent: function(dayNameBox, timeBox, eventTitleBox, includeDayName, day, time, desc) {
|
_addEvent: function(dayNameBox, timeBox, eventTitleBox, includeDayName, day, time, desc) {
|
||||||
@ -538,7 +538,7 @@ EventsList.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_addPeriod: function(header, begin, end, includeDayName) {
|
_addPeriod: function(header, begin, end, includeDayName) {
|
||||||
let tasks = this._event_source.getTasks(begin, end);
|
let tasks = this._eventSource.getTasks(begin, end);
|
||||||
|
|
||||||
if (tasks.length == 0)
|
if (tasks.length == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -24,7 +24,7 @@ const CLOCK_FORMAT_KEY = 'clock-format';
|
|||||||
const CLOCK_SHOW_DATE_KEY = 'show-date';
|
const CLOCK_SHOW_DATE_KEY = 'show-date';
|
||||||
const CLOCK_SHOW_SECONDS_KEY = 'show-seconds';
|
const CLOCK_SHOW_SECONDS_KEY = 'show-seconds';
|
||||||
|
|
||||||
function on_vert_sep_repaint (area)
|
function _onVertSepRepaint (area)
|
||||||
{
|
{
|
||||||
let cr = area.get_context();
|
let cr = area.get_context();
|
||||||
let themeNode = area.get_theme_node();
|
let themeNode = area.get_theme_node();
|
||||||
@ -60,8 +60,8 @@ DateMenuButton.prototype = {
|
|||||||
let hbox;
|
let hbox;
|
||||||
let vbox;
|
let vbox;
|
||||||
|
|
||||||
//this._event_source = new Calendar.EmptyEventSource();
|
//this._eventSource = new Calendar.EmptyEventSource();
|
||||||
this._event_source = new Calendar.FakeEventSource();
|
this._eventSource = new Calendar.FakeEventSource();
|
||||||
// TODO: write e.g. EvolutionEventSource
|
// TODO: write e.g. EvolutionEventSource
|
||||||
|
|
||||||
PanelMenu.Button.prototype._init.call(this, St.Align.START);
|
PanelMenu.Button.prototype._init.call(this, St.Align.START);
|
||||||
@ -82,10 +82,10 @@ DateMenuButton.prototype = {
|
|||||||
this._date.style_class = 'datemenu-date-label';
|
this._date.style_class = 'datemenu-date-label';
|
||||||
vbox.add(this._date);
|
vbox.add(this._date);
|
||||||
|
|
||||||
this._event_list = new Calendar.EventsList(this._event_source);
|
this._eventList = new Calendar.EventsList(this._eventSource);
|
||||||
|
|
||||||
// Calendar
|
// Calendar
|
||||||
this._calendar = new Calendar.Calendar(this._event_source, this._event_list);
|
this._calendar = new Calendar.Calendar(this._eventSource, this._eventList);
|
||||||
vbox.add(this._calendar.actor);
|
vbox.add(this._calendar.actor);
|
||||||
|
|
||||||
// Add vertical separator
|
// Add vertical separator
|
||||||
@ -93,17 +93,17 @@ DateMenuButton.prototype = {
|
|||||||
item = new St.DrawingArea({ style_class: 'calendar-vertical-separator',
|
item = new St.DrawingArea({ style_class: 'calendar-vertical-separator',
|
||||||
pseudo_class: 'highlighted' });
|
pseudo_class: 'highlighted' });
|
||||||
item.set_width(25); // TODO: don't hard-code the width
|
item.set_width(25); // TODO: don't hard-code the width
|
||||||
item.connect('repaint', Lang.bind(this, on_vert_sep_repaint));
|
item.connect('repaint', Lang.bind(this, _onVertSepRepaint));
|
||||||
hbox.add(item);
|
hbox.add(item);
|
||||||
|
|
||||||
// Fill up the second column
|
// Fill up the second column
|
||||||
//
|
//
|
||||||
// Event list
|
// Event list
|
||||||
hbox.add(this._event_list.actor);
|
hbox.add(this._eventList.actor);
|
||||||
|
|
||||||
// Whenever the menu is opened, select today
|
// Whenever the menu is opened, select today
|
||||||
this.menu.connect('open-state-changed', Lang.bind(this, function(menu, is_open) {
|
this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) {
|
||||||
if (is_open) {
|
if (isOpen) {
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
this._calendar.setDate(now);
|
this._calendar.setDate(now);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user