1
0

jQuery rewrite of invertSelection() function.

This works for entries, comments and media items including changing
the multidelete marker. Needs to be tested with Karma plugin which
uses the old function as well.
This commit is contained in:
Matthias Mees
2013-06-05 18:37:55 +02:00
parent 26df96b886
commit cb09463326
2 changed files with 21 additions and 10 deletions

View File

@ -164,7 +164,7 @@
</div>
{/if}
<div id="multidelete_tools" class="form_buttons">
<input name="toggle" type="button" value="{$CONST.INVERT_SELECTIONS}" onclick="invertSelection()">
<input class="invert_selection" name="toggle" type="button" value="{$CONST.INVERT_SELECTIONS}">
<input class="state_cancel" name="toggle" type="submit" value="{$CONST.DELETE_SELECTED_ENTRIES}">
</div>
</form>

View File

@ -533,13 +533,13 @@ function FT_toggle(id) {
// Inverts a selection of checkboxes
// NOTE: similar function (but not duplicate!) from admin_scripts.js, see below
function invertSelection() {
$('.input_checkbox').each(function(index, checkbox) {
$(checkbox).attr('checked', ! $(checkbox).attr('checked'));
var id = 'comment_' + checkbox.name.replace(/.*\[.*\]\[(.*)\]/, "$1"); // gets the id from the name of the checkbox, which is serendipity[delete][id]
highlightComment(id, $(checkbox).attr('checked'));
});
}
// function invertSelection() {
// $('.input_checkbox').each(function(index, checkbox) {
// $(checkbox).attr('checked', ! $(checkbox).attr('checked'));
// var id = 'comment_' + checkbox.name.replace(/.*\[.*\]\[(.*)\]/, "$1"); // gets the id from the name of the checkbox, which is serendipity[delete][id]
// highlightComment(id, $(checkbox).attr('checked'));
// });
// }
// ------------------------------------------------------------------------------
// This duplicate of invertSelection() was used in the defunct admin_scripts.js.
@ -563,6 +563,13 @@ function invertSelection() {
// }
// }
// Inverts a selection of checkboxes
function invertSelection() {
var $chkboxes = $('#formMultiDelete .multidelete');
$chkboxes.prop('checked', !$chkboxes.attr('checked'))
.trigger('click');
}
// Highlight/dehighlight elements in lists
function highlightComment(id, checkvalue) {
@ -700,13 +707,17 @@ function highlightComment(id, checkvalue) {
$('#imagepreview').attr('src', $('#category_icon').val());
});
// Comment selection for multidelete
// onclick="highlightComment('comment_{$comment.id}', this.checked)"
// Selection for multidelete
$('.multidelete').click(function(e) {
var $el = $(this);
highlightComment($el.attr('data-multidelid'), $el.attr('checked'));
});
// Invert checkboxes
$('.invert_selection').click(function(e) {
invertSelection();
});
// Add media db upload field
var $uploadForm = $('body').has('#uploadform');