Skip to content

Commit 65c890a

Browse files
committed
Add nprogress instead of spin
1 parent cd664a9 commit 65c890a

File tree

5 files changed

+35
-10
lines changed

5 files changed

+35
-10
lines changed

pootle/static/css/editor.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,20 @@ textarea.translation,
158158
margin: 180px auto;
159159
}
160160

161+
.editor-progress-container
162+
{
163+
position: absolute;
164+
top: 0;
165+
left: 0;
166+
right: 0;
167+
z-index: 99;
168+
}
169+
170+
.editor-progress
171+
{
172+
height: 5px;
173+
}
174+
161175
.editor-overlay
162176
{
163177
background-color: rgba(255, 255, 255, 0.8);

pootle/static/js/editor/app.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ 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';
30+
import 'nprogress/nprogress.css';
2931

3032
import UnitAPI from 'api/UnitAPI';
3133
import cookie from 'utils/cookie';
@@ -51,6 +53,10 @@ import ReactEditor from './index';
5153
// be the actual entry point, entirely superseding the `app` module.
5254
PTL.reactEditor = ReactEditor;
5355

56+
NProgress.configure({
57+
parent: '#js-editor-progress',
58+
showSpinner: false,
59+
});
5460

5561
const CTX_STEP = 1;
5662

@@ -135,7 +141,6 @@ PTL.editor = {
135141

136142
/* Cached elements */
137143
this.backToBrowserEl = q('.js-back-to-browser');
138-
this.$editorActivity = $('#js-editor-act');
139144
this.$editorBody = $('.js-editor-body');
140145
this.editorTableEl = q('.js-editor-table');
141146
this.$filterStatus = $('#js-filter-status');
@@ -166,8 +171,8 @@ PTL.editor = {
166171

167172
this.isUnitDirty = false;
168173

169-
this.isLoading = true;
170174
this.showActivity();
175+
this.isLoading = true;
171176

172177
this.fetchingOffsets = [];
173178

@@ -405,9 +410,7 @@ PTL.editor = {
405410
return;
406411
}
407412

408-
this.delayedActivityTimer = setTimeout(() => {
409-
this.showActivity();
410-
}, 3000);
413+
this.showActivity();
411414
});
412415
$(document).ajaxStop(() => {
413416
clearTimeout(this.delayedActivityTimer);
@@ -642,7 +645,6 @@ PTL.editor = {
642645
this.isUnitDirty = false;
643646
this.keepState = false;
644647
this.isLoading = false;
645-
this.hideActivity();
646648
},
647649

648650
/* Things to do when no results are returned */
@@ -1028,11 +1030,18 @@ PTL.editor = {
10281030

10291031
showActivity() {
10301032
this.hideMsg();
1031-
this.$editorActivity.spin().fadeIn(300);
1033+
if (this.isLoading) {
1034+
return;
1035+
}
1036+
clearTimeout(this.delayedActivityTimer);
1037+
this.delayedActivityTimer = setTimeout(() => NProgress.start(), 2000);
10321038
},
10331039

10341040
hideActivity() {
1035-
this.$editorActivity.spin(false).fadeOut(300);
1041+
if (!this.isLoading) {
1042+
clearTimeout(this.delayedActivityTimer);
1043+
NProgress.done();
1044+
}
10361045
},
10371046

10381047
/* 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>

pootle/templates/editor/main.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
{% block pre_content %}
2222
{% include 'editor/_toolbar.html' %}
23+
<div class="editor-progress-container">
24+
<div id="js-editor-progress" class="editor-progress"></div>
25+
</div>
2326
{% endblock %}
2427

2528
{% block content %}

0 commit comments

Comments
 (0)