code refactor

This commit is contained in:
MaysWind
2023-08-06 23:43:55 +08:00
parent 9b2fba9600
commit c6d38bb3d7
8 changed files with 40 additions and 150 deletions
@@ -264,6 +264,7 @@ import {
getShiftedDateRangeAndDateType,
getDateRangeByDateType
} from '@/lib/datetime.js';
import { scrollToSelectedItem } from '@/lib/ui.mobile.js';
export default {
props: [
@@ -523,25 +524,7 @@ export default {
this.f7router.navigate('/statistic/settings');
},
scrollPopoverToSelectedItem(event) {
if (!event || !event.$el || !event.$el.length) {
return;
}
const container = event.$el.find('.popover-inner');
const selectedItem = event.$el.find('li.list-item-selected');
if (!container.length || !selectedItem.length) {
return;
}
let targetPos = selectedItem.offset().top - container.offset().top - parseInt(container.css('padding-top'), 10)
- (container.outerHeight() - selectedItem.outerHeight()) / 2;
if (targetPos <= 0) {
return;
}
container.scrollTop(targetPos);
scrollToSelectedItem(event.$el, '.popover-inner', 'li.list-item-selected');
},
getDisplayAmount(amount, currency, textLimit) {
amount = this.getDisplayCurrency(amount, currency);
+2 -20
View File
@@ -435,7 +435,7 @@ import {
getDateRangeByDateType
} from '@/lib/datetime.js';
import { categoryTypeToTransactionType, transactionTypeToCategoryType } from '@/lib/category.js';
import { onSwipeoutDeleted } from '@/lib/ui.mobile.js';
import { onSwipeoutDeleted, scrollToSelectedItem } from '@/lib/ui.mobile.js';
export default {
props: [
@@ -826,25 +826,7 @@ export default {
});
},
scrollPopoverToSelectedItem(event) {
if (!event || !event.$el || !event.$el.length) {
return;
}
const container = event.$el.find('.popover-inner');
const selectedItem = event.$el.find('li.list-item-selected');
if (!container.length || !selectedItem.length) {
return;
}
let targetPos = selectedItem.offset().top - container.offset().top - parseInt(container.css('padding-top'), 10)
- (container.outerHeight() - selectedItem.outerHeight()) / 2;
if (targetPos <= 0) {
return;
}
container.scrollTop(targetPos);
scrollToSelectedItem(event.$el, '.popover-inner', 'li.list-item-selected');
},
getDisplayYearMonth(transactionMonthList) {
return this.$locale.formatTimeToLongYearMonth(this.userStore, transactionMonthList.yearMonth);