forked from activeadmin/activeadmin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed several issues after merging with the @gregbell master & refact…
…ored the JS support for batch actions out into a separate JS file.
- Loading branch information
Matthew Brewer
authored and
Matthew Brewer
committed
Dec 2, 2011
1 parent
5c62315
commit 5ee02e5
Showing
5 changed files
with
89 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
jQuery(function($) { | ||
|
||
// Batch actions stuff | ||
|
||
$('#batch_actions_button').toggle(function() { | ||
if (!$(this).hasClass("disabled")) { | ||
$("#batch_actions_popover").fadeIn(50); | ||
}; | ||
}, function() { | ||
$("#batch_actions_popover").fadeOut(100); | ||
}); | ||
|
||
$('#collection_selection_toggle_all').click(function() { | ||
|
||
var $this = $(this); | ||
var isTable = $this.closest(".index").hasClass("index_table"); | ||
|
||
if ($(this).attr('checked') == "checked") { | ||
$('#batch_actions_button').removeClass("disabled"); | ||
$('#batch_actions_button').addClass("selected"); | ||
$('.collection_selection').attr('checked', 'checked'); | ||
if ( isTable ) { | ||
$(this).parents(".index_table").find('tr').addClass("selected"); | ||
} | ||
} else { | ||
$('#batch_actions_button').addClass("disabled"); | ||
$('#batch_actions_button').removeClass("selected"); | ||
$('.collection_selection').attr('checked', false); | ||
if ( isTable ) { | ||
$(this).parents(".index_table").find('tr').removeClass("selected"); | ||
} | ||
} | ||
}); | ||
|
||
$('.collection_selection').click(function() { | ||
|
||
var $this = $(this); | ||
var isTable = $this.closest(".index").hasClass("index_table"); | ||
|
||
if ( $this.attr('checked') == "checked" ) { | ||
|
||
$('#batch_actions_button').removeClass("disabled"); | ||
$('#batch_actions_button').addClass("selected"); | ||
if ( isTable ) { | ||
$this.parents('tr').addClass("selected"); | ||
} | ||
|
||
} else { | ||
|
||
if ( $this.closest(".index").find("input:checked").length == 0) { | ||
$('#batch_actions_button').addClass("disabled"); | ||
$('#batch_actions_button').removeClass("selected"); | ||
} | ||
|
||
if ( isTable ) { | ||
$this.parents('tr').removeClass("selected"); | ||
} | ||
|
||
$("#collection_selection_toggle_all").attr('checked', false); | ||
|
||
} | ||
|
||
}); | ||
|
||
// Attach a click hanlder to each of the batch action items | ||
$('#batch_actions_popover a.batch_action').click(function(e) { | ||
|
||
// Present optional confirmation prompt to user | ||
var $target = $(e.target); | ||
if ( $target.attr("data-request-confirm") ) { | ||
if ( !confirm( $target.attr("data-request-confirm") ) ) { | ||
$("#batch_actions_popover").fadeOut(100); | ||
return false; | ||
} | ||
} | ||
|
||
// Submit the form, sending the request | ||
$('#batch_action').val( $target.attr("data-action") ); | ||
$('#collection_selection').submit(); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters