var updateRow=function(e,t){var a=$("table.listing tr#snippet-row-"+e);a.find("input[type=checkbox].toggle-select-row").prop("checked",t),t?a.addClass("selected"):a.removeClass("selected")},updateDeleteButton=function(e,t){var a=$("a.button.delete-button"),c=[];if($.each(t,(function(e,t){t&&c.push(e)})),e){a.removeClass("u-hidden");var l=a.data("url");l+=$.param({id:c},!0),a.attr("href",l)}else a.addClass("u-hidden"),a.attr("href",null)},updateSelectAllCheckbox=function(e){$("table.listing input[type=checkbox].toggle-select-all").prop("checked",e)},buildSelectedState=function(){var e={},t=$("table.listing tbody tr input[type=checkbox].toggle-select-row");return $.each(t,(function(t,a){var c=$(a),l=c.prop("checked"),n=c.attr("value");e[n]=l})),e},updateSelectedState=function(e,t,a){return null===a?$.each(e,(function(a,c){e[a]=t})):e[a]=t,e},updateView=function(e){var t=!0,a=!1,c=0,l=0;$.each(e,(function(e,t){updateRow(e,t),!1===t?c+=1:l+=1})),c>=1&&(t=!1),updateSelectAllCheckbox(t),l>=1&&(a=!0),updateDeleteButton(a,e)},onListingCheckboxClick=function(){$('table.listing input[type="checkbox"]').on("click",(function(e){var t=$(e.target),a=t.prop("checked"),c=buildSelectedState(),l=null;t.hasClass("toggle-select-row")&&(l=t.attr("value"));var n=updateSelectedState(c,a,l);updateView(n)}))};$(document).ready(onListingCheckboxClick);