2011-08-22 23:40:13 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
2011-08-10 10:20:43 +00:00
|
|
|
$(document).ready(function(){
|
|
|
|
$('#leftcontent li').each(function(index,li){
|
|
|
|
var app=$.parseJSON($(this).children('span').text());
|
|
|
|
$(li).data('app',app);
|
|
|
|
});
|
2012-05-04 15:54:52 +00:00
|
|
|
$('#leftcontent li').keydown(function(event) {
|
|
|
|
if (event.which == 13 || event.which == 32) {
|
|
|
|
$(event.target).click()
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
2011-08-10 10:20:43 +00:00
|
|
|
$('#leftcontent li').click(function(){
|
|
|
|
var app=$(this).data('app');
|
2012-06-03 21:48:59 +00:00
|
|
|
$('#rightcontent p.license').show();
|
2011-08-10 10:20:43 +00:00
|
|
|
$('#rightcontent span.name').text(app.name);
|
2012-04-21 13:30:58 +00:00
|
|
|
$('#rightcontent small.externalapp').text(app.internallabel);
|
2011-08-10 10:20:43 +00:00
|
|
|
$('#rightcontent span.version').text(app.version);
|
|
|
|
$('#rightcontent p.description').text(app.description);
|
2012-04-21 13:30:58 +00:00
|
|
|
$('#rightcontent img.preview').attr('src',app.preview);
|
|
|
|
$('#rightcontent small.externalapp').attr('style','visibility:visible');
|
2011-08-10 10:20:43 +00:00
|
|
|
$('#rightcontent span.author').text(app.author);
|
|
|
|
$('#rightcontent span.licence').text(app.licence);
|
|
|
|
|
|
|
|
$('#rightcontent input.enable').show();
|
2011-08-15 21:31:59 +00:00
|
|
|
$('#rightcontent input.enable').val((app.active)?t('settings','Disable'):t('settings','Enable'));
|
2011-08-10 10:20:43 +00:00
|
|
|
$('#rightcontent input.enable').data('appid',app.id);
|
|
|
|
$('#rightcontent input.enable').data('active',app.active);
|
2012-06-03 21:48:59 +00:00
|
|
|
if ( app.internal == false ) {
|
|
|
|
$('#rightcontent p.appslink').show();
|
|
|
|
$('#rightcontent a').attr('href','http://apps.owncloud.com/content/show.php?content='+app.id);
|
2012-06-04 18:26:03 +00:00
|
|
|
} else {
|
|
|
|
$('#rightcontent p.appslink').hide();
|
2012-06-03 21:48:59 +00:00
|
|
|
}
|
2012-05-04 15:54:52 +00:00
|
|
|
return false;
|
2011-08-10 10:20:43 +00:00
|
|
|
});
|
|
|
|
$('#rightcontent input.enable').click(function(){
|
2012-05-14 21:52:40 +00:00
|
|
|
var element = $(this);
|
2011-08-10 10:20:43 +00:00
|
|
|
var app=$(this).data('appid');
|
|
|
|
var active=$(this).data('active');
|
|
|
|
if(app){
|
|
|
|
if(active){
|
2012-04-14 10:57:03 +00:00
|
|
|
$.post(OC.filePath('settings','ajax','disableapp.php'),{appid:app},function(result){
|
2012-04-14 16:09:31 +00:00
|
|
|
if(!result || result.status!='success'){
|
2012-05-26 18:37:10 +00:00
|
|
|
OC.dialogs.alert('Error while disabling app','Error');
|
2012-04-14 10:57:03 +00:00
|
|
|
}
|
2012-05-14 21:52:40 +00:00
|
|
|
else {
|
|
|
|
element.data('active',false);
|
|
|
|
element.val(t('settings','Enable'));
|
|
|
|
var appData=$('#leftcontent li[data-id="'+app+'"]');
|
|
|
|
appData.active=false;
|
|
|
|
}
|
2012-04-14 10:57:03 +00:00
|
|
|
},'json');
|
2011-08-10 10:20:43 +00:00
|
|
|
$('#leftcontent li[data-id="'+app+'"]').removeClass('active');
|
|
|
|
}else{
|
2012-04-14 10:57:03 +00:00
|
|
|
$.post(OC.filePath('settings','ajax','enableapp.php'),{appid:app},function(result){
|
2012-04-14 16:09:31 +00:00
|
|
|
if(!result || result.status!='success'){
|
2012-05-26 18:37:10 +00:00
|
|
|
OC.dialogs.alert('Error while enabling app','Error');
|
2012-04-14 10:57:03 +00:00
|
|
|
}
|
2012-05-14 21:52:40 +00:00
|
|
|
else {
|
|
|
|
element.data('active',true);
|
|
|
|
element.val(t('settings','Disable'));
|
|
|
|
var appData=$('#leftcontent li[data-id="'+app+'"]');
|
|
|
|
appData.active=true;
|
|
|
|
}
|
2012-04-14 10:57:03 +00:00
|
|
|
},'json');
|
2011-08-10 10:20:43 +00:00
|
|
|
$('#leftcontent li[data-id="'+app+'"]').addClass('active');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2012-06-25 03:02:01 +00:00
|
|
|
|
|
|
|
if(appid) {
|
|
|
|
var item = $('#leftcontent li[data-id="'+appid+'"]');
|
|
|
|
if(item) {
|
|
|
|
item.trigger('click');
|
|
|
|
item.addClass('active');
|
|
|
|
$('#leftcontent').animate({scrollTop: $(item).offset().top-70}, 'slow','swing');
|
|
|
|
}
|
|
|
|
}
|
2011-08-10 10:20:43 +00:00
|
|
|
});
|