admin.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (c) 2014
  3. *
  4. * This file is licensed under the Affero General Public License version 3
  5. * or later.
  6. *
  7. * See the COPYING-README file.
  8. *
  9. */
  10. (function() {
  11. if (!OCA.Files) {
  12. /**
  13. * Namespace for the files app
  14. * @namespace OCA.Files
  15. */
  16. OCA.Files = {};
  17. }
  18. /**
  19. * @namespace OCA.Files.Admin
  20. */
  21. OCA.Files.Admin = {
  22. initialize: function() {
  23. $('#submitMaxUpload').on('click', _.bind(this._onClickSubmitMaxUpload, this));
  24. },
  25. _onClickSubmitMaxUpload: function () {
  26. OC.msg.startSaving('#maxUploadSizeSettingsMsg');
  27. var request = $.ajax({
  28. url: OC.generateUrl('/apps/files/settings/maxUpload'),
  29. type: 'POST',
  30. data: {
  31. maxUploadSize: $('#maxUploadSize').val()
  32. }
  33. });
  34. request.done(function (data) {
  35. $('#maxUploadSize').val(data.maxUploadSize);
  36. OC.msg.finishedSuccess('#maxUploadSizeSettingsMsg', 'Saved');
  37. });
  38. request.fail(function () {
  39. OC.msg.finishedError('#maxUploadSizeSettingsMsg', 'Error');
  40. });
  41. }
  42. }
  43. })();
  44. function switchPublicFolder() {
  45. var publicEnable = $('#publicEnable').is(':checked');
  46. // find all radiobuttons of that group
  47. var sharingaimGroup = $('input:radio[name=sharingaim]');
  48. $.each(sharingaimGroup, function(index, sharingaimItem) {
  49. // set all buttons to the correct state
  50. sharingaimItem.disabled = !publicEnable;
  51. });
  52. }
  53. $(document).ready(function() {
  54. OCA.Files.Admin.initialize();
  55. // Execute the function after loading DOM tree
  56. switchPublicFolder();
  57. $('#publicEnable').click(function() {
  58. // To get rid of onClick()
  59. switchPublicFolder();
  60. });
  61. });