Skip to content

Commit

Permalink
Merge pull request mozilla-b2g#7612 from dscravag/nightly2
Browse files Browse the repository at this point in the history
Nightly 2013-01-15
  • Loading branch information
dscravag committed Jan 15, 2013
2 parents df38c1b + 5a1b56d commit a03f7b5
Show file tree
Hide file tree
Showing 84 changed files with 1,186 additions and 805 deletions.
4 changes: 2 additions & 2 deletions apps/browser/js/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ var Browser = {
this.handleCrashedTab(tab);
break;

case 'mozbrowserscroll':
case 'mozbrowserasyncscroll':
this.handleScroll(evt);
break;
}
Expand Down Expand Up @@ -1161,7 +1161,7 @@ var Browser = {
var browserEvents = ['loadstart', 'loadend', 'locationchange',
'titlechange', 'iconchange', 'contextmenu',
'securitychange', 'openwindow', 'close',
'showmodalprompt', 'error', 'scroll',
'showmodalprompt', 'error', 'asyncscroll',
'usernameandpasswordrequired'];
browserEvents.forEach(function attachBrowserEvent(type) {
iframe.addEventListener('mozbrowser' + type,
Expand Down
85 changes: 45 additions & 40 deletions apps/calendar/js/views/modify_event.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,6 @@ Calendar.ns('Views').ModifyEvent = (function() {
if (allday) {
// enable case
this.element.classList.add(this.ALLDAY);

var start = this.getField('startDate').value;
var end = this.getField('endDate').value;

// parse dates so we can determine if they match
start = InputParser.importDate(start);
end = InputParser.importDate(end);

// if the dates match then the end date
// needs to be incremented by one otherwise
// the times are exactly the same.
if (start.year === end.year &&
start.month === end.month &&
start.date === end.date) {

// XXX: ideally we could pass a non-date
// object into the input parser ?
end = InputParser.exportDate(new Date(
end.year,
end.month,
end.date + 1
));

this.getField('endDate').value = end;
}

} else {
// disable case
this.element.classList.remove(this.ALLDAY);
Expand Down Expand Up @@ -426,6 +400,16 @@ Calendar.ns('Views').ModifyEvent = (function() {
endTime
);

if (allday) {
// when the event is all day we display the same
// day that the entire event spans but we must actually
// end the event at the first second, minute hour of the next
// day. This will ensure the server handles it as an all day event.
fields.endDate.setDate(
fields.endDate.getDate() + 1
);
}

return fields;
},

Expand All @@ -449,16 +433,46 @@ Calendar.ns('Views').ModifyEvent = (function() {

var dateSrc = model;
if (model.remote.isRecurring && this.busytime) {
dateSrc = this.busytime;
dateSrc = this.busytime;
}

var startDate = dateSrc.startDate;
var endDate = dateSrc.endDate;

// update the allday status of the view
var allday = this.getField('allday');
if (allday && (allday.checked = model.isAllDay)) {
this._toggleAllDay();

// when the event is something like this:
// 2012-01-02 and we detect this is an all day event
// we want to display the end date like this 2012-01-02.
if (
endDate.getHours() === 0 &&
endDate.getSeconds() === 0 &&
endDate.getMinutes() === 0
) {
// subtract the date to give the user a better
// idea of which dates the event spans...
endDate = new Date(
endDate.getFullYear(),
endDate.getMonth(),
endDate.getDate() - 1
);
}
}

this.getField('startDate').value =
InputParser.exportDate(dateSrc.startDate);
InputParser.exportDate(startDate);

this.getField('endDate').value =
InputParser.exportDate(dateSrc.endDate);
InputParser.exportDate(endDate);

this.getField('startTime').value =
InputParser.exportTime(dateSrc.startDate);
InputParser.exportTime(startDate);

this.getField('endTime').value =
InputParser.exportTime(dateSrc.endDate);
InputParser.exportTime(endDate);

this.getField('description').textContent =
model.description;
Expand All @@ -483,15 +497,6 @@ Calendar.ns('Views').ModifyEvent = (function() {
// calendar display
var currentCalendar = this.getField('currentCalendar');

// update the allday status of the view
var allday = this.getField('allday');
if (allday) {
allday.checked = model.isAllDay;
if (allday.checked) {
this.element.classList.add(this.ALLDAY);
}
}

currentCalendar.value = calendar.name;
currentCalendar.readOnly = true;
},
Expand Down
32 changes: 21 additions & 11 deletions apps/calendar/test/unit/views/modify_event_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,15 @@ suite('views/modify_event', function() {
event = Factory('event', {
calendarId: 'foo',
remote: {
startDate: new Date(2012, 1, 1),
endDate: new Date(2012, 1, 5)
startDate: new Date(2012, 1, 1, 1),
endDate: new Date(2012, 1, 5, 1)
}
});

busytime = Factory('busytime', {
eventId: event._id
eventId: event._id,
startDate: new Date(2012, 1, 1, 1),
endDate: new Date(2012, 1, 5, 1)
});

// add account & calendar to cache
Expand Down Expand Up @@ -264,7 +266,7 @@ suite('views/modify_event', function() {
list = subject.element.classList;
});

function updatesValues() {
function updatesValues(overrides) {
// just to verify we actually clear fields...
getField('title').value = 'foo';
event.remote.description = '<span>foo</span>';
Expand All @@ -281,6 +283,12 @@ suite('views/modify_event', function() {

var key;

if (overrides) {
for (key in overrides) {
expected[key] = overrides[key];
}
}

subject.onfirstseen();
subject.useModel(busytime, event);

Expand Down Expand Up @@ -340,14 +348,14 @@ suite('views/modify_event', function() {
calendarId: 'foo',
remote: {
isRecurring: true,
startDate: new Date(2012, 1, 1),
endDate: new Date(2012, 1, 5)
startDate: new Date(2012, 1, 1, 1),
endDate: new Date(2012, 1, 5, 1)
}
});
var busytimeRecurring = Factory('busytime', {
eventId: eventRecurring._id,
startDate: new Date(2012, 10, 30),
endDate: new Date(2012, 10, 31)
startDate: new Date(2012, 10, 30, 1),
endDate: new Date(2012, 10, 31, 1)
});

subject.useModel(busytimeRecurring, eventRecurring);
Expand All @@ -366,7 +374,9 @@ suite('views/modify_event', function() {
test('when start & end times are 00:00:00', function() {
remote.startDate = new Date(2012, 0, 1);
remote.endDate = new Date(2012, 0, 2);
updatesValues();
updatesValues({
endDate: '2012-01-01'
});

var allday = subject.getField('allday');
assert.isTrue(allday.checked, 'checks all day');
Expand Down Expand Up @@ -495,7 +505,7 @@ suite('views/modify_event', function() {

assert.hasProperties(subject.formData(), {
startDate: new Date(2012, 0, 1),
endDate: new Date(2012, 0, 2)
endDate: new Date(2012, 0, 3)
});
});

Expand Down Expand Up @@ -879,7 +889,7 @@ suite('views/modify_event', function() {
assert.ok(!list.contains(subject.ALLDAY), 'has allday');
});

test('when start & end are same dates', function() {
test('when start & end are same dates (all day)', function() {
var model = subject.event;
var date = new Date(2012, 0, 1);
var value = InputParser.exportDate(date);
Expand Down
2 changes: 1 addition & 1 deletion apps/camera/js/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ var Camera = {
// A file with this name may have been written by the user or
// our indexeddb sequence tracker was cleared, check we wont overwrite
// anything
var req = storage.get(path);
var req = storage.get(path + filename);

// A file existed, we bump the directory then try to generate a
// new filename
Expand Down
8 changes: 6 additions & 2 deletions apps/communications/contacts/js/contacts_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ contacts.List = (function() {
}
}
// Add organization name
if (contact.org && contact.org.length > 0 && contact.org[0] !== '') {
if (contact.org && contact.org.length > 0 && contact.org[0] !== '' &&
contact.org[0] != contact.givenName) {
meta.innerHTML += utils.text.escapeHTML(contact.org[0], true);
}

Expand Down Expand Up @@ -496,7 +497,9 @@ contacts.List = (function() {
// Fills the contact data to display if no givenName and familyName
var refillContactData = function refillContactData(contact) {
if (!contact.givenName && !contact.familyName) {
if (contact.tel && contact.tel.length > 0) {
if (contact.org && contact.org.length > 0) {
contact.givenName = contact.org;
} else if (contact.tel && contact.tel.length > 0) {
contact.givenName = contact.tel[0].value;
} else if (contact.email && contact.email.length > 0) {
contact.givenName = contact.email[0].value;
Expand Down Expand Up @@ -578,6 +581,7 @@ contacts.List = (function() {

ret.push(first);
ret.push(second);
ret.push(contact.org);
ret.push(contact.tel && contact.tel.length > 0 ?
contact.tel[0].value : '');
ret.push(contact.email && contact.email.length > 0 ?
Expand Down
33 changes: 28 additions & 5 deletions apps/communications/contacts/test/unit/contacts_list_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ suite('Render contacts list', function() {
assertNoGroup(groupFav, containerFav);
assertGroup(groupA, containerA, 1);
assertGroup(groupB, containerB, 1);
assertGroup(groupB, containerC, 1);
assertGroup(groupC, containerC, 1);
assertNoGroup(groupD, containerD);

});
Expand Down Expand Up @@ -309,13 +309,33 @@ suite('Render contacts list', function() {
assertTotal(3, 4);
});

test('rendering one with no name and phone', function() {
test('rendering one with no name nor phone and company', function() {
var newContact = new MockContactAllFields();
newContact.id = '4';
newContact.familyName = null;
newContact.givenName = null;
newContact.name = null;
newContact.category = null;
newContact.org = 'AD';
var newList = mockContacts.concat([newContact]);
subject.load(newList);
assert.isTrue(noContacts.classList.contains('hide'));
assertNoGroup(groupFav, containerFav);
var cContacts = assertGroup(groupC, containerC, 1);
assert.isTrue(cContacts[0].innerHTML.indexOf('CC') > -1);
var aContacts = assertGroup(groupA, containerA, 2);
assert.isTrue(aContacts[0].innerHTML.indexOf('AD') > -1);
assertTotal(3, 4);
});

test('rendering one with no name nor company and phone', function() {
var newContact = new MockContactAllFields();
newContact.id = '4';
newContact.familyName = null;
newContact.givenName = null;
newContact.name = null;
newContact.category = null;
newContact.org = null;
var newList = mockContacts.concat([newContact]);
subject.load(newList);
assert.isTrue(noContacts.classList.contains('hide'));
Expand All @@ -328,14 +348,15 @@ suite('Render contacts list', function() {
assertTotal(4, 4);
});

test('rendering one with no name and email', function() {
test('rendering one with no name nor company and email', function() {
var newContact = new MockContactAllFields();
newContact.id = '4';
newContact.familyName = null;
newContact.givenName = null;
newContact.name = null;
newContact.category = null;
newContact.tel = null;
newContact.org = null;
newContact.email[0].value = '[email protected]';
var newList = mockContacts.concat([newContact]);
subject.load(newList);
Expand All @@ -348,14 +369,15 @@ suite('Render contacts list', function() {
assertTotal(3, 4);
});

test('rendering one with no name nor email', function() {
test('rendering one with no name nor email nor company', function() {
var newContact = new MockContactAllFields();
newContact.id = '4';
newContact.familyName = null;
newContact.givenName = null;
newContact.name = null;
newContact.category = null;
newContact.tel = null;
newContact.org = null;
newContact.email = null;
var newList = mockContacts.concat([newContact]);
subject.load(newList);
Expand All @@ -368,14 +390,15 @@ suite('Render contacts list', function() {
assertTotal(4, 4);
});

test('rendering one with no name nor email and favorite', function() {
test('rendering one with no name nor email nor company and favorite', function() {
var newContact = new MockContactAllFields();
newContact.id = '4';
newContact.familyName = null;
newContact.givenName = null;
newContact.name = null;
newContact.category = ['favorite'];
newContact.tel = null;
newContact.org = null;
newContact.email = null;
var newList = mockContacts.concat([newContact]);
subject.load(newList);
Expand Down
4 changes: 2 additions & 2 deletions apps/communications/dialer/js/recents.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ var Recents = {

// All the scripts are now loaded
if (scriptLoadCount === scripts.length) {
var headerSelector = '#recents-container h2';
var headerSelector = '#recents-container header';
FixedHeader.init('#recents-container',
'#fixed-container', headerSelector);

Expand Down Expand Up @@ -769,7 +769,7 @@ var Recents = {
logItem.classList.add('isContact');
logItem.dataset['contactId'] = contact.id;
} else {
contactPhoto.classList.add('unknownContact');
logItem.classList.remove('hasPhoto');
delete logItem.dataset['contactId'];
var isContact = logItem.classList.contains('isContact');
if (isContact) {
Expand Down
5 changes: 5 additions & 0 deletions apps/communications/ftu/js/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ var Navigation = {
simOption.classList.add('disabled');
}
// If we have 3G or Wifi activate FB import
if(!WifiManager.api){
// Desktop
fbOption.classList.remove('disabled');
return;
}
if (WifiManager.api.connection.status === 'connected' ||
DataMobile.isDataAvailable) {
fbOption.classList.remove('disabled');
Expand Down
3 changes: 3 additions & 0 deletions apps/communications/ftu/js/wifi.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ var WifiManager = {
* Until this is properly implemented, we just compare SSIDs and
* capabilities to tell wether the network is already connected or not.
*/
if(!this.api){
return false;
}
var currentNetwork = this.api.connection.network;
if (!currentNetwork || this.api.connection.status != 'connected')
return false;
Expand Down
Loading

0 comments on commit a03f7b5

Please sign in to comment.