client/general: fix jscs warnings

This commit is contained in:
rr- 2016-06-12 22:10:20 +02:00
parent 0547ec5aa2
commit 3cbcbf1140
10 changed files with 45 additions and 43 deletions

View File

@ -51,7 +51,8 @@ class PostsController {
requestPage: pageController.createHistoryCacheProxy( requestPage: pageController.createHistoryCacheProxy(
ctx, ctx,
page => { page => {
const text = this._decorateSearchQuery(ctx.searchQuery.text); const text
= this._decorateSearchQuery(ctx.searchQuery.text);
return api.get( return api.get(
`/posts/?query=${text}&page=${page}&pageSize=40` + `/posts/?query=${text}&page=${page}&pageSize=40` +
'&fields=id,type,tags,score,favoriteCount,' + '&fields=id,type,tags,score,favoriteCount,' +
@ -69,8 +70,8 @@ class PostsController {
topNavController.activate('posts'); topNavController.activate('posts');
Promise.all([ Promise.all([
api.get('/post/' + id), api.get('/post/' + id),
api.get(`/post/${id}/around?fields=id&query=` api.get(`/post/${id}/around?fields=id&query=` +
+ this._decorateSearchQuery('')), this._decorateSearchQuery('')),
]).then(responses => { ]).then(responses => {
const [postResponse, aroundResponse] = responses; const [postResponse, aroundResponse] = responses;
this._postView.render({ this._postView.render({

View File

@ -212,8 +212,9 @@ class TagsController {
page => { page => {
const text = ctx.searchQuery.text; const text = ctx.searchQuery.text;
return api.get( return api.get(
`/tags/?query=${text}&page=${page}&pageSize=50&fields=` + `/tags/?query=${text}&page=${page}&pageSize=50` +
`names,suggestions,implications,lastEditTime,usages`); '&fields=names,suggestions,implications,' +
'lastEditTime,usages');
}), }),
headerRenderer: this._tagsHeaderView, headerRenderer: this._tagsHeaderView,
pageRenderer: this._tagsPageView, pageRenderer: this._tagsPageView,

View File

@ -62,8 +62,8 @@ class CommentFormControl {
this._hostNode.querySelector('.tabs-wrapper').style.minHeight = null; this._hostNode.querySelector('.tabs-wrapper').style.minHeight = null;
misc.disableExitConfirmation(); misc.disableExitConfirmation();
views.clearMessages(this._hostNode); views.clearMessages(this._hostNode);
this._hostNode.querySelector('.edit.tab textarea').value this._hostNode.querySelector('.edit.tab textarea').value =
= this._comment.text; this._comment.text;
} }
get _textareaNode() { get _textareaNode() {
@ -85,8 +85,8 @@ class CommentFormControl {
_evtPreviewClick(e) { _evtPreviewClick(e) {
e.preventDefault(); e.preventDefault();
this._contentNode.innerHTML this._contentNode.innerHTML =
= misc.formatMarkdown(this._textareaNode.value); misc.formatMarkdown(this._textareaNode.value);
this._freezeTabHeights(); this._freezeTabHeights();
this._selectTab('preview'); this._selectTab('preview');
} }
@ -124,8 +124,8 @@ class CommentFormControl {
} }
_growTextArea() { _growTextArea() {
this._textareaNode.style.height this._textareaNode.style.height =
= Math.max( Math.max(
this._settings.minHeight || 0, this._settings.minHeight || 0,
this._textareaNode.scrollHeight) + 'px'; this._textareaNode.scrollHeight) + 'px';
} }

View File

@ -38,7 +38,7 @@ class FileDropperControl {
files.map(file => file.name).join(', '); files.map(file => file.name).join(', ');
} }
this._options.resolve(files); this._options.resolve(files);
}; }
_evtFileChange(e) { _evtFileChange(e) {
this._resolve(e.target.files); this._resolve(e.target.files);

View File

@ -15,8 +15,8 @@ class PostNotesOverlayControl {
const bodyRect = document.body.getBoundingClientRect(); const bodyRect = document.body.getBoundingClientRect();
const svgRect = this._svgNode.getBoundingClientRect(); const svgRect = this._svgNode.getBoundingClientRect();
const polygonRect = e.target.getBBox(); const polygonRect = e.target.getBBox();
this._textNode.querySelector('.wrapper').innerHTML this._textNode.querySelector('.wrapper').innerHTML =
= misc.formatMarkdown(e.target.getAttribute('data-text')); misc.formatMarkdown(e.target.getAttribute('data-text'));
const x = ( const x = (
-bodyRect.left + svgRect.left + svgRect.width * polygonRect.x); -bodyRect.left + svgRect.left + svgRect.width * polygonRect.x);
const y = ( const y = (
@ -30,9 +30,9 @@ class PostNotesOverlayControl {
_evtMouseLeave(e) { _evtMouseLeave(e) {
const newElement = e.relatedTarget; const newElement = e.relatedTarget;
if (newElement === this._svgNode || if (newElement === this._svgNode ||
(!this._svgNode.contains(newElement) (!this._svgNode.contains(newElement) &&
&& !this._textNode.contains(newElement) !this._textNode.contains(newElement) &&
&& newElement !== this._textNode)) { newElement !== this._textNode)) {
this._textNode.style.display = 'none'; this._textNode.style.display = 'none';
} }
} }

View File

@ -42,12 +42,12 @@ class PostReadonlySidebarControl {
})); }));
const upvoteButton = sourceNode.querySelector('.upvote'); const upvoteButton = sourceNode.querySelector('.upvote');
const downvoteButton = sourceNode.querySelector('.downvote') const downvoteButton = sourceNode.querySelector('.downvote');
const addFavButton = sourceNode.querySelector('.add-favorite') const addFavButton = sourceNode.querySelector('.add-favorite');
const remFavButton = sourceNode.querySelector('.remove-favorite'); const remFavButton = sourceNode.querySelector('.remove-favorite');
const fitBothButton = sourceNode.querySelector('.fit-both') const fitBothButton = sourceNode.querySelector('.fit-both');
const fitOriginalButton = sourceNode.querySelector('.fit-original'); const fitOriginalButton = sourceNode.querySelector('.fit-original');
const fitWidthButton = sourceNode.querySelector('.fit-width') const fitWidthButton = sourceNode.querySelector('.fit-width');
const fitHeightButton = sourceNode.querySelector('.fit-height'); const fitHeightButton = sourceNode.querySelector('.fit-height');
if (upvoteButton) { if (upvoteButton) {
@ -105,7 +105,7 @@ class PostReadonlySidebarControl {
promise().then(() => { promise().then(() => {
this.install(); this.install();
}); });
} };
} }
_syncFitButton() { _syncFitButton() {
@ -153,7 +153,7 @@ class PostReadonlySidebarControl {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
requestPromise() requestPromise()
.then( .then(
response => { return api.get('/post/' + this._post.id) }, response => { return api.get('/post/' + this._post.id); },
response => { return Promise.reject(response); }) response => { return Promise.reject(response); })
.then( .then(
response => { response => {

View File

@ -183,7 +183,7 @@ function unindent(callSite, ...args) {
if (size < 0) { if (size < 0) {
size = m1.replace(/\t/g, ' ').length; size = m1.replace(/\t/g, ' ').length;
} }
return "\n" + m1.slice(Math.min(m1.length, size)); return '\n' + m1.slice(Math.min(m1.length, size));
}); });
} }
if (typeof callSite === 'string') { if (typeof callSite === 'string') {

View File

@ -14,7 +14,7 @@ NodeList.prototype.querySelector = function(...args) {
} }
} }
return null; return null;
} };
// non standard // non standard
Node.prototype.prependChild = function(child) { Node.prototype.prependChild = function(child) {

View File

@ -5,12 +5,12 @@ const router = require('../router.js');
const views = require('../util/views.js'); const views = require('../util/views.js');
const keyboard = require('../util/keyboard.js'); const keyboard = require('../util/keyboard.js');
const PostContentControl = require('../controls/post_content_control.js'); const PostContentControl = require('../controls/post_content_control.js');
const PostNotesOverlayControl const PostNotesOverlayControl =
= require('../controls/post_notes_overlay_control.js'); require('../controls/post_notes_overlay_control.js');
const PostReadonlySidebarControl const PostReadonlySidebarControl =
= require('../controls/post_readonly_sidebar_control.js'); require('../controls/post_readonly_sidebar_control.js');
const PostEditSidebarControl const PostEditSidebarControl =
= require('../controls/post_edit_sidebar_control.js'); require('../controls/post_edit_sidebar_control.js');
const CommentListControl = require('../controls/comment_list_control.js'); const CommentListControl = require('../controls/comment_list_control.js');
const CommentFormControl = require('../controls/comment_form_control.js'); const CommentFormControl = require('../controls/comment_form_control.js');
@ -33,20 +33,20 @@ class PostView {
const postViewNode = document.body.querySelector('.content-wrapper'); const postViewNode = document.body.querySelector('.content-wrapper');
const margin = ( const margin = (
postViewNode.getBoundingClientRect().top postViewNode.getBoundingClientRect().top -
- topNavNode.getBoundingClientRect().height); topNavNode.getBoundingClientRect().height);
this._postContentControl = new PostContentControl( this._postContentControl = new PostContentControl(
postContainerNode, postContainerNode,
ctx.post, ctx.post,
() => { () => {
return [ return [
window.innerWidth window.innerWidth -
- postContainerNode.getBoundingClientRect().left postContainerNode.getBoundingClientRect().left -
- margin, margin,
window.innerHeight window.innerHeight -
- topNavNode.getBoundingClientRect().height topNavNode.getBoundingClientRect().height -
- margin * 2, margin * 2,
]; ];
}); });

View File

@ -31,8 +31,8 @@ class PostsHeaderView {
}); });
keyboard.bind('p', () => { keyboard.bind('p', () => {
const firstPostNode const firstPostNode =
= document.body.querySelector('.post-list li:first-child a'); document.body.querySelector('.post-list li:first-child a');
if (firstPostNode) { if (firstPostNode) {
firstPostNode.focus(); firstPostNode.focus();
} }
@ -53,8 +53,8 @@ class PostsHeaderView {
e.target.classList.toggle('disabled'); e.target.classList.toggle('disabled');
const safety = e.target.getAttribute('data-safety'); const safety = e.target.getAttribute('data-safety');
let browsingSettings = settings.getSettings(); let browsingSettings = settings.getSettings();
browsingSettings.listPosts[safety] browsingSettings.listPosts[safety] =
= !browsingSettings.listPosts[safety]; !browsingSettings.listPosts[safety];
settings.saveSettings(browsingSettings, true); settings.saveSettings(browsingSettings, true);
router.show(url.replace(/{page}/, 1)); router.show(url.replace(/{page}/, 1));
} }