diff --git a/UI/WebServerResources/js/Common/Acl.service.js b/UI/WebServerResources/js/Common/Acl.service.js index ad1d2e827..ee5404384 100644 --- a/UI/WebServerResources/js/Common/Acl.service.js +++ b/UI/WebServerResources/js/Common/Acl.service.js @@ -161,7 +161,7 @@ if (!user.wasSubscribed && user.isSubscribed) { users.push(user.uid); // console.debug('subscribe ' + user.uid); - }; + } }); if (users.length) { param = {uids: users.join(',')}; diff --git a/UI/WebServerResources/js/Common/Authentication.service.js b/UI/WebServerResources/js/Common/Authentication.service.js index e3791073b..f39964635 100644 --- a/UI/WebServerResources/js/Common/Authentication.service.js +++ b/UI/WebServerResources/js/Common/Authentication.service.js @@ -2,6 +2,7 @@ /* JavaScript for Authentication */ (function() { + /* jshint validthis: true */ 'use strict'; angular.module('SOGo.Authentication', []) @@ -41,7 +42,7 @@ start++; if (start > 0) currentPair = currentPair.substr(start); - if (currentPair.indexOf(prefix) == 0) + if (currentPair.indexOf(prefix) === 0) foundCookie = currentPair.substr(prefix.length); } @@ -77,12 +78,11 @@ parts = baseAddress.split('/'); parts.splice(0, 3); altBaseAddress = parts.join('/'); - newAddress; - if ((address.startsWith(baseAddress) - || address.startsWith(altBaseAddress)) - && !address.endsWith('/logoff')) { + if ((address.startsWith(baseAddress) || address.startsWith(altBaseAddress)) && + !address.endsWith('/logoff')) { newAddress = address; - } else { + } + else { newAddress = baseAddress; } @@ -91,8 +91,9 @@ this.$get = getService; - getService.$inject = ['$q', '$http', 'passwordPolicyConfig'] + getService.$inject = ['$q', '$http', 'passwordPolicyConfig']; function getService($q, $http, passwordPolicyConfig) { + var _this = this, service; service = { @@ -183,7 +184,7 @@ d.resolve(); }).error(function(data, status) { var error, - perr = data["LDAPPasswordPolicyError"]; + perr = data.LDAPPasswordPolicyError; if (!perr) { perr = passwordPolicyConfig.PolicyPasswordSystemUnknown; diff --git a/UI/WebServerResources/js/Common/Dialog.service.js b/UI/WebServerResources/js/Common/Dialog.service.js index 76db73cea..4544dfaf4 100644 --- a/UI/WebServerResources/js/Common/Dialog.service.js +++ b/UI/WebServerResources/js/Common/Dialog.service.js @@ -90,11 +90,11 @@ scope.cancel = function() { d.reject(); $mdDialog.hide(); - } + }; scope.ok = function() { d.resolve(scope.name); $mdDialog.hide(); - } + }; } return d.promise; @@ -110,7 +110,7 @@ angular.extend(Dialog, { $q: $q , $modal: $mdDialog }); return Dialog; // return constructor - }; + } /* Factory registration in Angular module */ angular diff --git a/UI/WebServerResources/js/Common/Gravatar.service.js b/UI/WebServerResources/js/Common/Gravatar.service.js index 73967ddfd..9da6fe21e 100644 --- a/UI/WebServerResources/js/Common/Gravatar.service.js +++ b/UI/WebServerResources/js/Common/Gravatar.service.js @@ -21,8 +21,9 @@ } 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'; - } + }; } angular diff --git a/UI/WebServerResources/js/Common/User.service.js b/UI/WebServerResources/js/Common/User.service.js index 2ca26c176..79972c402 100644 --- a/UI/WebServerResources/js/Common/User.service.js +++ b/UI/WebServerResources/js/Common/User.service.js @@ -59,7 +59,10 @@ User.$query = search; 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) { // Remove excluded users from response results = _.filter(response.users, function(data) { @@ -84,9 +87,7 @@ // Remove users that no longer match the search query for (index = User.$users.length - 1; index >= 0; index--) { user = User.$users[index]; - if (!_.find(results, function(data) { - return user.uid == data.uid; - })) { + if (!_.find(results, compareUids)) { User.$users.splice(index, 1); } } @@ -109,10 +110,6 @@ this.$$image = this.image || User.$gravatar(this.c_email); }; - User.prototype.toString = function() { - return '[User ' + this.c_email + ']'; - }; - /** * @function $shortFormat * @memberof User.prototype @@ -276,4 +273,8 @@ return user; }; + User.prototype.toString = function() { + return '[User ' + this.c_email + ']'; + }; + })(); diff --git a/UI/WebServerResources/js/Common/sgFocus.service.js b/UI/WebServerResources/js/Common/sgFocus.service.js index bca9af356..f38526592 100644 --- a/UI/WebServerResources/js/Common/sgFocus.service.js +++ b/UI/WebServerResources/js/Common/sgFocus.service.js @@ -16,7 +16,7 @@ $timeout(function() { $rootScope.$broadcast('sgFocusOn', name); }); - } + }; } angular diff --git a/UI/WebServerResources/js/Common/sgFolderStylesheet.directive.js b/UI/WebServerResources/js/Common/sgFolderStylesheet.directive.js index d32d5bf1a..33bdf8512 100644 --- a/UI/WebServerResources/js/Common/sgFolderStylesheet.directive.js +++ b/UI/WebServerResources/js/Common/sgFolderStylesheet.directive.js @@ -35,7 +35,7 @@ ' }', '' ].join('') - } + }; } angular diff --git a/UI/WebServerResources/js/Common/sgSearch.directive.js b/UI/WebServerResources/js/Common/sgSearch.directive.js index 387e47751..2d0cdc273 100644 --- a/UI/WebServerResources/js/Common/sgSearch.directive.js +++ b/UI/WebServerResources/js/Common/sgSearch.directive.js @@ -1,6 +1,7 @@ /* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ (function() { + /* jshint validthis: true */ 'use strict'; /* @@ -66,7 +67,7 @@ if (buttonEl && compiledButtonEl) { compiledButtonEl.on('click', controller.cancelSearch); } - } + }; } } @@ -83,7 +84,7 @@ transclude(function(clone) { iElement.append(clone); }); - } + }; } } @@ -109,9 +110,9 @@ // Method to call on data changes 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.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 vm.doSearch($scope, { searchText: vm.searchText, searchField: vm.searchField }); } diff --git a/UI/WebServerResources/js/Common/sgSubscribe.directive.js b/UI/WebServerResources/js/Common/sgSubscribe.directive.js index f836104f7..a6dd7229e 100644 --- a/UI/WebServerResources/js/Common/sgSubscribe.directive.js +++ b/UI/WebServerResources/js/Common/sgSubscribe.directive.js @@ -1,6 +1,7 @@ /* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ (function() { + /* jshint validthis: true */ 'use strict'; /* @@ -27,7 +28,12 @@ controller: sgSubscribeDialogController, controllerAs: 'vm', 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 .module('SOGo.Common') .directive('sgSubscribe', sgSubscribe); diff --git a/UI/WebServerResources/js/Common/sgToggleGrid.directive.js b/UI/WebServerResources/js/Common/sgToggleGrid.directive.js index 125b3e631..c5cf2d42c 100644 --- a/UI/WebServerResources/js/Common/sgToggleGrid.directive.js +++ b/UI/WebServerResources/js/Common/sgToggleGrid.directive.js @@ -29,7 +29,8 @@ i, modelDays, modelAttr, - ensureInitRunsOnce; + ensureInitRunsOnce, + toggleClass; ensureInitRunsOnce = scope.$watch(function() { // Parse attribute until it returns a valid object @@ -51,18 +52,20 @@ ensureInitRunsOnce(); } }); - - for (i = 0; i < tiles.length; i++) { - tile = angular.element(tiles[i]); - tile.addClass('iconButton'); - tile.find('figure').addClass('md-icon'); - tile.on('click', function() { + + toggleClass = function() { // Toggle class on click event and call toggle function var tile = angular.element(this), day = tile.attr('value'); tile.toggleClass('sg-active'); 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) { diff --git a/UI/WebServerResources/js/Contacts/AddressBook.service.js b/UI/WebServerResources/js/Contacts/AddressBook.service.js index 259ab0d86..53ad51ce7 100644 --- a/UI/WebServerResources/js/Contacts/AddressBook.service.js +++ b/UI/WebServerResources/js/Contacts/AddressBook.service.js @@ -83,9 +83,9 @@ list = addressbook.isSubscription? this.$subscriptions : this.$addressbooks; sibling = _.find(list, function(o) { - return (addressbook.id == 'personal' - || (o.id != 'personal' - && o.name.localeCompare(addressbook.name) === 1)); + return (addressbook.id == 'personal' || + (o.id != 'personal' && + o.name.localeCompare(addressbook.name) === 1)); }); i = sibling ? _.indexOf(_.pluck(list, 'id'), sibling.id) : 1; list.splice(i, 0, addressbook); @@ -140,9 +140,9 @@ var _this = this; return AddressBook.$$resource.userResource(uid).fetch(path, 'subscribe').then(function(addressbookData) { var addressbook = new AddressBook(addressbookData); - if (!_.find(_this.$subscriptions, function(o) { + if (_.isUndefined(_.find(_this.$subscriptions, function(o) { return o.id == addressbookData.id; - })) { + }))) { // Not already subscribed AddressBook.$add(addressbook); } @@ -196,7 +196,7 @@ count = 0; 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; }; @@ -214,23 +214,22 @@ .then(function(response) { var index, card, results = response.cards, - cards = _this.cards; + cards = _this.cards, + compareIds = function(data) { + return this.id == data.id; + }; // Remove cards that no longer exist for (index = cards.length - 1; index >= 0; index--) { card = cards[index]; - if (!_.find(results, function(data) { - return card.id == data.id; - })) { + if (_.isUndefined(_.find(results, compareIds, card))) { cards.splice(index, 1); } } // Add new cards _.each(results, function(data, index) { - if (!_.find(cards, function(card) { - return card.id == data.id; - })) { + if (_.isUndefined(_.find(cards, compareIds, data))) { var card = new AddressBook.$Card(data); cards.splice(index, 0, card); } @@ -272,7 +271,10 @@ return this.$id().then(function(addressbookId) { return AddressBook.$$resource.fetch(addressbookId, 'view', _this.$query); }).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) { // Don't keep a copy of the resulting cards. // This is usefull when doing autocompletion. @@ -283,10 +285,8 @@ } if (excludedCards) { // Remove excluded cards from results - results = _.filter(response.cards, function(data) { - return !_.find(excludedCards, function(card) { - return card.id == data.id; - }); + results = _.filter(response.cards, function(card) { + return _.isUndefined(_.find(excludedCards, compareIds, card)); }); } else { @@ -295,17 +295,13 @@ // Remove cards that no longer match the search query for (index = cards.length - 1; index >= 0; index--) { card = cards[index]; - if (!_.find(results, function(data) { - return card.id == data.id; - })) { + if (_.isUndefined(_.find(results, compareIds, card))) { cards.splice(index, 1); } } // Add new cards matching the search query _.each(results, function(data, index) { - if (!_.find(cards, function(card) { - return card.id == data.id; - })) { + if (_.isUndefined(_.find(cards, compareIds, data))) { var card = new AddressBook.$Card(data, search); cards.splice(index, 0, card); } @@ -314,9 +310,7 @@ _.each(results, function(data, index) { var oldIndex, removedCards; if (cards[index].id != data.id) { - oldIndex = _.findIndex(cards, function(card) { - return card.id == data.id; - }); + oldIndex = _.findIndex(cards, compareIds, data); removedCards = cards.splice(oldIndex, 1); cards.splice(index, 0, removedCards[0]); } @@ -379,7 +373,7 @@ */ 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; return AddressBook.$$resource.post(this.id, 'batchDelete', {uids: uids}).then(function() { diff --git a/UI/WebServerResources/js/Contacts/AddressBookController.js b/UI/WebServerResources/js/Contacts/AddressBookController.js index 3c05c8237..31c53c499 100644 --- a/UI/WebServerResources/js/Contacts/AddressBookController.js +++ b/UI/WebServerResources/js/Contacts/AddressBookController.js @@ -61,7 +61,7 @@ scope.create = function(type) { $mdDialog.hide(); $state.go('app.addressbook.new', { addressbookId: addressbookId, contactType: type }); - } + }; } } @@ -78,8 +78,9 @@ l('Are you sure you want to delete the selected contacts?')) .then(function() { // 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); + delete vm.selectedFolder.selectedCard; }, function(data, status) { // Delete failed }); diff --git a/UI/WebServerResources/js/Contacts/AddressBooksController.js b/UI/WebServerResources/js/Contacts/AddressBooksController.js index 465153926..976a1b31f 100644 --- a/UI/WebServerResources/js/Contacts/AddressBooksController.js +++ b/UI/WebServerResources/js/Contacts/AddressBooksController.js @@ -127,7 +127,7 @@ function LinksDialogController(scope, $mdDialog) { scope.close = function() { $mdDialog.hide(); - } + }; } } @@ -206,7 +206,7 @@ vm.selectedUser = null; } }, 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.')); }); } diff --git a/UI/WebServerResources/js/Contacts/Card.service.js b/UI/WebServerResources/js/Contacts/Card.service.js index 52a818454..b4cdf11b2 100644 --- a/UI/WebServerResources/js/Contacts/Card.service.js +++ b/UI/WebServerResources/js/Contacts/Card.service.js @@ -54,7 +54,7 @@ * @desc Factory registration of Card in Angular module. */ angular.module('SOGo.ContactsUI') - .factory('Card', Card.$factory) + .factory('Card', Card.$factory); /** * @memberof Card @@ -171,7 +171,7 @@ Card.prototype.$fullname = function() { var fn = this.fn || '', names; - if (fn.length == 0) { + if (fn.length === 0) { names = []; if (this.givenname && this.givenname.length > 0) names.push(this.givenname); @@ -185,7 +185,7 @@ fn = this.org; } 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) { fn = this.c_cn; @@ -201,7 +201,7 @@ if (this.role) description.push(this.role); if (this.orgUnits && this.orgUnits.length > 0) _.forEach(this.orgUnits, function(unit) { - if (unit.value != '') + if (unit.value !== '') description.push(unit.value); }); if (this.org) description.push(this.org); @@ -307,7 +307,7 @@ if (angular.isUndefined(this.emails)) { 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: ''}); } return this.emails.length - 1; @@ -317,7 +317,7 @@ if (angular.isUndefined(this.phones)) { 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: ''}); } return this.phones.length - 1; @@ -327,7 +327,7 @@ if (angular.isUndefined(this.urls)) { 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}); } 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}]; } else if (!_.find(this.addresses, function(i) { - return i.street == street - && i.street2 == street2 - && i.locality == locality - && i.country == country - && i.postalcode == postalcode; + return i.street == street && + i.street2 == street2 && + i.locality == locality && + i.country == country && + i.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)) { this.refs = [card]; } - else if (email.length == 0) { + else if (email.length === 0) { this.refs.push(card); } else { @@ -469,4 +469,13 @@ }); return card; }; + + Card.prototype.toString = function() { + var desc = this.id + ' ' + this.$$fullname; + + if (this.$$email) + desc += ' <' + this.$$email + '>'; + + return '[' + desc + ']'; + }; })(); diff --git a/UI/WebServerResources/js/Contacts/CardController.js b/UI/WebServerResources/js/Contacts/CardController.js index ad82d6445..560d750e6 100644 --- a/UI/WebServerResources/js/Contacts/CardController.js +++ b/UI/WebServerResources/js/Contacts/CardController.js @@ -35,31 +35,31 @@ function addOrgUnit() { var i = vm.card.$addOrgUnit(''); focus('orgUnit_' + i); - }; + } function addEmail() { var i = vm.card.$addEmail(''); focus('email_' + i); - }; + } function addPhone() { var i = vm.card.$addPhone(''); focus('phone_' + i); - }; + } function addUrl() { var i = vm.card.$addUrl('', ''); focus('url_' + i); - }; + } function addAddress() { var i = vm.card.$addAddress('', '', '', '', '', '', '', ''); focus('address_' + i); - }; + } function addMember() { var i = vm.card.$addMember(''); focus('ref_' + i); - }; + } function userFilter($query, excludedCards) { AddressBook.selectedFolder.$filter($query, {dry: true, excludeLists: true}, excludedCards); return AddressBook.selectedFolder.$cards; - }; + } function save(form) { if (form.$valid) { vm.card.$save() @@ -79,10 +79,10 @@ console.log(err); }); } - }; + } function reset() { vm.card.$reset(); - }; + } function cancel() { vm.card.$reset(); if (vm.card.isNew) { @@ -95,7 +95,7 @@ // Cancelling the edition of an existing card $state.go('app.addressbook.card.view', { cardId: vm.card.id }); } - }; + } function confirmDelete(card) { Dialog.confirm(l('Warning'), l('Are you sure you want to delete the card of %{0}?', card.$fullname())) @@ -115,7 +115,7 @@ card.$fullname())); }); }); - }; + } } angular diff --git a/UI/WebServerResources/js/Contacts/sgAddress.directive.js b/UI/WebServerResources/js/Contacts/sgAddress.directive.js index a1fc1997f..eb82441f8 100644 --- a/UI/WebServerResources/js/Contacts/sgAddress.directive.js +++ b/UI/WebServerResources/js/Contacts/sgAddress.directive.js @@ -28,7 +28,7 @@ }; }], template: '
' - } + }; } angular diff --git a/UI/WebServerResources/js/Mailer/Mailbox.service.js b/UI/WebServerResources/js/Mailer/Mailbox.service.js index ff30b9ab9..a1a406754 100644 --- a/UI/WebServerResources/js/Mailer/Mailbox.service.js +++ b/UI/WebServerResources/js/Mailer/Mailbox.service.js @@ -160,7 +160,7 @@ // Make a copy of the data for an eventual reset this.$shadowData = this.$omit(); } - } + }; /** * @function $id @@ -183,7 +183,7 @@ count = 0; 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; }; @@ -215,7 +215,7 @@ angular.extend(options, { sortingAttributes: Mailbox.$query }); if (angular.isDefined(filters)) { 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) { var secondFilter, @@ -257,8 +257,8 @@ // Preload more headers if possible endIndex = Math.min(startIndex + Mailbox.PRELOAD.LOOKAHEAD, max - 1); - if (!angular.isDefined(this.$messages[endIndex].subject) - && !angular.isDefined(this.$messages[endIndex].loading)) { + if (!angular.isDefined(this.$messages[endIndex].subject) && + !angular.isDefined(this.$messages[endIndex].loading)) { endIndex = Math.min(startIndex + Mailbox.PRELOAD.SIZE, max); for (uids = []; startIndex < endIndex && startIndex < max; startIndex++) { if (angular.isDefined(this.$messages[startIndex].subject) || this.$messages[startIndex].loading) { @@ -332,7 +332,7 @@ // Find mailbox parent parent = findParent(null, this.$account.$mailboxes); - if (parent == null) + if (parent === null) children = this.$account.$mailboxes; else children = parent.children; diff --git a/UI/WebServerResources/js/Mailer/MailboxController.js b/UI/WebServerResources/js/Mailer/MailboxController.js index 103ddbdc9..4b1f4f525 100644 --- a/UI/WebServerResources/js/Mailer/MailboxController.js +++ b/UI/WebServerResources/js/Mailer/MailboxController.js @@ -40,7 +40,7 @@ l('Are you sure you want to delete the selected messages?')) .then(function() { // 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'); vm.selectedFolder.$deleteMessages(selectedUIDs).then(function() { vm.selectedFolder.$messages = _.difference(vm.selectedFolder.$messages, selectedMessages); @@ -51,7 +51,7 @@ } 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'); vm.selectedFolder.$copyMessages(selectedUIDs, '/' + folder).then(function() { // TODO: refresh target mailbox? diff --git a/UI/WebServerResources/js/Mailer/Message.service.js b/UI/WebServerResources/js/Mailer/Message.service.js index ddbba5ba8..5319de2fe 100644 --- a/UI/WebServerResources/js/Mailer/Message.service.js +++ b/UI/WebServerResources/js/Mailer/Message.service.js @@ -317,7 +317,7 @@ Message.prototype.$sendMDN = function() { this.shouldAskReceipt = 0; return Message.$$resource.post(this.id, 'sendMDN'); - } + }; /** * @function $deleteAttachment @@ -331,12 +331,13 @@ Message.$$resource.post(this.$absolutePath({asDraft: true}), action).then(function(data) { Message.$timeout(function() { _this.editable.attachmentAttrs = _.filter(_this.editable.attachmentAttrs, function(attachment) { - return attachment.filename != filename}); + return attachment.filename != filename; + }); }, function() { // TODO: show toast }); }); - } + }; /** * @function $markAsFlaggedOrUnflagged @@ -356,7 +357,7 @@ _this.isflagged = !_this.isflagged; }); }); - } + }; /** * @function $reload diff --git a/UI/WebServerResources/js/Mailer/MessageEditorController.js b/UI/WebServerResources/js/Mailer/MessageEditorController.js index 772bc63d4..473674b44 100644 --- a/UI/WebServerResources/js/Mailer/MessageEditorController.js +++ b/UI/WebServerResources/js/Mailer/MessageEditorController.js @@ -46,15 +46,15 @@ if ($stateParams.actionName == 'reply') { stateMessage.$reply().then(function(msgObject) { vm.message = msgObject; - vm.hideCc = (!msgObject.editable.cc || msgObject.editable.cc.length == 0); - vm.hideBcc = (!msgObject.editable.bcc || msgObject.editable.bcc.length == 0); + vm.hideCc = (!msgObject.editable.cc || msgObject.editable.cc.length === 0); + vm.hideBcc = (!msgObject.editable.bcc || msgObject.editable.bcc.length === 0); }); } else if ($stateParams.actionName == 'replyall') { stateMessage.$replyAll().then(function(msgObject) { vm.message = msgObject; - vm.hideCc = (!msgObject.editable.cc || msgObject.editable.cc.length == 0); - vm.hideBcc = (!msgObject.editable.bcc || msgObject.editable.bcc.length == 0); + vm.hideCc = (!msgObject.editable.cc || msgObject.editable.cc.length === 0); + vm.hideBcc = (!msgObject.editable.bcc || msgObject.editable.bcc.length === 0); }); } else if ($stateParams.actionName == 'forward') { diff --git a/UI/WebServerResources/js/Mailer/sgIMIP.directive.js b/UI/WebServerResources/js/Mailer/sgIMIP.directive.js index 559670eea..fdedc31fa 100644 --- a/UI/WebServerResources/js/Mailer/sgIMIP.directive.js +++ b/UI/WebServerResources/js/Mailer/sgIMIP.directive.js @@ -1,6 +1,7 @@ /* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ (function() { + /* jshint validthis: true */ 'use strict'; /** @@ -22,21 +23,20 @@ } controller.$inject = ['$scope', 'User']; - function controller($scope, User) { var vm = this; + $scope.delegateInvitation = false; $scope.delegatedTo = ''; $scope.searchText = ''; - + $scope.userFilter = function($query) { return User.$filter($query); }; - + $scope.iCalendarAction = function(action) { - var data; - + if (action == 'delegate') { data = {receiveUpdates: false, delegatedTo: $scope.delegatedTo.c_email}; @@ -46,7 +46,7 @@ }; } } - + angular .module('SOGo.MailerUI') .directive('sgImip', sgImip); diff --git a/UI/WebServerResources/js/Preferences/PreferencesController.js b/UI/WebServerResources/js/Preferences/PreferencesController.js index bc4566142..8f308b03c 100644 --- a/UI/WebServerResources/js/Preferences/PreferencesController.js +++ b/UI/WebServerResources/js/Preferences/PreferencesController.js @@ -59,16 +59,16 @@ vm.preferences.defaults.AuxiliaryMailAccounts.push({}); account = _.last(vm.preferences.defaults.AuxiliaryMailAccounts); - account['name'] = "New account"; - account['identities'] = []; - account['identities'][0] = {}; - account['identities'][0]['fullName'] = ""; - account['identities'][0]['email'] = ""; - account['receipts'] = {}; - account['receipts']['receiptAction'] = "ignore"; - account['receipts']['receiptNonRecipientAction'] = "ignore"; - account['receipts']['receiptOutsideDomainAction'] = "ignore"; - account['receipts']['receiptAnyAction'] = "ignore"; + account.name = "New account"; + account.identities = []; + account.identities[0] = {}; + account.identities[0].fullName = ""; + account.identities[0].email = ""; + account.receipts = {}; + account.receipts.receiptAction = "ignore"; + account.receipts.receiptNonRecipientAction = "ignore"; + account.receipts.receiptOutsideDomainAction = "ignore"; + account.receipts.receiptAnyAction = "ignore"; $mdDialog.show({ controller: 'AccountDialogController', @@ -103,7 +103,7 @@ } function addMailLabel() { - vm.preferences.defaults.SOGoMailLabelsColors["new_label"] = ["New label", "#aaa"]; + vm.preferences.defaults.SOGoMailLabelsColors.new_label = ["New label", "#aaa"]; } function removeMailLabel(key) { diff --git a/UI/WebServerResources/js/Scheduler.app.js b/UI/WebServerResources/js/Scheduler.app.js index e5fb1c7a9..ba644ddc4 100644 --- a/UI/WebServerResources/js/Scheduler.app.js +++ b/UI/WebServerResources/js/Scheduler.app.js @@ -8,7 +8,7 @@ angular.module('SOGo.MailerUI', []); 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', { baseURL: ApplicationBaseURL, diff --git a/UI/WebServerResources/js/Scheduler/Calendar.service.js b/UI/WebServerResources/js/Scheduler/Calendar.service.js index d83d66c33..0f521318a 100644 --- a/UI/WebServerResources/js/Scheduler/Calendar.service.js +++ b/UI/WebServerResources/js/Scheduler/Calendar.service.js @@ -61,8 +61,8 @@ list = this.$calendars; sibling = _.find(list, function(o) { - return (o.id != 'personal' - && o.name.localeCompare(calendar.name) === 1); + return (o.id != 'personal' && + o.name.localeCompare(calendar.name) === 1); }); i = sibling ? _.indexOf(_.pluck(list, 'id'), sibling.id) : 1; list.splice(i, 0, calendar); @@ -103,11 +103,11 @@ Calendar.$get = function(id) { var calendar; - calendar = _.find(Calendar.$calendars, function(o) { return o.id == id }); + calendar = _.find(Calendar.$calendars, function(o) { return o.id == id; }); if (!calendar) - calendar = _.find(Calendar.$subscriptions, function(o) { return o.id == id }); + calendar = _.find(Calendar.$subscriptions, function(o) { return o.id == id; }); if (!calendar) - calendar = _.find(Calendar.$webcalendars, function(o) { return o.id == id }); + calendar = _.find(Calendar.$webcalendars, function(o) { return o.id == id; }); return calendar; }; diff --git a/UI/WebServerResources/js/Scheduler/CalendarsController.js b/UI/WebServerResources/js/Scheduler/CalendarsController.js index 3dfa227ad..29ecfa3bd 100644 --- a/UI/WebServerResources/js/Scheduler/CalendarsController.js +++ b/UI/WebServerResources/js/Scheduler/CalendarsController.js @@ -25,9 +25,9 @@ $scope.$watch( function() { return _.union( - _.map(Calendar.$calendars, 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.$calendars, 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']); }) ); }, function(newList, oldList) { @@ -213,7 +213,7 @@ if (user.uid == vm.selectedUser.uid) vm.selectedUser = null; }, 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.$rights(); } - }; - }; - }; + } + } + } // Callback of sgSubscribe directive function subscribeToFolder(calendarData) { diff --git a/UI/WebServerResources/js/Scheduler/Component.service.js b/UI/WebServerResources/js/Scheduler/Component.service.js index 115c96098..17690510d 100644 --- a/UI/WebServerResources/js/Scheduler/Component.service.js +++ b/UI/WebServerResources/js/Scheduler/Component.service.js @@ -282,8 +282,8 @@ var type = (_this.type == 'appointment')? 'Events' : 'Tasks'; // Set default values from user's defaults - _this.classification = _this.classification - || Component.$Preferences.defaults['SOGoCalendar' + type + 'DefaultClassification'].toLowerCase(); + _this.classification = _this.classification || + Component.$Preferences.defaults['SOGoCalendar' + type + 'DefaultClassification'].toLowerCase(); }); if (this.startDate) @@ -665,8 +665,8 @@ // Update recurrence definition depending on selections if (this.$hasCustomRepeat) { - if (this.repeat.frequency == 'monthly' && this.repeat.month.type && this.repeat.month.type == 'byday' - || this.repeat.frequency == 'yearly' && this.repeat.year.byday) { + if (this.repeat.frequency == 'monthly' && this.repeat.month.type && this.repeat.month.type == 'byday' || + this.repeat.frequency == 'yearly' && this.repeat.year.byday) { // BYDAY mask for a monthly or yearly recurrence delete component.repeat.monthdays; component.repeat.days = [{ day: this.repeat.month.day, occurrence: this.repeat.month.occurrence.toString() }]; diff --git a/UI/WebServerResources/js/Scheduler/ComponentController.js b/UI/WebServerResources/js/Scheduler/ComponentController.js index 30f256def..1e517af6f 100644 --- a/UI/WebServerResources/js/Scheduler/ComponentController.js +++ b/UI/WebServerResources/js/Scheduler/ComponentController.js @@ -97,7 +97,7 @@ function addAttachUrl() { var i = vm.component.addAttachUrl(''); focus('attachUrl_' + i); - }; + } function toggleRecurrenceEditor() { vm.showRecurrenceEditor = !vm.showRecurrenceEditor; @@ -113,16 +113,13 @@ var index, indexResult, card; if ($query) { AddressBook.$filterAll($query).then(function(results) { + var compareIds = function(result) { + return this.id == result.id; + }; // Remove cards that no longer match the search query for (index = vm.cardResults.length - 1; index >= 0; index--) { card = vm.cardResults[index]; - indexResult = _.findIndex(results, function(result) { - return _.find(card.emails, function(data) { - return _.find(result.emails, function(resultData) { - return resultData.value == data.value; - }); - }); - }); + indexResult = _.findIndex(results, compareIds, card); if (indexResult >= 0) results.splice(indexResult, 1); else