app/assets/javascripts/umlaut/expand_contract_toggle.js in umlaut-3.0.5 vs app/assets/javascripts/umlaut/expand_contract_toggle.js in umlaut-3.1.0.pre1
- old
+ new
@@ -1,33 +1,25 @@
/* expand_contract_toggle.js: Support for show more/hide more in lists of umlaut content.
-
- The JS needs to swap out the image for expand/contract toggle. AND we need
- the URL it swaps in to be an ABSOLUTE url when we're using partial html
- widget.
-
- So we swap in a non-fingerprinted URL, even if the original was asset
- pipline fingerprinted. sorry, best way to make it work!
*/
jQuery(document).ready(function($) {
-
- $(document).on("click", ".expand_contract_toggle", function() {
- var content = $(this).next(".expand_contract_content");
- var icon = $(this).parent().find('img.toggle_icon');
-
- if (content.is(":visible")) {
- icon.attr("src", icon.attr("src").replace(/list_open[^.]*\.png/, "list_closed.png"));
- $(this).find(".expand_contract_action_label").text("Show ");
-
- content.hide();
-
- }
- else {
- icon.attr("src", icon.attr("src").replace(/list_closed[^.]*\.png/, "list_open.png"));
- $(this).find(".expand_contract_action_label").text("Hide ");
- content.show();
- }
-
- return false;
- });
-
-
+ $(".collapse_toggle").each(function(){
+ $(this).collapse('toggle');
+ });
+ $(document).on("click", ".collapse-toggle", function(event) {
+ event.preventDefault();
+ return false;
+ });
+ $(document).on("show", ".collapse", function(event) {
+ // Update the icon
+ $(this).parent().find('.collapse-toggle i').removeClass("umlaut_icons-list-closed").addClass("umlaut_icons-list-open");
+ // Update the action label
+ $(this).parent().find(".expand_contract_action_label").text("Hide ");
+
+ });
+ $(document).on("hide", ".collapse", function(event) {
+ // Update the icon
+ $(this).parent().find('.collapse-toggle i').removeClass("umlaut_icons-list-open").addClass("umlaut_icons-list-closed");
+ // Update the action label
+ $(this).parent().find(".expand_contract_action_label").text("Show ");
+
+ });
});