Committer: dpetrov
LJSUP-7518: Add checkboxes for removing posts from Top entries admin toolA trunk/htdocs/js/admin/ A trunk/htdocs/js/admin/topentries.js
Added: trunk/htdocs/js/admin/topentries.js =================================================================== --- trunk/htdocs/js/admin/topentries.js (rev 0) +++ trunk/htdocs/js/admin/topentries.js 2010-12-13 04:58:30 UTC (rev 17906) @@ -0,0 +1,23 @@ +jQuery( function( $ ) { + var CONFIG = { + container: "#delete-posts", + selectall: "li:first input[type=checkbox]", + elements: "li:not(:first) input[type=checkbox]" + } + + var container = $( CONFIG.container ), + selectall = container.find( CONFIG.selectall ), + elements = container.find( CONFIG.elements ); + + function selectAllCheckboxes() { + var checked = !!selectall.attr( 'checked' ); + elements.attr( 'checked', checked ); + } + + selectall.change( function() { setTimeout( selectAllCheckboxes, 0 ) } ); + elements.change( function() { + if( !this.checked ) { + selectall.attr( 'checked', false ); + } + } ); +} );