From 44c27a5d386e5b5b1e1e54d1cd11e7af4b962032 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 29 Oct 2019 21:26:12 +0100 Subject: [PATCH] No need to define a custom helper for selectAllOrNone, have this directly in backup's controllers --- src/js/yunohost/controllers/backup.js | 29 +++++++++++++++++++++++++-- src/js/yunohost/helpers.js | 14 ------------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/js/yunohost/controllers/backup.js b/src/js/yunohost/controllers/backup.js index 1eaf5777..42a5d455 100644 --- a/src/js/yunohost/controllers/backup.js +++ b/src/js/yunohost/controllers/backup.js @@ -62,7 +62,21 @@ data['apps'] = {}; c.api('GET', '/apps?with_backup', {}, function(apps_list) { data['apps'] = apps_list.apps; - c.view('backup/backup_create', data, c.selectAllOrNone); + c.view('backup/backup_create', data, function() { + + // Configure buttons "select all" and "select none" + + // Remove active style from buttons + $(".select_all-none input").click(function(){ $(this).toggleClass("active"); }); + // Select all checkbox in this panel + $(".select_all").click(function(){ + $(this).parents(".panel").children(".list-group").find("input").prop("checked", true); + }); + // Deselect all checkbox in this panel + $(".select_none").click(function(){ + $(this).parents(".panel").children(".list-group").find("input").prop("checked", false); + }); + }); }); }); }); @@ -88,7 +102,18 @@ data.locale = y18n.locale; c.view('backup/backup_info', data, function() { - c.selectAllOrNone(); + // Configure buttons "select all" and "select none" + + // Remove active style from buttons + $(".select_all-none input").click(function(){ $(this).toggleClass("active"); }); + // Select all checkbox in this panel + $(".select_all").click(function(){ + $(this).parents(".panel").children(".list-group").find("input").prop("checked", true); + }); + // Deselect all checkbox in this panel + $(".select_none").click(function(){ + $(this).parents(".panel").children(".list-group").find("input").prop("checked", false); + }); // Delete button $('button[data-action="delete"]').on('click', function() { diff --git a/src/js/yunohost/helpers.js b/src/js/yunohost/helpers.js index 0ba638e2..0798820a 100644 --- a/src/js/yunohost/helpers.js +++ b/src/js/yunohost/helpers.js @@ -497,20 +497,6 @@ // Misc helpers used in views etc.. // - selectAllOrNone: function () { - // Remove active style from buttons - $(".select_all-none input").click(function(){ $(this).toggleClass("active"); }); - // Select all checkbox in this panel - $(".select_all").click(function(){ - $(this).parents(".panel").children(".list-group").find("input").prop("checked", true); - }); - // Deselect all checkbox in this panel - $(".select_none").click(function(){ - $(this).parents(".panel").children(".list-group").find("input").prop("checked", false); - }); - }, - - // Paste
         prePaste: function() {
             var pasteButtons = $('button[data-paste-content],a[data-paste-content]');