|
@@ -1,6 +1,8 @@
|
|
|
// JavaScript source code
|
|
// JavaScript source code
|
|
|
(function () {
|
|
(function () {
|
|
|
angular.module('bsTable', []).directive('bsTableControl', function () {
|
|
angular.module('bsTable', []).directive('bsTableControl', function () {
|
|
|
|
|
+ var SEARCH_SELECTOR = '.search input';
|
|
|
|
|
+ var CONTAINER_SELECTOR = '.bootstrap-table';
|
|
|
return {
|
|
return {
|
|
|
restrict: 'EA',
|
|
restrict: 'EA',
|
|
|
scope: {options: '='},
|
|
scope: {options: '='},
|
|
@@ -25,6 +27,7 @@
|
|
|
$s.$watch('options', function (newOptions) {
|
|
$s.$watch('options', function (newOptions) {
|
|
|
if (!newOptions) return;
|
|
if (!newOptions) return;
|
|
|
|
|
|
|
|
|
|
+ var searchHasFocus = $el.closest(CONTAINER_SELECTOR).find(SEARCH_SELECTOR).is(':focus');
|
|
|
if (options) {
|
|
if (options) {
|
|
|
scroll = $el.bootstrapTable('getScrollPosition');
|
|
scroll = $el.bootstrapTable('getScrollPosition');
|
|
|
$el.bootstrapTable('destroy');
|
|
$el.bootstrapTable('destroy');
|
|
@@ -36,10 +39,11 @@
|
|
|
options = newOptions;
|
|
options = newOptions;
|
|
|
$el.bootstrapTable(options);
|
|
$el.bootstrapTable(options);
|
|
|
if (scroll) $el.bootstrapTable('scrollTo', scroll);
|
|
if (scroll) $el.bootstrapTable('scrollTo', scroll);
|
|
|
|
|
+ if (searchHasFocus) $el.closest(CONTAINER_SELECTOR).find(SEARCH_SELECTOR).focus(); // $el gets detached so have to recompute whole chain
|
|
|
}, true);
|
|
}, true);
|
|
|
$(window).resize(function () {
|
|
$(window).resize(function () {
|
|
|
if (options) $el.bootstrapTable('resetView');
|
|
if (options) $el.bootstrapTable('resetView');
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
})
|
|
})
|