(js) Minor JavaScript improvements

This commit is contained in:
Francis Lachapelle 2015-07-01 15:21:22 -04:00
parent cc7eeca2c4
commit a408fdff52
4 changed files with 5 additions and 7 deletions

View file

@ -67,7 +67,7 @@
function sgSearchController($scope, $element) { function sgSearchController($scope, $element) {
// Controller variables // Controller variables
this.previous = { searchText: '', searchField: '' }; this.previous = { searchText: '', searchField: '' };
this.searchText = ''; this.searchText = null;
this.searchField = $element.find('md-option').attr('value'); // defaults to first option this.searchField = $element.find('md-option').attr('value'); // defaults to first option
// Model options // Model options
@ -81,7 +81,7 @@
// Method to call on data changes // Method to call on data changes
this.onChange = function(value) { this.onChange = function(value) {
if (typeof this.searchText != 'undefined') { if (this.searchText != null) {
if (this.searchText != this.previous.searchText || this.searchField != this.previous.searchField) { if (this.searchText != this.previous.searchText || this.searchField != this.previous.searchField) {
if (this.searchText.length > 2 || this.searchText.length == 0) { if (this.searchText.length > 2 || this.searchText.length == 0) {
// See https://github.com/angular/angular.js/issues/7635 // See https://github.com/angular/angular.js/issues/7635

View file

@ -118,7 +118,7 @@
if (!this.$$fullname) if (!this.$$fullname)
this.$$fullname = this.$fullname(); this.$$fullname = this.$fullname();
if (!this.$$email) if (!this.$$email)
this.$$email = this.$preferredEmail(); this.$$email = this.$preferredEmail(partial);
if (!this.$$image) if (!this.$$image)
this.$$image = this.image || Card.$gravatar(this.$preferredEmail(partial), 32); this.$$image = this.image || Card.$gravatar(this.$preferredEmail(partial), 32);
this.selected = false; this.selected = false;

View file

@ -178,7 +178,7 @@
Mailbox.prototype.$filter = function(sort, filters) { Mailbox.prototype.$filter = function(sort, filters) {
var futureMailboxData, options; var futureMailboxData, options;
if (!angular.isDefined(sort)) { if (angular.isUndefined(sort)) {
sort = { sortingAttributes: { match: 'OR', sort: 'date', asc: false } }; sort = { sortingAttributes: { match: 'OR', sort: 'date', asc: false } };
} }
options = { sortingAttributes: sort }; options = { sortingAttributes: sort };
@ -366,7 +366,6 @@
* @return a promise of the HTTP operation * @return a promise of the HTTP operation
*/ */
Mailbox.prototype.$deleteMessages = function(uids) { Mailbox.prototype.$deleteMessages = function(uids) {
var _this = this;
return Mailbox.$$resource.post(this.id, 'batchDelete', {uids: uids}); return Mailbox.$$resource.post(this.id, 'batchDelete', {uids: uids});
}; };
@ -377,7 +376,6 @@
* @return a promise of the HTTP operation * @return a promise of the HTTP operation
*/ */
Mailbox.prototype.$copyMessages = function(uids, folder) { Mailbox.prototype.$copyMessages = function(uids, folder) {
var _this = this;
return Mailbox.$$resource.post(this.id, 'copyMessages', {uids: uids, folder: folder}); return Mailbox.$$resource.post(this.id, 'copyMessages', {uids: uids, folder: folder});
}; };
@ -388,7 +386,6 @@
* @return a promise of the HTTP operation * @return a promise of the HTTP operation
*/ */
Mailbox.prototype.$moveMessages = function(uids, folder) { Mailbox.prototype.$moveMessages = function(uids, folder) {
var _this = this;
return Mailbox.$$resource.post(this.id, 'moveMessages', {uids: uids, folder: folder}); return Mailbox.$$resource.post(this.id, 'moveMessages', {uids: uids, folder: folder});
}; };

View file

@ -159,6 +159,7 @@
folder: calendar folder: calendar
} }
}); });
/** /**
* @ngInject * @ngInject
*/ */