1 2(function($) { 3 4 Drupal.Collapsiblock = Drupal.Collapsiblock || {}; 5 6 Drupal.behaviors.collapsiblock = { 7 8 attach: function (context,settings) { 9 var cookieData = Drupal.Collapsiblock.getCookieData(); 10 var slidetype = settings.collapsiblock.slide_type; 11 var defaultState = settings.collapsiblock.default_state; 12 var slidespeed = parseInt(settings.collapsiblock.slide_speed,10); 13 var title = settings.collapsiblock.block_title; 14 var block = settings.collapsiblock.block; 15 var block_content = settings.collapsiblock.block_content; 16 $(block + ':not(.collapsiblock-processed)', context).addClass('collapsiblock-processed').each(function () { 17 var id = this.id.replace(/_/g, '-'); 18 var titleElt = $(title, this).not($('.content :header',this)); 19 if (titleElt.size()) { 20 titleElt = titleElt[0]; 21 // Status values: 1 = not collapsible, 2 = collapsible and expanded, 3 = collapsible and collapsed, 4 = always collapsed 22 var stat = settings.collapsiblock.blocks[id] ? settings.collapsiblock.blocks[id] : defaultState; 23 if (stat == 1) { 24 return; 25 } 26 27 titleElt.target = $(this).find(block_content); 28 $(titleElt) 29 .wrapInner('<a href="#' + id +'" role="link" />') 30 .addClass('collapsiblock') 31 .click(function (e) { 32 e.preventDefault(); 33 var st = Drupal.Collapsiblock.getCookieData(); 34 if ($(this).is('.collapsiblockCollapsed')) { 35 $(this).removeClass('collapsiblockCollapsed'); 36 if (slidetype == 1) { 37 $(this.target).slideDown(slidespeed).attr('aria-hidden', false); 38 } 39 else { 40 $(this.target).animate({ 41 height:'show', 42 opacity:'show' 43 }, slidespeed); 44 } 45 46 // Don't save cookie data if the block is always collapsed. 47 if (stat != 4) { 48 st[id] = 1; 49 } 50 } 51 else { 52 $(this).addClass('collapsiblockCollapsed'); 53 if (slidetype == 1) { 54 $(this.target).slideUp(slidespeed).attr('aria-hidden', true); 55 } 56 else { 57 $(this.target).animate({ 58 height:'hide', 59 opacity:'hide' 60 }, slidespeed); 61 } 62 63 // Don't save cookie data if the block is always collapsed. 64 if (stat != 4) { 65 st[id] = 0; 66 } 67 } 68 // Stringify the object in JSON format for saving in the cookie. 69 var cookieString = '{ '; 70 var cookieParts = []; 71 $.each(st, function (id, setting) { 72 cookieParts[cookieParts.length] = ' "' + id + '": ' + setting; 73 }); 74 cookieString += cookieParts.join(', ') + ' }'; 75 $.cookie('collapsiblock', cookieString, { 76 path: settings.basePath 77 }); 78 }); 79 $('a[role=link]', titleElt).click(function (e) { 80 e.preventDefault(); 81 }); 82 // Leave active blocks uncollapsed. If the block is expanded, do nothing. 83 if (stat == 4 || (cookieData[id] == 0 || (stat == 3 && cookieData[id] == undefined)) && !$(this).find('a.active').size()) { 84 // Allow block content to assign class 'collapsiblock-force-open' to it's content to force 85 // itself to stay open. E.g. useful if block contains a form that was just ajaxly updated and should be visible 86 if (titleElt.target.hasClass('collapsiblock-force-open') || titleElt.target.find('.collapsiblock-force-open').size() > 0) { 87 return; 88 } 89 $(titleElt).addClass('collapsiblockCollapsed'); 90 $(titleElt.target).hide(); 91 } 92 } 93 }); 94 } 95 96 }; 97 98 Drupal.Collapsiblock.getCookieData = function () { 99 if ($.cookie) { 100 var cookieString = $.cookie('collapsiblock'); 101 return cookieString ? $.parseJSON(cookieString) : {}; 102 } 103 else { 104 return ''; 105 } 106 }; 107 108 109})(jQuery); 110; 111/** 112 * JavaScript source file for Book Review Module 113 */ 114 115/*Functions*/ 116function activate_review_avatar(fid) { 117 var calback_uri = 'book_review/callback/avatar/process_image'; 118 var successReturn = function (data) { 119 var response = JSON.parse(data); 120 jQuery('.rev-con-select').html(''); 121 jQuery('.rev-con-select').html(response.image); 122 jQuery('#review_avatar_fid').val(fid); 123 }; 124 125 var errorReturn = function(jqXHR, textStatus, errorThrown){ 126 alert(textStatus + errorThrown); //Better diagnostics 127 }; 128 jQuery.ajax({ 129 beforeSend : function() { 130 var loader = '<img id="" class="loader" src="'+Drupal.settings.basePath+'sites/all/modules/custom/book_review/images/ajax-loader.gif" />'; 131 jQuery('.rev-con-select').html(loader); 132 }, 133 cache: false, 134 url: Drupal.settings.basePath + '?q=' + calback_uri, 135 data: {file : fid}, 136 type: 'POST', 137 dataType: 'JSON', 138 success : successReturn, 139 error : errorReturn 140 }); 141};
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.