From 2c6615b69799ca6267ae4d28a2f674e8e85c9c42 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Tue, 19 Apr 2016 19:41:25 +1000 Subject: [PATCH] Fix(ui): dont show till respecIsReady (closes #410) --- js/core/css/respec2.css | 4 ++++ js/core/ui.js | 10 +++++++++- js/profile-w3c-common.js | 12 ++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/js/core/css/respec2.css b/js/core/css/respec2.css index f7ec63d394..b8ccdecb31 100644 --- a/js/core/css/respec2.css +++ b/js/core/css/respec2.css @@ -108,6 +108,10 @@ table.simple { margin-bottom: 0; } +.hidden { + display: none; +} + @media print { .removeOnSave { display: none; diff --git a/js/core/ui.js b/js/core/ui.js index 7b0c7068e7..d53851e694 100644 --- a/js/core/ui.js +++ b/js/core/ui.js @@ -31,6 +31,7 @@ define( , warnings = [] , buttons = {} , $respecButton + , $respecUI , errWarn = function (msg, arr, butName, bg, title) { arr.push(msg); if (!buttons[butName]) { @@ -98,10 +99,16 @@ define( ; var conf, doc, msg; var ui = { + show: function(){ + $respecUI[0].classList.remove("hidden"); + }, + hide: function(){ + $respecUI[0].classList.add("hidden"); + }, run: function (_conf, _doc, cb, _msg) { conf = _conf, doc = _doc, msg = _msg; msg.pub("start", "core/ui"); - var $div = $("
", doc) + var $div = $respecUI = $("
", doc) .css({ position: "fixed" , top: "20px" @@ -134,6 +141,7 @@ define( if (buttons.warning) buttons.warning.click(); }); msg.pub("end", "core/ui"); + this.hide(); cb(); } , addCommand: function (label, module, keyShort) { diff --git a/js/profile-w3c-common.js b/js/profile-w3c-common.js index 1699a0c231..64a0a9dc93 100644 --- a/js/profile-w3c-common.js +++ b/js/profile-w3c-common.js @@ -69,13 +69,21 @@ define([ "ui/search-specref", ], function(domReady, runner, ui) { - var args = Array.prototype.slice.call(arguments); + var args = Array.from(arguments); domReady(function() { ui.addCommand("Save Snapshot", "ui/save-html", "Ctrl+Shift+Alt+S"); ui.addCommand("About ReSpec", "ui/about-respec", "Ctrl+Shift+Alt+A"); ui.addCommand("Definition List", "ui/dfn-list", "Ctrl+Shift+Alt+D"); ui.addCommand("Search Specref DB", "ui/search-specref", "Ctrl+Shift+Alt+space"); - runner.runAll(args); + runner + .runAll(args) + .then(document.respectIsReady) + .then(ui.show) + .catch(function(err){ + console.error(err); + // even if things go critically bad, we should still try to show the UI + ui.show(); + }) }); } );