Skip to content

Commit

Permalink
Fix(ui): dont show till respecIsReady (closes #410)
Browse files Browse the repository at this point in the history
* fix(profile-w3c-common): forgot to include fetch poly for Safari

* Chore(.travis.yml): use latest firefox

* Fix(ui): dont show till respecIsReady (closes #410)
  • Loading branch information
Marcos Cáceres committed Apr 20, 2016
1 parent 19b5647 commit 751aa63
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 15 deletions.
2 changes: 1 addition & 1 deletion builds/respec-w3c-common.build.js.map

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions builds/respec-w3c-common.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions js/core/css/respec2.css
Expand Up @@ -108,6 +108,10 @@ table.simple {
margin-bottom: 0;
}

.respec-hidden {
display: none;
}

@media print {
.removeOnSave {
display: none;
Expand Down
11 changes: 10 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("respec-hidden");
},
hide: function(){
$respecUI[0].classList.add("respec-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 Expand Up @@ -219,6 +227,7 @@ define(
;
}
};
window.respecUI = ui;
if (window.respecEvents) respecEvents.sub("error", function (details) {
ui.error(details);
});
Expand Down
12 changes: 10 additions & 2 deletions js/profile-w3c-common.js
Expand Up @@ -71,13 +71,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();
})
});
}
);
24 changes: 24 additions & 0 deletions tests/spec/core/ui-spec.js
@@ -0,0 +1,24 @@
"use strict";

describe("Core - Ui", function () {
afterAll(function (done) {
flushIframes();
done();
});

it("shows and hides the UI", function (done) {
makeRSDoc(makeStandardOps(), function (doc) {
var ui = doc.defaultView.respecUI;
var pillContainer = doc.querySelector("#respec-ui");
// Initially, it should be showing
expect(pillContainer.classList.contains("respec-hidden")).toBe(false);
ui.show();
// showing it doesn't change it from showing
expect(pillContainer.classList.contains("respec-hidden")).toBe(false);
ui.hide();
expect(pillContainer.classList.contains("respec-hidden")).toBe(true);
ui.show();
expect(pillContainer.classList.contains("respec-hidden")).toBe(false);
}).then(done);
});
});
1 change: 1 addition & 0 deletions tests/testFiles.json
Expand Up @@ -22,6 +22,7 @@
"spec/core/section-refs-spec.js",
"spec/core/structure-spec.js",
"spec/core/style-spec.js",
"spec/core/ui-spec.js",
"spec/core/utils-spec.js",
"spec/core/webidl-contiguous-spec.js",
"spec/core/webidl-oldschool-spec.js",
Expand Down

0 comments on commit 751aa63

Please sign in to comment.