(js) Fix possible errors (help from jsjint)

pull/91/head
Francis Lachapelle 2015-07-24 16:14:53 -04:00
parent e064dc4a46
commit dc9a0896e5
27 changed files with 166 additions and 157 deletions

View File

@ -161,7 +161,7 @@
if (!user.wasSubscribed && user.isSubscribed) { if (!user.wasSubscribed && user.isSubscribed) {
users.push(user.uid); users.push(user.uid);
// console.debug('subscribe ' + user.uid); // console.debug('subscribe ' + user.uid);
}; }
}); });
if (users.length) { if (users.length) {
param = {uids: users.join(',')}; param = {uids: users.join(',')};

View File

@ -2,6 +2,7 @@
/* JavaScript for Authentication */ /* JavaScript for Authentication */
(function() { (function() {
/* jshint validthis: true */
'use strict'; 'use strict';
angular.module('SOGo.Authentication', []) angular.module('SOGo.Authentication', [])
@ -41,7 +42,7 @@
start++; start++;
if (start > 0) if (start > 0)
currentPair = currentPair.substr(start); currentPair = currentPair.substr(start);
if (currentPair.indexOf(prefix) == 0) if (currentPair.indexOf(prefix) === 0)
foundCookie = currentPair.substr(prefix.length); foundCookie = currentPair.substr(prefix.length);
} }
@ -77,12 +78,11 @@
parts = baseAddress.split('/'); parts = baseAddress.split('/');
parts.splice(0, 3); parts.splice(0, 3);
altBaseAddress = parts.join('/'); altBaseAddress = parts.join('/');
newAddress; if ((address.startsWith(baseAddress) || address.startsWith(altBaseAddress)) &&
if ((address.startsWith(baseAddress) !address.endsWith('/logoff')) {
|| address.startsWith(altBaseAddress))
&& !address.endsWith('/logoff')) {
newAddress = address; newAddress = address;
} else { }
else {
newAddress = baseAddress; newAddress = baseAddress;
} }
@ -91,8 +91,9 @@
this.$get = getService; this.$get = getService;
getService.$inject = ['$q', '$http', 'passwordPolicyConfig'] getService.$inject = ['$q', '$http', 'passwordPolicyConfig'];
function getService($q, $http, passwordPolicyConfig) { function getService($q, $http, passwordPolicyConfig) {
var _this = this, service; var _this = this, service;
service = { service = {
@ -183,7 +184,7 @@
d.resolve(); d.resolve();
}).error(function(data, status) { }).error(function(data, status) {
var error, var error,
perr = data["LDAPPasswordPolicyError"]; perr = data.LDAPPasswordPolicyError;
if (!perr) { if (!perr) {
perr = passwordPolicyConfig.PolicyPasswordSystemUnknown; perr = passwordPolicyConfig.PolicyPasswordSystemUnknown;

View File

@ -90,11 +90,11 @@
scope.cancel = function() { scope.cancel = function() {
d.reject(); d.reject();
$mdDialog.hide(); $mdDialog.hide();
} };
scope.ok = function() { scope.ok = function() {
d.resolve(scope.name); d.resolve(scope.name);
$mdDialog.hide(); $mdDialog.hide();
} };
} }
return d.promise; return d.promise;
@ -110,7 +110,7 @@
angular.extend(Dialog, { $q: $q , $modal: $mdDialog }); angular.extend(Dialog, { $q: $q , $modal: $mdDialog });
return Dialog; // return constructor return Dialog; // return constructor
}; }
/* Factory registration in Angular module */ /* Factory registration in Angular module */
angular angular

View File

@ -21,8 +21,9 @@
} }
hash = email.md5(); hash = email.md5();
// return 'https://www.gravatar.com/avatar/' + hash + '?s=' + s + '&d=identicon';
return 'https://www.gravatar.com/avatar/' + hash + '?s=' + s + '&d=wavatar'; return 'https://www.gravatar.com/avatar/' + hash + '?s=' + s + '&d=wavatar';
} };
} }
angular angular

View File

@ -59,7 +59,10 @@
User.$query = search; User.$query = search;
return User.$$resource.fetch(null, 'usersSearch', param).then(function(response) { return User.$$resource.fetch(null, 'usersSearch', param).then(function(response) {
var results, index, user; var results, index, user,
compareUids = function(data) {
return user.uid == data.uid;
};
if (excludedUsers) { if (excludedUsers) {
// Remove excluded users from response // Remove excluded users from response
results = _.filter(response.users, function(data) { results = _.filter(response.users, function(data) {
@ -84,9 +87,7 @@
// Remove users that no longer match the search query // Remove users that no longer match the search query
for (index = User.$users.length - 1; index >= 0; index--) { for (index = User.$users.length - 1; index >= 0; index--) {
user = User.$users[index]; user = User.$users[index];
if (!_.find(results, function(data) { if (!_.find(results, compareUids)) {
return user.uid == data.uid;
})) {
User.$users.splice(index, 1); User.$users.splice(index, 1);
} }
} }
@ -109,10 +110,6 @@
this.$$image = this.image || User.$gravatar(this.c_email); this.$$image = this.image || User.$gravatar(this.c_email);
}; };
User.prototype.toString = function() {
return '[User ' + this.c_email + ']';
};
/** /**
* @function $shortFormat * @function $shortFormat
* @memberof User.prototype * @memberof User.prototype
@ -276,4 +273,8 @@
return user; return user;
}; };
User.prototype.toString = function() {
return '[User ' + this.c_email + ']';
};
})(); })();

View File

@ -16,7 +16,7 @@
$timeout(function() { $timeout(function() {
$rootScope.$broadcast('sgFocusOn', name); $rootScope.$broadcast('sgFocusOn', name);
}); });
} };
} }
angular angular

View File

@ -35,7 +35,7 @@
' }', ' }',
'</style>' '</style>'
].join('') ].join('')
} };
} }
angular angular

View File

@ -1,6 +1,7 @@
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
(function() { (function() {
/* jshint validthis: true */
'use strict'; 'use strict';
/* /*
@ -66,7 +67,7 @@
if (buttonEl && compiledButtonEl) { if (buttonEl && compiledButtonEl) {
compiledButtonEl.on('click', controller.cancelSearch); compiledButtonEl.on('click', controller.cancelSearch);
} }
} };
} }
} }
@ -83,7 +84,7 @@
transclude(function(clone) { transclude(function(clone) {
iElement.append(clone); iElement.append(clone);
}); });
} };
} }
} }
@ -109,9 +110,9 @@
// Method to call on data changes // Method to call on data changes
vm.onChange = function() { vm.onChange = function() {
if (vm.searchText != null) { if (vm.searchText !== null) {
if (vm.searchText != vm.previous.searchText || vm.searchField != vm.previous.searchField) { if (vm.searchText != vm.previous.searchText || vm.searchField != vm.previous.searchField) {
if (vm.searchText.length > 2 || vm.searchText.length == 0) { if (vm.searchText.length > 2 || vm.searchText.length === 0) {
// doSearch is the compiled expression of the sg-search attribute // doSearch is the compiled expression of the sg-search attribute
vm.doSearch($scope, { searchText: vm.searchText, searchField: vm.searchField }); vm.doSearch($scope, { searchText: vm.searchText, searchField: vm.searchField });
} }

View File

@ -1,6 +1,7 @@
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
(function() { (function() {
/* jshint validthis: true */
'use strict'; 'use strict';
/* /*
@ -27,7 +28,12 @@
controller: sgSubscribeDialogController, controller: sgSubscribeDialogController,
controllerAs: 'vm', controllerAs: 'vm',
link: link link: link
} };
}
function link(scope, element, attrs, controller) {
var inputEl = element.find('input');
element.on('click', controller.showDialog);
} }
/** /**
@ -85,12 +91,6 @@
}; };
} }
function link(scope, element, attrs, controller) {
var inputEl = element.find('input');
element.on('click', controller.showDialog);
}
angular angular
.module('SOGo.Common') .module('SOGo.Common')
.directive('sgSubscribe', sgSubscribe); .directive('sgSubscribe', sgSubscribe);

View File

@ -29,7 +29,8 @@
i, i,
modelDays, modelDays,
modelAttr, modelAttr,
ensureInitRunsOnce; ensureInitRunsOnce,
toggleClass;
ensureInitRunsOnce = scope.$watch(function() { ensureInitRunsOnce = scope.$watch(function() {
// Parse attribute until it returns a valid object // Parse attribute until it returns a valid object
@ -51,18 +52,20 @@
ensureInitRunsOnce(); ensureInitRunsOnce();
} }
}); });
for (i = 0; i < tiles.length; i++) { toggleClass = function() {
tile = angular.element(tiles[i]);
tile.addClass('iconButton');
tile.find('figure').addClass('md-icon');
tile.on('click', function() {
// Toggle class on click event and call toggle function // Toggle class on click event and call toggle function
var tile = angular.element(this), var tile = angular.element(this),
day = tile.attr('value'); day = tile.attr('value');
tile.toggleClass('sg-active'); tile.toggleClass('sg-active');
toggle(day); toggle(day);
}); };
for (i = 0; i < tiles.length; i++) {
tile = angular.element(tiles[i]);
tile.addClass('iconButton');
tile.find('figure').addClass('md-icon');
tile.on('click', toggleClass);
} }
function toggle(day) { function toggle(day) {

View File

@ -83,9 +83,9 @@
list = addressbook.isSubscription? this.$subscriptions : this.$addressbooks; list = addressbook.isSubscription? this.$subscriptions : this.$addressbooks;
sibling = _.find(list, function(o) { sibling = _.find(list, function(o) {
return (addressbook.id == 'personal' return (addressbook.id == 'personal' ||
|| (o.id != 'personal' (o.id != 'personal' &&
&& o.name.localeCompare(addressbook.name) === 1)); o.name.localeCompare(addressbook.name) === 1));
}); });
i = sibling ? _.indexOf(_.pluck(list, 'id'), sibling.id) : 1; i = sibling ? _.indexOf(_.pluck(list, 'id'), sibling.id) : 1;
list.splice(i, 0, addressbook); list.splice(i, 0, addressbook);
@ -140,9 +140,9 @@
var _this = this; var _this = this;
return AddressBook.$$resource.userResource(uid).fetch(path, 'subscribe').then(function(addressbookData) { return AddressBook.$$resource.userResource(uid).fetch(path, 'subscribe').then(function(addressbookData) {
var addressbook = new AddressBook(addressbookData); var addressbook = new AddressBook(addressbookData);
if (!_.find(_this.$subscriptions, function(o) { if (_.isUndefined(_.find(_this.$subscriptions, function(o) {
return o.id == addressbookData.id; return o.id == addressbookData.id;
})) { }))) {
// Not already subscribed // Not already subscribed
AddressBook.$add(addressbook); AddressBook.$add(addressbook);
} }
@ -196,7 +196,7 @@
count = 0; count = 0;
if (this.cards) { if (this.cards) {
count = (_.filter(this.cards, function(card) { return card.selected })).length; count = (_.filter(this.cards, function(card) { return card.selected; })).length;
} }
return count; return count;
}; };
@ -214,23 +214,22 @@
.then(function(response) { .then(function(response) {
var index, card, var index, card,
results = response.cards, results = response.cards,
cards = _this.cards; cards = _this.cards,
compareIds = function(data) {
return this.id == data.id;
};
// Remove cards that no longer exist // Remove cards that no longer exist
for (index = cards.length - 1; index >= 0; index--) { for (index = cards.length - 1; index >= 0; index--) {
card = cards[index]; card = cards[index];
if (!_.find(results, function(data) { if (_.isUndefined(_.find(results, compareIds, card))) {
return card.id == data.id;
})) {
cards.splice(index, 1); cards.splice(index, 1);
} }
} }
// Add new cards // Add new cards
_.each(results, function(data, index) { _.each(results, function(data, index) {
if (!_.find(cards, function(card) { if (_.isUndefined(_.find(cards, compareIds, data))) {
return card.id == data.id;
})) {
var card = new AddressBook.$Card(data); var card = new AddressBook.$Card(data);
cards.splice(index, 0, card); cards.splice(index, 0, card);
} }
@ -272,7 +271,10 @@
return this.$id().then(function(addressbookId) { return this.$id().then(function(addressbookId) {
return AddressBook.$$resource.fetch(addressbookId, 'view', _this.$query); return AddressBook.$$resource.fetch(addressbookId, 'view', _this.$query);
}).then(function(response) { }).then(function(response) {
var results, cards, card, index; var results, cards, card, index,
compareIds = function(data) {
return this.id == data.id;
};
if (options && options.dry) { if (options && options.dry) {
// Don't keep a copy of the resulting cards. // Don't keep a copy of the resulting cards.
// This is usefull when doing autocompletion. // This is usefull when doing autocompletion.
@ -283,10 +285,8 @@
} }
if (excludedCards) { if (excludedCards) {
// Remove excluded cards from results // Remove excluded cards from results
results = _.filter(response.cards, function(data) { results = _.filter(response.cards, function(card) {
return !_.find(excludedCards, function(card) { return _.isUndefined(_.find(excludedCards, compareIds, card));
return card.id == data.id;
});
}); });
} }
else { else {
@ -295,17 +295,13 @@
// Remove cards that no longer match the search query // Remove cards that no longer match the search query
for (index = cards.length - 1; index >= 0; index--) { for (index = cards.length - 1; index >= 0; index--) {
card = cards[index]; card = cards[index];
if (!_.find(results, function(data) { if (_.isUndefined(_.find(results, compareIds, card))) {
return card.id == data.id;
})) {
cards.splice(index, 1); cards.splice(index, 1);
} }
} }
// Add new cards matching the search query // Add new cards matching the search query
_.each(results, function(data, index) { _.each(results, function(data, index) {
if (!_.find(cards, function(card) { if (_.isUndefined(_.find(cards, compareIds, data))) {
return card.id == data.id;
})) {
var card = new AddressBook.$Card(data, search); var card = new AddressBook.$Card(data, search);
cards.splice(index, 0, card); cards.splice(index, 0, card);
} }
@ -314,9 +310,7 @@
_.each(results, function(data, index) { _.each(results, function(data, index) {
var oldIndex, removedCards; var oldIndex, removedCards;
if (cards[index].id != data.id) { if (cards[index].id != data.id) {
oldIndex = _.findIndex(cards, function(card) { oldIndex = _.findIndex(cards, compareIds, data);
return card.id == data.id;
});
removedCards = cards.splice(oldIndex, 1); removedCards = cards.splice(oldIndex, 1);
cards.splice(index, 0, removedCards[0]); cards.splice(index, 0, removedCards[0]);
} }
@ -379,7 +373,7 @@
*/ */
AddressBook.prototype.$deleteCards = function(cards) { AddressBook.prototype.$deleteCards = function(cards) {
var uids = _.map(cards, function(card) { return card.id }); var uids = _.map(cards, function(card) { return card.id; });
var _this = this; var _this = this;
return AddressBook.$$resource.post(this.id, 'batchDelete', {uids: uids}).then(function() { return AddressBook.$$resource.post(this.id, 'batchDelete', {uids: uids}).then(function() {

View File

@ -61,7 +61,7 @@
scope.create = function(type) { scope.create = function(type) {
$mdDialog.hide(); $mdDialog.hide();
$state.go('app.addressbook.new', { addressbookId: addressbookId, contactType: type }); $state.go('app.addressbook.new', { addressbookId: addressbookId, contactType: type });
} };
} }
} }
@ -78,8 +78,9 @@
l('Are you sure you want to delete the selected contacts?')) l('Are you sure you want to delete the selected contacts?'))
.then(function() { .then(function() {
// User confirmed the deletion // User confirmed the deletion
var selectedCards = _.filter(vm.selectedFolder.cards, function(card) { return card.selected }); var selectedCards = _.filter(vm.selectedFolder.cards, function(card) { return card.selected; });
vm.selectedFolder.$deleteCards(selectedCards); vm.selectedFolder.$deleteCards(selectedCards);
delete vm.selectedFolder.selectedCard;
}, function(data, status) { }, function(data, status) {
// Delete failed // Delete failed
}); });

View File

@ -127,7 +127,7 @@
function LinksDialogController(scope, $mdDialog) { function LinksDialogController(scope, $mdDialog) {
scope.close = function() { scope.close = function() {
$mdDialog.hide(); $mdDialog.hide();
} };
} }
} }
@ -206,7 +206,7 @@
vm.selectedUser = null; vm.selectedUser = null;
} }
}, function(data, status) { }, function(data, status) {
Dialog.alert(l('Warning'), l('An error occured please try again.')) Dialog.alert(l('Warning'), l('An error occured please try again.'));
}); });
} }

View File

@ -54,7 +54,7 @@
* @desc Factory registration of Card in Angular module. * @desc Factory registration of Card in Angular module.
*/ */
angular.module('SOGo.ContactsUI') angular.module('SOGo.ContactsUI')
.factory('Card', Card.$factory) .factory('Card', Card.$factory);
/** /**
* @memberof Card * @memberof Card
@ -171,7 +171,7 @@
Card.prototype.$fullname = function() { Card.prototype.$fullname = function() {
var fn = this.fn || '', names; var fn = this.fn || '', names;
if (fn.length == 0) { if (fn.length === 0) {
names = []; names = [];
if (this.givenname && this.givenname.length > 0) if (this.givenname && this.givenname.length > 0)
names.push(this.givenname); names.push(this.givenname);
@ -185,7 +185,7 @@
fn = this.org; fn = this.org;
} }
else if (this.emails && this.emails.length > 0) { else if (this.emails && this.emails.length > 0) {
fn = _.find(this.emails, function(i) { return i.value != ''; }).value; fn = _.find(this.emails, function(i) { return i.value !== ''; }).value;
} }
else if (this.c_cn && this.c_cn.length > 0) { else if (this.c_cn && this.c_cn.length > 0) {
fn = this.c_cn; fn = this.c_cn;
@ -201,7 +201,7 @@
if (this.role) description.push(this.role); if (this.role) description.push(this.role);
if (this.orgUnits && this.orgUnits.length > 0) if (this.orgUnits && this.orgUnits.length > 0)
_.forEach(this.orgUnits, function(unit) { _.forEach(this.orgUnits, function(unit) {
if (unit.value != '') if (unit.value !== '')
description.push(unit.value); description.push(unit.value);
}); });
if (this.org) description.push(this.org); if (this.org) description.push(this.org);
@ -307,7 +307,7 @@
if (angular.isUndefined(this.emails)) { if (angular.isUndefined(this.emails)) {
this.emails = [{type: type, value: ''}]; this.emails = [{type: type, value: ''}];
} }
else if (!_.find(this.emails, function(i) { return i.value == ''; })) { else if (_.isUndefined(_.find(this.emails, function(i) { return i.value === ''; }))) {
this.emails.push({type: type, value: ''}); this.emails.push({type: type, value: ''});
} }
return this.emails.length - 1; return this.emails.length - 1;
@ -317,7 +317,7 @@
if (angular.isUndefined(this.phones)) { if (angular.isUndefined(this.phones)) {
this.phones = [{type: type, value: ''}]; this.phones = [{type: type, value: ''}];
} }
else if (!_.find(this.phones, function(i) { return i.value == ''; })) { else if (_.isUndefined(_.find(this.phones, function(i) { return i.value === ''; }))) {
this.phones.push({type: type, value: ''}); this.phones.push({type: type, value: ''});
} }
return this.phones.length - 1; return this.phones.length - 1;
@ -327,7 +327,7 @@
if (angular.isUndefined(this.urls)) { if (angular.isUndefined(this.urls)) {
this.urls = [{type: type, value: url}]; this.urls = [{type: type, value: url}];
} }
else if (!_.find(this.urls, function(i) { return i.value == url; })) { else if (_.isUndefined(_.find(this.urls, function(i) { return i.value == url; }))) {
this.urls.push({type: type, value: url}); this.urls.push({type: type, value: url});
} }
return this.urls.length - 1; return this.urls.length - 1;
@ -338,11 +338,11 @@
this.addresses = [{type: type, postoffice: postoffice, street: street, street2: street2, locality: locality, region: region, country: country, postalcode: postalcode}]; this.addresses = [{type: type, postoffice: postoffice, street: street, street2: street2, locality: locality, region: region, country: country, postalcode: postalcode}];
} }
else if (!_.find(this.addresses, function(i) { else if (!_.find(this.addresses, function(i) {
return i.street == street return i.street == street &&
&& i.street2 == street2 i.street2 == street2 &&
&& i.locality == locality i.locality == locality &&
&& i.country == country i.country == country &&
&& i.postalcode == postalcode; i.postalcode == postalcode;
})) { })) {
this.addresses.push({type: type, postoffice: postoffice, street: street, street2: street2, locality: locality, region: region, country: country, postalcode: postalcode}); this.addresses.push({type: type, postoffice: postoffice, street: street, street2: street2, locality: locality, region: region, country: country, postalcode: postalcode});
} }
@ -355,7 +355,7 @@
if (angular.isUndefined(this.refs)) { if (angular.isUndefined(this.refs)) {
this.refs = [card]; this.refs = [card];
} }
else if (email.length == 0) { else if (email.length === 0) {
this.refs.push(card); this.refs.push(card);
} }
else { else {
@ -469,4 +469,13 @@
}); });
return card; return card;
}; };
Card.prototype.toString = function() {
var desc = this.id + ' ' + this.$$fullname;
if (this.$$email)
desc += ' <' + this.$$email + '>';
return '[' + desc + ']';
};
})(); })();

View File

@ -35,31 +35,31 @@
function addOrgUnit() { function addOrgUnit() {
var i = vm.card.$addOrgUnit(''); var i = vm.card.$addOrgUnit('');
focus('orgUnit_' + i); focus('orgUnit_' + i);
}; }
function addEmail() { function addEmail() {
var i = vm.card.$addEmail(''); var i = vm.card.$addEmail('');
focus('email_' + i); focus('email_' + i);
}; }
function addPhone() { function addPhone() {
var i = vm.card.$addPhone(''); var i = vm.card.$addPhone('');
focus('phone_' + i); focus('phone_' + i);
}; }
function addUrl() { function addUrl() {
var i = vm.card.$addUrl('', ''); var i = vm.card.$addUrl('', '');
focus('url_' + i); focus('url_' + i);
}; }
function addAddress() { function addAddress() {
var i = vm.card.$addAddress('', '', '', '', '', '', '', ''); var i = vm.card.$addAddress('', '', '', '', '', '', '', '');
focus('address_' + i); focus('address_' + i);
}; }
function addMember() { function addMember() {
var i = vm.card.$addMember(''); var i = vm.card.$addMember('');
focus('ref_' + i); focus('ref_' + i);
}; }
function userFilter($query, excludedCards) { function userFilter($query, excludedCards) {
AddressBook.selectedFolder.$filter($query, {dry: true, excludeLists: true}, excludedCards); AddressBook.selectedFolder.$filter($query, {dry: true, excludeLists: true}, excludedCards);
return AddressBook.selectedFolder.$cards; return AddressBook.selectedFolder.$cards;
}; }
function save(form) { function save(form) {
if (form.$valid) { if (form.$valid) {
vm.card.$save() vm.card.$save()
@ -79,10 +79,10 @@
console.log(err); console.log(err);
}); });
} }
}; }
function reset() { function reset() {
vm.card.$reset(); vm.card.$reset();
}; }
function cancel() { function cancel() {
vm.card.$reset(); vm.card.$reset();
if (vm.card.isNew) { if (vm.card.isNew) {
@ -95,7 +95,7 @@
// Cancelling the edition of an existing card // Cancelling the edition of an existing card
$state.go('app.addressbook.card.view', { cardId: vm.card.id }); $state.go('app.addressbook.card.view', { cardId: vm.card.id });
} }
}; }
function confirmDelete(card) { function confirmDelete(card) {
Dialog.confirm(l('Warning'), Dialog.confirm(l('Warning'),
l('Are you sure you want to delete the card of %{0}?', card.$fullname())) l('Are you sure you want to delete the card of %{0}?', card.$fullname()))
@ -115,7 +115,7 @@
card.$fullname())); card.$fullname()));
}); });
}); });
}; }
} }
angular angular

View File

@ -28,7 +28,7 @@
}; };
}], }],
template: '<address ng-bind-html="addressLines(data)"></address>' template: '<address ng-bind-html="addressLines(data)"></address>'
} };
} }
angular angular

View File

@ -160,7 +160,7 @@
// Make a copy of the data for an eventual reset // Make a copy of the data for an eventual reset
this.$shadowData = this.$omit(); this.$shadowData = this.$omit();
} }
} };
/** /**
* @function $id * @function $id
@ -183,7 +183,7 @@
count = 0; count = 0;
if (this.$messages) { if (this.$messages) {
count = (_.filter(this.$messages, function(message) { return message.selected })).length; count = (_.filter(this.$messages, function(message) { return message.selected; })).length;
} }
return count; return count;
}; };
@ -215,7 +215,7 @@
angular.extend(options, { sortingAttributes: Mailbox.$query }); angular.extend(options, { sortingAttributes: Mailbox.$query });
if (angular.isDefined(filters)) { if (angular.isDefined(filters)) {
options.filters = _.reject(filters, function(filter) { options.filters = _.reject(filters, function(filter) {
return angular.isUndefined(filter.searchInput) || filter.searchInput.length == 0; return angular.isUndefined(filter.searchInput) || filter.searchInput.length === 0;
}); });
_.each(options.filters, function(filter) { _.each(options.filters, function(filter) {
var secondFilter, var secondFilter,
@ -257,8 +257,8 @@
// Preload more headers if possible // Preload more headers if possible
endIndex = Math.min(startIndex + Mailbox.PRELOAD.LOOKAHEAD, max - 1); endIndex = Math.min(startIndex + Mailbox.PRELOAD.LOOKAHEAD, max - 1);
if (!angular.isDefined(this.$messages[endIndex].subject) if (!angular.isDefined(this.$messages[endIndex].subject) &&
&& !angular.isDefined(this.$messages[endIndex].loading)) { !angular.isDefined(this.$messages[endIndex].loading)) {
endIndex = Math.min(startIndex + Mailbox.PRELOAD.SIZE, max); endIndex = Math.min(startIndex + Mailbox.PRELOAD.SIZE, max);
for (uids = []; startIndex < endIndex && startIndex < max; startIndex++) { for (uids = []; startIndex < endIndex && startIndex < max; startIndex++) {
if (angular.isDefined(this.$messages[startIndex].subject) || this.$messages[startIndex].loading) { if (angular.isDefined(this.$messages[startIndex].subject) || this.$messages[startIndex].loading) {
@ -332,7 +332,7 @@
// Find mailbox parent // Find mailbox parent
parent = findParent(null, this.$account.$mailboxes); parent = findParent(null, this.$account.$mailboxes);
if (parent == null) if (parent === null)
children = this.$account.$mailboxes; children = this.$account.$mailboxes;
else else
children = parent.children; children = parent.children;

View File

@ -40,7 +40,7 @@
l('Are you sure you want to delete the selected messages?')) l('Are you sure you want to delete the selected messages?'))
.then(function() { .then(function() {
// User confirmed the deletion // User confirmed the deletion
var selectedMessages = _.filter(vm.selectedFolder.$messages, function(message) { return message.selected }); var selectedMessages = _.filter(vm.selectedFolder.$messages, function(message) { return message.selected; });
var selectedUIDs = _.pluck(selectedMessages, 'uid'); var selectedUIDs = _.pluck(selectedMessages, 'uid');
vm.selectedFolder.$deleteMessages(selectedUIDs).then(function() { vm.selectedFolder.$deleteMessages(selectedUIDs).then(function() {
vm.selectedFolder.$messages = _.difference(vm.selectedFolder.$messages, selectedMessages); vm.selectedFolder.$messages = _.difference(vm.selectedFolder.$messages, selectedMessages);
@ -51,7 +51,7 @@
} }
function copySelectedMessages(folder) { function copySelectedMessages(folder) {
var selectedMessages = _.filter(vm.selectedFolder.$messages, function(message) { return message.selected }); var selectedMessages = _.filter(vm.selectedFolder.$messages, function(message) { return message.selected; });
var selectedUIDs = _.pluck(selectedMessages, 'uid'); var selectedUIDs = _.pluck(selectedMessages, 'uid');
vm.selectedFolder.$copyMessages(selectedUIDs, '/' + folder).then(function() { vm.selectedFolder.$copyMessages(selectedUIDs, '/' + folder).then(function() {
// TODO: refresh target mailbox? // TODO: refresh target mailbox?

View File

@ -317,7 +317,7 @@
Message.prototype.$sendMDN = function() { Message.prototype.$sendMDN = function() {
this.shouldAskReceipt = 0; this.shouldAskReceipt = 0;
return Message.$$resource.post(this.id, 'sendMDN'); return Message.$$resource.post(this.id, 'sendMDN');
} };
/** /**
* @function $deleteAttachment * @function $deleteAttachment
@ -331,12 +331,13 @@
Message.$$resource.post(this.$absolutePath({asDraft: true}), action).then(function(data) { Message.$$resource.post(this.$absolutePath({asDraft: true}), action).then(function(data) {
Message.$timeout(function() { Message.$timeout(function() {
_this.editable.attachmentAttrs = _.filter(_this.editable.attachmentAttrs, function(attachment) { _this.editable.attachmentAttrs = _.filter(_this.editable.attachmentAttrs, function(attachment) {
return attachment.filename != filename}); return attachment.filename != filename;
});
}, function() { }, function() {
// TODO: show toast // TODO: show toast
}); });
}); });
} };
/** /**
* @function $markAsFlaggedOrUnflagged * @function $markAsFlaggedOrUnflagged
@ -356,7 +357,7 @@
_this.isflagged = !_this.isflagged; _this.isflagged = !_this.isflagged;
}); });
}); });
} };
/** /**
* @function $reload * @function $reload

View File

@ -46,15 +46,15 @@
if ($stateParams.actionName == 'reply') { if ($stateParams.actionName == 'reply') {
stateMessage.$reply().then(function(msgObject) { stateMessage.$reply().then(function(msgObject) {
vm.message = msgObject; vm.message = msgObject;
vm.hideCc = (!msgObject.editable.cc || msgObject.editable.cc.length == 0); vm.hideCc = (!msgObject.editable.cc || msgObject.editable.cc.length === 0);
vm.hideBcc = (!msgObject.editable.bcc || msgObject.editable.bcc.length == 0); vm.hideBcc = (!msgObject.editable.bcc || msgObject.editable.bcc.length === 0);
}); });
} }
else if ($stateParams.actionName == 'replyall') { else if ($stateParams.actionName == 'replyall') {
stateMessage.$replyAll().then(function(msgObject) { stateMessage.$replyAll().then(function(msgObject) {
vm.message = msgObject; vm.message = msgObject;
vm.hideCc = (!msgObject.editable.cc || msgObject.editable.cc.length == 0); vm.hideCc = (!msgObject.editable.cc || msgObject.editable.cc.length === 0);
vm.hideBcc = (!msgObject.editable.bcc || msgObject.editable.bcc.length == 0); vm.hideBcc = (!msgObject.editable.bcc || msgObject.editable.bcc.length === 0);
}); });
} }
else if ($stateParams.actionName == 'forward') { else if ($stateParams.actionName == 'forward') {

View File

@ -1,6 +1,7 @@
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
(function() { (function() {
/* jshint validthis: true */
'use strict'; 'use strict';
/** /**
@ -22,21 +23,20 @@
} }
controller.$inject = ['$scope', 'User']; controller.$inject = ['$scope', 'User'];
function controller($scope, User) { function controller($scope, User) {
var vm = this; var vm = this;
$scope.delegateInvitation = false; $scope.delegateInvitation = false;
$scope.delegatedTo = ''; $scope.delegatedTo = '';
$scope.searchText = ''; $scope.searchText = '';
$scope.userFilter = function($query) { $scope.userFilter = function($query) {
return User.$filter($query); return User.$filter($query);
}; };
$scope.iCalendarAction = function(action) { $scope.iCalendarAction = function(action) {
var data; var data;
if (action == 'delegate') { if (action == 'delegate') {
data = {receiveUpdates: false, data = {receiveUpdates: false,
delegatedTo: $scope.delegatedTo.c_email}; delegatedTo: $scope.delegatedTo.c_email};
@ -46,7 +46,7 @@
}; };
} }
} }
angular angular
.module('SOGo.MailerUI') .module('SOGo.MailerUI')
.directive('sgImip', sgImip); .directive('sgImip', sgImip);

View File

@ -59,16 +59,16 @@
vm.preferences.defaults.AuxiliaryMailAccounts.push({}); vm.preferences.defaults.AuxiliaryMailAccounts.push({});
account = _.last(vm.preferences.defaults.AuxiliaryMailAccounts); account = _.last(vm.preferences.defaults.AuxiliaryMailAccounts);
account['name'] = "New account"; account.name = "New account";
account['identities'] = []; account.identities = [];
account['identities'][0] = {}; account.identities[0] = {};
account['identities'][0]['fullName'] = ""; account.identities[0].fullName = "";
account['identities'][0]['email'] = ""; account.identities[0].email = "";
account['receipts'] = {}; account.receipts = {};
account['receipts']['receiptAction'] = "ignore"; account.receipts.receiptAction = "ignore";
account['receipts']['receiptNonRecipientAction'] = "ignore"; account.receipts.receiptNonRecipientAction = "ignore";
account['receipts']['receiptOutsideDomainAction'] = "ignore"; account.receipts.receiptOutsideDomainAction = "ignore";
account['receipts']['receiptAnyAction'] = "ignore"; account.receipts.receiptAnyAction = "ignore";
$mdDialog.show({ $mdDialog.show({
controller: 'AccountDialogController', controller: 'AccountDialogController',
@ -103,7 +103,7 @@
} }
function addMailLabel() { function addMailLabel() {
vm.preferences.defaults.SOGoMailLabelsColors["new_label"] = ["New label", "#aaa"]; vm.preferences.defaults.SOGoMailLabelsColors.new_label = ["New label", "#aaa"];
} }
function removeMailLabel(key) { function removeMailLabel(key) {

View File

@ -8,7 +8,7 @@
angular.module('SOGo.MailerUI', []); angular.module('SOGo.MailerUI', []);
angular.module('SOGo.PreferencesUI', []); angular.module('SOGo.PreferencesUI', []);
angular.module('SOGo.SchedulerUI', ['ngSanitize', 'ui.router', 'ct.ui.router.extras.sticky', 'ct.ui.router.extras.previous', 'SOGo.Common', 'SOGo.ContactsUI', 'SOGo.MailerUI', 'SOGo.PreferencesUI']) angular.module('SOGo.SchedulerUI', ['ngSanitize', 'ui.router', 'SOGo.Common', 'SOGo.ContactsUI', 'SOGo.MailerUI', 'SOGo.PreferencesUI'])
.constant('sgSettings', { .constant('sgSettings', {
baseURL: ApplicationBaseURL, baseURL: ApplicationBaseURL,

View File

@ -61,8 +61,8 @@
list = this.$calendars; list = this.$calendars;
sibling = _.find(list, function(o) { sibling = _.find(list, function(o) {
return (o.id != 'personal' return (o.id != 'personal' &&
&& o.name.localeCompare(calendar.name) === 1); o.name.localeCompare(calendar.name) === 1);
}); });
i = sibling ? _.indexOf(_.pluck(list, 'id'), sibling.id) : 1; i = sibling ? _.indexOf(_.pluck(list, 'id'), sibling.id) : 1;
list.splice(i, 0, calendar); list.splice(i, 0, calendar);
@ -103,11 +103,11 @@
Calendar.$get = function(id) { Calendar.$get = function(id) {
var calendar; var calendar;
calendar = _.find(Calendar.$calendars, function(o) { return o.id == id }); calendar = _.find(Calendar.$calendars, function(o) { return o.id == id; });
if (!calendar) if (!calendar)
calendar = _.find(Calendar.$subscriptions, function(o) { return o.id == id }); calendar = _.find(Calendar.$subscriptions, function(o) { return o.id == id; });
if (!calendar) if (!calendar)
calendar = _.find(Calendar.$webcalendars, function(o) { return o.id == id }); calendar = _.find(Calendar.$webcalendars, function(o) { return o.id == id; });
return calendar; return calendar;
}; };

View File

@ -25,9 +25,9 @@
$scope.$watch( $scope.$watch(
function() { function() {
return _.union( return _.union(
_.map(Calendar.$calendars, function(o) { return _.pick(o, ['id', 'active', 'color']) }), _.map(Calendar.$calendars, function(o) { return _.pick(o, ['id', 'active', 'color']); }),
_.map(Calendar.$subscriptions, function(o) { return _.pick(o, ['id', 'active', 'color']) }), _.map(Calendar.$subscriptions, function(o) { return _.pick(o, ['id', 'active', 'color']); }),
_.map(Calendar.$webcalendars, function(o) { return _.pick(o, ['id', 'active', 'color']) }) _.map(Calendar.$webcalendars, function(o) { return _.pick(o, ['id', 'active', 'color']); })
); );
}, },
function(newList, oldList) { function(newList, oldList) {
@ -213,7 +213,7 @@
if (user.uid == vm.selectedUser.uid) if (user.uid == vm.selectedUser.uid)
vm.selectedUser = null; vm.selectedUser = null;
}, function(data, status) { }, function(data, status) {
Dialog.alert(l('Warning'), l('An error occured please try again.')) Dialog.alert(l('Warning'), l('An error occured please try again.'));
}); });
} }
@ -234,9 +234,9 @@
vm.selectedUser = user; vm.selectedUser = user;
vm.selectedUser.$rights(); vm.selectedUser.$rights();
} }
}; }
}; }
}; }
// Callback of sgSubscribe directive // Callback of sgSubscribe directive
function subscribeToFolder(calendarData) { function subscribeToFolder(calendarData) {

View File

@ -282,8 +282,8 @@
var type = (_this.type == 'appointment')? 'Events' : 'Tasks'; var type = (_this.type == 'appointment')? 'Events' : 'Tasks';
// Set default values from user's defaults // Set default values from user's defaults
_this.classification = _this.classification _this.classification = _this.classification ||
|| Component.$Preferences.defaults['SOGoCalendar' + type + 'DefaultClassification'].toLowerCase(); Component.$Preferences.defaults['SOGoCalendar' + type + 'DefaultClassification'].toLowerCase();
}); });
if (this.startDate) if (this.startDate)
@ -665,8 +665,8 @@
// Update recurrence definition depending on selections // Update recurrence definition depending on selections
if (this.$hasCustomRepeat) { if (this.$hasCustomRepeat) {
if (this.repeat.frequency == 'monthly' && this.repeat.month.type && this.repeat.month.type == 'byday' if (this.repeat.frequency == 'monthly' && this.repeat.month.type && this.repeat.month.type == 'byday' ||
|| this.repeat.frequency == 'yearly' && this.repeat.year.byday) { this.repeat.frequency == 'yearly' && this.repeat.year.byday) {
// BYDAY mask for a monthly or yearly recurrence // BYDAY mask for a monthly or yearly recurrence
delete component.repeat.monthdays; delete component.repeat.monthdays;
component.repeat.days = [{ day: this.repeat.month.day, occurrence: this.repeat.month.occurrence.toString() }]; component.repeat.days = [{ day: this.repeat.month.day, occurrence: this.repeat.month.occurrence.toString() }];

View File

@ -97,7 +97,7 @@
function addAttachUrl() { function addAttachUrl() {
var i = vm.component.addAttachUrl(''); var i = vm.component.addAttachUrl('');
focus('attachUrl_' + i); focus('attachUrl_' + i);
}; }
function toggleRecurrenceEditor() { function toggleRecurrenceEditor() {
vm.showRecurrenceEditor = !vm.showRecurrenceEditor; vm.showRecurrenceEditor = !vm.showRecurrenceEditor;
@ -113,16 +113,13 @@
var index, indexResult, card; var index, indexResult, card;
if ($query) { if ($query) {
AddressBook.$filterAll($query).then(function(results) { AddressBook.$filterAll($query).then(function(results) {
var compareIds = function(result) {
return this.id == result.id;
};
// Remove cards that no longer match the search query // Remove cards that no longer match the search query
for (index = vm.cardResults.length - 1; index >= 0; index--) { for (index = vm.cardResults.length - 1; index >= 0; index--) {
card = vm.cardResults[index]; card = vm.cardResults[index];
indexResult = _.findIndex(results, function(result) { indexResult = _.findIndex(results, compareIds, card);
return _.find(card.emails, function(data) {
return _.find(result.emails, function(resultData) {
return resultData.value == data.value;
});
});
});
if (indexResult >= 0) if (indexResult >= 0)
results.splice(indexResult, 1); results.splice(indexResult, 1);
else else