core: getJSFiles -> getJSPlugins
- 각각 js를 불러오기보다.. 초기화 함수를 직접 호출 - lazy loading은 어차피 나중에 새로 만들거니까 안 함.
This commit is contained in:
+6
-1
@@ -4,6 +4,11 @@ import { convertFormData } from './util/convertFormData';
|
||||
import { InvalidResponse } from './defs';
|
||||
import { unwrap_any } from './util/unwrap_any';
|
||||
import { setAxiosXMLHttpRequest } from './util/setAxiosXMLHttpRequest';
|
||||
import { exportWindow } from './util/exportWindow';
|
||||
import Popper from 'popper.js';
|
||||
exportWindow(Popper, 'Popper');
|
||||
import 'bootstrap';
|
||||
import 'select2/dist/js/select2.full.js'
|
||||
|
||||
type GeneralSelectorItem = {
|
||||
id: string|number,
|
||||
@@ -54,7 +59,7 @@ async function changePermission(isAmbassador: boolean, rawGeneralList: GeneralSe
|
||||
|
||||
$(function () {
|
||||
setAxiosXMLHttpRequest();
|
||||
|
||||
|
||||
$('#selectAmbassador').select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: "",
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import { reloadWorldMap } from "./map";
|
||||
import { unwrap_any } from "./util/unwrap_any";
|
||||
/*import $ from 'jquery';
|
||||
import 'select2';*///TODO: processing
|
||||
|
||||
|
||||
export function loadPlugin(): void {
|
||||
export function defaultSelectCityByMap(): void {
|
||||
const $target = $("#destCityID");
|
||||
console.log('target', $target);
|
||||
console.log('city', $target);
|
||||
void reloadWorldMap({
|
||||
isDetailMap: false,
|
||||
clickableAll: true,
|
||||
@@ -14,15 +11,12 @@ export function loadPlugin(): void {
|
||||
useCachedMap: true,
|
||||
selectCallback: function (city) {
|
||||
const currVal = unwrap_any<string>($target.val());
|
||||
$target.val(city.id).trigger("change");
|
||||
$target.val(city.id);
|
||||
$target.trigger("change");
|
||||
if ($target.val() === null) {
|
||||
$target.val(currVal).trigger("change");
|
||||
$target.val(currVal).trigger("change").blur();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(function () {
|
||||
loadPlugin();
|
||||
});
|
||||
@@ -1,10 +1,9 @@
|
||||
import { reloadWorldMap } from "./map";
|
||||
import { unwrap_any } from "./util/unwrap_any";
|
||||
/*import $ from 'jquery';
|
||||
import 'select2';*///TODO: processing
|
||||
|
||||
export function loadPlugin(): void{
|
||||
export function defaultSelectNationByMap(): void{
|
||||
const $target = $("#destNationID");
|
||||
console.log('nation', $target);
|
||||
void reloadWorldMap({
|
||||
isDetailMap: false,
|
||||
clickableAll: true,
|
||||
@@ -22,8 +21,4 @@ export function loadPlugin(): void{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
loadPlugin();
|
||||
});
|
||||
}
|
||||
+23
-3
@@ -1,15 +1,23 @@
|
||||
//import $ from 'jquery';
|
||||
//import 'bootstrap';
|
||||
import $ from 'jquery';
|
||||
exportWindow($, '$');
|
||||
import { exportWindow } from './util/exportWindow';
|
||||
import axios from 'axios';
|
||||
//import 'select2';
|
||||
import Popper from 'popper.js';
|
||||
exportWindow(Popper, 'Popper');
|
||||
import 'bootstrap';
|
||||
import 'select2/dist/js/select2.full.js'
|
||||
import { setAxiosXMLHttpRequest } from './util/setAxiosXMLHttpRequest';
|
||||
import { convertFormData } from './util/convertFormData';
|
||||
import { InvalidResponse } from './defs';
|
||||
import { unwrap_any } from './util/unwrap_any';
|
||||
import { DataFormat, IdTextPair, OptionData } from 'select2';
|
||||
import { unwrap } from "./util/unwrap";
|
||||
import { defaultSelectCityByMap } from './defaultSelectCityByMap';
|
||||
import { defaultSelectNationByMap } from './defaultSelectNationByMap';
|
||||
|
||||
declare const isChiefTurn: boolean;
|
||||
declare const jsPlugins: string[];
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
submitAction: () => Promise<void>;
|
||||
@@ -275,4 +283,16 @@ $(function ($) {
|
||||
}
|
||||
});
|
||||
|
||||
const pluginMap:Record<string, ()=>void> = {
|
||||
'defaultSelectCityByMap': defaultSelectCityByMap,
|
||||
'defaultSelectNationByMap': defaultSelectNationByMap,
|
||||
};
|
||||
for (const jsPlugin of jsPlugins) {
|
||||
if (jsPlugin in pluginMap) {
|
||||
pluginMap[jsPlugin]()
|
||||
}
|
||||
else{
|
||||
console.error(`'${jsPlugin}' is not supported`);
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user