forked from evoluteur/structured-filter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
156 lines (129 loc) · 5.49 KB
/
index.html
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
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>structured-filter Demo</title>
<meta name="description" content="Structured filter widget for jQuery UI.">
<meta name="keywords" content="jQuery UI widget metadata advanced structured filter search form">
<link id="jquiCSS" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/ui-lightness/jquery-ui.css" type="text/css" media="all">
<link rel="stylesheet" href="css/demo.css" type="text/css" media="all">
<link rel="stylesheet" href="css/structured-filter.css" type="text/css" media="all">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js" type="text/javascript"></script>
<script src="js/structured-filter.js" type="text/javascript"></script>
<script src="js/model-demo1.js" type="text/javascript"></script>
</head>
<body>
<h1>Structured Filter Demo</h1>
<h2 id="github">
<a href="https://github.com/evoluteur/structured-filter">GitHub</a>
</h2>
<p>structured-filter (currently v1.0.11) is a Web UI for building structured search queries. It is a full jQuery UI widget, supporting various configurations and themes.
</p>
<p class="demo-links">API Tests:
<a href="#" id="addCondition">Add Condition</a> -
<a href="#" id="delFilter">Remove First Condition</a> -
<a href="#" id="length">Number of Conditions</a> -
<a href="#" id="clear">Clear</a>
</p>
<div id="evol"></div>
<p class="demo-links">Themes:
<a href="#" class="css sel">ui-lightness</a> -
<a href="#" class="css">ui-darkness</a> -
<a href="#" class="css">redmond</a> -
<a href="#" class="css">start</a> -
<a href="#" class="css">le-frog</a>
</p>
<p class="demo-links" id="linksValues">Value Formats:
<a href="#" data-id="json" class="sel">JSON</a> -
<a href="#" data-id="text">Text</a> -
<a href="#" data-id="url">URL</a>
</p>
<p>
<textarea id="myFilter" class="demoValue" rows="16"></textarea>
</p>
<p><br/>
The <a href="https://github.com/evoluteur/structured-filter#readme">documentation</a> and source code are available at <a href="https://github.com/evoluteur/structured-filter" target="git">GitHub</a>
under <a href="http://github.com/evoluteur/structured-filter/raw/master/LICENSE.md">MIT license</a>.</p>
<p>There is a fork of the code using <a href="http://getbootstrap.com">Bootstrap</a> and <a href="http://backbonejs.org">Backbone.js</a> as part of <a href="http://evoluteur.github.com/evolutility/index.html">Evolutility</a>.
</p>
<br/><br/>
<div class="footer">© 2016 Olivier Giulieri</div>
<script>
$(document).ready(function(){
var v,
valueFormat = 'json';
function updateValue(format){
switch(format){
case 'json':
v = JSON.stringify($('#evol').structFilter("val"), null, 2);
break;
case 'text':
v = $('#evol').structFilter("valText");
break;
case 'url':
v = $('#evol').structFilter("valUrl");
}
$('#myFilter').val(v);
}
// ***** setup theme links *****
$('.css').click(function(){
$('#jquiCSS').attr('href','http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/'+this.innerHTML+'/jquery-ui.css');
$('.css').removeClass('sel');
$(this).addClass('sel');
});
// ***** setup structured filter widget *****
$('#evol').structFilter({fields:contacts })
.on('submit.search change.search', function(evt){
updateValue(valueFormat);
});
// ***** setup values *****
$('#linksValues > a').on('click',function(){
var $this=$(this),
id=$this.data('id');
$this.addClass('sel')
.siblings().removeClass('sel');
valueFormat=id;
updateValue(id);
});
// ***** setup api tests links *****
$('#addCondition').click(function(){
var randomChar = String.fromCharCode(Math.floor(Math.random()*25)+65),
filterDef = {
field:{
label: 'Lastname',
value: 'Lastname'
},
operator:{
label: 'contains',
value: 'ct'
},
value:{
label: '"' + randomChar + '"',
value: randomChar
}
};
$('#evol').structFilter("addCondition", filterDef);
});
$('#delFilter').click(function(){
$('#evol').structFilter("removeCondition", 0);
});
$('#clear').click(function(){
$('#evol').structFilter("clear");
});
$('#length').click(function(){
var v = $('#evol').structFilter("length"),
msg;
if(v===0){
msg = 'No conditions specified.';
}else if(v===1){
msg = '1 condition in filter.';
}else{
msg = v + ' conditions in filter.';
}
alert(msg);
});
// ***** Prevent links from scrolling *****
$('.demo-links > a[href="#"]').attr('href', 'javascript:void(0)');
});
</script>
</body>
</html>