aboutsummaryrefslogtreecommitdiffstats
path: root/admin/themes/default/template
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2014-05-27 21:47:57 +0000
committermistic100 <mistic@piwigo.org>2014-05-27 21:47:57 +0000
commit82b52dd0c0b33c67ac10d44d4f1411da2838ba29 (patch)
tree3bcd0d72898b6921d4430b148eb9b316629a98d4 /admin/themes/default/template
parentaf740fa3e4e5217539b3f2826fba0b453ba2c66b (diff)
feature 3077 : factorize code for cache/selectize
git-svn-id: http://piwigo.org/svn/trunk@28550 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/themes/default/template/batch_manager_global.tpl52
-rw-r--r--admin/themes/default/template/batch_manager_unit.tpl38
-rw-r--r--admin/themes/default/template/cat_perm.tpl74
-rw-r--r--admin/themes/default/template/picture_modify.tpl42
4 files changed, 23 insertions, 183 deletions
diff --git a/admin/themes/default/template/batch_manager_global.tpl b/admin/themes/default/template/batch_manager_global.tpl
index a5a48e8de..00cdc50f3 100644
--- a/admin/themes/default/template/batch_manager_global.tpl
+++ b/admin/themes/default/template/batch_manager_global.tpl
@@ -68,55 +68,13 @@ jQuery(document).ready(function() {ldelim}
jQuery("a.preview-box").colorbox();
{* <!-- TAGS --> *}
- var tagsCache = new LocalStorageCache({
- key: 'tagsAdminList',
+ var tagsCache = new TagsCache({
serverKey: '{$CACHE_KEYS.tags}',
serverId: '{$CACHE_KEYS._hash}',
-
- loader: function(callback) {
- jQuery.getJSON('{$ROOT_URL}ws.php?format=json&method=pwg.tags.getAdminList', function(data) {
- var tags = data.result.tags;
-
- for (var i=0, l=tags.length; i<l; i++) {
- tags[i].id = '~~' + tags[i].id + '~~';
- }
-
- callback(tags);
- });
- }
- });
-
- jQuery('[data-selectize=tags]').selectize({
- valueField: 'id',
- labelField: 'name',
- searchField: ['name'],
- plugins: ['remove_button']
- });
-
- jQuery('[data-selectize=tags-create]').selectize({
- valueField: 'id',
- labelField: 'name',
- searchField: ['name'],
- plugins: ['remove_button'],
- create: true
+ rootUrl: '{$ROOT_URL}'
});
-
- tagsCache.get(function(tags) {
- jQuery('[data-selectize^=tags]').each(function() {
- this.selectize.load(function(callback) {
- // one select is populated with <option>
- if (jQuery.isEmptyObject(this.options)) {
- callback(tags);
- }
- });
- if (jQuery(this).data('value')) {
- jQuery.each(jQuery(this).data('value'), jQuery.proxy(function(i, tag) {
- this.selectize.addItem(tag.id);
- }, this));
- }
- });
- });
+ tagsCache.selectize(jQuery('[data-selectize=tags]'));
{* <!-- CATEGORIES --> *}
var categoriesCache = new CategoriesCache({
@@ -654,7 +612,7 @@ $(document).ready(function() {
<input type="checkbox" name="filter_tags_use" class="useFilterCheckbox" {if isset($filter.tags)}checked="checked"{/if}>
{'Tags'|@translate}
<select data-selectize="tags" data-value="{$filter_tags|@json_encode|escape:html}"
- name="filter_tags[]" multiple style="width:400px;" ></select>
+ name="filter_tags[]" multiple style="width:400px;"></select>
<label><span><input type="radio" name="tag_mode" value="AND" {if !isset($filter.tag_mode) or $filter.tag_mode eq 'AND'}checked="checked"{/if}> {'All tags'|@translate}</span></label>
<label><span><input type="radio" name="tag_mode" value="OR" {if isset($filter.tag_mode) and $filter.tag_mode eq 'OR'}checked="checked"{/if}> {'Any tag'|@translate}</span></label>
</li>
@@ -874,7 +832,7 @@ UL.thumbnails SPAN.wrap2 {ldelim}
<!-- add_tags -->
<div id="action_add_tags" class="bulkAction">
- <select data-selectize="tags-create" name="add_tags[]" multiple style="width:400px;"></select>
+ <select data-selectize="tags" data-selectize-create name="add_tags[]" multiple style="width:400px;"></select>
</div>
<!-- del_tags -->
diff --git a/admin/themes/default/template/batch_manager_unit.tpl b/admin/themes/default/template/batch_manager_unit.tpl
index 6d5a90ddd..27f8cd721 100644
--- a/admin/themes/default/template/batch_manager_unit.tpl
+++ b/admin/themes/default/template/batch_manager_unit.tpl
@@ -10,43 +10,13 @@
{footer_script}
(function(){
{* <!-- TAGS --> *}
-var tagsCache = new LocalStorageCache({
- key: 'tagsAdminList',
+var tagsCache = new TagsCache({
serverKey: '{$CACHE_KEYS.tags}',
serverId: '{$CACHE_KEYS._hash}',
-
- loader: function(callback) {
- jQuery.getJSON('{$ROOT_URL}ws.php?format=json&method=pwg.tags.getAdminList', function(data) {
- var tags = data.result.tags;
-
- for (var i=0, l=tags.length; i<l; i++) {
- tags[i].id = '~~' + tags[i].id + '~~';
- }
-
- callback(tags);
- });
- }
-});
-
-jQuery('[data-selectize=tags]').selectize({
- valueField: 'id',
- labelField: 'name',
- searchField: ['name'],
- plugins: ['remove_button'],
- create: true
+ rootUrl: '{$ROOT_URL}'
});
-tagsCache.get(function(tags) {
- jQuery('[data-selectize=tags]').each(function() {
- this.selectize.load(function(callback) {
- callback(tags);
- });
-
- jQuery.each(jQuery(this).data('value'), jQuery.proxy(function(i, tag) {
- this.selectize.addItem(tag.id);
- }, this));
- });
-});
+tagsCache.selectize(jQuery('[data-selectize=tags]'));
{* <!-- DATEPICKER --> *}
jQuery(function(){ {* <!-- onLoad needed to wait localization loads --> *}
@@ -128,7 +98,7 @@ $(".elementEdit img")
<td><strong>{'Tags'|@translate}</strong></td>
<td>
<select data-selectize="tags" data-value="{$element.TAGS|@json_encode|escape:html}"
- name="tags-{$element.id}[]" multiple style="width:500px;" ></select>
+ name="tags-{$element.id}[]" multiple style="width:500px;" data-selectize-create></select>
</td>
</tr>
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(){
{* <!-- GROUPS --> *}
-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]'));
{* <!-- USERS --> *}
-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]'));
{* <!-- TOGGLES --> *}
function checkStatusOptions() {
@@ -130,7 +72,7 @@ jQuery("#selectStatus").change(function() {
<strong>{'Permission granted for groups'|@translate}</strong>
<br>
<select data-selectize="groups" data-value="{$groups_selected|@json_encode|escape:html}"
- name="groups[]" multiple style="width:600px;" ></select>
+ name="groups[]" multiple style="width:600px;"></select>
{else}
{'There is no group in this gallery.'|@translate} <a href="admin.php?page=group_list" class="externalLink">{'Group management'|@translate}</a>
{/if}
@@ -140,7 +82,7 @@ jQuery("#selectStatus").change(function() {
<strong>{'Permission granted for users'|@translate}</strong>
<br>
<select data-selectize="users" data-value="{$users_selected|@json_encode|escape:html}"
- name="users[]" multiple style="width:600px;" ></select>
+ name="users[]" multiple style="width:600px;"></select>
</p>
{if isset($nb_users_granted_indirect) && $nb_users_granted_indirect>0}
diff --git a/admin/themes/default/template/picture_modify.tpl b/admin/themes/default/template/picture_modify.tpl
index 454a06428..60c98140d 100644
--- a/admin/themes/default/template/picture_modify.tpl
+++ b/admin/themes/default/template/picture_modify.tpl
@@ -24,43 +24,13 @@ categoriesCache.selectize(jQuery('[data-selectize=categories]'), { {if $STORAGE_
{/if} });
{* <!-- TAGS --> *}
-var tagsCache = new LocalStorageCache({
- key: 'tagsAdminList',
+var tagsCache = new TagsCache({
serverKey: '{$CACHE_KEYS.tags}',
serverId: '{$CACHE_KEYS._hash}',
-
- loader: function(callback) {
- jQuery.getJSON('{$ROOT_URL}ws.php?format=json&method=pwg.tags.getAdminList', function(data) {
- var tags = data.result.tags;
-
- for (var i=0, l=tags.length; i<l; i++) {
- tags[i].id = '~~' + tags[i].id + '~~';
- }
-
- callback(tags);
- });
- }
-});
-
-jQuery('[data-selectize=tags]').selectize({
- valueField: 'id',
- labelField: 'name',
- searchField: ['name'],
- plugins: ['remove_button'],
- create: true
+ rootUrl: '{$ROOT_URL}'
});
-tagsCache.get(function(tags) {
- jQuery('[data-selectize=tags]').each(function() {
- this.selectize.load(function(callback) {
- callback(tags);
- });
-
- jQuery.each(jQuery(this).data('value'), jQuery.proxy(function(i, tag) {
- this.selectize.addItem(tag.id);
- }, this));
- });
-});
+tagsCache.selectize(jQuery('[data-selectize=tags]'));
{* <!-- DATEPICKER --> *}
jQuery(function(){ {* <!-- onLoad needed to wait localization loads --> *}
@@ -139,21 +109,21 @@ jQuery(function(){ {* <!-- onLoad needed to wait localization loads --> *}
<strong>{'Linked albums'|@translate}</strong>
<br>
<select data-selectize="categories" data-value="{$associated_albums|@json_encode|escape:html}"
- name="associate[]" multiple style="width:600px;" ></select>
+ name="associate[]" multiple style="width:600px;"></select>
</p>
<p>
<strong>{'Representation of albums'|@translate}</strong>
<br>
<select data-selectize="categories" data-value="{$represented_albums|@json_encode|escape:html}"
- name="represent[]" multiple style="width:600px;" ></select>
+ name="represent[]" multiple style="width:600px;"></select>
</p>
<p>
<strong>{'Tags'|@translate}</strong>
<br>
<select data-selectize="tags" data-value="{$tag_selection|@json_encode|escape:html}"
- name="tags[]" multiple style="width:600px;" ></select>
+ name="tags[]" multiple style="width:600px;" data-selectize-create></select>
</p>
<p>