[Rt-commit] rt branch 5.0/bootstrap-select-live-search created. rt-5.0.3-214-gf821e8bdfc
BPS Git Server
git at git.bestpractical.com
Fri Dec 16 21:49:16 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/bootstrap-select-live-search has been created
at f821e8bdfcb68de34c20a44af8b7a9a6a2822869 (commit)
- Log -----------------------------------------------------------------
commit f821e8bdfcb68de34c20a44af8b7a9a6a2822869
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Dec 17 05:14:35 2022 +0800
Automatically enable live search for selects that have 10 or more options
If the select already has data-live-search specified, leave it alone.
diff --git a/share/static/js/assets.js b/share/static/js/assets.js
index a70a4dcd62..6eba4c09d5 100644
--- a/share/static/js/assets.js
+++ b/share/static/js/assets.js
@@ -8,7 +8,7 @@ jQuery(function() {
// We need to refresh the select picker plugin on AJAX calls
// since the plugin only runs on page load.
- jQuery('.selectpicker').selectpicker('refresh');
+ refreshSelectpicker();
};
jQuery(".ticket-assets form").submit(function(){
diff --git a/share/static/js/cascaded.js b/share/static/js/cascaded.js
index b73b99f2fb..d9596cbd5d 100644
--- a/share/static/js/cascaded.js
+++ b/share/static/js/cascaded.js
@@ -80,6 +80,6 @@ function filter_cascade_select (select, complete_select, vals) {
}
if ( jQuery(select).closest('div.bootstrap-select').length ) {
- jQuery(select).selectpicker('refresh');
+ refreshSelectpicker(jQuery(select));
}
}
diff --git a/share/static/js/lifecycleui-editor.js b/share/static/js/lifecycleui-editor.js
index e31757a458..c61412dfce 100644
--- a/share/static/js/lifecycleui-editor.js
+++ b/share/static/js/lifecycleui-editor.js
@@ -360,7 +360,7 @@ jQuery(function () {
jQuery(item).val(element[item.name]);
}
self.editing_node = element;
- jQuery('.selectpicker').selectpicker('refresh');
+ refreshSelectpicker();
}
else {
var name = document.getElementsByName('name')[0].value;
diff --git a/share/static/js/util.js b/share/static/js/util.js
index a965479375..f844ebaf82 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -44,7 +44,7 @@ var showModal = function(html) {
// We need to refresh the select picker plugin on AJAX calls
// since the plugin only runs on page load.
- jQuery('.selectpicker').selectpicker('refresh');
+ refreshSelectpicker();
RT.Autocomplete.bind(modal);
};
@@ -1315,6 +1315,8 @@ jQuery(function () {
});
});
});
+
+ updateSelectpickerLiveSearch();
});
// focus jquery object in window, only moving the screen when necessary
@@ -1406,3 +1408,16 @@ function toggleTransactionDetails () {
return false;
}
+
+function updateSelectpickerLiveSearch (element) {
+ element ||= jQuery('.selectpicker');
+ element.filter(':not([data-live-search])').each(function() {
+ jQuery(this).attr('data-live-search', jQuery(this).find('option').length >= 10 ? true : false );
+ });
+}
+
+function refreshSelectpicker (element) {
+ element ||= jQuery('.selectpicker');
+ updateSelectpickerLiveSearch(element);
+ element.selectpicker('refresh');
+}
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list