Permalink
Browse files

Adding the stylesheet differently

Adding it via jQuery was firing DOMContentLoaded before all of the CSS
was loaded, thus messing up CSS rules and messing up automatic <select>
styling - see bug #287.  Changing this to document.write to add it immediately
before the jQuery script tag.

Moved all post-jQuery-load things into index.js.

Also updated the demo page to put CSS in front of the script tags.
  • Loading branch information...
fidian committed Feb 19, 2013
1 parent e922257 commit cdaf52296dd5bdb0fdc09303a4d3e081a649b10d
Showing with 12 additions and 11 deletions.
  1. +2 −2 demo/demo.html
  2. +1 −1 www-fragments/index-start.html
  3. +8 −8 www/javascripts/index-theme.js
  4. +1 −0 www/javascripts/index.js
View
@@ -34,6 +34,8 @@
}
+ css('../themes/' + optionValues.theme + '/css/uniform.' + optionValues.theme + '.css');
+
url = '://ajax.googleapis.com/ajax/libs/jquery/'
if (window.location.protocol == 'https:') {
@@ -57,8 +59,6 @@
} else {
script('../jquery.uniform.js');
}
-
- css('../themes/' + optionValues.theme + '/css/uniform.' + optionValues.theme + '.css');
}());
</script>
<script type="text/javascript">
@@ -3,8 +3,8 @@
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
<link type="text/css" rel="stylesheet" href="stylesheets/site.css" />
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script type='text/javascript' src="javascripts/index-theme.js"></script>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script src="javascripts/jquery.uniform.min.js" type="text/javascript"></script>
<script type='text/javascript' src="javascripts/index.js"></script>
<title>Uniform - Sexy forms with jQuery</title>
@@ -1,9 +1,10 @@
-/*global $, window*/
+/*global document, window*/
+
+window.theme = 'aristo';
(function () {
'use strict';
- var theme = 'aristo',
- params = window.location.search,
+ var params = window.location.search,
i,
keyValue;
@@ -14,15 +15,14 @@
keyValue = params[i].split('=');
if (keyValue[0] === 'theme') {
if (' agent aristo default jeans '.indexOf(' ' + keyValue[1] + ' ') >= 0) {
- theme = keyValue[1];
+ window.theme = keyValue[1];
}
}
}
}
// Courtesy of Nathan Hartwell <njhartwell@gmail.com>
- $('head').append('<link type="text/css" rel="stylesheet" href="stylesheets/uniform.' + theme + '.css" />');
- $(function () {
- $("#theme").val(theme);
- });
+ /*jslint evil:true*/
+ document.write('<link type="text/css" rel="stylesheet" href="stylesheets/uniform.' + window.theme + '.css" />');
+ /*jslint evil:false*/
}());
View
@@ -3,6 +3,7 @@
(function () {
'use strict';
$(function () {
+ $("#theme").val(window.theme);
$("#theme").change(function () {
this.form.submit();
return false;

0 comments on commit cdaf522

Please sign in to comment.