2011-08-23 03:40:13 +04:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
|
2012-08-04 22:12:18 +04:00
|
|
|
* Copyright (c) 2012, Thomas Tanghus <thomas@tanghus.net>
|
2011-08-23 03:40:13 +04:00
|
|
|
* This file is licensed under the Affero General Public License version 3 or later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
2012-08-04 22:12:18 +04:00
|
|
|
OC.Settings = OC.Settings || {};
|
|
|
|
OC.Settings.Apps = OC.Settings.Apps || {
|
2012-08-05 01:48:09 +04:00
|
|
|
loadApp:function(app) {
|
2014-03-20 12:04:50 +04:00
|
|
|
var page = $('#app-content');
|
2012-08-05 01:48:09 +04:00
|
|
|
page.find('p.license').show();
|
|
|
|
page.find('span.name').text(app.name);
|
|
|
|
page.find('small.externalapp').text(app.internallabel);
|
|
|
|
if (app.version) {
|
|
|
|
page.find('span.version').text(app.version);
|
|
|
|
} else {
|
|
|
|
page.find('span.version').text('');
|
|
|
|
}
|
2012-10-08 17:49:48 +04:00
|
|
|
page.find('span.score').html(app.score);
|
2013-03-04 03:19:07 +04:00
|
|
|
page.find('p.description').text(app.description);
|
2012-08-05 01:48:09 +04:00
|
|
|
page.find('img.preview').attr('src', app.preview);
|
2013-06-28 22:53:56 +04:00
|
|
|
if (app.preview && app.preview.length) {
|
|
|
|
page.find('img.preview').show();
|
|
|
|
} else {
|
|
|
|
page.find('img.preview').hide();
|
|
|
|
}
|
2012-08-05 01:48:09 +04:00
|
|
|
page.find('small.externalapp').attr('style', 'visibility:visible');
|
|
|
|
page.find('span.author').text(app.author);
|
2013-08-29 00:12:01 +04:00
|
|
|
|
|
|
|
// FIXME licenses of downloaded apps go into app.licence, licenses of not-downloaded apps into app.license
|
2013-08-29 00:42:43 +04:00
|
|
|
var appLicense = '';
|
2013-08-29 00:12:01 +04:00
|
|
|
if (typeof(app.licence) !== 'undefined') {
|
2013-08-29 00:42:43 +04:00
|
|
|
appLicense = app.licence;
|
2013-08-29 00:12:01 +04:00
|
|
|
} else if (typeof(app.license) !== 'undefined') {
|
2013-08-29 00:42:43 +04:00
|
|
|
appLicense = app.license;
|
2013-08-29 00:12:01 +04:00
|
|
|
}
|
2013-08-29 00:42:43 +04:00
|
|
|
page.find('span.licence').text(appLicense);
|
2012-08-05 01:48:09 +04:00
|
|
|
|
2014-01-17 17:05:39 +04:00
|
|
|
var userDocumentation = false;
|
|
|
|
var adminDocumentation = false;
|
2014-01-17 19:35:48 +04:00
|
|
|
if (typeof(app.documentation) !== 'undefined') {
|
|
|
|
if (typeof(app.documentation.user) !== 'undefined') {
|
|
|
|
userDocumentation = true;
|
|
|
|
page.find('span.userDocumentation').html("<a id='userDocumentation' href='" + app.documentation.user + "'>" + t('settings', 'User Documentation') + "</a>");
|
|
|
|
page.find('p.documentation').show();
|
|
|
|
}
|
2014-05-26 00:14:46 +04:00
|
|
|
else {
|
|
|
|
page.find('span.userDocumentation').empty();
|
|
|
|
userDocumentation = false;
|
|
|
|
}
|
2014-01-17 19:35:48 +04:00
|
|
|
if (typeof(app.documentation.admin) !== 'undefined') {
|
|
|
|
adminDocumentation = true;
|
|
|
|
page.find('span.adminDocumentation').html("<a id='adminDocumentation' href='" + app.documentation.admin + "'>" + t('settings', 'Admin Documentation') + "</a>");
|
|
|
|
page.find('p.documentation').show();
|
|
|
|
}
|
2014-05-26 00:14:46 +04:00
|
|
|
else {
|
|
|
|
page.find('span.adminDocumentation').empty();
|
|
|
|
adminDocumentation = false;
|
|
|
|
}
|
2014-01-17 17:05:39 +04:00
|
|
|
|
2014-01-17 19:35:48 +04:00
|
|
|
if(userDocumentation && adminDocumentation) {
|
2014-05-26 00:14:46 +04:00
|
|
|
page.find('span.comma').remove();
|
|
|
|
page.find('span.userDocumentation').after('<span class="comma">, </span>');
|
2014-01-17 19:35:48 +04:00
|
|
|
}
|
2014-05-26 00:14:46 +04:00
|
|
|
else {
|
|
|
|
page.find('span.comma').remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
page.find('p.documentation').hide();
|
2014-01-17 17:05:39 +04:00
|
|
|
}
|
|
|
|
|
2014-01-17 19:35:48 +04:00
|
|
|
if (typeof(app.website) !== 'undefined') {
|
|
|
|
page.find('p.website').show();
|
|
|
|
page.find('a#websitelink').attr('href', app.website);
|
|
|
|
}
|
2014-01-17 17:05:39 +04:00
|
|
|
|
2013-04-17 17:32:03 +04:00
|
|
|
if (app.update !== false) {
|
2013-01-21 23:40:23 +04:00
|
|
|
page.find('input.update').show();
|
|
|
|
page.find('input.update').data('appid', app.id);
|
2013-01-31 17:11:31 +04:00
|
|
|
page.find('input.update').attr('value',t('settings', 'Update to {appversion}', {appversion:app.update}));
|
2013-01-21 23:40:23 +04:00
|
|
|
} else {
|
|
|
|
page.find('input.update').hide();
|
|
|
|
}
|
|
|
|
|
2014-05-31 19:50:39 +04:00
|
|
|
if (app.removable !== false) {
|
|
|
|
page.find('input.uninstall').show();
|
|
|
|
page.find('input.uninstall').data('appid', app.id);
|
|
|
|
page.find('input.uninstall').attr('value', t('settings', 'Uninstall App'));
|
|
|
|
} else {
|
|
|
|
page.find('input.uninstall').hide();
|
|
|
|
}
|
|
|
|
|
2012-08-05 01:48:09 +04:00
|
|
|
page.find('input.enable').show();
|
|
|
|
page.find('input.enable').val((app.active) ? t('settings', 'Disable') : t('settings', 'Enable'));
|
|
|
|
page.find('input.enable').data('appid', app.id);
|
|
|
|
page.find('input.enable').data('active', app.active);
|
2013-04-17 17:32:03 +04:00
|
|
|
if (app.internal === false) {
|
2012-10-08 17:49:48 +04:00
|
|
|
page.find('span.score').show();
|
2014-01-17 19:35:48 +04:00
|
|
|
page.find('p.appstore').show();
|
|
|
|
page.find('a#appstorelink').attr('href', 'http://apps.owncloud.com/content/show.php?content=' + app.id);
|
2012-10-08 15:33:52 +04:00
|
|
|
page.find('small.externalapp').hide();
|
2012-08-05 01:48:09 +04:00
|
|
|
} else {
|
|
|
|
page.find('p.appslink').hide();
|
2012-10-08 17:49:48 +04:00
|
|
|
page.find('span.score').hide();
|
2012-08-05 01:48:09 +04:00
|
|
|
}
|
2014-03-24 16:29:53 +04:00
|
|
|
if (typeof($('#app-navigation ul li[data-id="'+app.id+'"]').data('errormsg')) !== "undefined") {
|
2013-08-18 19:37:22 +04:00
|
|
|
page.find(".warning").show();
|
2014-03-24 16:29:53 +04:00
|
|
|
page.find(".warning").text($('#app-navigation ul li[data-id="'+app.id+'"]').data('errormsg'));
|
2013-08-18 15:49:34 +04:00
|
|
|
} else {
|
2013-08-18 19:37:22 +04:00
|
|
|
page.find(".warning").hide();
|
2013-08-18 15:49:34 +04:00
|
|
|
}
|
2014-04-18 16:29:45 +04:00
|
|
|
|
|
|
|
page.find("div.multiselect").parent().remove();
|
2014-04-28 15:27:32 +04:00
|
|
|
if(OC.Settings.Apps.isType(app, 'filesystem') || OC.Settings.Apps.isType(app, 'prelogin') ||
|
|
|
|
OC.Settings.Apps.isType(app, 'authentication') || OC.Settings.Apps.isType(app, 'logging')) {
|
2014-04-18 16:29:45 +04:00
|
|
|
page.find("#groups_enable").hide();
|
|
|
|
page.find("label[for='groups_enable']").hide();
|
2014-04-28 15:27:32 +04:00
|
|
|
page.find("#groups_enable").attr('checked', null);
|
|
|
|
} else {
|
|
|
|
$('#group_select > option').each(function (i, el) {
|
|
|
|
if (app.groups.length === 0 || app.groups.indexOf(el.value) >= 0) {
|
|
|
|
$(el).attr('selected', 'selected');
|
|
|
|
} else {
|
|
|
|
$(el).attr('selected', null);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (app.active) {
|
|
|
|
if (app.groups.length) {
|
|
|
|
$('#group_select').multiSelect();
|
|
|
|
page.find("#groups_enable").attr('checked','checked');
|
|
|
|
} else {
|
|
|
|
page.find("#groups_enable").attr('checked', null);
|
|
|
|
}
|
|
|
|
page.find("#groups_enable").show();
|
|
|
|
page.find("label[for='groups_enable']").show();
|
|
|
|
} else {
|
|
|
|
page.find("#groups_enable").hide();
|
|
|
|
page.find("label[for='groups_enable']").hide();
|
|
|
|
}
|
2014-04-18 16:29:45 +04:00
|
|
|
}
|
2012-08-05 01:48:09 +04:00
|
|
|
},
|
2014-04-18 16:29:45 +04:00
|
|
|
enableApp:function(appid, active, element, groups) {
|
|
|
|
groups = groups || [];
|
2014-03-20 12:04:50 +04:00
|
|
|
var appitem=$('#app-navigation ul li[data-id="'+appid+'"]');
|
2013-01-21 23:40:23 +04:00
|
|
|
element.val(t('settings','Please wait....'));
|
2014-04-18 16:29:45 +04:00
|
|
|
if(active && !groups.length) {
|
2012-08-05 01:48:09 +04:00
|
|
|
$.post(OC.filePath('settings','ajax','disableapp.php'),{appid:appid},function(result) {
|
2013-04-17 17:32:03 +04:00
|
|
|
if(!result || result.status !== 'success') {
|
2013-08-06 19:19:18 +04:00
|
|
|
if (result.data && result.data.message) {
|
2013-08-18 15:49:34 +04:00
|
|
|
OC.Settings.Apps.showErrorMessage(result.data.message);
|
2013-08-18 16:49:11 +04:00
|
|
|
appitem.data('errormsg', result.data.message);
|
2013-08-06 19:19:18 +04:00
|
|
|
} else {
|
2013-08-18 15:49:34 +04:00
|
|
|
OC.Settings.Apps.showErrorMessage(t('settings', 'Error while disabling app'));
|
2013-08-18 16:49:11 +04:00
|
|
|
appitem.data('errormsg', t('settings', 'Error while disabling app'));
|
2013-08-06 19:19:18 +04:00
|
|
|
}
|
2013-08-18 15:49:34 +04:00
|
|
|
element.val(t('settings','Disable'));
|
2013-08-18 16:49:11 +04:00
|
|
|
appitem.addClass('appwarning');
|
2012-08-05 01:48:09 +04:00
|
|
|
}
|
|
|
|
else {
|
2013-08-18 16:49:11 +04:00
|
|
|
appitem.data('active',false);
|
2014-04-18 16:29:45 +04:00
|
|
|
appitem.data('groups', '');
|
2013-09-20 22:29:15 +04:00
|
|
|
element.data('active',false);
|
2012-10-26 22:12:14 +04:00
|
|
|
OC.Settings.Apps.removeNavigation(appid);
|
2013-08-18 16:49:11 +04:00
|
|
|
appitem.removeClass('active');
|
2012-08-05 01:48:09 +04:00
|
|
|
element.val(t('settings','Enable'));
|
2014-04-18 16:29:45 +04:00
|
|
|
element.parent().find("#groups_enable").hide();
|
|
|
|
element.parent().find("label[for='groups_enable']").hide();
|
2014-05-06 14:41:06 +04:00
|
|
|
var app = OC.get('appData_' + appid);
|
|
|
|
app.active = false;
|
2012-08-05 01:48:09 +04:00
|
|
|
}
|
|
|
|
},'json');
|
|
|
|
} else {
|
2014-04-18 16:29:45 +04:00
|
|
|
$.post(OC.filePath('settings','ajax','enableapp.php'),{appid: appid, groups: groups},function(result) {
|
2013-04-17 17:32:03 +04:00
|
|
|
if(!result || result.status !== 'success') {
|
2013-08-06 19:19:18 +04:00
|
|
|
if (result.data && result.data.message) {
|
2013-08-18 15:49:34 +04:00
|
|
|
OC.Settings.Apps.showErrorMessage(result.data.message);
|
2013-08-18 16:49:11 +04:00
|
|
|
appitem.data('errormsg', result.data.message);
|
2013-08-06 19:19:18 +04:00
|
|
|
} else {
|
2013-08-18 15:49:34 +04:00
|
|
|
OC.Settings.Apps.showErrorMessage(t('settings', 'Error while enabling app'));
|
2013-08-18 16:49:11 +04:00
|
|
|
appitem.data('errormsg', t('settings', 'Error while disabling app'));
|
2013-08-06 19:19:18 +04:00
|
|
|
}
|
|
|
|
element.val(t('settings','Enable'));
|
2013-08-18 16:49:11 +04:00
|
|
|
appitem.addClass('appwarning');
|
2013-08-06 19:19:18 +04:00
|
|
|
} else {
|
2012-10-26 22:12:14 +04:00
|
|
|
OC.Settings.Apps.addNavigation(appid);
|
2013-08-18 16:49:11 +04:00
|
|
|
appitem.data('active',true);
|
2013-09-20 22:29:15 +04:00
|
|
|
element.data('active',true);
|
2013-08-18 16:49:11 +04:00
|
|
|
appitem.addClass('active');
|
2012-08-05 01:48:09 +04:00
|
|
|
element.val(t('settings','Disable'));
|
2014-05-06 14:41:06 +04:00
|
|
|
var app = OC.get('appData_' + appid);
|
|
|
|
app.active = true;
|
|
|
|
if (OC.Settings.Apps.isType(app, 'filesystem') || OC.Settings.Apps.isType(app, 'prelogin') ||
|
|
|
|
OC.Settings.Apps.isType(app, 'authentication') || OC.Settings.Apps.isType(app, 'logging')) {
|
|
|
|
element.parent().find("#groups_enable").hide();
|
|
|
|
element.parent().find("label[for='groups_enable']").hide();
|
2014-04-18 16:29:45 +04:00
|
|
|
} else {
|
2014-05-06 14:41:06 +04:00
|
|
|
element.parent().find("#groups_enable").show();
|
|
|
|
element.parent().find("label[for='groups_enable']").show();
|
|
|
|
if (groups) {
|
|
|
|
appitem.data('groups', JSON.stringify(groups));
|
|
|
|
} else {
|
|
|
|
appitem.data('groups', '');
|
|
|
|
}
|
2014-04-18 16:29:45 +04:00
|
|
|
}
|
2012-08-05 01:48:09 +04:00
|
|
|
}
|
2013-03-23 15:19:43 +04:00
|
|
|
},'json')
|
2014-01-17 17:05:39 +04:00
|
|
|
.fail(function() {
|
2013-08-18 15:49:34 +04:00
|
|
|
OC.Settings.Apps.showErrorMessage(t('settings', 'Error while enabling app'));
|
2013-08-18 16:49:11 +04:00
|
|
|
appitem.data('errormsg', t('settings', 'Error while enabling app'));
|
|
|
|
appitem.data('active',false);
|
|
|
|
appitem.addClass('appwarning');
|
2013-03-23 15:19:43 +04:00
|
|
|
OC.Settings.Apps.removeNavigation(appid);
|
|
|
|
element.val(t('settings','Enable'));
|
|
|
|
});
|
2012-08-05 01:48:09 +04:00
|
|
|
}
|
|
|
|
},
|
2013-01-21 23:40:23 +04:00
|
|
|
updateApp:function(appid, element) {
|
2013-02-01 03:51:00 +04:00
|
|
|
element.val(t('settings','Updating....'));
|
2013-01-21 23:40:23 +04:00
|
|
|
$.post(OC.filePath('settings','ajax','updateapp.php'),{appid:appid},function(result) {
|
2013-04-17 17:32:03 +04:00
|
|
|
if(!result || result.status !== 'success') {
|
2013-08-18 15:49:34 +04:00
|
|
|
OC.Settings.Apps.showErrorMessage(t('settings','Error while updating app'),t('settings','Error'));
|
|
|
|
element.val(t('settings','Update'));
|
2013-01-21 23:40:23 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
element.val(t('settings','Updated'));
|
|
|
|
element.hide();
|
|
|
|
}
|
|
|
|
},'json');
|
|
|
|
},
|
2014-05-31 19:50:39 +04:00
|
|
|
uninstallApp:function(appid, element) {
|
|
|
|
element.val(t('settings','Uninstalling ....'));
|
|
|
|
$.post(OC.filePath('settings','ajax','uninstallapp.php'),{appid:appid},function(result) {
|
|
|
|
if(!result || result.status !== 'success') {
|
|
|
|
OC.Settings.Apps.showErrorMessage(t('settings','Error while uninstalling app'),t('settings','Error'));
|
|
|
|
element.val(t('settings','Uninstall'));
|
|
|
|
} else {
|
|
|
|
OC.Settings.Apps.removeNavigation(appid);
|
|
|
|
appitem.removeClass('active');
|
|
|
|
}
|
|
|
|
},'json');
|
|
|
|
},
|
2013-01-21 23:40:23 +04:00
|
|
|
|
2012-08-04 22:12:18 +04:00
|
|
|
insertApp:function(appdata) {
|
2014-03-20 12:04:50 +04:00
|
|
|
var applist = $('#app-navigation ul li');
|
2012-08-04 22:12:18 +04:00
|
|
|
var app =
|
2012-08-05 01:48:09 +04:00
|
|
|
$('<li data-id="' + appdata.id + '" data-type="external" data-installed="0">'
|
|
|
|
+ '<a class="app externalapp" href="' + OC.filePath('settings', 'apps', 'index.php') + '&appid=' + appdata.id+'">'
|
2012-08-04 22:12:18 +04:00
|
|
|
+ appdata.name+'</a><small class="externalapp list">3rd party</small></li>');
|
|
|
|
app.data('app', appdata);
|
|
|
|
var added = false;
|
|
|
|
applist.each(function() {
|
|
|
|
if(!parseInt($(this).data('installed')) && $(this).find('a').text().toLowerCase() > appdata.name.toLowerCase()) {
|
|
|
|
$(this).before(app);
|
|
|
|
added = true;
|
|
|
|
return false; // dang, remember this to get out of loop
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if(!added) {
|
|
|
|
applist.last().after(app);
|
|
|
|
}
|
|
|
|
return app;
|
2012-10-26 22:12:14 +04:00
|
|
|
},
|
|
|
|
removeNavigation: function(appid){
|
2012-10-28 21:52:18 +04:00
|
|
|
$.getJSON(OC.filePath('settings', 'ajax', 'navigationdetect.php'), {app: appid}).done(function(response){
|
2012-10-26 22:12:14 +04:00
|
|
|
if(response.status === 'success'){
|
|
|
|
var navIds=response.nav_ids;
|
|
|
|
for(var i=0; i< navIds.length; i++){
|
2014-06-04 20:22:40 +04:00
|
|
|
$('#apps ul').children('li[data-id="'+navIds[i]+'"]').remove();
|
2012-10-26 22:12:14 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
addNavigation: function(appid){
|
2012-10-28 21:52:18 +04:00
|
|
|
$.getJSON(OC.filePath('settings', 'ajax', 'navigationdetect.php'), {app: appid}).done(function(response){
|
2012-10-26 22:12:14 +04:00
|
|
|
if(response.status === 'success'){
|
|
|
|
var navEntries=response.nav_entries;
|
|
|
|
for(var i=0; i< navEntries.length; i++){
|
|
|
|
var entry = navEntries[i];
|
2014-06-04 20:22:40 +04:00
|
|
|
var container = $('#apps ul');
|
2012-10-26 22:12:14 +04:00
|
|
|
|
|
|
|
if(container.children('li[data-id="'+entry.id+'"]').length === 0){
|
2013-02-05 14:30:18 +04:00
|
|
|
var li=$('<li></li>');
|
2012-10-26 22:12:14 +04:00
|
|
|
li.attr('data-id', entry.id);
|
2013-02-14 18:47:48 +04:00
|
|
|
var img= $('<img class="icon"/>').attr({ src: entry.icon});
|
2013-01-31 10:22:56 +04:00
|
|
|
var a=$('<a></a>').attr('href', entry.href);
|
2013-06-29 00:10:40 +04:00
|
|
|
var filename=$('<span></span>');
|
2013-04-12 16:45:59 +04:00
|
|
|
filename.text(entry.name);
|
|
|
|
a.prepend(filename);
|
2013-02-03 19:02:25 +04:00
|
|
|
a.prepend(img);
|
2012-10-26 22:12:14 +04:00
|
|
|
li.append(a);
|
2014-02-26 13:34:38 +04:00
|
|
|
|
|
|
|
// append the new app as last item in the list
|
2014-06-04 20:22:40 +04:00
|
|
|
// which is the "add apps" entry with the id
|
|
|
|
// #apps-management
|
|
|
|
$('#apps-management').before(li);
|
2014-02-26 13:34:38 +04:00
|
|
|
|
|
|
|
// scroll the app navigation down
|
|
|
|
// so the newly added app is seen
|
|
|
|
$('#navigation').animate({
|
|
|
|
scrollTop: $('#navigation').height()
|
|
|
|
}, 'slow');
|
|
|
|
|
|
|
|
// draw attention to the newly added app entry
|
|
|
|
// by flashing it twice
|
2014-06-04 20:22:40 +04:00
|
|
|
$('#header .menutoggle')
|
2014-06-05 12:52:06 +04:00
|
|
|
.animate({opacity: 0.5})
|
2014-02-26 13:34:38 +04:00
|
|
|
.animate({opacity: 1})
|
2014-06-05 12:52:06 +04:00
|
|
|
.animate({opacity: 0.5})
|
2014-06-04 20:22:40 +04:00
|
|
|
.animate({opacity: 1})
|
2014-06-05 12:52:06 +04:00
|
|
|
.animate({opacity: 0.75});
|
2013-08-07 23:54:28 +04:00
|
|
|
|
2013-06-29 00:18:11 +04:00
|
|
|
if (!SVGSupport() && entry.icon.match(/\.svg$/i)) {
|
2013-06-29 00:10:40 +04:00
|
|
|
$(img).addClass('svg');
|
|
|
|
replaceSVG();
|
|
|
|
}
|
2012-10-26 22:12:14 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2013-08-18 15:49:34 +04:00
|
|
|
},
|
|
|
|
showErrorMessage: function(message) {
|
2013-08-18 19:37:22 +04:00
|
|
|
$('.appinfo .warning').show();
|
|
|
|
$('.appinfo .warning').text(message);
|
2014-04-28 15:27:32 +04:00
|
|
|
},
|
|
|
|
isType: function(app, type){
|
|
|
|
return app.types && app.types.indexOf(type) !== -1;
|
2012-08-04 22:12:18 +04:00
|
|
|
}
|
2012-09-06 00:17:33 +04:00
|
|
|
};
|
2012-08-04 22:12:18 +04:00
|
|
|
|
2011-08-10 14:20:43 +04:00
|
|
|
$(document).ready(function(){
|
2014-03-20 12:04:50 +04:00
|
|
|
$('#app-navigation ul li').each(function(index,li){
|
2012-08-31 00:17:54 +04:00
|
|
|
var app = OC.get('appData_'+$(li).data('id'));
|
2014-04-21 15:00:29 +04:00
|
|
|
if (app) {
|
|
|
|
app.groups= $(li).data('groups') || [];
|
|
|
|
}
|
2011-08-10 14:20:43 +04:00
|
|
|
$(li).data('app',app);
|
2012-08-04 22:12:18 +04:00
|
|
|
$(this).find('span.hidden').remove();
|
2011-08-10 14:20:43 +04:00
|
|
|
});
|
2014-03-20 12:04:50 +04:00
|
|
|
$('#app-navigation ul li').keydown(function(event) {
|
2013-04-17 17:32:03 +04:00
|
|
|
if (event.which === 13 || event.which === 32) {
|
2012-09-06 00:17:33 +04:00
|
|
|
$(event.target).click();
|
2012-05-04 19:54:52 +04:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
2012-08-04 22:12:18 +04:00
|
|
|
|
2014-03-20 12:04:50 +04:00
|
|
|
$(document).on('click', '#app-navigation', function(event){
|
2012-08-04 22:12:18 +04:00
|
|
|
var tgt = $(event.target);
|
|
|
|
if (tgt.is('li') || tgt.is('a')) {
|
|
|
|
var item = tgt.is('li') ? $(tgt) : $(tgt).parent();
|
|
|
|
var app = item.data('app');
|
2012-08-05 01:48:09 +04:00
|
|
|
OC.Settings.Apps.loadApp(app);
|
2014-03-20 12:04:50 +04:00
|
|
|
$('#app-navigation .selected').removeClass('selected');
|
2014-02-26 14:41:32 +04:00
|
|
|
item.addClass('selected');
|
2012-06-04 01:48:59 +04:00
|
|
|
}
|
2012-05-04 19:54:52 +04:00
|
|
|
return false;
|
2011-08-10 14:20:43 +04:00
|
|
|
});
|
2014-03-20 12:04:50 +04:00
|
|
|
$('#app-content input.enable').click(function(){
|
2012-05-15 01:52:40 +04:00
|
|
|
var element = $(this);
|
2012-08-05 01:48:09 +04:00
|
|
|
var appid=$(this).data('appid');
|
2011-08-10 14:20:43 +04:00
|
|
|
var active=$(this).data('active');
|
2012-08-05 01:48:09 +04:00
|
|
|
if(appid) {
|
|
|
|
OC.Settings.Apps.enableApp(appid, active, element);
|
2011-08-10 14:20:43 +04:00
|
|
|
}
|
|
|
|
});
|
2014-03-20 12:04:50 +04:00
|
|
|
$('#app-content input.update').click(function(){
|
2013-01-21 23:40:23 +04:00
|
|
|
var element = $(this);
|
|
|
|
var appid=$(this).data('appid');
|
|
|
|
if(appid) {
|
|
|
|
OC.Settings.Apps.updateApp(appid, element);
|
|
|
|
}
|
|
|
|
});
|
2014-05-31 19:50:39 +04:00
|
|
|
$('#app-content input.uninstall').click(function(){
|
|
|
|
var element = $(this);
|
|
|
|
var appid=$(this).data('appid');
|
|
|
|
if(appid) {
|
|
|
|
OC.Settings.Apps.uninstallApp(appid, element);
|
|
|
|
}
|
|
|
|
});
|
2012-08-04 22:12:18 +04:00
|
|
|
|
2014-04-18 16:29:45 +04:00
|
|
|
$('#group_select').change(function() {
|
|
|
|
var element = $('#app-content input.enable');
|
|
|
|
var groups = $(this).val();
|
|
|
|
var appid = element.data('appid');
|
|
|
|
if (appid) {
|
|
|
|
OC.Settings.Apps.enableApp(appid, false, element, groups);
|
2014-05-08 20:07:06 +04:00
|
|
|
var li = $('[data-id="'+appid+'"]');
|
2014-05-08 13:18:41 +04:00
|
|
|
var app = OC.get('appData_' + $(li).data('id'));
|
|
|
|
app.groups = groups;
|
|
|
|
li.data('groups', groups);
|
|
|
|
li.attr('data-groups', JSON.stringify(groups));
|
2014-04-18 16:29:45 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-06-25 07:02:01 +04:00
|
|
|
if(appid) {
|
2014-03-20 12:04:50 +04:00
|
|
|
var item = $('#app-navigation ul li[data-id="'+appid+'"]');
|
2012-06-25 07:02:01 +04:00
|
|
|
if(item) {
|
|
|
|
item.trigger('click');
|
|
|
|
item.addClass('active');
|
2014-03-20 12:04:50 +04:00
|
|
|
$('#app-navigation').animate({scrollTop: $(item).offset().top-70}, 'slow','swing');
|
2012-06-25 07:02:01 +04:00
|
|
|
}
|
|
|
|
}
|
2014-04-18 16:29:45 +04:00
|
|
|
|
|
|
|
$("#groups_enable").change(function() {
|
|
|
|
if (this.checked) {
|
|
|
|
$("div.multiselect").parent().remove();
|
|
|
|
$('#group_select').multiSelect();
|
|
|
|
} else {
|
|
|
|
$('#group_select').hide().val(null);
|
|
|
|
$("div.multiselect").parent().remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#group_select').change();
|
|
|
|
});
|
2011-08-10 14:20:43 +04:00
|
|
|
});
|