-
Notifications
You must be signed in to change notification settings - Fork 1
/
codes.php
384 lines (365 loc) · 18 KB
/
codes.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
<?php
require_once dirname( __FILE__ ) . '/config.php';
// First require the iconindexed.php to see if a backup is present
if ( file_exists( ABSPATH . 'iconindexed.php' ) ) {
require_once ABSPATH . 'iconindexed.php';
}
// Now get the functions
require_once ABSPATH . 'functions.php';
get_header();
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#example_form').bootstrapValidator({
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
submitHandler: function(validator, form, submitButton) {
alert('Validated');
}
}).on('change', 'select, input', function() {
var val = $(this).val(),
parent = $(this).closest('.form-group'),
valueContainer = parent.find('.track-change .text-primary'),
iconContainer = parent.find('.track-change .text-success');
valueContainer.html(val);
if ( val == '' ) {
iconContainer.html('');
} else if ( iconContainer.hasClass('by_decimal') ) {
iconContainer.html('<i <?php echo HTML_ATTR ?>="&#x' + parseInt( val ).toString(16) + ';"></i>' );
} else if ( iconContainer.hasClass('by_hex') ) {
iconContainer.html('<i <?php echo HTML_ATTR ?>="&#x' + val + ';"></i>' );
} else if ( iconContainer.hasClass('by_unicode') ) {
iconContainer.html('<i <?php echo HTML_ATTR ?>="' + val + '"></i>' );
} else {
iconContainer.html('<i class="' + val + '"></i>' );
}
}).find('select, input').trigger('change');
});
</script>
<div class="container">
<?php if ( ! isset( $icomoon_icons ) ) : ?>
<div class="alert alert-warning">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>No Indexed Icons Found</strong> It seems you haven't run an indexing on the icons yet. Please click on the Auto Generate link to get started.
</div>
<?php else : ?>
<h1><span class="glyphicon glyphicon-check"></span> Source Codes</h1>
<hr />
<h2><span class="glyphicon glyphicon-check"></span> PHP</h2>
<hr />
<pre class="brush: php">
<?php echo htmlentities( file_get_contents( ABSPATH . 'iconindexed.php' ) ); ?>
</pre>
<hr />
<h2><span class="glyphicon glyphicon-check"></span> JSON</h2>
<hr />
<pre class="brush: js">
<?php ob_start(); ?>
var source = <?php echo imii_generate_fip_source_json( $icomoon_icons, 'key' ); ?>;
var searchSource = <?php echo imii_generate_fip_search_json( $icomoon_icons ); ?>;
var sourceClass = <?php echo imii_generate_fip_source_json( $icomoon_icons, 'class' ); ?>;
<?php $source_json = ob_get_clean(); echo htmlentities( $source_json ); ?>
</pre>
<h1><span class="glyphicon glyphicon-check"></span> Examples and Codes</h1>
<hr />
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Setup Instruction</h3>
</div>
<div class="panel-body">
<p>This Application comes with a few PHP functions which can generate:</p>
<ul>
<li>HTML <code>SELECT</code> elements (it's options).</li>
<li>JSON for direct use with <a href="https://github.com/micc83/fontIconPicker">fontIconPicker</a>.</li>
</ul>
<p>Shown below are some real world examples and it's codes. The form is validated by the <a href="http://bootstrapvalidator.com/">BootstrapValidator</a>.</p>
<p>Before you try out any of the demo on your server, make sure to include the generated file <code>iconindexed.php</code> and the <code>functions.php</code>.</p>
<pre class="brush: php">
<?php
// First require the iconindexed.php to see if a backup is present
if ( file_exists( ABSPATH . 'iconindexed.php' ) ) {
require_once ABSPATH . 'iconindexed.php';
}
// Now get the functions
require_once ABSPATH . 'functions.php';
// Check for errors like this
if ( ! isset( $icomoon_icons ) ) {
// Error has occured
}
</pre>
<p>Now include all <code>script</code> and <code>stylesheet</code> from fontIconPicker into the head of your html file.</p>
</div>
</div>
<form action="" method="GET" role="form" class="form-horizontal" id="example_form">
<hr />
<h2><span class="glyphicon glyphicon-edit"></span> Using on generic <code>SELECT</code> HTML</h2>
<hr />
<!-- by class -->
<div class="form-group">
<label for="" class="col-md-4">Populated by <code>CLASS</code> as <code>OPTION</code> value:</label>
<div class="col-md-4">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
<select data-bv-notempty="true" data-bv-notempty-message="You must pick a font" name="select_1" id="select_1" class="form-control by_class">
<option value="" selected="selected">--please select--</option>
<?php echo imii_generate_select_options( $icomoon_icons, 'class' ); ?>
</select>
</div>
</div>
<div class="col-md-4">
<p class="form-control-static track-change">Selected Value: <span class="text-primary"></span> | Selected Icon: <span class="text-success by_class"></span></p>
</div>
</div>
<div class="form-group">
<hr />
<h3><span class="glyphicon glyphicon-fire"></span> Source Code <code>PHP</code></h3>
<hr />
<pre class="brush: php">
<div class="form-group">
<label for="" class="col-md-4">Populated by <code>CLASS</code> as <code>OPTION</code> value:</label>
<div class="col-md-4">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
<select data-bv-notempty="true" data-bv-notempty-message="You must pick a font" name="select_1" id="select_1" class="form-control by_class">
<option value="" selected="selected">--please select--</option>
<?php echo imii_generate_select_options( $icomoon_icons, 'class' ); ?>
</select>
</div>
</div>
<div class="col-md-4">
<p class="form-control-static track-change">Selected Value: <span class="text-primary"></span> | Selected Icon: <span class="text-success by_class"></span></p>
</div>
</div>
</pre>
</div>
<!-- by decimal key -->
<div class="form-group">
<label for="" class="col-md-4">Populated by <code>Decimal Key</code> as <code>OPTION</code> value:</label>
<div class="col-md-4">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
<select data-bv-notempty="true" data-bv-notempty-message="You must pick a font" name="select_2" id="select_2" class="form-control by_class">
<option value="" selected="selected">--please select--</option>
<?php echo imii_generate_select_options( $icomoon_icons, 'key' ); ?>
</select>
</div>
</div>
<div class="col-md-4">
<p class="form-control-static track-change">Selected Value: <span class="text-primary"></span> | Selected Icon: <span class="text-success by_decimal"></span></p>
</div>
</div>
<div class="form-group">
<hr />
<h3><span class="glyphicon glyphicon-fire"></span> Source Code <code>PHP</code></h3>
<hr />
<pre class="brush: php">
<div class="form-group">
<label for="" class="col-md-4">Populated by <code>Decimal Key</code> as <code>OPTION</code> value:</label>
<div class="col-md-4">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
<select data-bv-notempty="true" data-bv-notempty-message="You must pick a font" name="select_2" id="select_2" class="form-control by_class">
<option value="" selected="selected">--please select--</option>
<?php echo imii_generate_select_options( $icomoon_icons, 'key' ); ?>
</select>
</div>
</div>
<div class="col-md-4">
<p class="form-control-static track-change">Selected Value: <span class="text-primary"></span> | Selected Icon: <span class="text-success by_decimal"></span></p>
</div>
</div>
</pre>
</div>
<!-- by Unicode -->
<div class="form-group">
<label for="" class="col-md-4">Populated by <code>Unicode</code> as <code>OPTION</code> value:</label>
<div class="col-md-4">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
<select data-bv-notempty="true" data-bv-notempty-message="You must pick a font" name="select_3" id="select_3" class="form-control by_class">
<option value="" selected="selected">--please select--</option>
<?php echo imii_generate_select_options( $icomoon_icons, 'unicode' ); ?>
</select>
</div>
</div>
<div class="col-md-4">
<p class="form-control-static track-change">Selected Value: <span class="text-primary"></span> | Selected Icon: <span class="text-success by_unicode"></span></p>
</div>
</div>
<div class="form-group">
<hr />
<h3><span class="glyphicon glyphicon-fire"></span> Source Code <code>PHP</code></h3>
<hr />
<pre class="brush: php">
<div class="form-group">
<label for="" class="col-md-4">Populated by <code>Unicode</code> as <code>OPTION</code> value:</label>
<div class="col-md-4">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
<select data-bv-notempty="true" data-bv-notempty-message="You must pick a font" name="select_3" id="select_3" class="form-control by_class">
<option value="" selected="selected">--please select--</option>
<?php echo imii_generate_select_options( $icomoon_icons, 'unicode' ); ?>
</select>
</div>
</div>
<div class="col-md-4">
<p class="form-control-static track-change">Selected Value: <span class="text-primary"></span> | Selected Icon: <span class="text-success by_unicode"></span></p>
</div>
</div>
</pre>
</div>
<!-- by Hexcode -->
<div class="form-group">
<label for="" class="col-md-4">Populated by <code>Hexadecimal String</code> as <code>OPTION</code> value:</label>
<div class="col-md-4">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
<select data-bv-notempty="true" data-bv-notempty-message="You must pick a font" name="select_4" id="select_4" class="form-control by_class">
<option value="" selected="selected">--please select--</option>
<?php echo imii_generate_select_options( $icomoon_icons, 'hex' ); ?>
</select>
</div>
</div>
<div class="col-md-4">
<p class="form-control-static track-change">Selected Value: <span class="text-primary"></span> | Selected Icon: <span class="text-success by_hex"></span></p>
</div>
</div>
<div class="form-group">
<hr />
<h3><span class="glyphicon glyphicon-fire"></span> Source Code <code>PHP</code></h3>
<hr />
<pre class="brush: php">
<div class="form-group">
<label for="" class="col-md-4">Populated by <code>Hexadecimal String</code> as <code>OPTION</code> value:</label>
<div class="col-md-4">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
<select data-bv-notempty="true" data-bv-notempty-message="You must pick a font" name="select_4" id="select_4" class="form-control by_class">
<option value="" selected="selected">--please select--</option>
<?php echo imii_generate_select_options( $icomoon_icons, 'hex' ); ?>
</select>
</div>
</div>
<div class="col-md-4">
<p class="form-control-static track-change">Selected Value: <span class="text-primary"></span> | Selected Icon: <span class="text-success by_hex"></span></p>
</div>
</div>
</pre>
</div>
<hr />
<h2><span class="glyphicon glyphicon-edit"></span> Using on fontIconPicker Elements</h2>
<hr />
<!-- fontIconPicker - by class -->
<script type="text/javascript">
jQuery(document).ready(function($) {
var source = <?php echo imii_generate_fip_source_json( $icomoon_icons, 'class' ); ?>;
var searchSource = <?php echo imii_generate_fip_search_json( $icomoon_icons ); ?>;
$('#fip_1').fontIconPicker({
source: source,
searchSource: searchSource,
theme: 'fip-bootstrap'
});
});
</script>
<div class="form-group">
<label for="" class="col-md-4">Populated by <code>classes</code> into <code>source</code> option and <code>Icon Name</code> into <code>searchSource</code> option:</label>
<div class="col-md-4">
<input data-bv-notempty="true" data-bv-notempty-message="You must pick a font" type="text" name="fip_1" id="fip_1" value="" />
</div>
<div class="col-md-4">
<p class="form-control-static track-change">Selected Value: <span class="text-primary"></span> | Selected Icon: <span class="text-success by_class"></span></p>
</div>
</div>
<div class="form-group">
<hr />
<h3><span class="glyphicon glyphicon-fire"></span> Source Code <code>PHP</code></h3>
<hr />
<pre class="brush: php">
<script type="text/javascript">
jQuery(document).ready(function($) {
var source = <?php echo imii_generate_fip_source_json( $icomoon_icons, 'class' ); ?>;
var searchSource = <?php echo imii_generate_fip_search_json( $icomoon_icons ); ?>;
$('#fip_1').fontIconPicker({
source: source,
searchSource: searchSource,
theme: 'fip-bootstrap'
});
});
</script>
<div class="form-group">
<label for="" class="col-md-4">Populated by <code>classes</code> into <code>source</code> option and <code>Icon Name</code> into <code>searchSource</code> option:</label>
<div class="col-md-4">
<input data-bv-notempty="true" data-bv-notempty-message="You must pick a font" type="text" name="fip_1" id="fip_1" value="" />
</div>
<div class="col-md-4">
<p class="form-control-static track-change">Selected Value: <span class="text-primary"></span> | Selected Icon: <span class="text-success by_class"></span></p>
</div>
</div>
</pre>
</div>
<!-- fontIconPicker - by decimal value (key) -->
<script type="text/javascript">
jQuery(document).ready(function($) {
var source = <?php echo imii_generate_fip_source_json( $icomoon_icons, 'key' ); ?>;
var searchSource = <?php echo imii_generate_fip_search_json( $icomoon_icons ); ?>;
$('#fip_2').fontIconPicker({
source: source,
searchSource: searchSource,
theme: 'fip-bootstrap',
useAttribute: true,
attributeName: 'data-icomoon'
});
});
</script>
<div class="form-group">
<label for="" class="col-md-4">Populated by <code>decimal keys</code> into <code>source</code> option and <code>Icon Name</code> into <code>searchSource</code> option:</label>
<div class="col-md-4">
<input data-bv-notempty="true" data-bv-notempty-message="You must pick a font" type="text" name="fip_2" id="fip_2" value="" />
</div>
<div class="col-md-4">
<p class="form-control-static track-change">Selected Value: <span class="text-primary"></span> | Selected Icon: <span class="text-success by_decimal"></span></p>
</div>
</div>
<div class="form-group">
<hr />
<h3><span class="glyphicon glyphicon-fire"></span> Source Code <code>PHP</code></h3>
<hr />
<pre class="brush: php">
<script type="text/javascript">
jQuery(document).ready(function($) {
var source = <?php echo imii_generate_fip_source_json( $icomoon_icons, 'key' ); ?>;
var searchSource = <?php echo imii_generate_fip_search_json( $icomoon_icons ); ?>;
$('#fip_2').fontIconPicker({
source: source,
searchSource: searchSource,
theme: 'fip-bootstrap',
useAttribute: true,
attributeName: 'data-icomoon'
});
});
</script>
<div class="form-group">
<label for="" class="col-md-4">Populated by <code>decimal keys</code> into <code>source</code> option and <code>Icon Name</code> into <code>searchSource</code> option:</label>
<div class="col-md-4">
<input data-bv-notempty="true" data-bv-notempty-message="You must pick a font" type="text" name="fip_2" id="fip_2" value="" />
</div>
<div class="col-md-4">
<p class="form-control-static track-change">Selected Value: <span class="text-primary"></span> | Selected Icon: <span class="text-success by_decimal"></span></p>
</div>
</div>
</pre>
</div>
<div class="form-group">
<div class="col-md-12">
<p class="pull-right">
<button type="submit" class="btn btn-primary btn-lg"><span class="glyphicon glyphicon-floppy-save"></span> Submit the form</button>
</p>
</div>
</div>
</form>
<?php endif; ?>
</div>
<?php get_footer(); ?>