Reworked Admin JS with ES6

This commit is contained in:
Djamil Legato
2016-02-01 11:27:34 -08:00
parent c62fb6bdb5
commit 35fa588438
85 changed files with 31905 additions and 824 deletions

View File

@@ -571,7 +571,7 @@ class AdminPlugin extends Plugin
$this->theme = $this->config->get('plugins.admin.theme', 'grav');
$assets = $this->grav['assets'];
$translations = 'if (!window.translations) window.translations = {}; ' . PHP_EOL . 'window.translations.PLUGIN_ADMIN = {};' . PHP_EOL;
$translations = 'this.GravAdmin = this.GravAdmin || {}; if (!this.GravAdmin.translations) this.GravAdmin.translations = {}; ' . PHP_EOL . 'this.GravAdmin.translations.PLUGIN_ADMIN = {';
// Enable language translations
$translations_actual_state = $this->config->get('system.languages.translations');
@@ -597,13 +597,16 @@ class AdminPlugin extends Plugin
'DAYS',
'PAGE_MODES',
'PAGE_TYPES',
'ACCESS_LEVELS'
'ACCESS_LEVELS',
'NOTHING_TO_SAVE'
];
foreach($strings as $string) {
$translations .= 'translations.PLUGIN_ADMIN.' . $string .' = "' . $this->admin->translate('PLUGIN_ADMIN.' . $string) . '"; ' . PHP_EOL;;
$separator = (end($strings) === $string) ? '' : ',';
$translations .= '"' . $string .'": "' . $this->admin->translate('PLUGIN_ADMIN.' . $string) . '"' . $separator;
}
$translations .= '};';
// set the actual translations state back
$this->config->set('system.languages.translations', $translations_actual_state);