Skip to content

Commit 6172080

Browse files
committed
if Bootstrap Selectpicker is available, use it for filter & operator selects
1 parent 0c47d65 commit 6172080

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

examples/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html>
33
<head>
44
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
56

67
<link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.min.css">
78
<link rel="stylesheet" href="../src/query-builder.css">

src/query-builder.js

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,15 @@
574574
container.append($rule);
575575
$rule.find('.rule-filter-container').append($filterSelect);
576576

577+
if ($.fn.selectpicker) {
578+
$filterSelect.selectpicker({
579+
container: 'body',
580+
style: 'btn-inverse btn-xs',
581+
width: 'auto',
582+
showIcon: false
583+
});
584+
}
585+
577586
if (this.settings.onAfterAddRule) {
578587
this.settings.onAfterAddRule.call(this, $rule);
579588
}
@@ -597,6 +606,15 @@
597606
$operatorSelect = $(this.getRuleOperatorSelect($rule.attr('id'), operators));
598607

599608
$operatorContainer.html($operatorSelect);
609+
610+
if ($.fn.selectpicker) {
611+
$operatorSelect.selectpicker({
612+
container: 'body',
613+
style: 'btn-inverse btn-xs',
614+
width: 'auto',
615+
showIcon: false
616+
});
617+
}
600618
};
601619

602620
/**
@@ -1077,9 +1095,15 @@
10771095
<dl id="'+ group_id +'" class="rules-group-container" '+ (this.settings.sortable ? 'draggable="true"' : '') +'> \
10781096
<dt class="rules-group-header"> \
10791097
<div class="btn-group pull-right"> \
1080-
<button type="button" class="btn btn-xs btn-success" data-add="rule"><i class="glyphicon glyphicon-plus"></i> '+ this.lang.add_rule +'</button> \
1081-
'+ (this.settings.allow_groups ? '<button type="button" class="btn btn-xs btn-success" data-add="group"><i class="glyphicon glyphicon-plus-sign"></i> '+ this.lang.add_group +'</button>' : '') +' \
1082-
'+ (!main ? '<button type="button" class="btn btn-xs btn-danger" data-delete="group"><i class="glyphicon glyphicon-remove"></i> '+ this.lang.delete_group +'</button>' : '') +' \
1098+
<button type="button" class="btn btn-xs btn-success" data-add="rule"> \
1099+
<i class="glyphicon glyphicon-plus"></i> '+ this.lang.add_rule +' \
1100+
</button> \
1101+
'+ (this.settings.allow_groups ? '<button type="button" class="btn btn-xs btn-success" data-add="group"> \
1102+
<i class="glyphicon glyphicon-plus-sign"></i> '+ this.lang.add_group +' \
1103+
</button>' : '') +' \
1104+
'+ (!main ? '<button type="button" class="btn btn-xs btn-danger" data-delete="group"> \
1105+
<i class="glyphicon glyphicon-remove"></i> '+ this.lang.delete_group +' \
1106+
</button>' : '') +' \
10831107
</div> \
10841108
<div class="btn-group"> \
10851109
'+ this.getGroupConditions(group_id) +' \
@@ -1107,7 +1131,10 @@
11071131
active = cond == this.settings.default_condition,
11081132
label = this.lang['condition_'+ cond.toLowerCase()] || cond;
11091133

1110-
h+= '<label class="btn btn-xs btn-primary '+ (active?'active':'') +'"><input type="radio" name="'+ group_id +'_cond" value="'+ cond +'" '+ (active?'checked':'') +'> '+ label +'</label>';
1134+
h+= '\
1135+
<label class="btn btn-xs btn-primary '+ (active?'active':'') +'"> \
1136+
<input type="radio" name="'+ group_id +'_cond" value="'+ cond +'" '+ (active?'checked':'') +'> '+ label +' \
1137+
</label>';
11111138
}
11121139

11131140
return h;
@@ -1123,7 +1150,9 @@
11231150
<li id="'+ rule_id +'" class="rule-container" '+ (this.settings.sortable ? 'draggable="true"' : '') +'> \
11241151
<div class="rule-header"> \
11251152
<div class="btn-group pull-right"> \
1126-
<button type="button" class="btn btn-xs btn-danger" data-delete="rule"><i class="glyphicon glyphicon-remove"></i> '+ this.lang.delete_rule +'</button> \
1153+
<button type="button" class="btn btn-xs btn-danger" data-delete="rule"> \
1154+
<i class="glyphicon glyphicon-remove"></i> '+ this.lang.delete_rule +' \
1155+
</button> \
11271156
</div> \
11281157
</div> \
11291158
'+ (this.settings.sortable ? '<div class="drag-handle"><i class="glyphicon glyphicon-sort"></i></div>' : '') +' \

0 commit comments

Comments
 (0)