Browse Source

Options: bugfix, first save options, then reload; set var options before hook options_save; +docu

master
parent
commit
227f84ee1a
  1. 1
      README.md
  2. 8
      src/language.js
  3. 13
      src/options.js

1
README.md

@ -119,3 +119,4 @@ With the function `register_hook` you can hook into several functions. The follo
* `state-get`: modules can add values into the current state. Parameters: `state`: an object, which can be modified by modules. * `state-get`: modules can add values into the current state. Parameters: `state`: an object, which can be modified by modules.
* `state-apply`: when a state is applied to the app. Parameters: `state`: state which should be applied. * `state-apply`: when a state is applied to the app. Parameters: `state`: state which should be applied.
* `show-details`: called when details are being displayed. Parameters: data (see properties in doc/TwigJS.md), category, dom, callback. * `show-details`: called when details are being displayed. Parameters: data (see properties in doc/TwigJS.md), category, dom, callback.
* `options_save`: called when options are saved. Parameters: options (the new object), old_options (before save)

8
src/language.js

@ -111,10 +111,10 @@ register_hook('options_form', function (def) {
} }
}) })
register_hook('options_save', function (data) {
if ('data_lang' in data) {
if ('data_lang' in options && options.data_lang !== data.data_lang) {
tagTranslations.setTagLanguage(data.data_lang)
register_hook('options_save', function (options, old_options) {
if ('data_lang' in options) {
if (old_options.data_lang !== options.data_lang) {
tagTranslations.setTagLanguage(options.data_lang)
baseCategory.recalc() baseCategory.recalc()
} }
} }

13
src/options.js

@ -59,16 +59,17 @@ moduleOptions.submit = function (optionsForm) {
} }
} }
if (reload) {
location.reload()
}
ajax('options_save', null, data, function (ret) { ajax('options_save', null, data, function (ret) {
call_hooks('options_save', data)
old_options = options
options = data options = data
document.getElementById('content').className = prevPage document.getElementById('content').className = prevPage
call_hooks('options_save', data, old_options)
if (reload) {
location.reload()
}
}) })
return false return false

Loading…
Cancel
Save