From ad10a97f4ac3ffad5508b90da45b5c5a63db95ff Mon Sep 17 00:00:00 2001 From: mistic100 Date: Sat, 24 May 2014 16:24:52 +0000 Subject: feature 3077 : use selectize on batch_manager_global, cat_modify and photos_add_direct + rewrite "add album" popup (more flexible and working with selectize) git-svn-id: http://piwigo.org/svn/trunk@28533 68402e56-0260-453c-a942-63ccdbb3a9ee --- .../default/template/batch_manager_global.tpl | 81 ++++++++++++++++------ 1 file changed, 59 insertions(+), 22 deletions(-) (limited to 'admin/themes/default/template/batch_manager_global.tpl') diff --git a/admin/themes/default/template/batch_manager_global.tpl b/admin/themes/default/template/batch_manager_global.tpl index 087f9916a..4fdad75d3 100644 --- a/admin/themes/default/template/batch_manager_global.tpl +++ b/admin/themes/default/template/batch_manager_global.tpl @@ -117,6 +117,55 @@ jQuery(document).ready(function() {ldelim} } }); }); + + {* *} + var categoriesCache = new LocalStorageCache({ + key: 'categoriesAdminList', + serverKey: '{$CACHE_KEYS.categories}', + serverId: '{$CACHE_KEYS._hash}', + + loader: function(callback) { + jQuery.getJSON('{$ROOT_URL}ws.php?format=json&method=pwg.categories.getAdminList', function(data) { + callback(data.result.categories); + }); + } + }); + + jQuery('[data-selectize=categories]').selectize({ + valueField: 'id', + labelField: 'fullname', + sortField: 'fullname', + searchField: ['fullname'], + plugins: ['remove_button'] + }); + + categoriesCache.get(function(categories) { + categories.sort(function(a, b) { + return a.fullname.localeCompare(b.fullname); + }); + + jQuery('[data-selectize=categories]').each(function() { + this.selectize.load(function(callback) { + callback(categories); + }); + + if (jQuery(this).data('value')) { + this.selectize.setValue(jQuery(this).data('value')[0]); + } + + // prevent empty value + if (this.selectize.getValue() == '') { + this.selectize.setValue(categories[0].id); + } + this.selectize.on('dropdown_close', function() { + if (this.getValue() == '') { + this.setValue(categories[0].id); + } + }); + }); + }); + + jQuery('[data-add-album]').pwgAddAlbum({ cache: categoriesCache }); }); var nb_thumbs_page = {$nb_thumbs_page}; @@ -228,13 +277,6 @@ $(document).ready(function() { $("[id^=action_]").hide(); $("#action_"+$(this).prop("value")).show(); - /* make sure the #albumSelect is on the right select box so that the */ - /* "add new album" popup fills the right select box */ - if ("associate" == $(this).prop("value") || "move" == $(this).prop("value")) { - jQuery("#albumSelect").removeAttr("id"); - jQuery("#action_"+$(this).prop("value")+" select").attr("id", "albumSelect"); - } - if ($(this).val() != -1) { $("#applyActionBlock").show(); } @@ -621,9 +663,8 @@ $(document).ready(function() { [x] {'Album'|@translate} - + @@ -631,7 +672,7 @@ $(document).ready(function() { [x] {'Tags'|@translate} - @@ -833,26 +874,22 @@ UL.thumbnails SPAN.wrap2 {ldelim}
- -
{'... or '|@translate} {'create a new album'|@translate} + +
{'... or '|@translate} + {'create a new album'|@translate}
- -
{'... or '|@translate} {'create a new album'|@translate} + +
{'... or '|@translate} + {'create a new album'|@translate}
- +
-- cgit v1.2.3