mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-09 11:03:17 +00:00
wip: js modularization and cleanup
This commit is contained in:
39
resources/www/common/js/components/user.js
Normal file
39
resources/www/common/js/components/user.js
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
var userModule = (function(){
|
||||
function setPref(name, value) {
|
||||
if (jQuery.data['pref_' + name] && jQuery.data['pref_' + name].abort) {
|
||||
jQuery.data['pref_' + name].abort();
|
||||
jQuery.data['pref_' + name] = false;
|
||||
}
|
||||
|
||||
jQuery.data['pref_' + name] = $.ajax({
|
||||
type: "POST",
|
||||
url: "/user/preferences/",
|
||||
data: {
|
||||
prop: name,
|
||||
value: value
|
||||
},
|
||||
dataType: 'json',
|
||||
timeout: function () {
|
||||
jQuery.data['pref_' + name] = false;
|
||||
},
|
||||
error: function () {
|
||||
jQuery.data['pref_' + name] = false;
|
||||
},
|
||||
success: function (data) {
|
||||
if (data.success) {
|
||||
humane.info(data.message);
|
||||
}
|
||||
else {
|
||||
humane.error(data.message);
|
||||
}
|
||||
jQuery.data['pref_' + name] = false;
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {setPref: setPref}
|
||||
})();
|
||||
|
||||
|
Reference in New Issue
Block a user