diff options
author | Bruno Wagner <bwagner@thoughtworks.com> | 2014-10-07 15:01:42 +0200 |
---|---|---|
committer | Bruno Wagner <bwagner@thoughtworks.com> | 2014-10-07 15:01:54 +0200 |
commit | 6299531f4c8f7daa1b4afab45d0439f635b03982 (patch) | |
tree | 92b2876e732731e5219e50ef7719c72ec2cb478a /web-ui/app/js | |
parent | 88abefd3e62fb65a08dde62a7d7e4ce1fa22f563 (diff) |
Fixed jshint errors
Diffstat (limited to 'web-ui/app/js')
27 files changed, 75 insertions, 52 deletions
diff --git a/web-ui/app/js/dispatchers/middle_pane_dispatcher.js b/web-ui/app/js/dispatchers/middle_pane_dispatcher.js index 5f662ceb..f988454c 100644 --- a/web-ui/app/js/dispatchers/middle_pane_dispatcher.js +++ b/web-ui/app/js/dispatchers/middle_pane_dispatcher.js @@ -36,7 +36,7 @@ define(['flight/lib/component', 'page/events', 'helpers/triggering'], function(d this.updateMiddlePaneHeight = function() { var vh = $(window).height(); - var top = $("#main").outerHeight() + $("#top-pane").outerHeight(); + var top = $('#main').outerHeight() + $('#top-pane').outerHeight(); this.select('middlePane').css({height: (vh - top) + 'px'}); }; diff --git a/web-ui/app/js/features/features.js b/web-ui/app/js/features/features.js index 0d766d12..9ca1d932 100644 --- a/web-ui/app/js/features/features.js +++ b/web-ui/app/js/features/features.js @@ -14,6 +14,8 @@ * You should have received a copy of the GNU Affero General Public License * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. */ +/* global _ */ +'use strict'; define([], function() { var cachedDisabledFeatures; diff --git a/web-ui/app/js/foundation/off_canvas.js b/web-ui/app/js/foundation/off_canvas.js index 6a1cdf06..59213d28 100644 --- a/web-ui/app/js/foundation/off_canvas.js +++ b/web-ui/app/js/foundation/off_canvas.js @@ -14,6 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. */ +'use strict'; define(['flight/lib/component', 'page/events'], function (defineComponent, events) { return defineComponent(function() { diff --git a/web-ui/app/js/helpers/contenttype.js b/web-ui/app/js/helpers/contenttype.js index 7a3957d3..764b6032 100644 --- a/web-ui/app/js/helpers/contenttype.js +++ b/web-ui/app/js/helpers/contenttype.js @@ -14,6 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. */ +'use strict'; define([], function () { var exports = {}; @@ -23,24 +24,25 @@ define([], function () { function MediaType(s, p){ this.type = ''; this.params = {}; - if(typeof s=='string'){ - var c = splitQuotedString(s); + var c, i, n; + if(typeof s==='string'){ + c = splitQuotedString(s); this.type = c.shift(); - for(var i=0; i<c.length; i++){ + for(i=0; i<c.length; i++){ this.parseParameter(c[i]); } }else if(s instanceof MediaType){ this.type = s.type; this.q = s.q; - for(var n in s.params) this.params[n]=s.params[n]; + for(n in s.params) this.params[n]=s.params[n]; } - if(typeof p=='string'){ - var c = splitQuotedString(p); - for(var i=0; i<c.length; i++){ + if(typeof p==='string'){ + c = splitQuotedString(p); + for(i=0; i<c.length; i++){ this.parseParameter(c[i]); } - }else if(typeof p=='object'){ - for(var n in p) this.params[n]=p[n]; + }else if(typeof p==='object'){ + for(n in p) this.params[n]=p[n]; } } MediaType.prototype.parseParameter = function parseParameter(s){ @@ -48,16 +50,16 @@ define([], function () { var name = param[0].trim(); var value = s.substr(param[0].length+1).trim(); if(!value || !name) return; - if(name=='q' && this.q===undefined){ + if(name==='q' && this.q===undefined){ this.q=parseFloat(value); }else{ - if(value[0]=='"' && value[value.length-1]=='"'){ + if(value[0]==='"' && value[value.length-1]==='"'){ value = value.substr(1, value.length-2); value = value.replace(/\\(.)/g, function(a,b){return b;}); } this.params[name]=value; } - } + }; MediaType.prototype.toString = function toString(){ var str = this.type + ';q='+this.q; for(var n in this.params){ @@ -69,7 +71,7 @@ define([], function () { } } return str; - } + }; exports.MediaType = MediaType; // Split a string by character, but ignore quoted parts and backslash-escaped characters @@ -157,8 +159,8 @@ define([], function () { else if(a.type!=='*/*' && b.type==='*/*') return -1; var ac = (a.type||'').split('/'); var bc = (b.type||'').split('/'); - if(ac[0]=='*' && bc[0]!='*') return 1; - if(ac[0]!='*' && bc[0]=='*') return -1; + if(ac[0]==='*' && bc[0]!=='*') return 1; + if(ac[0]!=='*' && bc[0]==='*') return -1; if(a.type!==b.type) return null; var ap = a.params || {}; var bp = b.params || {}; diff --git a/web-ui/app/js/helpers/iterator.js b/web-ui/app/js/helpers/iterator.js index 093d8df1..b5b44379 100644 --- a/web-ui/app/js/helpers/iterator.js +++ b/web-ui/app/js/helpers/iterator.js @@ -14,6 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. */ +'use strict'; define(function () { return Iterator; @@ -24,7 +25,7 @@ define(function () { this.elems = elems; this.hasPrevious = function () { - return this.index != 0; + return this.index !== 0; }; this.hasNext = function () { @@ -51,7 +52,7 @@ define(function () { var removed = this.current(), toRemove = this.index; - !this.hasNext() && this.index--; + if(!this.hasNext()) { this.index--; } this.elems.remove(toRemove); return removed; }; diff --git a/web-ui/app/js/helpers/view_helper.js b/web-ui/app/js/helpers/view_helper.js index a9a10378..841a1077 100644 --- a/web-ui/app/js/helpers/view_helper.js +++ b/web-ui/app/js/helpers/view_helper.js @@ -79,9 +79,9 @@ define( } function moveCaretToEnd(el) { - if (typeof el.selectionStart == "number") { + if (typeof el.selectionStart === 'number') { el.selectionStart = el.selectionEnd = el.value.length; - } else if (typeof el.createTextRange != "undefined") { + } else if (typeof el.createTextRange !== 'undefined') { el.focus(); var range = el.createTextRange(); range.collapse(false); @@ -92,7 +92,7 @@ define( function fixedSizeNumber(num, size) { var res = num.toString(); while(res.length < size) { - res = "0" + res; + res = '0' + res; } return res; } @@ -100,9 +100,9 @@ define( function getFormattedDate(date){ var today = createTodayDate(); if (date.getTime() > today.getTime()) { - return fixedSizeNumber(date.getHours(), 2) + ":" + fixedSizeNumber(date.getMinutes(), 2); + return fixedSizeNumber(date.getHours(), 2) + ':' + fixedSizeNumber(date.getMinutes(), 2); } else { - return "" + date.getFullYear() + "-" + fixedSizeNumber(date.getMonth() + 1, 2) + "-" + fixedSizeNumber(date.getDate(), 2); + return '' + date.getFullYear() + '-' + fixedSizeNumber(date.getMonth() + 1, 2) + '-' + fixedSizeNumber(date.getDate(), 2); } } diff --git a/web-ui/app/js/lib/html_whitelister.js b/web-ui/app/js/lib/html_whitelister.js index 892efb2b..849427e1 100644 --- a/web-ui/app/js/lib/html_whitelister.js +++ b/web-ui/app/js/lib/html_whitelister.js @@ -63,10 +63,10 @@ define(['lib/html-sanitizer'], function (htmlSanitizer) { attributesAndValues.push(attributes[i]); attributesAndValues.push(attributes[i+1]); } - }; + } return attributesAndValues; - }; + } function tagPolicy (tagName, attributes) { if (!tagAndAttributeWhitelist[tagName]) { diff --git a/web-ui/app/js/mail_list/ui/mail_item_factory.js b/web-ui/app/js/mail_list/ui/mail_item_factory.js index d7b10e9b..e922a642 100644 --- a/web-ui/app/js/mail_list/ui/mail_item_factory.js +++ b/web-ui/app/js/mail_list/ui/mail_item_factory.js @@ -14,6 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. */ +/* global _ */ 'use strict'; define( @@ -50,12 +51,12 @@ define( var detectMailType = function(mail) { if(_.include(mail.tags, 'drafts')) { - return MAIL_ITEM_TYPE['drafts']; + return MAIL_ITEM_TYPE.drafts; } else if(_.include(mail.tags, 'sent')) { - return MAIL_ITEM_TYPE['sent']; + return MAIL_ITEM_TYPE.sent; } else { return GenericMailItem; - }; + } }; return { diff --git a/web-ui/app/js/mail_list/ui/mail_items/generic_mail_item.js b/web-ui/app/js/mail_list/ui/mail_items/generic_mail_item.js index 631f1a32..3d426447 100644 --- a/web-ui/app/js/mail_list/ui/mail_items/generic_mail_item.js +++ b/web-ui/app/js/mail_list/ui/mail_items/generic_mail_item.js @@ -88,7 +88,7 @@ define( var mailItemHtml = templates.mails.single(this.attr); this.$node.html(mailItemHtml); this.$node.addClass(this.attr.statuses); - this.attr.selected && this.select(); + if(this.attr.selected) { this.select(); } this.on(this.$node.find('a'), 'click', this.triggerOpenMail); }; diff --git a/web-ui/app/js/mail_list/ui/mail_items/sent_item.js b/web-ui/app/js/mail_list/ui/mail_items/sent_item.js index 702e14b6..eeaa845f 100644 --- a/web-ui/app/js/mail_list/ui/mail_items/sent_item.js +++ b/web-ui/app/js/mail_list/ui/mail_items/sent_item.js @@ -31,7 +31,7 @@ define( function sentItem() { function isOpeningOnANewTab(ev) { - return ev.metaKey || ev.ctrlKey || ev.which == 2; + return ev.metaKey || ev.ctrlKey || ev.which === 2; } this.triggerOpenMail = function (ev) { @@ -55,7 +55,7 @@ define( var mailItemHtml = templates.mails.sent(this.attr); this.$node.html(mailItemHtml); this.$node.addClass(this.attr.statuses); - this.attr.selected && this.select(); + if(this.attr.selected) { this.select(); } this.on(this.$node.find('a'), 'click', this.triggerOpenMail); }; diff --git a/web-ui/app/js/mail_list_actions/ui/pagination_trigger.js b/web-ui/app/js/mail_list_actions/ui/pagination_trigger.js index 3bcd65ce..f9d531a4 100644 --- a/web-ui/app/js/mail_list_actions/ui/pagination_trigger.js +++ b/web-ui/app/js/mail_list_actions/ui/pagination_trigger.js @@ -30,7 +30,7 @@ define( this.defaultAttrs({ previous: '#left-arrow', next: '#right-arrow', - currentPage: "#current-page" + currentPage: '#current-page' }); this.renderWithPageNumber = function(pageNumber) { diff --git a/web-ui/app/js/mail_view/ui/mail_view.js b/web-ui/app/js/mail_view/ui/mail_view.js index f8fb9318..bda0c4a9 100644 --- a/web-ui/app/js/mail_view/ui/mail_view.js +++ b/web-ui/app/js/mail_view/ui/mail_view.js @@ -54,12 +54,14 @@ define( var date = new Date(data.mail.header.date); data.mail.header.formattedDate = viewHelpers.getFormattedDate(date); + var signed, encrypted; + data.mail.security_casing = data.mail.security_casing || {}; if(features.isEnabled('signatureStatus')) { - var signed = this.checkSigned(data.mail); + signed = this.checkSigned(data.mail); } if(features.isEnabled('encryptionStatus')) { - var encrypted = this.checkEncrypted(data.mail); + encrypted = this.checkEncrypted(data.mail); } this.$node.html(templates.mails.fullView({ diff --git a/web-ui/app/js/mail_view/ui/recipients/recipients_iterator.js b/web-ui/app/js/mail_view/ui/recipients/recipients_iterator.js index 19f8dea9..5253d915 100644 --- a/web-ui/app/js/mail_view/ui/recipients/recipients_iterator.js +++ b/web-ui/app/js/mail_view/ui/recipients/recipients_iterator.js @@ -14,6 +14,8 @@ * You should have received a copy of the GNU Affero General Public License * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. */ +/*global _ */ +'use strict'; define(['helpers/iterator'], function (Iterator) { return RecipientsIterator; @@ -47,7 +49,7 @@ define(['helpers/iterator'], function (Iterator) { this.iterator.removeCurrent().destroy(); if (this.iterator.hasElements()) { - this.iterator.current().select() + this.iterator.current().select(); } else { this.input.focus(); } diff --git a/web-ui/app/js/mixins/with_feature_toggle.js b/web-ui/app/js/mixins/with_feature_toggle.js index 1b364457..7336b74a 100644 --- a/web-ui/app/js/mixins/with_feature_toggle.js +++ b/web-ui/app/js/mixins/with_feature_toggle.js @@ -14,6 +14,8 @@ * You should have received a copy of the GNU Affero General Public License * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. */ +/* global _ */ +'use strict'; define(['features'], function(features) { diff --git a/web-ui/app/js/mixins/with_hide_and_show.js b/web-ui/app/js/mixins/with_hide_and_show.js index 7c2a92c4..c8902f61 100644 --- a/web-ui/app/js/mixins/with_hide_and_show.js +++ b/web-ui/app/js/mixins/with_hide_and_show.js @@ -15,6 +15,7 @@ * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. */ define(function(require) { + 'use strict'; function withHideAndShow() { this.hide = function () { diff --git a/web-ui/app/js/mixins/with_mail_edit_base.js b/web-ui/app/js/mixins/with_mail_edit_base.js index 2882758c..181af736 100644 --- a/web-ui/app/js/mixins/with_mail_edit_base.js +++ b/web-ui/app/js/mixins/with_mail_edit_base.js @@ -59,9 +59,9 @@ define( }; function thereAreRecipientsToDisplay() { - return this.attr.recipientValues.to - && this.attr.recipientValues.cc - && !_.isEmpty(this.attr.recipientValues.to.concat(this.attr.recipientValues.cc)); + return this.attr.recipientValues.to && + this.attr.recipientValues.cc && + !_.isEmpty(this.attr.recipientValues.to.concat(this.attr.recipientValues.cc)); } this.render = function(template, context) { diff --git a/web-ui/app/js/mixins/with_mail_tagging.js b/web-ui/app/js/mixins/with_mail_tagging.js index 6ea047ed..f5bd7840 100644 --- a/web-ui/app/js/mixins/with_mail_tagging.js +++ b/web-ui/app/js/mixins/with_mail_tagging.js @@ -15,6 +15,9 @@ * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. */ /*global Bloodhound */ +/*global _ */ +/*global Handlebars */ +'use strict'; define( ['page/events', 'features'], function (events, features) { @@ -63,7 +66,7 @@ define( this.after('displayMail', function () { this.on(this.select('newTagInput'), 'typeahead:selected typeahead:autocompleted', this.createNewTag); }); - }; + } return withMailTagging; } diff --git a/web-ui/app/js/page/pane_contract_expand.js b/web-ui/app/js/page/pane_contract_expand.js index fdea3db6..153e38e5 100644 --- a/web-ui/app/js/page/pane_contract_expand.js +++ b/web-ui/app/js/page/pane_contract_expand.js @@ -43,7 +43,7 @@ define(['flight/lib/component', 'page/events'], function (describeComponent, eve this.on(document, events.dispatchers.rightPane.openComposeBox, this.contractMiddlePaneExpandRightPane); this.on(document, events.dispatchers.rightPane.openDraft, this.contractMiddlePaneExpandRightPane); this.on(document, events.dispatchers.rightPane.openNoMessageSelected, this.expandMiddlePaneContractRightPane); - this.expandMiddlePaneContractRightPane() + this.expandMiddlePaneContractRightPane(); }); } diff --git a/web-ui/app/js/page/router.js b/web-ui/app/js/page/router.js index 28f654bc..9b2516b0 100644 --- a/web-ui/app/js/page/router.js +++ b/web-ui/app/js/page/router.js @@ -23,7 +23,7 @@ define(['flight/lib/component', 'page/events', 'page/router/url_params'], functi }); function createHash(data) { - var hash = "/#/" + data.tag; + var hash = '/#/' + data.tag; if (!_.isUndefined(data.mailIdent)) { hash += '/mail/' + data.mailIdent; } diff --git a/web-ui/app/js/page/router/url_params.js b/web-ui/app/js/page/router/url_params.js index 4048b802..3e999ecc 100644 --- a/web-ui/app/js/page/router/url_params.js +++ b/web-ui/app/js/page/router/url_params.js @@ -15,6 +15,7 @@ * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. */ define([], function () { + 'use strict'; function defaultTag() { return 'inbox'; diff --git a/web-ui/app/js/search/search_trigger.js b/web-ui/app/js/search/search_trigger.js index e64d8477..8f5bbb86 100644 --- a/web-ui/app/js/search/search_trigger.js +++ b/web-ui/app/js/search/search_trigger.js @@ -55,8 +55,7 @@ define( }; this.clearInput = function(event, data) { - if (!data.skipMailListRefresh) - this.select('input').val(''); + if (!data.skipMailListRefresh) { this.select('input').val(''); } }; this.showOnlySearchTerms = function(event){ diff --git a/web-ui/app/js/services/mail_service.js b/web-ui/app/js/services/mail_service.js index 35e6a39b..2e877a2c 100644 --- a/web-ui/app/js/services/mail_service.js +++ b/web-ui/app/js/services/mail_service.js @@ -62,7 +62,7 @@ define( }) .fail(function (resp) { var msg = i18n('Could not update mail tags'); - if(resp.status == 403) { + if(resp.status === 403) { msg = i18n('Invalid tag name'); } that.trigger(document, events.ui.userAlerts.displayMessage, { message: msg }); diff --git a/web-ui/app/js/services/model/mail.js b/web-ui/app/js/services/model/mail.js index 18a8ec2f..373eb683 100644 --- a/web-ui/app/js/services/model/mail.js +++ b/web-ui/app/js/services/model/mail.js @@ -113,7 +113,7 @@ define(['helpers/contenttype'], bodyParts = _.reject(bodyParts, function(bodyPart) { return _.isEmpty(bodyPart.trim()); }); return _.map(bodyParts, parseWithHeaders); - }; + } function getMailMediaType () { return new contentType.MediaType(this.header.content_type); diff --git a/web-ui/app/js/style_guide/main.js b/web-ui/app/js/style_guide/main.js index 8dc2b949..170d1187 100644 --- a/web-ui/app/js/style_guide/main.js +++ b/web-ui/app/js/style_guide/main.js @@ -14,13 +14,15 @@ * You should have received a copy of the GNU Affero General Public License * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. */ +'use strict'; + $(document).ready(function(){ $('a[href*=#]').click(function() { - if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') - && location.hostname == this.hostname) { + if (location.pathname.replace(/^\//,'') === this.pathname.replace(/^\//,'') && + location.hostname === this.hostname) { var $target = $(this.hash); - $target = $target.length && $target - || $('[name=' + this.hash.slice(1) +']'); + $target = $target.length && $target || + $('[name=' + this.hash.slice(1) +']'); if ($target.length) { var targetOffset = $target.offset().top; $('html,body') diff --git a/web-ui/app/js/tags/ui/tag.js b/web-ui/app/js/tags/ui/tag.js index 031a1cba..c2b7f588 100644 --- a/web-ui/app/js/tags/ui/tag.js +++ b/web-ui/app/js/tags/ui/tag.js @@ -42,7 +42,7 @@ define( this.viewFor = function (tag, template) { return template({ - tagName: tag.default ? i18n("tags." + tag.name) : tag.name, + tagName: tag.default ? i18n('tags.' + tag.name) : tag.name, ident: tag.ident, count: this.badgeType(tag) === 'total' ? tag.counts.total : (tag.counts.total - tag.counts.read), displayBadge: this.displayBadge(tag), @@ -64,7 +64,8 @@ define( }; this.selectTag = function (ev, data) { - data.tag === this.attr.tag.name ? this.doSelect(data) : this.doUnselect(); + if(data.tag === this.attr.tag.name) { this.doSelect(data); } + else { this.doUnselect(); } }; this.doUnselect = function () { diff --git a/web-ui/app/js/tags/ui/tag_base.js b/web-ui/app/js/tags/ui/tag_base.js index eaf8a3d5..9b2a06a9 100644 --- a/web-ui/app/js/tags/ui/tag_base.js +++ b/web-ui/app/js/tags/ui/tag_base.js @@ -15,6 +15,7 @@ * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. */ define(['views/i18n', 'page/events'], function(i18n, events) { + 'use strict'; function tagBase() { var ALWAYS_HIDE_BADGE_FOR = ['sent', 'trash', 'all']; diff --git a/web-ui/app/js/tags/ui/tag_shortcut.js b/web-ui/app/js/tags/ui/tag_shortcut.js index 9ec03eae..5710592e 100644 --- a/web-ui/app/js/tags/ui/tag_shortcut.js +++ b/web-ui/app/js/tags/ui/tag_shortcut.js @@ -14,6 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. */ +'use strict'; define( [ 'flight/lib/component', @@ -63,7 +64,8 @@ define( }; this.selectTag = function (ev, data) { - data.tag === this.attr.linkTo.name ? this.doSelect() : this.doUnselect(); + if(data.tag === this.attr.linkTo.name) { this.doSelect(); } + else { this.doUnselect(); } }; this.doUnselect = function () { |