MDL-76974 javascript: convert remaining uses of old preferences API.

Implement component preference definition callbacks, update JS code
to use the `core_user/repository` module instead of the now deprecated
API.
This commit is contained in:
Paul Holden
2023-08-22 14:43:34 +01:00
parent d096c60e0c
commit b30245b3e2
21 changed files with 180 additions and 38 deletions
+6 -2
View File
@@ -160,7 +160,9 @@ M.util.CollapsibleRegion = function(Y, id, userpref, strtooltip) {
animation.set('reverse', this.div.hasClass('collapsed'));
// Update the user preference.
if (this.userpref) {
M.util.set_user_preference(this.userpref, !this.div.hasClass('collapsed'));
require(['core_user/repository'], function(UserRepository) {
UserRepository.setUserPreference(this.userpref, !this.div.hasClass('collapsed'));
}.bind(this));
}
animation.run();
}, this, animation);
@@ -577,7 +579,9 @@ M.util.init_block_hider = function(Y, config) {
}
},
updateState : function(e, hide) {
M.util.set_user_preference(this.get('preference'), hide);
require(['core_user/repository'], function(UserRepository) {
UserRepository.setUserPreference(this.get('preference'), hide);
}.bind(this));
if (hide) {
this.get('block').addClass('hidden');
this.get('block').one('.block-hider-show').focus();