{include file='include/datepicker.inc.tpl' load_mode='async'} {include file='include/colorbox.inc.tpl' load_mode='async'} {include file='include/add_album.inc.tpl' load_mode='async'} {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'} {assign var="selectizeTheme" value=($themeconf.name=='roma')|ternary:'dark':'default'} {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.`$selectizeTheme`.css"} {combine_script id='jquery.progressBar' load='async' path='themes/default/js/plugins/jquery.progressbar.min.js'} {combine_script id='jquery.ajaxmanager' load='async' path='themes/default/js/plugins/jquery.ajaxmanager.js'} {combine_script id='batchManagerGlobal' load='async' require='jquery,datepicker,jquery.colorbox,addAlbum' path='admin/themes/default/js/batchManagerGlobal.js'} {footer_script} var lang = { Cancel: '{'Cancel'|translate|escape:'javascript'}', AreYouSure: "{'Are you sure?'|translate|escape:'javascript'}" }; jQuery(document).ready(function() { {* *} var tagsCache = new TagsCache({ serverKey: '{$CACHE_KEYS.tags}', serverId: '{$CACHE_KEYS._hash}', rootUrl: '{$ROOT_URL}' }); tagsCache.selectize(jQuery('[data-selectize=tags]'), { lang: { 'Add': '{'Create'|translate}' }}); {* *} window.categoriesCache = new CategoriesCache({ serverKey: '{$CACHE_KEYS.categories}', serverId: '{$CACHE_KEYS._hash}', rootUrl: '{$ROOT_URL}' }); categoriesCache.selectize(jQuery('[data-selectize=categories]'), { filter: function(categories, options) { if (this.name == 'dissociate') { var filtered = jQuery.grep(categories, function(cat) { return !cat.dir; }); if (filtered.length > 0) { jQuery('.albumDissociate').show(); options.default = filtered[0].id; } return filtered; } else { return categories; } } }); }); var nb_thumbs_page = {$nb_thumbs_page}; var nb_thumbs_set = {$nb_thumbs_set}; var applyOnDetails_pattern = "{'on the %d selected photos'|@translate}"; var all_elements = [{if !empty($all_elements)}{','|@implode:$all_elements}{/if}]; var selectedMessage_pattern = "{'%d of %d photos selected'|@translate}"; var selectedMessage_none = "{'No photo selected, %d photos in current set'|@translate}"; var selectedMessage_all = "{'All %d photos are selected'|@translate}"; $(document).ready(function() { function checkPermitAction() { var nbSelected = 0; if ($("input[name=setSelected]").is(':checked')) { nbSelected = nb_thumbs_set; } else { nbSelected = $(".thumbnails input[type=checkbox]").filter(':checked').length; } if (nbSelected == 0) { $("#permitAction").hide(); $("#forbidAction").show(); } else { $("#permitAction").show(); $("#forbidAction").hide(); } $("#applyOnDetails").text( sprintf( applyOnDetails_pattern, nbSelected ) ); // display the number of currently selected photos in the "Selection" fieldset if (nbSelected == 0) { $("#selectedMessage").text( sprintf( selectedMessage_none, nb_thumbs_set ) ); } else if (nbSelected == nb_thumbs_set) { $("#selectedMessage").text( sprintf( selectedMessage_all, nb_thumbs_set ) ); } else { $("#selectedMessage").text( sprintf( selectedMessage_pattern, nbSelected, nb_thumbs_set ) ); } } $("[id^=action_]").hide(); $("select[name=selectAction]").change(function () { $("[id^=action_]").hide(); $("#action_"+$(this).prop("value")).show(); if ($(this).val() != -1) { $("#applyActionBlock").show(); } else { $("#applyActionBlock").hide(); } }); $(".wrap1 label").click(function (event) { $("input[name=setSelected]").prop('checked', false); var wrap2 = $(this).children(".wrap2"); var checkbox = $(this).children("input[type=checkbox]"); checkbox.triggerHandler("shclick",event); if ($(checkbox).is(':checked')) { $(wrap2).addClass("thumbSelected"); } else { $(wrap2).removeClass('thumbSelected'); } checkPermitAction(); }); $("#selectAll").click(function () { $("input[name=setSelected]").prop('checked', false); selectPageThumbnails(); checkPermitAction(); return false; }); function selectPageThumbnails() { $(".thumbnails label").each(function() { var wrap2 = $(this).children(".wrap2"); var checkbox = $(this).children("input[type=checkbox]"); $(checkbox).prop('checked', true); $(wrap2).addClass("thumbSelected"); }); } $("#selectNone").click(function () { $("input[name=setSelected]").prop('checked', false); $(".thumbnails label").each(function() { var wrap2 = $(this).children(".wrap2"); var checkbox = $(this).children("input[type=checkbox]"); $(checkbox).prop('checked', false); $(wrap2).removeClass("thumbSelected"); }); checkPermitAction(); return false; }); $("#selectInvert").click(function () { $("input[name=setSelected]").prop('checked', false); $(".thumbnails label").each(function() { var wrap2 = $(this).children(".wrap2"); var checkbox = $(this).children("input[type=checkbox]"); $(checkbox).prop('checked', !$(checkbox).is(':checked')); if ($(checkbox).is(':checked')) { $(wrap2).addClass("thumbSelected"); } else { $(wrap2).removeClass('thumbSelected'); } }); checkPermitAction(); return false; }); $("#selectSet").click(function () { selectPageThumbnails(); $("input[name=setSelected]").prop('checked', true); checkPermitAction(); return false; }); jQuery('#applyAction').click(function() { var action = jQuery('[name="selectAction"]').val(); if (action == 'delete_derivatives') { var d_count = $('#action_delete_derivatives input[type=checkbox]').filter(':checked').length , e_count = $('input[name="setSelected"]').is(':checked') ? nb_thumbs_set : $('.thumbnails input[type=checkbox]').filter(':checked').length; if (d_count*e_count > 500) return confirm(lang.AreYouSure); } if (action != 'generate_derivatives' || derivatives.finished() ) { return true; } jQuery('.bulkAction').hide(); var queuedManager = jQuery.manageAjax.create('queued', { queue: true, cacheResponse: false, maxRequests: 1 }); derivatives.elements = []; if (jQuery('input[name="setSelected"]').is(':checked')) derivatives.elements = all_elements; else jQuery('.thumbnails input[type=checkbox]').each(function() { if (jQuery(this).is(':checked')) { derivatives.elements.push(jQuery(this).val()); } }); jQuery('#applyActionBlock').hide(); jQuery('select[name="selectAction"]').hide(); jQuery('#regenerationMsg').show(); progress(); getDerivativeUrls(); return false; }); checkPermitAction(); {* /* dimensions sliders */ /** * find the key from a value in the startStopValues array */ *} function getSliderKeyFromValue(value, values) { for (var key in values) { if (values[key] == value) { return key; } } return 0; } var dimension_values = { width:[{$dimensions.widths}], height:[{$dimensions.heights}], ratio:[{$dimensions.ratios}] }; function onSliderChange(type, ui, pattern) { $("input[name='filter_dimension_min_"+type+"']").val(dimension_values[type][ui.values[0]]); $("input[name='filter_dimension_max_"+type+"']").val(dimension_values[type][ui.values[1]]); $("#filter_dimension_"+type+"_info").html(sprintf( pattern, dimension_values[type][ui.values[0]], dimension_values[type][ui.values[1]] )); } $("#filter_dimension_width_slider").slider({ range: true, min: 0, max: dimension_values['width'].length - 1, values: [ getSliderKeyFromValue({$dimensions.selected.min_width}, dimension_values['width']), getSliderKeyFromValue({$dimensions.selected.max_width}, dimension_values['width']) ], slide: function(event, ui) { onSliderChange('width', ui, "{'between %d and %d pixels'|translate|escape:'javascript'}"); }, change: function(event, ui) { onSliderChange('width', ui, "{'between %d and %d pixels'|translate|escape:'javascript'}"); } }); $("#filter_dimension_height_slider").slider({ range: true, min: 0, max: dimension_values['height'].length - 1, values: [ getSliderKeyFromValue({$dimensions.selected.min_height}, dimension_values['height']), getSliderKeyFromValue({$dimensions.selected.max_height}, dimension_values['height']) ], slide: function(event, ui) { onSliderChange('height', ui, "{'between %d and %d pixels'|translate|escape:'javascript'}"); }, change: function(event, ui) { onSliderChange('height', ui, "{'between %d and %d pixels'|translate|escape:'javascript'}"); } }); $("#filter_dimension_ratio_slider").slider({ range: true, min: 0, max: dimension_values['ratio'].length - 1, values: [ getSliderKeyFromValue({$dimensions.selected.min_ratio}, dimension_values['ratio']), getSliderKeyFromValue({$dimensions.selected.max_ratio}, dimension_values['ratio']) ], slide: function(event, ui) { onSliderChange('ratio', ui, "{'between %.2f and %.2f'|translate|escape:'javascript'}"); }, change: function(event, ui) { onSliderChange('ratio', ui, "{'between %.2f and %.2f'|translate|escape:'javascript'}"); } }); $("a.dimensions-choice").click(function() { var type = jQuery(this).data("type"); var min = jQuery(this).data("min"); var max = jQuery(this).data("max"); $("#filter_dimension_"+ type +"_slider") .slider("values", 0, getSliderKeyFromValue(min, dimension_values[type]) ) .slider("values", 1, getSliderKeyFromValue(max, dimension_values[type]) ); }); jQuery("select[name=filter_prefilter]").change(function() { jQuery("#empty_caddie").toggle(jQuery(this).val() == "caddie"); }); }); {/footer_script}