Skip to content

Commit

Permalink
feature 3077 : use Selectize on batch_manager_global
Browse files Browse the repository at this point in the history
git-svn-id: http://piwigo.org/svn/trunk@28502 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
mistic100 committed May 18, 2014
1 parent 2755a2f commit 40fa9b3
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 50 deletions.
8 changes: 1 addition & 7 deletions admin/batch_manager_global.php
Expand Up @@ -554,13 +554,7 @@
if (count($page['cat_elements_id']) > 0)
{
// remove tags
$tags = get_common_tags($page['cat_elements_id'], -1);

$template->assign(
array(
'DEL_TAG_SELECTION' => get_html_tag_selection($tags, 'del_tags'),
)
);
$template->assign('associated_tags', get_common_tags($page['cat_elements_id'], -1));
}

// creation date
Expand Down
114 changes: 71 additions & 43 deletions admin/themes/default/template/batch_manager_global.tpl
Expand Up @@ -4,9 +4,18 @@
{include file='include/add_album.inc.tpl'}

{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'}

{combine_script id='jquery.ui.slider' require='jquery.ui' load='footer' path='themes/default/js/ui/minified/jquery.ui.slider.min.js'}
{combine_css path="themes/default/js/ui/theme/jquery.ui.slider.css"}

{combine_script id='LocalStorageCache' load='footer' path='admin/themes/default/js/LocalStorageCache.js'}

{combine_script id='jquery.selectize' load='footer' path='themes/default/js/plugins/selectize.min.js'}
{combine_css id='jquery.selectize' path="themes/default/js/plugins/selectize.default.css"}

{combine_script id='jquery.progressBar' load='footer' path='themes/default/js/plugins/jquery.progressbar.min.js'}
{combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'}

{footer_script}{literal}
/* Shift-click: select all photos between the click and the shift+click */
jQuery(document).ready(function() {
Expand Down Expand Up @@ -51,49 +60,66 @@ jQuery(document).ready(function() {
}
$('ul.thumbnails').enableShiftClick();
});
{/literal}{/footer_script}

{combine_css path='themes/default/js/plugins/jquery.tokeninput.css'}
{combine_script id='jquery.tokeninput' load='footer' require='jquery' path='themes/default/js/plugins/jquery.tokeninput.js'}
{combine_script id='jquery.progressBar' load='footer' path='themes/default/js/plugins/jquery.progressbar.min.js'}
{combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'}
{/literal}

{footer_script require='jquery.tokeninput'}
jQuery(document).ready(function() {ldelim}
jQuery('[data-datepicker]').pwgDatepicker({ showTimepicker: true });

jQuery("a.preview-box").colorbox();

var tag_src = [{foreach from=$tags item=tag name=tags}{ldelim}name:"{$tag.name|@escape:'javascript'}",id:"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}];
jQuery("#tags").tokenInput(
tag_src,
{ldelim}
hintText: '{'Type in a search term'|@translate}',
noResultsText: '{'No results'|@translate}',
searchingText: '{'Searching...'|@translate}',
newText: ' ({'new'|@translate})',
animateDropdown: false,
preventDuplicates: true,
allowFreeTagging: true
}
);

jQuery("#tagsFilter").tokenInput(
tag_src,
{ldelim}
hintText: '{'Type in a search term'|@translate}',
noResultsText: '{'No results'|@translate}',
searchingText: '{'Searching...'|@translate}',
animateDropdown: false,
preventDuplicates: true,
allowFreeTagging: false
{* <!-- TAGS --> *}
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;
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: function(input, callback) {
tagsCache.clear();
callback({
id: input,
name: input
});
}
);
});

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));
}
});
});
});
{/footer_script}

{footer_script}
var nb_thumbs_page = {$nb_thumbs_page};
var nb_thumbs_set = {$nb_thumbs_set};
var are_you_sure = "{'Are you sure?'|@translate|@escape:'javascript'}";
Expand Down Expand Up @@ -606,11 +632,8 @@ $(document).ready(function() {
<a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
<input type="checkbox" name="filter_tags_use" class="useFilterCheckbox" {if isset($filter.tags)}checked="checked"{/if}>
{'Tags'|@translate}
<select id="tagsFilter" name="filter_tags">
{if isset($filter_tags)}{foreach from=$filter_tags item=tag}
<option value="{$tag.id}">{$tag.name}</option>
{/foreach}{/if}
</select>
<select data-selectize="tags" data-value="{if isset($filter_tags)}{$filter_tags|@json_encode|escape:html}{else}[]{/if}"
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>
Expand Down Expand Up @@ -670,7 +693,7 @@ $(document).ready(function() {
{'Search'|@translate}
<input name="q" size=40 value="{$filter.search.q|stripslashes|htmlspecialchars}">
{combine_script id='core.scripts' load='async' path='themes/default/js/scripts.js'}
<a href="admin/popuphelp.php?page=quick_search"onclick="popuphelp(this.href);return false;" title="{'Help'|@translate}"><span class="icon-help-circled"></span></a>
<a href="admin/popuphelp.php?page=quick_search" onclick="popuphelp(this.href);return false;" title="{'Help'|@translate}"><span class="icon-help-circled"></span></a>
</li>
</ul>

Expand Down Expand Up @@ -782,7 +805,7 @@ UL.thumbnails SPAN.wrap2 {ldelim}
<option value="dissociate">{'Dissociate from album'|@translate}</option>
{/if}
<option value="add_tags">{'Add tags'|@translate}</option>
{if !empty($DEL_TAG_SELECTION)}
{if !empty($associated_tags)}
<option value="del_tags">{'remove tags'|@translate}</option>
{/if}
<option value="author">{'Set author'|@translate}</option>
Expand Down Expand Up @@ -836,13 +859,18 @@ UL.thumbnails SPAN.wrap2 {ldelim}

<!-- add_tags -->
<div id="action_add_tags" class="bulkAction">
<select id="tags" name="add_tags">
</select>
<select data-selectize="tags-create" name="add_tags[]" multiple style="width:400px;"></select>
</div>

<!-- del_tags -->
<div id="action_del_tags" class="bulkAction">
{if !empty($DEL_TAG_SELECTION)}{$DEL_TAG_SELECTION}{/if}
{if !empty($associated_tags)}
<select data-selectize="tags" name="del_tags[]" multiple style="width:400px;">
{foreach from=$associated_tags item=tag}
<option value="{$tag.id}">{$tag.name}</option>
{/foreach}
</select>
{/if}
</div>

<!-- author -->
Expand Down

0 comments on commit 40fa9b3

Please sign in to comment.