forked from evoluteur/structured-filter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
170 lines (136 loc) · 5.56 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<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 plugin metadata advanced structured filter query builder editor search form">
<link id="jquiCSS" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.12.0/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://code.jquery.com/ui/1.11.4/jquery-ui.min.js" type="text/javascript"></script>
<script src="js/structured-filter.min.js" type="text/javascript" type="text/javascript"></script>
<script src="js/model-demo1.js" type="text/javascript"></script>
</head>
<body>
<h2 id="github">
<a href="https://github.com/evoluteur/structured-filter">GitHub</a><br/>
<iframe src="https://ghbtns.com/github-btn.html?user=evoluteur&repo=structured-filter&type=star&count=true&size=small" frameborder="0" scrolling="0" width="100px" height="30px"></iframe>
</h2>
<h1>Structured-Filter</h1>
<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>
With it you can build structured search conditions like
Firstname starts with 'A' and Birthday after 1/1/1990 and State in (CA, NY, FL)... 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>
<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>
<div id="evol"></div>
<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/>
<a href="https://github.com/evoluteur/structured-filter/archive/master.zip">Download</a> and <a href="https://github.com/evoluteur/structured-filter#readme">documentation</a>
are available at
<a href="https://github.com/evoluteur/structured-filter" target="git">GitHub</a>.</p>
<p>Structured-Filter is released under the <a href="http://github.com/evoluteur/structured-filter/raw/master/LICENSE.md">MIT license</a>.</p>
<p>© 2017 <a href="https://evoluteur.github.io/">Olivier Giulieri</a></p>
<br/><br/>
<script>
function addRandomCondition(){
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);
}
$(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.12.0/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(addRandomCondition);
$('#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);
});
addRandomCondition();
// ***** Prevent links from scrolling *****
$('.demo-links > a[href="#"]').attr('href', 'javascript:void(0)');
});
</script>
</body>
</html>