You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-3Lines changed: 8 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ It is also designed to be used with settings pages that save their settings auto
9
9
* can automatically save all options in a useful data format (number values are also saved as numbers, not strings)
10
10
*[saving multiple options grouped together in JS objects](#option-groups)
11
11
*[MessageHandler integration](https://github.com/TinyWebEx/MessageHandler), e.g. to show errors when saving or loading an option fails, or to show a message if some managed options are used.
12
+
*[can automatically let your reset button spring to live](#reset-button)
12
13
13
14
## Usage
14
15
@@ -156,7 +157,7 @@ In both cases, you get the `optionValue` of the setting, the option name and the
156
157
157
158
This is mostly useful if some options depend on each other (that happens often when using [option groups](#option-groups) e.g.), so you can interactively disable elements based on the user selection/input; or, if you want top verify the data the user entered and show some warnings or so.
158
159
159
-
Note however, that this way is seperate from the whole loading & saving of the data, so you cannot prevent an invalid value from being saved or so, here. Do [overwrite the loading or saving behaviour](#overwriting-loading-and-saving-behaviour) if you want to do this.
160
+
Note however, that this way is separate from the whole loading & saving of the data, so you cannot prevent an invalid value from being saved or so, here. Do [overwrite the loading or saving behaviour](#overwriting-loading-and-saving-behaviour) if you want to do this.
160
161
161
162
Note that you need to add the additional classes `trigger-on-update` (for the update trigger/`registerUpdate`) or `trigger-on-change` (for the input trigger/`registerChange`) to the respective options, to make this feature work. Without it, the library does not bind to these elements.
162
163
@@ -165,7 +166,7 @@ Note that you need to add the additional classes `trigger-on-update` (for the up
165
166
You can use `AutomaticSettings.Trigger.registerSave` to register a "save trigger" that is executed when an option is saved (actually directly before it is saved).
166
167
It is thus quite useful to automatically apply the option or send it to other parts of the browser extension, so they are notified that a the value of the option changed. This is a useful feature for your usability, because the `AutomaticSetings` module automatically saves all options, so they should also automatically be applied, so the user immediately sees the difference.
167
168
168
-
You can also use it to validate the input and cancel saving, you need to throw some errors then. Note that you should then show an appropiate error message yourself, as this error is not catched by the library - in contrast to everything else that happens afterwards, i.e. the saving of the option itself, e.g.
169
+
You can also use it to validate the input and cancel saving, you need to throw some errors then. Note that you should then show an appropriate error message yourself, as this error is not catched by the library - in contrast to everything else that happens afterwards, i.e. the saving of the option itself, e.g.
169
170
170
171
### Triggers before and after loading
171
172
@@ -175,7 +176,7 @@ To solve this, there is `AutomaticSettings.Trigger.registerAfterLoad`, which can
175
176
176
177
Similarly there is `AutomaticSettings.Trigger.registerBeforeLoad` to let you execute stuff before any option is loaded.
177
178
178
-
### Overwriting loading and saving behaviour
179
+
### Overwriting loading and saving behavior
179
180
180
181
Sometimes it is needed to present data to the user in one way, but save it in another way. Thus, you need to manipulate how data is loaded or saved.
181
182
If [option groups](#option-groups) are not enough for you, you can use `AutomaticSettings.Trigger.addCustomLoadOverride` and `AutomaticSettings.Trigger.addCustomSaveOverride` to override the respective features.
@@ -207,6 +208,10 @@ function saveOptionXy(param) {
207
208
}
208
209
```
209
210
211
+
## Reset buttons
212
+
213
+
Doc is TODO…
214
+
210
215
## API note
211
216
212
217
Everything in the `internal` dir is considered to be an internal module/file and thus not be considered to be an API under _semantic versioning_. That means the API there can change at any time, do _not_ import anything from there!
0 commit comments