apps.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
  3. * This file is licensed under the Affero General Public License version 3 or later.
  4. * See the COPYING-README file.
  5. */
  6. $(document).ready(function(){
  7. $('#leftcontent li').each(function(index,li){
  8. var app=$.parseJSON($(this).children('span').text());
  9. $(li).data('app',app);
  10. });
  11. $('#leftcontent li').keydown(function(event) {
  12. if (event.which == 13 || event.which == 32) {
  13. $(event.target).click()
  14. }
  15. return false;
  16. });
  17. $('#leftcontent li').click(function(){
  18. var app=$(this).data('app');
  19. $('#rightcontent p.license').show();
  20. $('#rightcontent span.name').text(app.name);
  21. $('#rightcontent small.externalapp').text(app.internallabel);
  22. $('#rightcontent span.version').text(app.version);
  23. $('#rightcontent p.description').text(app.description);
  24. $('#rightcontent img.preview').attr('src',app.preview);
  25. $('#rightcontent small.externalapp').attr('style','visibility:visible');
  26. $('#rightcontent span.author').text(app.author);
  27. $('#rightcontent span.licence').text(app.licence);
  28. $('#rightcontent input.enable').show();
  29. $('#rightcontent input.enable').val((app.active)?t('settings','Disable'):t('settings','Enable'));
  30. $('#rightcontent input.enable').data('appid',app.id);
  31. $('#rightcontent input.enable').data('active',app.active);
  32. if ( app.internal == false ) {
  33. $('#rightcontent p.appslink').show();
  34. $('#rightcontent a').attr('href','http://apps.owncloud.com/content/show.php?content='+app.id);
  35. } else {
  36. $('#rightcontent p.appslink').hide();
  37. }
  38. return false;
  39. });
  40. $('#rightcontent input.enable').click(function(){
  41. var element = $(this);
  42. var app=$(this).data('appid');
  43. var active=$(this).data('active');
  44. if(app){
  45. if(active){
  46. $.post(OC.filePath('settings','ajax','disableapp.php'),{appid:app},function(result){
  47. if(!result || result.status!='success'){
  48. OC.dialogs.alert('Error while disabling app','Error');
  49. }
  50. else {
  51. element.data('active',false);
  52. element.val(t('settings','Enable'));
  53. var appData=$('#leftcontent li[data-id="'+app+'"]');
  54. appData.active=false;
  55. }
  56. },'json');
  57. $('#leftcontent li[data-id="'+app+'"]').removeClass('active');
  58. }else{
  59. $.post(OC.filePath('settings','ajax','enableapp.php'),{appid:app},function(result){
  60. if(!result || result.status!='success'){
  61. OC.dialogs.alert('Error while enabling app','Error');
  62. }
  63. else {
  64. element.data('active',true);
  65. element.val(t('settings','Disable'));
  66. var appData=$('#leftcontent li[data-id="'+app+'"]');
  67. appData.active=true;
  68. }
  69. },'json');
  70. $('#leftcontent li[data-id="'+app+'"]').addClass('active');
  71. }
  72. }
  73. });
  74. });