forked from selectize/selectize.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_demos.js
More file actions
39 lines (33 loc) · 1.06 KB
/
_demos.js
File metadata and controls
39 lines (33 loc) · 1.06 KB
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
$(function() {
var $wrapper = $('#wrapper');
// display scripts on the page
$('script', $wrapper).each(function() {
var code = this.text;
if (code && code.length) {
var lines = code.split('\n');
var indent = null;
for (var i = 0; i < lines.length; i++) {
if (/^[ ]*$/.test(lines[i])) continue;
if (!indent) {
var lineindent = lines[i].match(/^([ ]+)/);
if (!lineindent) break;
indent = lineindent[1];
}
lines[i] = lines[i].replace(new RegExp('^' + indent), '');
}
var code = $.trim(lines.join('\n')).replace(/ /g, ' ');
var $pre = $('<pre>').addClass('js').text(code);
$pre.insertAfter(this);
}
});
// show current input values
$('select.selectized,input.selectized', $wrapper).each(function() {
var $container = $('<div>').addClass('value').html('Current Value: ');
var $value = $('<span>').appendTo($container);
var $input = $(this);
var update = function(e) { $value.text(JSON.stringify($input.val())); }
$(this).on('change', update);
update();
$container.insertAfter($input);
});
});