Skip to content

Commit 3b905e7

Browse files
committed
Add nprogress instead of spin
1 parent 1825ead commit 3b905e7

File tree

5 files changed

+99
-10
lines changed

5 files changed

+99
-10
lines changed

pootle/apps/pootle_app/assets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,6 @@
8181

8282
css_editor = Bundle(
8383
'css/editor.css',
84+
'css/nprogress.css',
8485
filters='cssmin', output='css/editor.min.%(version)s.css')
8586
register('css_editor', css_editor)

pootle/static/css/nprogress.css

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#nprogress
2+
{
3+
pointer-events: none;
4+
}
5+
6+
#nprogress .bar
7+
{
8+
background: #29d;
9+
10+
position: fixed;
11+
z-index: 1031;
12+
top: 0;
13+
left: 0;
14+
15+
width: 100%;
16+
height: 2px;
17+
}
18+
19+
/* Fancy blur effect */
20+
#nprogress .peg
21+
{
22+
display: block;
23+
position: absolute;
24+
right: 0px;
25+
width: 100px;
26+
height: 100%;
27+
box-shadow: 0 0 10px #29d, 0 0 5px #29d;
28+
opacity: 1.0;
29+
30+
-webkit-transform: rotate(3deg) translate(0px, -4px);
31+
-ms-transform: rotate(3deg) translate(0px, -4px);
32+
transform: rotate(3deg) translate(0px, -4px);
33+
}
34+
35+
/* Remove these to get rid of the spinner */
36+
#nprogress .spinner
37+
{
38+
display: block;
39+
position: fixed;
40+
z-index: 1031;
41+
top: 15px;
42+
right: 15px;
43+
}
44+
45+
#nprogress .spinner-icon
46+
{
47+
width: 18px;
48+
height: 18px;
49+
box-sizing: border-box;
50+
51+
border: solid 2px transparent;
52+
border-top-color: #29d;
53+
border-left-color: #29d;
54+
border-radius: 50%;
55+
56+
-webkit-animation: nprogress-spinner 400ms linear infinite;
57+
animation: nprogress-spinner 400ms linear infinite;
58+
}
59+
60+
.nprogress-custom-parent
61+
{
62+
overflow: hidden;
63+
position: relative;
64+
}
65+
66+
.nprogress-custom-parent #nprogress .spinner,
67+
.nprogress-custom-parent #nprogress .bar
68+
{
69+
position: absolute;
70+
}
71+
72+
@-webkit-keyframes nprogress-spinner
73+
{
74+
0% { -webkit-transform: rotate(0deg); }
75+
100% { -webkit-transform: rotate(360deg); }
76+
}
77+
@keyframes nprogress-spinner
78+
{
79+
0% { transform: rotate(0deg); }
80+
100% { transform: rotate(360deg); }
81+
}

pootle/static/js/editor/app.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import cx from 'classnames';
2626
import Levenshtein from 'levenshtein';
2727
import mousetrap from 'mousetrap';
2828
import assign from 'object-assign';
29+
import NProgress from 'nprogress';
2930

3031
import UnitAPI from 'api/UnitAPI';
3132
import cookie from 'utils/cookie';
@@ -51,6 +52,10 @@ import ReactEditor from './index';
5152
// be the actual entry point, entirely superseding the `app` module.
5253
PTL.reactEditor = ReactEditor;
5354

55+
NProgress.configure({
56+
parent: '#body',
57+
showSpinner: false,
58+
});
5459

5560
const CTX_STEP = 1;
5661

@@ -135,7 +140,6 @@ PTL.editor = {
135140

136141
/* Cached elements */
137142
this.backToBrowserEl = q('.js-back-to-browser');
138-
this.$editorActivity = $('#js-editor-act');
139143
this.$editorBody = $('.js-editor-body');
140144
this.editorTableEl = q('.js-editor-table');
141145
this.$filterStatus = $('#js-filter-status');
@@ -166,8 +170,8 @@ PTL.editor = {
166170

167171
this.isUnitDirty = false;
168172

169-
this.isLoading = true;
170173
this.showActivity();
174+
this.isLoading = true;
171175

172176
this.fetchingOffsets = [];
173177

@@ -405,9 +409,7 @@ PTL.editor = {
405409
return;
406410
}
407411

408-
this.delayedActivityTimer = setTimeout(() => {
409-
this.showActivity();
410-
}, 3000);
412+
this.showActivity();
411413
});
412414
$(document).ajaxStop(() => {
413415
clearTimeout(this.delayedActivityTimer);
@@ -642,7 +644,6 @@ PTL.editor = {
642644
this.isUnitDirty = false;
643645
this.keepState = false;
644646
this.isLoading = false;
645-
this.hideActivity();
646647
},
647648

648649
/* Things to do when no results are returned */
@@ -1028,11 +1029,18 @@ PTL.editor = {
10281029

10291030
showActivity() {
10301031
this.hideMsg();
1031-
this.$editorActivity.spin().fadeIn(300);
1032+
if (this.isLoading) {
1033+
return;
1034+
}
1035+
clearTimeout(this.delayedActivityTimer);
1036+
this.delayedActivityTimer = setTimeout(() => NProgress.start(), 3000);
10321037
},
10331038

10341039
hideActivity() {
1035-
this.$editorActivity.spin(false).fadeOut(300);
1040+
if (!this.isLoading) {
1041+
clearTimeout(this.delayedActivityTimer);
1042+
NProgress.done();
1043+
}
10361044
},
10371045

10381046
/* Displays an informative message */

pootle/static/js/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"diff-match-patch": "^1.0.0",
4343
"imports-loader": "^0.6.3",
4444
"mousetrap": "^1.5.3",
45+
"nprogress": "^0.2.0",
4546
"object-assign": "^2.0.0",
4647
"react": "^0.14.6",
4748
"react-addons-pure-render-mixin": "^0.14.6",

pootle/templates/editor/_editor.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{% load locale %}
22
<div id="editor">
3-
<div id="js-editor-act" class="hide editor-overlay loader"></div>
43
<div id="js-editor-msg-overlay"></div>
5-
64
<table class="translate-table js-editor-table {% if cansuggest and not cantranslate %} suggest-mode{% endif %}" dir="{% locale_dir %}">
75
<tbody class="js-editor-body">
86
</tbody>

0 commit comments

Comments
 (0)