Fix last eslint rules

This commit is contained in:
Filipa Lacerda 2018-01-08 20:45:34 +00:00
parent 349d06688f
commit 7e3405d76c
No known key found for this signature in database
GPG Key ID: 9CA3FDE4D1E2F1C8
9 changed files with 162 additions and 149 deletions

View File

@ -16,7 +16,8 @@
"localStorage": false "localStorage": false
}, },
"parserOptions": { "parserOptions": {
"parser": "babel-eslint" "parser": "babel-eslint",
"ecmaVersion": 2017
}, },
"plugins": [ "plugins": [
"filenames", "filenames",

View File

@ -94,102 +94,104 @@ export default class ImageFile {
}); });
return [maxWidth, maxHeight]; return [maxWidth, maxHeight];
} }
// eslint-disable-next-line class-methods-use-this
views() {
return {
'two-up': function() {
return $('.two-up.view .wrap', this.file).each((function(_this) {
return function(index, wrap) {
$('img', wrap).each(function() {
var currentWidth;
currentWidth = $(this).width();
if (currentWidth > availWidth / 2) {
return $(this).width(availWidth / 2);
}
});
return _this.requestImageInfo($('img', wrap), function(width, height) {
$('.image-info .meta-width', wrap).text(width + "px");
$('.image-info .meta-height', wrap).text(height + "px");
return $('.image-info', wrap).removeClass('hide');
});
};
})(this));
},
'swipe': function() {
var maxHeight, maxWidth;
maxWidth = 0;
maxHeight = 0;
return $('.swipe.view', this.file).each((function(_this) {
return function(index, view) {
var $swipeWrap, $swipeBar, $swipeFrame, wrapPadding, ref;
ref = _this.prepareFrames(view), maxWidth = ref[0], maxHeight = ref[1];
$swipeFrame = $('.swipe-frame', view);
$swipeWrap = $('.swipe-wrap', view);
$swipeBar = $('.swipe-bar', view);
views = { $swipeFrame.css({
'two-up': function() { width: maxWidth + 16,
return $('.two-up.view .wrap', this.file).each((function(_this) { height: maxHeight + 28
return function(index, wrap) { });
$('img', wrap).each(function() { $swipeWrap.css({
var currentWidth; width: maxWidth + 1,
currentWidth = $(this).width(); height: maxHeight + 2
if (currentWidth > availWidth / 2) { });
return $(this).width(availWidth / 2); // Set swipeBar left position to match image frame
} $swipeBar.css({
}); left: 1
return _this.requestImageInfo($('img', wrap), function(width, height) { });
$('.image-info .meta-width', wrap).text(width + "px");
$('.image-info .meta-height', wrap).text(height + "px");
return $('.image-info', wrap).removeClass('hide');
});
};
})(this));
},
'swipe': function() {
var maxHeight, maxWidth;
maxWidth = 0;
maxHeight = 0;
return $('.swipe.view', this.file).each((function(_this) {
return function(index, view) {
var $swipeWrap, $swipeBar, $swipeFrame, wrapPadding, ref;
ref = _this.prepareFrames(view), maxWidth = ref[0], maxHeight = ref[1];
$swipeFrame = $('.swipe-frame', view);
$swipeWrap = $('.swipe-wrap', view);
$swipeBar = $('.swipe-bar', view);
$swipeFrame.css({ wrapPadding = parseInt($swipeWrap.css('right').replace('px', ''), 10);
width: maxWidth + 16,
height: maxHeight + 28
});
$swipeWrap.css({
width: maxWidth + 1,
height: maxHeight + 2
});
// Set swipeBar left position to match image frame
$swipeBar.css({
left: 1
});
wrapPadding = parseInt($swipeWrap.css('right').replace('px', ''), 10); _this.initDraggable($swipeBar, wrapPadding, function(e, left) {
if (left > 0 && left < $swipeFrame.width() - (wrapPadding * 2)) {
$swipeWrap.width((maxWidth + 1) - left);
$swipeBar.css('left', left);
}
});
};
})(this));
},
'onion-skin': function() {
var dragTrackWidth, maxHeight, maxWidth;
maxWidth = 0;
maxHeight = 0;
dragTrackWidth = $('.drag-track', this.file).width() - $('.dragger', this.file).width();
return $('.onion-skin.view', this.file).each((function(_this) {
return function(index, view) {
var $frame, $track, $dragger, $frameAdded, framePadding, ref, dragging = false;
ref = _this.prepareFrames(view), maxWidth = ref[0], maxHeight = ref[1];
$frame = $('.onion-skin-frame', view);
$frameAdded = $('.frame.added', view);
$track = $('.drag-track', view);
$dragger = $('.dragger', $track);
_this.initDraggable($swipeBar, wrapPadding, function(e, left) { $frame.css({
if (left > 0 && left < $swipeFrame.width() - (wrapPadding * 2)) { width: maxWidth + 16,
$swipeWrap.width((maxWidth + 1) - left); height: maxHeight + 28
$swipeBar.css('left', left); });
} $('.swipe-wrap', view).css({
}); width: maxWidth + 1,
}; height: maxHeight + 2
})(this)); });
}, $dragger.css({
'onion-skin': function() { left: dragTrackWidth
var dragTrackWidth, maxHeight, maxWidth; });
maxWidth = 0;
maxHeight = 0;
dragTrackWidth = $('.drag-track', this.file).width() - $('.dragger', this.file).width();
return $('.onion-skin.view', this.file).each((function(_this) {
return function(index, view) {
var $frame, $track, $dragger, $frameAdded, framePadding, ref, dragging = false;
ref = _this.prepareFrames(view), maxWidth = ref[0], maxHeight = ref[1];
$frame = $('.onion-skin-frame', view);
$frameAdded = $('.frame.added', view);
$track = $('.drag-track', view);
$dragger = $('.dragger', $track);
$frame.css({ $frameAdded.css('opacity', 1);
width: maxWidth + 16, framePadding = parseInt($frameAdded.css('right').replace('px', ''), 10);
height: maxHeight + 28
});
$('.swipe-wrap', view).css({
width: maxWidth + 1,
height: maxHeight + 2
});
$dragger.css({
left: dragTrackWidth
});
$frameAdded.css('opacity', 1); _this.initDraggable($dragger, framePadding, function(e, left) {
framePadding = parseInt($frameAdded.css('right').replace('px', ''), 10); var opacity = left / dragTrackWidth;
_this.initDraggable($dragger, framePadding, function(e, left) { if (opacity >= 0 && opacity <= 1) {
var opacity = left / dragTrackWidth; $dragger.css('left', left);
$frameAdded.css('opacity', opacity);
if (opacity >= 0 && opacity <= 1) { }
$dragger.css('left', left); });
$frameAdded.css('opacity', opacity); };
} })(this));
}); }
}; };
})(this));
}
} }
requestImageInfo(img, callback) { requestImageInfo(img, callback) {

View File

@ -1,56 +1,56 @@
<script> <script>
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import tooltip from '~/vue_shared/directives/tooltip'; import tooltip from '~/vue_shared/directives/tooltip';
import icon from '~/vue_shared/components/icon.vue'; import icon from '~/vue_shared/components/icon.vue';
import modal from '~/vue_shared/components/modal.vue'; import modal from '~/vue_shared/components/modal.vue';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import { COMMON_STR } from '../constants'; import { COMMON_STR } from '../constants';
export default { export default {
components: { components: {
icon, icon,
modal, modal,
},
directives: {
tooltip,
},
props: {
parentGroup: {
type: Object,
required: false,
default: () => ({}),
}, },
group: { directives: {
type: Object, tooltip,
required: true,
}, },
}, props: {
data() { parentGroup: {
return { type: Object,
modalStatus: false, required: false,
}; default: () => ({}),
}, },
computed: { group: {
leaveBtnTitle() { type: Object,
return COMMON_STR.LEAVE_BTN_TITLE; required: true,
},
}, },
editBtnTitle() { data() {
return COMMON_STR.EDIT_BTN_TITLE; return {
modalStatus: false,
};
}, },
leaveConfirmationMessage() { computed: {
return s__(`GroupsTree|Are you sure you want to leave the "${this.group.fullName}" group?`); leaveBtnTitle() {
return COMMON_STR.LEAVE_BTN_TITLE;
},
editBtnTitle() {
return COMMON_STR.EDIT_BTN_TITLE;
},
leaveConfirmationMessage() {
return s__(`GroupsTree|Are you sure you want to leave the "${this.group.fullName}" group?`);
},
}, },
}, methods: {
methods: { onLeaveGroup() {
onLeaveGroup() { this.modalStatus = true;
this.modalStatus = true; },
leaveGroup() {
this.modalStatus = false;
eventHub.$emit('leaveGroup', this.group, this.parentGroup);
},
}, },
leaveGroup() { };
this.modalStatus = false;
eventHub.$emit('leaveGroup', this.group, this.parentGroup);
},
},
};
</script> </script>
<template> <template>

View File

@ -26,30 +26,18 @@
default: () => ({}), default: () => ({}),
}, },
}, },
data() {
return {
outputType: '',
};
},
computed: { computed: {
componentName() { componentName() {
if (this.output.text) { if (this.output.text) {
return 'code-cell'; return 'code-cell';
} else if (this.output.data['image/png']) { } else if (this.output.data['image/png']) {
this.outputType = 'image/png';
return 'image-output'; return 'image-output';
} else if (this.output.data['text/html']) { } else if (this.output.data['text/html']) {
this.outputType = 'text/html';
return 'html-output'; return 'html-output';
} else if (this.output.data['image/svg+xml']) { } else if (this.output.data['image/svg+xml']) {
this.outputType = 'image/svg+xml';
return 'html-output'; return 'html-output';
} }
this.outputType = 'text/plain';
return 'code-cell'; return 'code-cell';
}, },
rawCode() { rawCode() {
@ -59,6 +47,19 @@
return this.dataForType(this.outputType); return this.dataForType(this.outputType);
}, },
outputType() {
if (this.output.text) {
return '';
} else if (this.output.data['image/png']) {
return 'image/png';
} else if (this.output.data['text/html']) {
return 'text/html';
} else if (this.output.data['image/svg+xml']) {
return 'image/svg+xml';
}
return 'text/plain';
},
}, },
methods: { methods: {
dataForType(type) { dataForType(type) {

View File

@ -305,7 +305,8 @@ js-gfm-input js-autosize markdown-area js-vue-textarea"
</textarea> </textarea>
</markdown-field> </markdown-field>
<div class="note-form-actions"> <div class="note-form-actions">
<div class="pull-left btn-group <div
class="pull-left btn-group
append-right-10 comment-type-dropdown js-comment-type-dropdown droplab-dropdown"> append-right-10 comment-type-dropdown js-comment-type-dropdown droplab-dropdown">
<button <button
@click.prevent="handleSave()" @click.prevent="handleSave()"

View File

@ -115,7 +115,7 @@
name="body" name="body"
:text="text" :text="text"
> >
<p>{{ this.text }}</p> <p>{{ text }}</p>
</slot> </slot>
</div> </div>
<div <div

View File

@ -13,14 +13,17 @@
selectedDate: { selectedDate: {
type: Date, type: Date,
required: false, required: false,
default: null,
}, },
minDate: { minDate: {
type: Date, type: Date,
required: false, required: false,
default: null,
}, },
maxDate: { maxDate: {
type: Date, type: Date,
required: false, required: false,
default: null,
}, },
}, },
mounted() { mounted() {

View File

@ -23,10 +23,12 @@
minDate: { minDate: {
type: Date, type: Date,
required: false, required: false,
default: null,
}, },
maxDate: { maxDate: {
type: Date, type: Date,
required: false, required: false,
default: null,
}, },
disableClickableIcons: { disableClickableIcons: {
type: Boolean, type: Boolean,

View File

@ -42,14 +42,17 @@
selectedDate: { selectedDate: {
type: Date, type: Date,
required: false, required: false,
default: null,
}, },
minDate: { minDate: {
type: Date, type: Date,
required: false, required: false,
default: null,
}, },
maxDate: { maxDate: {
type: Date, type: Date,
required: false, required: false,
default: null,
}, },
}, },
data() { data() {