Load main stylesheet using AJAX in the CSS editor.

This commit is contained in:
Max Goodman
2011-08-29 16:05:29 -07:00
committed by Neil Williams
parent 18c5e4211c
commit e9c50e59b3
2 changed files with 12 additions and 12 deletions

View File

@@ -313,14 +313,6 @@ class Globals(object):
print ("Warning: g.media_domain == g.domain. " +
"This may give untrusted content access to user cookies")
#read in our CSS so that it can become a default for subreddit
#stylesheets
stylesheet_path = os.path.join(self.paths.get('static_files'),
self.static_path.lstrip('/'),
self.stylesheet)
with open(stylesheet_path) as s:
self.default_stylesheet = s.read()
self.profanities = None
if self.profanity_wordlist and os.path.exists(self.profanity_wordlist):
with open(self.profanity_wordlist, 'r') as handle:

View File

@@ -62,7 +62,6 @@
name="default_stylesheet"
readonly="readonly"
>
${keep_space(g.default_stylesheet)}
</textarea>
</div>
</div>
@@ -142,13 +141,22 @@
$(".img-status").innerHTML = "";
}
function showDefaultStylesheet(btn) {
var default_stylesheet = $('#default_stylesheet');
if (!default_stylesheet.data('loaded')) {
default_stylesheet.text('loading...');
$.get(document.styleSheets[0].href, function(css) {
default_stylesheet.val(css);
default_stylesheet.data('loaded', true);
})
}
$("#stylesheet_contents").parents(".col")
.animate( { width: "50%" }, function() {
$("#default_stylesheet").parents(".col")
default_stylesheet.parents(".col")
.css("width", "50%")
.fadeIn();
} );
});
}
function hideDefaultStylesheet(btn) {
$("#default_stylesheet").parents(".col")