Skip to content

Commit 4a8c619

Browse files
authored
Merge pull request #8 from uncinc/develop
Fix/chrome issues (#7)
2 parents 18c2d2e + 5a107d9 commit 4a8c619

File tree

29 files changed

+199
-88
lines changed

29 files changed

+199
-88
lines changed

gulpfile.babel.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ gulp.task('watch', ['build'], () => {
9393
$.runSequence('icons', $.livereload.reload);
9494
});
9595
gulp.watch(['./src/scripts/**/*']).on('change', () => {
96+
$.runSequence('lint.js');
9697
$.runSequence('js', $.livereload.reload);
9798
});
9899
gulp.watch(['./src/styles/**/*']).on('change', () => {
@@ -153,6 +154,16 @@ gulp.task('js', () => {
153154
return buildJS(target);
154155
});
155156

157+
gulp.task('lint.js', () => { // generate a zip
158+
return gulp.src(['./src/scripts/background/*.js', './src/scripts/components/**/*.js', './src/scripts/config/*.js', './src/scripts/utils/*.js']).pipe($.eslint())
159+
// $.eslint.format() outputs the lint results to the console.
160+
// Alternatively use $.eslint.formatEach() (see Docs).
161+
.pipe($.eslint.format())
162+
// To have the process exit with an error code (1) on
163+
// lint error, return the stream and pipe to failAfterError last.
164+
// .pipe($.eslint.failAfterError());
165+
});
166+
156167
gulp.task('styles', () => {
157168
return gulp.src([`src/styles/index.${target}.scss`])
158169
.pipe($.plumber())
@@ -213,6 +224,7 @@ gulp.task('dist', (cb) => { // generate a zip
213224
$.runSequence('build', 'zip', cb);
214225
});
215226

227+
216228
gulp.task('zip', () => {
217229
return pipe(`./build/${target}/**/*`, $.zip(`${target}.zip`), './dist');
218230
});
@@ -258,7 +270,7 @@ function buildJS(target) {
258270
let tasks = files.map(file => {
259271
return browserify({
260272
entries: 'src/scripts/' + file.source,
261-
debug: true
273+
debug: !production
262274
})
263275
.transform('babelify', {
264276
presets: [

src/scripts/background/data.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const data = (() => {
6363
});
6464
}
6565

66-
//clean all tickets an user acount data;
66+
// //clean all tickets an user acount data;
6767
function cleanAll() {
6868
console.log('>-------- The app is cleaned');
6969
setStorage({
@@ -181,7 +181,7 @@ const data = (() => {
181181
filtertTickets: filtertTickets,
182182
filtertTicketsAmout: filtertTickets.length,
183183
allTicketsFromThisWebsite: amountTicketsOnWebsite,
184-
allTicketsFromThisWebsiteAmount: amountTicketsOnWebsite.length,
184+
allTicketsFromThisWebsiteAmount: amountTicketsOnWebsite.length
185185
});
186186

187187
}).catch(function (err) {
@@ -216,7 +216,7 @@ const data = (() => {
216216
account: {
217217
userName: accountUserName,
218218
passWord: accountPassword,
219-
token: accountToken,
219+
token: accountToken
220220
},
221221
tool: {
222222
project: toolProjectId,

src/scripts/background/findUserData.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,40 @@ var data = (() => {
1717
browserVersion: browserConfig.version,
1818
osversion: browserConfig.osversion,
1919
user_agent: window.navigator.appVersion,
20-
os: (browserConfig.mac) ? 'mac' : false || (browserConfig.windows) ? 'windows' : false || (browserConfig.windowsphone) ? 'windowsphone' : false || (browserConfig.linux) ? 'linux' : false || (browserConfig.chromeos) ? 'chromeos' : false || (browserConfig.android) ? 'android' : false || (browserConfig.ios) ? 'ios' : false || (browserConfig.blackberry) ? 'blackberry' : false || (browserConfig.firefoxos) ? 'firefoxos' : false || (browserConfig.webos) ? 'webos' : false || (browserConfig.bada) ? 'bada' : false || (browserConfig.tizen) ? 'tizen' : false || (browserConfig.sailfish) ? 'sailfish' : false
20+
os: getOs()
2121
};
2222
};
2323

24+
function getOs() {
25+
if (browserConfig.mac) {
26+
return 'mac';
27+
} else if (browserConfig.windows) {
28+
return 'windows';
29+
} else if (browserConfig.windowsphone) {
30+
return 'windowsphone';
31+
} else if (browserConfig.linux) {
32+
return 'linux';
33+
} else if (browserConfig.chromeos) {
34+
return 'chromeos';
35+
} else if (browserConfig.android) {
36+
return 'android';
37+
} else if (browserConfig.ios) {
38+
return 'ios';
39+
} else if (browserConfig.blackberry) {
40+
return 'blackberry';
41+
} else if (browserConfig.firefoxos) {
42+
return 'firefoxos';
43+
} else if (browserConfig.webos) {
44+
return 'webos';
45+
} else if (browserConfig.bada) {
46+
return 'bada';
47+
} else if (browserConfig.tizen) {
48+
return 'tizen';
49+
} else if (browserConfig.sailfish) {
50+
return 'sailfish';
51+
}
52+
return false;
53+
}
2454

2555
/**
2656
* Get specific user data
@@ -35,7 +65,7 @@ var data = (() => {
3565
shortlink: shortlink,
3666
hostname: hostname,
3767
time: new Date(),
38-
screenresolution: screenresolution,
68+
screenresolution: screenresolution
3969
// history: getHistory()
4070
};
4171

src/scripts/background/mantisApi.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,12 @@ let mantisApi = (() => {
9595
message: 'Your credentials are wrong'
9696
});
9797
} else {
98-
resolve(res);
98+
//if there is only one project in mantis the api returns a object instead of a array
99+
if (res.item) {
100+
resolve([res.item]);
101+
} else {
102+
resolve(res);
103+
}
99104
}
100105
}
101106

@@ -136,10 +141,10 @@ let mantisApi = (() => {
136141
os_build: newTicketObject.data.browserData.osversion,
137142
priority: {
138143
id: (newTicketObject.isImportant === true) ? IMPORTANT_WEIGHT : NOMAL_WEIGHT,
139-
name: (newTicketObject.isImportant === true) ? 'height' : 'normal',
144+
name: (newTicketObject.isImportant === true) ? 'height' : 'normal'
140145
},
141146
steps_to_reproduce: JSON.stringify(newTicketObject.data),
142-
category: 'General', //This one is requert by mantis.
147+
category: 'General' //This one is requert by mantis.
143148
// attachments: newTicketObject.assets
144149
};
145150

src/scripts/components/button.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
/* Setup ==================================================================== */
4-
import React, {Component} from 'react';
4+
import React, {Component} from 'react'; // eslint-disable-line no-unused-vars
55

66
/* Component ==================================================================== */
77
class Button extends Component {

src/scripts/components/commentbox/fileItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
/* Setup ==================================================================== */
4-
import React, {Component} from 'react';
4+
import React, {Component} from 'react'; // eslint-disable-line no-unused-vars
55

66
import helpers, {translate} from '../../utils/helpers';
77

src/scripts/components/commentbox/index.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
'use strict';
22

33
/* Setup ==================================================================== */
4+
/*eslint-disable no-unused-vars*/
45
import React, {Component} from 'react';
56
import Anime from 'react-anime';
67

78
import message from '../../utils/message.js';
89

910
//import components
10-
import Button from '../button'
11+
import Button from '../button';
1112
import TextareaAutosize from '../textareaAutosize';
1213
import FileItem from './fileItem';
1314
import Loader from '../loader';
@@ -17,6 +18,7 @@ import helpers, {translate} from '../../utils/helpers';
1718
import generalConfig from '../../config/general';
1819
// import data from '../../utils/data''Turn Layernotes On'
1920
import routerHelper from '../router/routerHelper';
21+
/*eslint-enable no-unused-vars*/
2022

2123
/* Component ==================================================================== */
2224
class CommentBox extends Component {
@@ -60,15 +62,9 @@ class CommentBox extends Component {
6062
super(props);
6163
this.state = {
6264
isError: false, //it the error should be shown
63-
errorText: '', // the error text
64-
scale: [1] //Do not scale by default
65+
errorText: '' // the error text
6566
};
6667
}
67-
componentWillUnmount() {
68-
this.setState({
69-
scale: [1, 0.3]
70-
});
71-
}
7268

7369
/**
7470
* Adds for normal inputs
@@ -233,8 +229,19 @@ class CommentBox extends Component {
233229
//set the posiotn of the comment box
234230
_setPosition = () => {
235231
const MAX_POSITON_BOTTOM = 250;
232+
const HEIGHT = {
233+
CONTENTMODE: 231,
234+
ELSE: 192,
235+
EDDITMODE: 480
236+
};
237+
const SPACEING = 100;
238+
const PADDING = 15;
236239
//-------------------------------------------------------------------------------standard height with edit bar: standard height without eddit bar ------------------------------------------- the margin;
237-
const commentBoxHeight = (document.querySelector('.ln-commentbox') === null) ? ((this.props.inEditMode) ? 231 : 192) : document.querySelector('.ln-commentbox').getBoundingClientRect().height + 15;
240+
const commentBoxHeight = (document.querySelector('.ln-commentbox') === null)
241+
? ((this.props.inEditMode)
242+
? HEIGHT.CONTENTMODE
243+
: HEIGHT.ELSE)
244+
: document.querySelector('.ln-commentbox').getBoundingClientRect().height + PADDING;
238245

239246
//this comment box is used 2 times in the app. When creating and edditigng isseu;
240247
let position = {
@@ -249,8 +256,8 @@ class CommentBox extends Component {
249256
position.style.left = this.props.ticket.position.x;
250257

251258
//when the position of the box is on the right side posion the box on the right;
252-
if (this.props.ticket.position.x > (generalConfig.maxX(0) / 2) - 100) {
253-
position.style.left = this.props.ticket.position.x - 480 + this.props.ticket.position.width;
259+
if (this.props.ticket.position.x > (generalConfig.maxX(0) / 2) - SPACEING) {
260+
position.style.left = this.props.ticket.position.x - HEIGHT.EDDITMODE + this.props.ticket.position.width;
254261
position.class = 'ln-commentbox-right';
255262
}
256263
position.style.top = this.props.ticket.position.height + this.props.ticket.position.y; //only add the top prop to the style when creating;
@@ -260,7 +267,7 @@ class CommentBox extends Component {
260267
}
261268

262269
if (this.props.ticket.position.y > helpers.pageHeight() - this.props.ticket.position.height - MAX_POSITON_BOTTOM) {
263-
position.style.transform = - (commentBoxHeight + this.props.ticket.position.height);
270+
position.style.transform = -(commentBoxHeight + this.props.ticket.position.height);
264271

265272
position.class = position.class + ' ln-commentbox-top';
266273
}
@@ -346,7 +353,7 @@ class CommentBox extends Component {
346353

347354
render = () => {
348355
return (
349-
<Anime left={this._setPosition().style.left} top={this._setPosition().style.top} scale={this.state.scale} translateY={this._setPosition().style.transform}>
356+
<Anime left={this._setPosition().style.left} top={this._setPosition().style.top} translateY={this._setPosition().style.transform}>
350357
<form className={`ln-commentbox ${this._setPosition().class}`} onSubmit={this._prepareSumbit} method="POST">
351358
{this._renderOverLay()}
352359

src/scripts/components/inputText/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* Setup ==================================================================== */
44

55
//imports
6-
import React, {Component} from 'react';
6+
import React, {Component} from 'react'; // eslint-disable-line no-unused-vars
77

88
import validate from '../../utils/validate';
99
import {translate} from '../../utils/helpers';

src/scripts/components/loader/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* Setup ==================================================================== */
44

55
//imports
6-
import React, {Component} from 'react';
6+
import React, {Component} from 'react'; // eslint-disable-line no-unused-vars
77

88
/* Component ==================================================================== */
99
class Loader extends Component {

src/scripts/components/rootElement/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
'use strict';
22

33
/* Setup ==================================================================== */
4-
import React, {Component} from 'react';
4+
5+
import React, {Component} from 'react'; // eslint-disable-line no-unused-vars
56

67
//import helpers
78
import helpers from '../../utils/helpers';
89

910
// Components
10-
import Router from '../router';
11+
import Router from '../router'; // eslint-disable-line no-unused-vars
1112

1213
/* Component ==================================================================== */
1314
class Root extends Component {

0 commit comments

Comments
 (0)