From ce8a29810abe6f7fdf82043b32ca87ba0f14220c Mon Sep 17 00:00:00 2001 From: mistic100 Date: Sat, 17 May 2014 15:33:37 +0000 Subject: feature 3077 : use Selectize with AJAX load/cache on cat_perm and batch_manager_unit git-svn-id: http://piwigo.org/svn/trunk@28496 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/themes/default/template/picture_modify.tpl | 40 +++++++++--------------- 1 file changed, 14 insertions(+), 26 deletions(-) (limited to 'admin/themes/default/template/picture_modify.tpl') diff --git a/admin/themes/default/template/picture_modify.tpl b/admin/themes/default/template/picture_modify.tpl index dd49fbd86..50392f7ab 100644 --- a/admin/themes/default/template/picture_modify.tpl +++ b/admin/themes/default/template/picture_modify.tpl @@ -10,7 +10,7 @@ {footer_script} (function(){ {* *} -var categoriesCache = new LocalStorageCache('categoriesAdminList', 60, function(callback) { +var categoriesCache = new LocalStorageCache('categoriesAdminList', 5*60, function(callback) { jQuery.getJSON('{$ROOT_URL}ws.php?format=json&method=pwg.categories.getAdminList', function(data) { callback(data.result.categories); }); @@ -24,25 +24,19 @@ jQuery('[data-selectize=categories]').selectize({ }); categoriesCache.get(function(categories) { - var selects = jQuery('[data-selectize=categories]'); - - jQuery.each(categories, function(i, category) { - selects.each(function() { - this.selectize.addOption(category); + jQuery('[data-selectize=categories]').each(function() { + this.selectize.load(function(callback) { + callback(categories); }); - }); - - selects.each(function() { - var that = this; - jQuery.each(jQuery(this).data('value'), function(i, id) { - that.selectize.addItem(id); - }); + jQuery.each(jQuery(this).data('value'), jQuery.proxy(function(i, id) { + this.selectize.addItem(id); + }, this)); }); }); {* *} -var tagsCache = new LocalStorageCache('tagsAdminList', 60, function(callback) { +var tagsCache = new LocalStorageCache('tagsAdminList', 5*60, function(callback) { jQuery.getJSON('{$ROOT_URL}ws.php?format=json&method=pwg.tags.getAdminList', function(data) { var tags = data.result.tags; @@ -70,20 +64,14 @@ jQuery('[data-selectize=tags]').selectize({ }); tagsCache.get(function(tags) { - var selects = jQuery('[data-selectize=tags]'); - - jQuery.each(tags, function(i, tag) { - selects.each(function() { - this.selectize.addOption(tag); + jQuery('[data-selectize=tags]').each(function() { + this.selectize.load(function(callback) { + callback(tags); }); - }); - - selects.each(function() { - var that = this; - jQuery.each(jQuery(this).data('value'), function(i, tag) { - that.selectize.addItem(tag.id); - }); + jQuery.each(jQuery(this).data('value'), jQuery.proxy(function(i, tag) { + this.selectize.addItem(tag.id); + }, this)); }); }); -- cgit v1.2.3