Skip to content

Commit 8eae883

Browse files
committed
use bootstrap-select replace native select input
1 parent ecaae36 commit 8eae883

File tree

6 files changed

+25
-1
lines changed

6 files changed

+25
-1
lines changed

pywebio/html/css/bootstrap-select.min.css

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pywebio/html/js/bootstrap-select.min.js

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pywebio/platform/tpl/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<link rel="stylesheet" href="{{ base_url }}css/codemirror.min.css">
1212
<link rel="stylesheet" href="{{ base_url }}css/toastify.min.css">
1313
<link rel="stylesheet" href="{{ base_url }}css/bs-theme/{{ theme }}.min.css">
14+
<link rel="stylesheet" href="{{ base_url }}css/bootstrap-select.min.css">
1415
<link rel="stylesheet" href="{{ base_url }}css/app.css">
1516
{% for css in css_file %}
1617
{% if css %}<link rel="stylesheet" href="{{ css }}">{% end %}
@@ -56,6 +57,7 @@
5657
<script src="{{ base_url }}js/toastify.min.js"></script> <!-- toast -->
5758
<script src="{{ base_url }}js/bs-custom-file-input.min.js"></script> <!-- bootstrap custom file input-->
5859
<script src="{{ base_url }}js/purify.min.js"></script> <!-- XSS sanitizer -->
60+
<script src="{{ base_url }}js/bootstrap-select.min.js"></script>
5961
<script>
6062
if (window.navigator.userAgent.indexOf('MSIE ') !== -1 || window.navigator.userAgent.indexOf('Trident/') !== -1)
6163
$('#output-container').html('<div class="alert alert-danger" role="alert"> Sorry, this website does not support IE browser. ☹ </div>');

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"html/css/toastify.min.css",
5151
"html/css/app.css",
5252
"html/css/codemirror.min.css",
53+
"html/css/bootstrap-select.min.css",
5354
"html/css/bs-theme/default.min.css",
5455
"html/css/bs-theme/minty.min.css",
5556
"html/css/bs-theme/yeti.min.css",
@@ -68,6 +69,7 @@
6869
"html/js/toastify.min.js",
6970
"html/js/require.min.js",
7071
"html/js/codemirror.min.js",
72+
"html/js/bootstrap-select.min.js",
7173
"html/image/favicon_open_16.png",
7274
"html/image/favicon_closed_32.png",
7375
"platform/tpl/index.html"

test/template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ def test_input(browser: Chrome, enable_percy=False):
709709

710710
browser.find_element_by_name('password').clear()
711711
browser.find_element_by_name('password').send_keys("123")
712-
browser.execute_script("$('form button').eq(1).click()")
712+
browser.execute_script("$('form button[type=\"submit\"]').eq(1).click()")
713713
time.sleep(1)
714714
browser.execute_script('$("html, body").scrollTop( $(document).height()+100);')
715715
time.sleep(1)

webiojs/src/models/input/select.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ const select_input_tpl = `
1717
<small id="{{id_name}}_help" class="form-text text-muted">{{help_text}}</small>
1818
</div>`;
1919

20+
// @ts-ignore
21+
$.fn.selectpicker.Constructor.BootstrapVersion = '4';
22+
2023
export class Select extends InputItem {
2124
static accept_input_types: string[] = ["select"];
2225

@@ -44,6 +47,8 @@ export class Select extends InputItem {
4447
this.on_input_event("change", this);
4548
});
4649
}
50+
// @ts-ignore
51+
this.element.find('select').selectpicker();
4752
return this.element;
4853
}
4954

0 commit comments

Comments
 (0)