Skip to content

Commit

Permalink
Fix(ui): dont show till respecIsReady (closes #410)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres committed Apr 19, 2016
1 parent 185c057 commit 2c6615b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions js/core/css/respec2.css
Expand Up @@ -108,6 +108,10 @@ table.simple {
margin-bottom: 0;
}

.hidden {
display: none;
}

@media print {
.removeOnSave {
display: none;
Expand Down
10 changes: 9 additions & 1 deletion js/core/ui.js
Expand Up @@ -31,6 +31,7 @@ define(
, warnings = []
, buttons = {}
, $respecButton
, $respecUI
, errWarn = function (msg, arr, butName, bg, title) {
arr.push(msg);
if (!buttons[butName]) {
Expand Down Expand Up @@ -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 = $("<div id='respec-ui' class='removeOnSave'></div>", doc)
var $div = $respecUI = $("<div id='respec-ui' class='removeOnSave'></div>", doc)
.css({
position: "fixed"
, top: "20px"
Expand Down Expand Up @@ -134,6 +141,7 @@ define(
if (buttons.warning) buttons.warning.click();
});
msg.pub("end", "core/ui");
this.hide();
cb();
}
, addCommand: function (label, module, keyShort) {
Expand Down
12 changes: 10 additions & 2 deletions js/profile-w3c-common.js
Expand Up @@ -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();
})
});
}
);

0 comments on commit 2c6615b

Please sign in to comment.