Skip to content
This repository was archived by the owner on Oct 2, 2018. It is now read-only.

Commit cb4166a

Browse files
committed
Two more bugfixes
- Toolbar is shown after focus -> blur in ODT docs - First fixMenu call permanently removes links
1 parent 2623bae commit cb4166a

1 file changed

Lines changed: 29 additions & 16 deletions

File tree

scripts/firetext.js

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function initModules(callback) {
9494
bugsenseInit();
9595

9696
// Fix menu before url request
97-
fixMenu();
97+
fixMenu(true);
9898

9999
// Initialize urls
100100
initURLs(function(){
@@ -215,33 +215,44 @@ function initURLs(callback) {
215215
xhr.send('request=urls&version='+version);
216216
}
217217

218-
function fixMenu() {
219-
var tempElements = [];
218+
function fixMenu(soft) {
219+
var tempElements = [], tempLinks = [];
220220
var urlNames = ['about','support','credits','rate'];
221221

222222
// Find empty urls
223223
urlNames.forEach(function(v){
224224
if (!urls[v]) {
225225
tempElements = addMenuElementsToArray(tempElements, document.querySelectorAll('[data-type="sidebar"] nav [data-click-location="'+v+'"]'));
226+
} else {
227+
tempLinks = addMenuElementsToArray(tempLinks, document.querySelectorAll('[data-type="sidebar"] nav [data-click-location="'+v+'"]'));
228+
for (var i = 0; i < tempLinks.length; i++) {
229+
tempLinks[i].parentNode.classList.remove('hidden-item');
230+
}
226231
}
227232
});
228233

229-
// Remove list items
230-
for (var i = 0; i < tempElements.length; i++) {
231-
var tempParent = tempElements[i].parentNode.parentNode;
232-
if (tempParent) {
233-
tempParent.removeChild(tempElements[i].parentNode);
234+
if (soft === true) {
235+
for (var i = 0; i < tempElements.length; i++) {
236+
tempElements[i].parentNode.classList.add('hidden-item');
237+
}
238+
} else {
239+
// Remove list items
240+
for (var i = 0; i < tempElements.length; i++) {
241+
var tempParent = tempElements[i].parentNode.parentNode;
242+
if (tempParent) {
243+
tempParent.removeChild(tempElements[i].parentNode);
244+
}
234245
}
235-
}
236246

237-
// Remove empty lists
238-
var tempLists = document.querySelectorAll('[data-type="sidebar"] nav ul');
239-
for (var i = 0; i < tempLists.length; i++) {
240-
if (tempLists[i].childElementCount == 0) {
241-
if (tempLists[i].previousElementSibling) {
242-
tempLists[i].parentNode.removeChild(tempLists[i].previousElementSibling);
247+
// Remove empty lists
248+
var tempLists = document.querySelectorAll('[data-type="sidebar"] nav ul');
249+
for (var i = 0; i < tempLists.length; i++) {
250+
if (tempLists[i].childElementCount == 0) {
251+
if (tempLists[i].previousElementSibling) {
252+
tempLists[i].parentNode.removeChild(tempLists[i].previousElementSibling);
253+
}
254+
tempLists[i].parentNode.removeChild(tempLists[i]);
243255
}
244-
tempLists[i].parentNode.removeChild(tempLists[i]);
245256
}
246257
}
247258
}
@@ -1166,6 +1177,7 @@ function processActions(eventAttribute, target) {
11661177
} else if (calledFunction == 'hideToolbar') {
11671178
if (deviceType != 'desktop') {
11681179
if (document.getElementById('currentFileType').textContent != '.txt' &&
1180+
document.getElementById('currentFileType').textContent != '.odt' &&
11691181
target.id === 'editor') {
11701182
document.getElementById('edit-bar').style.display = 'none';
11711183
editor.classList.add('no-toolbar');
@@ -1174,6 +1186,7 @@ function processActions(eventAttribute, target) {
11741186
}
11751187
} else if (calledFunction == 'showToolbar') {
11761188
if (document.getElementById('currentFileType').textContent != '.txt' &&
1189+
document.getElementById('currentFileType').textContent != '.odt' &&
11771190
target.id === 'editor') {
11781191
document.getElementById('edit-bar').style.display = 'block';
11791192
editor.classList.remove('no-toolbar');

0 commit comments

Comments
 (0)