aboutsummaryrefslogtreecommitdiffstats
path: root/settings/js
diff options
context:
space:
mode:
Diffstat (limited to 'settings/js')
-rw-r--r--settings/js/apps.js133
-rw-r--r--settings/js/personal.js4
2 files changed, 87 insertions, 50 deletions
diff --git a/settings/js/apps.js b/settings/js/apps.js
index f844bcc08e2..c15d6a0f74d 100644
--- a/settings/js/apps.js
+++ b/settings/js/apps.js
@@ -330,67 +330,104 @@ OC.Settings.Apps = OC.Settings.Apps || {
$('div#app-'+appId+' .warning')
.hide()
.text('');
- }
+ },
-};
+ filter: function(query) {
+ query = query.toLowerCase();
+ $('#apps-list').find('.section').addClass('hidden');
-$(document).ready(function () {
- OC.Settings.Apps.loadCategories();
+ var apps = _.filter(OC.Settings.Apps.State.apps, function (app) {
+ return app.name.toLowerCase().indexOf(query) !== -1;
+ });
- $(document).on('click', 'ul#apps-categories li', function () {
- var categoryId = $(this).data('categoryId');
- OC.Settings.Apps.loadCategory(categoryId);
- });
+ apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) {
+ return app.description.toLowerCase().indexOf(query) !== -1;
+ }));
- $(document).on('click', '#apps-list input.enable', function () {
- var appId = $(this).data('appid');
- var element = $(this);
- var active = $(this).data('active');
+ apps = _.uniq(apps, function(app){return app.id;});
- OC.Settings.Apps.enableApp(appId, active, element);
- });
+ _.each(apps, function (app) {
+ $('#app-' + app.id).removeClass('hidden');
+ });
- $(document).on('click', '#apps-list input.uninstall', function () {
- var appId = $(this).data('appid');
- var element = $(this);
+ $('#searchresults').hide();
+ },
- OC.Settings.Apps.uninstallApp(appId, element);
- });
+ /**
+ * Initializes the apps list
+ */
+ initialize: function($el) {
+ OC.Plugins.register('OCA.Search', OC.Settings.Apps.Search);
+ OC.Settings.Apps.loadCategories();
- $(document).on('click', '#apps-list input.update', function () {
- var appId = $(this).data('appid');
- var element = $(this);
+ $(document).on('click', 'ul#apps-categories li', function () {
+ var categoryId = $(this).data('categoryId');
+ OC.Settings.Apps.loadCategory(categoryId);
+ });
- OC.Settings.Apps.updateApp(appId, element);
- });
+ $(document).on('click', '#apps-list input.enable', function () {
+ var appId = $(this).data('appid');
+ var element = $(this);
+ var active = $(this).data('active');
- $(document).on('change', '#group_select', function() {
- var element = $(this).parent().find('input.enable');
- var groups = $(this).val();
- if (groups && groups !== '') {
- groups = groups.split(',');
- } else {
- groups = [];
- }
+ OC.Settings.Apps.enableApp(appId, active, element);
+ });
- var appId = element.data('appid');
- if (appId) {
- OC.Settings.Apps.enableApp(appId, false, element, groups);
- OC.Settings.Apps.State.apps[appId].groups = groups;
- }
- });
+ $(document).on('click', '#apps-list input.uninstall', function () {
+ var appId = $(this).data('appid');
+ var element = $(this);
- $(document).on('change', ".groups-enable", function() {
- var $select = $(this).parent().find('#group_select');
- $select.val('');
+ OC.Settings.Apps.uninstallApp(appId, element);
+ });
- if (this.checked) {
- OC.Settings.Apps.setupGroupsSelect($select);
- } else {
- $select.select2('destroy');
- }
+ $(document).on('click', '#apps-list input.update', function () {
+ var appId = $(this).data('appid');
+ var element = $(this);
+
+ OC.Settings.Apps.updateApp(appId, element);
+ });
+
+ $(document).on('change', '#group_select', function() {
+ var element = $(this).parent().find('input.enable');
+ var groups = $(this).val();
+ if (groups && groups !== '') {
+ groups = groups.split(',');
+ } else {
+ groups = [];
+ }
+
+ var appId = element.data('appid');
+ if (appId) {
+ OC.Settings.Apps.enableApp(appId, false, element, groups);
+ OC.Settings.Apps.State.apps[appId].groups = groups;
+ }
+ });
+
+ $(document).on('change', ".groups-enable", function() {
+ var $select = $(this).parent().find('#group_select');
+ $select.val('');
+
+ if (this.checked) {
+ OC.Settings.Apps.setupGroupsSelect($select);
+ } else {
+ $select.select2('destroy');
+ }
- $select.change();
- });
+ $select.change();
+ });
+ }
+};
+
+OC.Settings.Apps.Search = {
+ attach: function (search) {
+ search.setFilter('settings', OC.Settings.Apps.filter);
+ }
+};
+
+$(document).ready(function () {
+ // HACK: FIXME: use plugin approach
+ if (!window.TESTING) {
+ OC.Settings.Apps.initialize($('#apps-list'));
+ }
});
diff --git a/settings/js/personal.js b/settings/js/personal.js
index a157c1b5c0c..e2fb6f025f1 100644
--- a/settings/js/personal.js
+++ b/settings/js/personal.js
@@ -110,7 +110,7 @@ function showAvatarCropper () {
var $cropperImage = $('#cropper img');
$cropperImage.attr('src',
- OC.generateUrl('/avatar/tmp') + '?requesttoken=' + oc_requesttoken + '#' + Math.floor(Math.random() * 1000));
+ OC.generateUrl('/avatar/tmp') + '?requesttoken=' + encodeURIComponent(oc_requesttoken) + '#' + Math.floor(Math.random() * 1000));
// Looks weird, but on('load', ...) doesn't work in IE8
$cropperImage.ready(function () {
@@ -316,7 +316,7 @@ $(document).ready(function () {
var url = OC.generateUrl(
'/avatar/{user}/{size}',
{user: OC.currentUser, size: 1}
- ) + '?requesttoken=' + oc_requesttoken;
+ ) + '?requesttoken=' + encodeURIComponent(oc_requesttoken);
$.get(url, function (result) {
if (typeof(result) === 'object') {
$('#removeavatar').hide();