This repository has been archived by the owner on Jan 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Provide local CSS when external CDN fails #363
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var local_bootstrap = document.createElement('link'); | ||
local_bootstrap.setAttribute('rel', 'stylesheet'); | ||
local_bootstrap.setAttribute('type', 'text/css'); | ||
local_bootstrap.setAttribute('href', '/static/stylesheets/css/' + cssStyles[cs]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be chained like this:
var local_bootstrap = document.createElement('link');
.setAttribute('rel', 'stylesheet');
.setAttribute('type', 'text/css');
.setAttribute('href', '/static/stylesheets/css/' + cssStyles[cs]);
ryanjohara
force-pushed
the
issue-239
branch
2 times, most recently
from
September 10, 2014 15:02
e55401e
to
b3b997a
Compare
Fixes chop-dbhi#352 Signed-off-by: Ryan O'Hara <oharar@email.chop.edu>
ryanjohara
force-pushed
the
issue-239
branch
from
September 10, 2014 15:03
b3b997a
to
10a273b
Compare
|
||
} | ||
|
||
var cssStyles = ['bootstrap.css', 'bootstrap-responsive.css', 'font-awesome.css']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the cssLoaded
method can be removed and this code should be simplified into:
var requiredCSS = ['bootstrap.css', 'bootstrap-responsive.css', 'font-awesome.css'],
loadedCSS = document.styleSheets,
isLoaded;
for (var i = 0; i < requiredCSS.length; i++) {
isLoaded = _.some(loadedCSS, function(sheet) {
return sheet['href'].indexOf(requiredCSS[i]) >= 0;
});
if (isLoaded) continue;
var localLink = document.createElement('link');
.setAttribute('rel', 'stylesheet');
.setAttribute('type', 'text/css');
.setAttribute('href', '/static/stylesheets/css/' + requiredCSS[i]);
document.getElementsByTagName('head')[0].appendChild(localLink);
}
The original fix is actually broken. The test I used must not have been comprehensive. I was also unable to get the |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #352
Signed-off-by: Ryan O'Hara oharar@email.chop.edu