@@ -1057,119 +1057,151 @@ module.exports = {
10571057 valid ;
10581058
10591059 // Route the actions
1060- if ( action === 'save' ) {
1061- valid = validateAdminForm ( $self ) ;
1062- if ( valid ) {
1063- saveLevel ( $section , lockClass ) ;
1060+ switch ( action ) {
1061+ case 'save' :
1062+ valid = validateAdminForm ( $self ) ;
1063+ if ( valid ) {
1064+ saveLevel ( $section , lockClass ) ;
1065+ }
1066+ break ;
1067+ case 'save-no-validation' :
1068+ saveLevel ( ) ;
1069+ break ;
1070+ case 'add-new' :
1071+ addNewSection ( $self ) ;
1072+ break ;
1073+ case 'save-category' :
1074+ updateCategory ( $section ) ;
1075+ break ;
1076+ case 'create' :
1077+ valid = validateAdminForm ( $self ) ;
1078+ if ( valid ) {
1079+ createElement ( $section ) ;
1080+ }
1081+ break ;
1082+ case 'create-announcement' :
1083+ createAnnouncement ( $section ) ;
1084+ break ;
1085+ case 'export-attachments' :
1086+ attachmentsExport ( ) ;
1087+ break ;
1088+ case 'backup-db' :
1089+ databaseBackup ( ) ;
1090+ break ;
1091+ case 'import-game' :
1092+ importGame ( ) ;
1093+ break ;
1094+ case 'create-tokens' :
1095+ createTokens ( $section ) ;
1096+ break ;
1097+ case 'export-tokens' :
1098+ exportTokens ( $section ) ;
1099+ break ;
1100+ case 'export-game' :
1101+ exportCurrentGame ( ) ;
1102+ break ;
1103+ case 'import-teams' :
1104+ importTeams ( ) ;
1105+ break ;
1106+ case 'export-teams' :
1107+ exportCurrentTeams ( ) ;
1108+ break ;
1109+ case 'import-logos' :
1110+ iimportLogos ( ) ;
1111+ break ;
1112+ case 'export-logos' :
1113+ exportCurrentLogos ( ) ;
1114+ break ;
1115+ case 'import-levels' :
1116+ importLevels ( ) ;
1117+ break ;
1118+ case 'import-attachments' :
1119+ importAttachments ( ) ;
1120+ break ;
1121+ case 'export-levels' :
1122+ exportCurrentLevels ( ) ;
1123+ break ;
1124+ case 'import-categories' :
1125+ importCategories ( ) ;
1126+ break ;
1127+ case 'export-categories' :
1128+ exportCurrentCategories ( ) ;
1129+ break ;
1130+ case 'flush-memcached' :
1131+ flushMemcached ( ) ;
1132+ break ;
1133+ case 'reset-game-schedule' :
1134+ resetGameSchedule ( ) ;
1135+ break ;
1136+ case 'create-tokens' :
1137+ createTokens ( ) ;
1138+ break ;
1139+ case 'export-tokens' :
1140+ exportTokens ( ) ;
1141+ break ;
1142+ case 'edit' :
1143+ $section . removeClass ( lockClass ) ;
1144+ $ ( 'input[type="text"], input[type="password"], textarea' , $section ) . prop ( 'disabled' , false ) ;
1145+ var entity_select = $ ( '[name=entity_id]' , $section ) [ 0 ] ;
1146+ var category_select = $ ( '[name=category_id]' , $section ) [ 0 ] ;
1147+ if ( entity_select !== undefined ) {
1148+ Dropkick ( entity_select ) . disable ( false ) ;
1149+ }
1150+ if ( category_select !== undefined ) {
1151+ Dropkick ( category_select ) . disable ( false ) ;
1152+ }
1153+ break ;
1154+ case 'delete' :
1155+ $section . remove ( ) ;
1156+ deleteElement ( $section ) ;
1157+ break ;
1158+ case 'disable-logo' :
1159+ toggleLogo ( $section ) ;
1160+ break ;
1161+ case 'enable-logo' :
1162+ toggleLogo ( $section ) ;
1163+ break ;
1164+ case 'disable-country' :
1165+ toggleCountry ( $section ) ;
1166+ break ;
1167+ case 'enable-country' :
1168+ toggleCountry ( $section ) ;
1169+ break ;
1170+ case 'add-attachment' :
1171+ addNewAttachment ( $section ) ;
1172+ break ;
1173+ case 'create-attachment' :
1174+ $containingDiv = $self . closest ( '.new-attachment' ) ;
1175+ createAttachment ( $containingDiv ) ;
1176+ break ;
1177+ case 'delete-new-attachment' :
1178+ $containingDiv = $self . closest ( '.new-attachment' ) ;
1179+ $containingDiv . remove ( ) ;
1180+ deleteAttachment ( $containingDiv ) ;
1181+ break ;
1182+ case 'delete-attachment' :
1183+ $containingDiv = $self . closest ( '.existing-attachment' ) ;
1184+ $containingDiv . remove ( ) ;
1185+ deleteAttachment ( $containingDiv ) ;
1186+ break ;
1187+ case 'add-link' :
1188+ addNewLink ( $section ) ;
1189+ break ;
1190+ case 'create-link' :
1191+ $containingDiv = $self . closest ( '.new-link' ) ;
1192+ createLink ( $containingDiv ) ;
1193+ break ;
1194+ case 'delete-new-link' :
1195+ $containingDiv = $self . closest ( '.new-link' ) ;
1196+ $containingDiv . remove ( ) ;
1197+ deleteLink ( $containingDiv ) ;
1198+ break ;
1199+ case 'delete-link' :
1200+ $containingDiv = $self . closest ( '.existing-link' ) ;
1201+ $containingDiv . remove ( ) ;
1202+ deleteLink ( $containingDiv ) ;
1203+ break ;
10641204 }
1065- } else if ( action === 'save-no-validation' ) {
1066- saveLevel ( ) ;
1067- } else if ( action === 'add-new' ) {
1068- addNewSection ( $self ) ;
1069- } else if ( action === 'save-category' ) {
1070- updateCategory ( $section ) ;
1071- } else if ( action === 'create' ) {
1072- valid = validateAdminForm ( $self ) ;
1073- if ( valid ) {
1074- createElement ( $section ) ;
1075- }
1076- } else if ( action === 'create-announcement' ) {
1077- createAnnouncement ( $section ) ;
1078- } else if ( action === 'export-attachments' ) {
1079- attachmentsExport ( ) ;
1080- } else if ( action === 'backup-db' ) {
1081- databaseBackup ( ) ;
1082- } else if ( action === 'import-game' ) {
1083- importGame ( ) ;
1084- } else if ( action === 'create-tokens' ) {
1085- createTokens ( $section ) ;
1086- } else if ( action === 'export-tokens' ) {
1087- exportTokens ( $section ) ;
1088- } else if ( action === 'export-game' ) {
1089- exportCurrentGame ( ) ;
1090- } else if ( action === 'import-teams' ) {
1091- importTeams ( ) ;
1092- } else if ( action === 'export-teams' ) {
1093- exportCurrentTeams ( ) ;
1094- } else if ( action === 'import-logos' ) {
1095- importLogos ( ) ;
1096- } else if ( action === 'export-logos' ) {
1097- exportCurrentLogos ( ) ;
1098- } else if ( action === 'import-levels' ) {
1099- importLevels ( ) ;
1100- } else if ( action === 'import-attachments' ) {
1101- importAttachments ( ) ;
1102- } else if ( action === 'export-levels' ) {
1103- exportCurrentLevels ( ) ;
1104- } else if ( action === 'import-categories' ) {
1105- importCategories ( ) ;
1106- } else if ( action === 'export-categories' ) {
1107- exportCurrentCategories ( ) ;
1108- } else if ( action === 'flush-memcached' ) {
1109- flushMemcached ( ) ;
1110- } else if ( action === 'reset-game-schedule' ) {
1111- resetGameSchedule ( ) ;
1112- } else if ( action === 'create-tokens' ) {
1113- createTokens ( ) ;
1114- } else if ( action === 'export-tokens' ) {
1115- exportTokens ( ) ;
1116- } else if ( action === 'edit' ) {
1117- $section . removeClass ( lockClass ) ;
1118- $ ( 'input[type="text"], input[type="password"], textarea' , $section ) . prop ( 'disabled' , false ) ;
1119- var entity_select = $ ( '[name=entity_id]' , $section ) [ 0 ] ;
1120- var category_select = $ ( '[name=category_id]' , $section ) [ 0 ] ;
1121- if ( entity_select !== undefined ) {
1122- Dropkick ( entity_select ) . disable ( false ) ;
1123- }
1124- if ( category_select !== undefined ) {
1125- Dropkick ( category_select ) . disable ( false ) ;
1126- }
1127- } else if ( action === 'delete' ) {
1128- $section . remove ( ) ;
1129- deleteElement ( $section ) ;
1130- // rename the section boxes
1131- /*$('.admin-box').each(function(i, el){
1132- var $titleObj = $('.admin-box-header h3', el),
1133- title = $titleObj.text(),
1134- newTitle = title.substring( 0, title.lastIndexOf(" ") + 1 ) + (i + 1);
1135-
1136- $titleObj.text(newTitle);
1137- });*/
1138- } else if ( action === 'disable-logo' ) {
1139- toggleLogo ( $section ) ;
1140- } else if ( action === 'enable-logo' ) {
1141- toggleLogo ( $section ) ;
1142- } else if ( action === 'disable-country' ) {
1143- toggleCountry ( $section ) ;
1144- } else if ( action === 'enable-country' ) {
1145- toggleCountry ( $section ) ;
1146- } else if ( action === 'add-attachment' ) {
1147- addNewAttachment ( $section ) ;
1148- } else if ( action === 'create-attachment' ) {
1149- $containingDiv = $self . closest ( '.new-attachment' ) ;
1150- createAttachment ( $containingDiv ) ;
1151- } else if ( action === 'delete-new-attachment' ) {
1152- $containingDiv = $self . closest ( '.new-attachment' ) ;
1153- $containingDiv . remove ( ) ;
1154- deleteAttachment ( $containingDiv ) ;
1155- } else if ( action === 'delete-attachment' ) {
1156- $containingDiv = $self . closest ( '.existing-attachment' ) ;
1157- $containingDiv . remove ( ) ;
1158- deleteAttachment ( $containingDiv ) ;
1159- } else if ( action === 'add-link' ) {
1160- addNewLink ( $section ) ;
1161- } else if ( action === 'create-link' ) {
1162- $containingDiv = $self . closest ( '.new-link' ) ;
1163- createLink ( $containingDiv ) ;
1164- } else if ( action === 'delete-new-link' ) {
1165- $containingDiv = $self . closest ( '.new-link' ) ;
1166- $containingDiv . remove ( ) ;
1167- deleteLink ( $containingDiv ) ;
1168- } else if ( action === 'delete-link' ) {
1169- $containingDiv = $self . closest ( '.existing-link' ) ;
1170- $containingDiv . remove ( ) ;
1171- deleteLink ( $containingDiv ) ;
1172- }
11731205
11741206 if ( actionModal ) {
11751207 Modal . loadPopup ( 'p=action&model=' + actionModal , 'action-' + actionModal , function ( ) {
0 commit comments