1/*jslint bitwise: true, eqeqeq: true, immed: true, newcap: true, nomen: false, 2 onevar: false, plusplus: false, regexp: true, undef: true, white: true, indent: 2 3 browser: true */ 4 5/*global jQuery: true Drupal: true window: true ThemeBuilder: true */ 6 7(function ($) { 8 /** 9 * Acquia object is created if it doesn't exist. 10 */ 11 Drupal.behaviors.acquia = Drupal.behaviors.acquia || {}; 12 13 /** 14 * Attach handler. 15 */ 16 Drupal.behaviors.acquia = { 17 equalCols: true, 18 delay: NaN, 19 attach: function (context, settings) { 20 var addCommentTrigger = $('.comment-add a'); 21 var addCommentForm = $('#comment-new'); 22 var themebuilderIsOpen = Drupal.behaviors.acquia.checkThemeBuilderStatus(); 23 // Add only if the comment form exists on the page. 24 if (addCommentForm.length > 0) { 25 // Bind click event handlers to all .comment_add links 26 addCommentTrigger.bind('click', {scrollTarget: addCommentForm}, Drupal.behaviors.acquia.scrollTo); 27 } 28 // Run functions that require a slight delay so that the screen can finish painting 29 Drupal.behaviors.acquia.delay = setTimeout(Drupal.behaviors.acquia.delayFunctions, 750); 30 // Run the following only if the ThemeBuilder is closed 31 if (!themebuilderIsOpen) { 32 Drupal.behaviors.acquia.enhanceRotatingBanner(); 33 } 34 } 35 }; 36 37 38 /** 39 * Run functions that require a slight delay so that the screen can finish painting 40 */ 41 Drupal.behaviors.acquia.delayFunctions = function () { 42 // Set all sidebars to the height of their parent container. 43 Drupal.behaviors.acquia.equalizeColumns(); 44 }; 45 46 /** 47 * Scrolls the page to the clicked element's location 48 * @param {event} event 49 * The event. 50 */ 51 Drupal.behaviors.acquia.scrollTo = function (event) { 52 // Keep the page from jumping to the hash target 53 event.preventDefault(); 54 var toolbar = {}; 55 toolbar.menuHeight = $('.toolbar-menu', '#toolbar').height() || 0; 56 toolbar.drawerHeight = $('.toolbar-drawer', '#toolbar').height() || 0; 57 var targetOffset = event.data.scrollTarget.offset().top - toolbar.menuHeight - toolbar.drawerHeight; 58 $('html,body').animate({scrollTop: targetOffset}, 1000); 59 }; 60 61 /** 62 * Equalizes all .col elements in a stack to the height of the tallest .col 63 */ 64 Drupal.behaviors.acquia.equalizeColumns = function () { 65 if (Drupal.behaviors.acquia.equalCols) { 66 $('body').once('acquia-equalcols', function() { 67 var $stacks = $('.box'); 68 for (var i = 0; i < $stacks.length; i++) { 69 // Get the current stack reference 70 var _this = $stacks.eq(i); 71 // Instantiate the boxHeight variable 72 var boxHeight = 0; 73 // Get the columns in the stack 74 var cols = _this.find('.tb-height-balance'); 75 // We don't need to balance the columns if only one column is present 76 if (cols.length > 1) { 77 for (var j = 0; j < cols.size(); j++) { 78 var col = cols.eq(j); 79 // Only balance the height if the col is visible 80 if (col.css('display') !== 'none' && col.css('visibility') !== 'hidden') { 81 var colHeight = col.outerHeight(false); 82 if (colHeight > boxHeight) { 83 // If the height of the col is more than previous height, use it 84 boxHeight = colHeight; 85 } 86 } 87 } 88 } 89 // Only set the min-heights if boxHeight was assigned a real value 90 if (boxHeight > 0) { 91 cols.css('min-height', boxHeight); 92 } 93 } 94 }); 95 } 96 }; 97 98 /** 99 * Adds a click handler to the layout wrapper of the rotating banner. Otherwise this element 100 * would obsure the link wrapped around the image element 101 */ 102 Drupal.behaviors.acquia.enhanceRotatingBanner = function () { 103 var layouts = $('.layout-wrapper', '.rotating-banner'); 104 var len = layouts.length; 105 if (len > 0) { 106 while (len--) { 107 Drupal.behaviors.acquia.pseudoLink(layouts.eq(len)); 108 } 109 } 110 }; 111 112 /** 113 * Navigates to the designated element's data-link attribute value 114 * 115 * @param {DomElement} element 116 * Element that the pseudo link will be applied to 117 * 118 * @attribute 119 * data-link is an element attribute that uses the HTML5 data- pattern to
119store information in the DOM 120 */ 121 Drupal.behaviors.acquia.pseudoLink = function (element) { 122 var link = element.attr('data-link'); 123 if (link && link.length > 0) { 124 //Bind a click event to the slide layout wrapper if it has a link, stored in data-link attribute 125 element.click(function (event) { 126 window.location = $(event.currentTarget).attr('data-link'); 127 }); 128 } 129 }; 130 131 /** 132 * Determines if the ThemeBuilder is open 133 * 134 * @return {Boolean} 135 * returns a boolean that represents the open state of the ThemeBuilder. True equals open. 136 */ 137 Drupal.behaviors.acquia.checkThemeBuilderStatus = function () { 138 return $('body').hasClass('themebuilder') ? true : false; 139 }; 140 141}(jQuery)); 142;
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.