From 82b52dd0c0b33c67ac10d44d4f1411da2838ba29 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Tue, 27 May 2014 21:47:57 +0000 Subject: feature 3077 : factorize code for cache/selectize git-svn-id: http://piwigo.org/svn/trunk@28550 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/themes/default/template/cat_perm.tpl | 74 ++++-------------------------- 1 file changed, 8 insertions(+), 66 deletions(-) (limited to 'admin/themes/default/template/cat_perm.tpl') diff --git a/admin/themes/default/template/cat_perm.tpl b/admin/themes/default/template/cat_perm.tpl index d810475b2..edaab262a 100644 --- a/admin/themes/default/template/cat_perm.tpl +++ b/admin/themes/default/template/cat_perm.tpl @@ -6,80 +6,22 @@ {footer_script} (function(){ {* *} -var groupsCache = new LocalStorageCache({ - key: 'groupsAdminList', +var groupsCache = new GroupsCache({ serverKey: '{$CACHE_KEYS.groups}', serverId: '{$CACHE_KEYS._hash}', - - loader: function(callback) { - jQuery.getJSON('{$ROOT_URL}ws.php?format=json&method=pwg.groups.getList&per_page=99999', function(data) { - callback(data.result.groups); - }); - } -}); - -jQuery('[data-selectize=groups]').selectize({ - valueField: 'id', - labelField: 'name', - searchField: ['name'], - plugins: ['remove_button'] + rootUrl: '{$ROOT_URL}' }); -groupsCache.get(function(groups) { - jQuery('[data-selectize=groups]').each(function() { - this.selectize.load(function(callback) { - callback(groups); - }); - - jQuery.each(jQuery(this).data('value'), jQuery.proxy(function(i, id) { - this.selectize.addItem(id); - }, this)); - }); -}); +groupsCache.selectize(jQuery('[data-selectize=groups]')); {* *} -var usersCache = new LocalStorageCache({ - key: 'usersAdminList', +var usersCache = new UsersCache({ serverKey: '{$CACHE_KEYS.users}', serverId: '{$CACHE_KEYS._hash}', - - loader: function(callback) { - var users = []; - - // recursive loader - (function load(page){ - jQuery.getJSON('{$ROOT_URL}ws.php?format=json&method=pwg.users.getList&display=username&per_page=99999&page='+ page, function(data) { - users = users.concat(data.result.users); - - if (data.result.paging.count == data.result.paging.per_page) { - load(++page); - } - else { - callback(users); - } - }); - }(0)); - } -}); - -jQuery('[data-selectize=users]').selectize({ - valueField: 'id', - labelField: 'username', - searchField: ['username'], - plugins: ['remove_button'] + rootUrl: '{$ROOT_URL}' }); -usersCache.get(function(users) { - jQuery('[data-selectize=users]').each(function() { - this.selectize.load(function(callback) { - callback(users); - }); - - jQuery.each(jQuery(this).data('value'), jQuery.proxy(function(i, id) { - this.selectize.addItem(id); - }, this)); - }); -}); +usersCache.selectize(jQuery('[data-selectize=users]')); {* *} function checkStatusOptions() { @@ -130,7 +72,7 @@ jQuery("#selectStatus").change(function() { {'Permission granted for groups'|@translate}
+ name="groups[]" multiple style="width:600px;"> {else} {'There is no group in this gallery.'|@translate} {'Group management'|@translate} {/if} @@ -140,7 +82,7 @@ jQuery("#selectStatus").change(function() { {'Permission granted for users'|@translate}
+ name="users[]" multiple style="width:600px;">

{if isset($nb_users_granted_indirect) && $nb_users_granted_indirect>0} -- cgit v1.2.3