1(function ($) { 2 3 Drupal.Collapsiblock = Drupal.Collapsiblock || {}; 4 5 Drupal.behaviors.collapsiblock = { 6 7 attach: function (context, settings) { 8 var cookieData = Drupal.Collapsiblock.getCookieData(); 9 var slidetype = settings.collapsiblock.slide_type; 10 var activePages = settings.collapsiblock.active_pages; 11 var slidespeed = parseInt(settings.collapsiblock.slide_speed, 10); 12 $('.collapsiblock').once('collapsiblock', function () { 13 var id = this.id.split("-").pop(); 14 var titleElt = $(this)[0]; 15 if (titleElt.children.length > 0) { 16 // Status values: 1 = not collapsible, 2 = collapsible and expanded, 17 // 3 = collapsible and collapsed, 4 = always collapsed, 18 // 5 = always expanded 19 var stat = $(this).data('collapsiblock-action'); 20 if (stat == 1) { 21 return; 22 } 23 24 titleElt.target = $(this).siblings().not($('.contextual-links-wrapper')); 25 $(titleElt) 26 .wrapInner('<a href="#collapse-' + id + '" role="link" />') 27 .click(function (e) { 28 if ($(this).is('.collapsiblockCollapsed')) { 29 $(this).removeClass('collapsiblockCollapsed'); 30 if (slidetype == 1) { 31 $(this.target).slideDown(slidespeed).attr('aria-hidden', false); 32 } 33 else { 34 $(this.target).animate({ 35 height: 'show', 36 opacity: 'show' 37 }, slidespeed); 38 } 39 40 // Don't save cookie data if the block is always collapsed. 41 if (stat != 4 && stat != 5) { 42 cookieData[id] = 1; 43 } 44 } 45 else { 46 $(this).addClass('collapsiblockCollapsed'); 47 if (slidetype == 1) { 48 $(this.target).slideUp(slidespeed).attr('aria-hidden', true); 49 } 50 else { 51 $(this.target).animate({ 52 height: 'hide', 53 opacity: 'hide' 54 }, slidespeed); 55 } 56 57 // Don't save cookie data if the block is always collapsed. 58 if (stat != 4 && stat != 5) { 59 cookieData[id] = 0; 60 } 61 } 62 // Stringify the object in JSON format for saving in the cookie. 63 cookieString = JSON.stringify(cookieData); 64 $.cookie('collapsiblock', cookieString, { 65 path: settings.basePath 66 }); 67 }); 68 // Leave active blocks if Remember collapsed on active pages is false. 69 // If the block is expanded, do nothing. 70 if (stat == 4 || (cookieData[id] == 0 || (stat == 3 && cookieData[id] == undefined))) { 71 if (!$(this).find('a.active').size() || activePages === 1) { 72 // Allow block content to assign class 'collapsiblock-force-open' 73 // to it's content to force itself to stay open. E.g. useful if 74 // block contains a form that was just ajaxly updated and should 75 // be visible 76 if (titleElt.target.hasClass('collapsiblock-force-open') || titleElt.target.find('.collapsiblock-force-open').size() > 0) { 77 return; 78 } 79 $(titleElt).addClass('collapsiblockCollapsed'); 80 $(titleElt.target).hide(); 81 } 82 } 83 } 84 }); 85 } 86 87 }; 88 89 Drupal.Collapsiblock.getCookieData = function () { 90 if ($.cookie) { 91 var cookieString = $.cookie('collapsiblock'); 92 return cookieString ? $.parseJSON(cookieString) : {}; 93 } 94 else { 95 return ''; 96 } 97 }; 98 99 100})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.