/
index.php
199 lines (149 loc) · 5.88 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?PHP
include "../index.php";
$shell['title3'] = "selectColorize";
$shell['h2'] = 'Basic cross-browser colored select boxes';
// ========================================================================== //
// SCRIPT
// ========================================================================== //
ob_start();
?>
$(function(){
$('a.enable').click(function(){
// Calling .change() might be necessary to visually update selects in
// all browsers, if multiple selects are being initialized at the same
// time.
$('select').selectColorize().change(); // Initialize.
});
$('a.destroy').click(function(){
$('select').selectColorize( false ); // Destroy.
});
});
<?
$shell['script'] = ob_get_contents();
ob_end_clean();
// ========================================================================== //
// HTML HEAD ADDITIONAL
// ========================================================================== //
ob_start();
?>
<script type="text/javascript" src="../../jquery.ba-selectcolorize.js"></script>
<script type="text/javascript" language="javascript">
<?= $shell['script']; ?>
$(function(){
// Prevent default click action for example links.
$('a.example').click(function(e){
e.preventDefault();
});
// Syntax highlighter.
SyntaxHighlighter.highlight();
});
</script>
<style type="text/css" title="text/css">
/*
bg: #FDEBDC
bg1: #FFD6AF
bg2: #FFAB59
orange: #FF7F00
brown: #913D00
lt. brown: #C4884F
*/
#page {
width: 700px;
}
/* options inherit from the select (but not in webkit) */
select {
margin-top: 0.3em;
}
select.first,
select.fourth {
color: #777;
}
select.second {
background: #777;
}
select.third {
color: orange;
background: #ffc;
}
</style>
<?
$shell['html_head'] = ob_get_contents();
ob_end_clean();
// ========================================================================== //
// HTML BODY
// ========================================================================== //
ob_start();
?>
<?= $shell['donate'] ?>
<p>
By default, select elements in Internet Explorer and Opera show the selected option's color and background color, while Firefox and WebKit browsers do not. <a href="http://benalman.com/projects/jquery-misc-plugins/#selectcolorize">jQuery selectColorize</a> normalizes this behavior cross-browser for basic select box color styling, without having to resort to more "fancy" select box replacements.
</p>
<p>
<em>Note that inline option color/background styles are necessary in Firefox due to an annoying getComputedStyle bug. Also, due to rendering issues in Firefox and Opera, it's best to set a background color on the select element if any of its options have background colors, otherwise it may have initial rendering issues.</em>
</p>
<p>
<a href="#" class="enable example">Enable selectColorize</a>, <a href="#" class="destroy example">Destroy selectColorize</a>
</p>
<select class="first">
<option>------</option>
<option style="color:#f00;background:#fcc;" selected="selected">Sample red option, fg+bg</option>
<option style="color:#0a0;background:#cfc;">Sample green option, fg+bg</option>
<option style="color:#00f;background:#ccf;">Sample blue option, fg+bg</option>
<option style="color:#f00;">Sample red option, fg</option>
<option style="color:#0a0;">Sample green option, fg</option>
<option style="color:#00f;">Sample blue option, fg</option>
<option style="background:#fcc;">Sample red option, bg</option>
<option style="background:#cfc;">Sample green option, bg</option>
<option style="background:#ccf;">Sample blue option, bg</option>
</select>
(select fg color set via CSS, options have fg+bg colors)
<br>
<select class="second">
<option>------</option>
<option style="color:#f00;background:#fcc;">Sample red option, fg+bg</option>
<option style="color:#0a0;background:#cfc;" selected="selected">Sample green option, fg+bg</option>
<option style="color:#00f;background:#ccf;">Sample blue option, fg+bg</option>
<option style="color:#f00;">Sample red option, fg</option>
<option style="color:#0a0;">Sample green option, fg</option>
<option style="color:#00f;">Sample blue option, fg</option>
<option style="background:#fcc;">Sample red option, bg</option>
<option style="background:#cfc;">Sample green option, bg</option>
<option style="background:#ccf;">Sample blue option, bg</option>
</select>
(select bg color set via CSS, options have fg+bg colors)
<br>
<select class="third">
<option>------</option>
<option style="color:#f00;background:#fcc;">Sample red option, fg+bg</option>
<option style="color:#0a0;background:#cfc;">Sample green option, fg+bg</option>
<option style="color:#00f;background:#ccf;" selected="selected">Sample blue option, fg+bg</option>
<option style="color:#f00;">Sample red option, fg</option>
<option style="color:#0a0;">Sample green option, fg</option>
<option style="color:#00f;">Sample blue option, fg</option>
<option style="background:#fcc;">Sample red option, bg</option>
<option style="background:#cfc;">Sample green option, bg</option>
<option style="background:#ccf;">Sample blue option, bg</option>
</select>
(select fg and bg colors set via CSS, options have fg+bg colors)
<br>
<select class="fourth">
<option>------</option>
<option style="color:#f00;">Sample red option, fg</option>
<option style="color:#0a0;" selected="selected">Sample green option, fg</option>
<option style="color:#00f;">Sample blue option, fg</option>
</select>
(select fg color set via CSS, options only have fg colors)
<h3>The code</h3>
<div class="clear"></div>
<pre class="brush:js">
<?= htmlspecialchars( $shell['script'] ); ?>
</pre>
<?
$shell['html_body'] = ob_get_contents();
ob_end_clean();
// ========================================================================== //
// DRAW SHELL
// ========================================================================== //
draw_shell();
?>