1(function ($) { 2 3/** 4 * Toggle the visibility of a fieldset using smooth animations. 5 */ 6Drupal.toggleFieldset = function (fieldset) { 7 var $toggle = $($(fieldset).find('[data-toggle=collapse]').data('target')); 8 if ($toggle.length) { 9 $toggle.collapse('toggle'); 10 } 11}; 12 13/** 14 * Scroll a given fieldset into view as much as possible. 15 */ 16Drupal.collapseScrollIntoView = function (node) { 17 var h = document.documentElement.clientHeight || document.body.clientHeight || 0; 18 var offset = document.documentElement.scrollTop || document.body.scrollTop || 0; 19 var posY = $(node).offset().top; 20 var fudge = 55; 21 if (posY + node.offsetHeight + fudge > h + offset) { 22 if (node.offsetHeight > h) { 23 window.scrollTo(0, posY); 24 } 25 else { 26 window.scrollTo(0, posY + node.offsetHeight - h + fudge); 27 } 28 } 29}; 30 31Drupal.behaviors.collapse = { 32 attach: function (context, settings) { 33 $('fieldset.collapsible', context).once('collapse', function () { 34 var $fieldset = $(this); 35 var $body = $fieldset.find('> .panel-collapse'); 36 // Expand fieldset if there are errors inside, or if it contains an 37 // element that is targeted by the URI fragment identifier. 38 var anchor = location.hash && location.hash != '#' ? ', ' + location.hash : ''; 39 if ($fieldset.find('.error' + anchor).length) { 40 $fieldset.removeClass('collapsed'); 41 $body.removeClass('collapsed'); 42 } 43 44 var summary = $('<span class="summary"></span>'); 45 $fieldset. 46 bind('summaryUpdated', function () { 47 var text = $.trim($fieldset.drupalGetSummary()); 48 summary.html(text ? ' (' + text + ')' : ''); 49 }) 50 .trigger('summaryUpdated'); 51 52 // Turn the legend into a clickable link, but retain span.fieldset-legend 53 // for CSS positioning. 54 var $legend = $('> legend .fieldset-legend', this); 55 56 $('<span class="fieldset-legend-prefix element-invisible"></span>') 57 .append($fieldset.hasClass('collapsed') ? Drupal.t('Show') : Drupal.t('Hide')) 58 .prependTo($legend); 59 60 // Bind Bootstrap events with Drupal core events. 61 $fieldset 62 .append(summary) 63 .on('show.bs.collapse', function () { 64 $fieldset 65 .removeClass('collapsed') 66 .find('> legend span.fieldset-legend-prefix').html(Drupal.t('Hide')); 67 $body.removeClass('collapsed'); 68 }) 69 .on('shown.bs.collapse', function () { 70 $fieldset.trigger({ type: 'collapsed', value: false }); 71 Drupal.collapseScrollIntoView($fieldset.get(0)); 72 }) 73 .on('hide.bs.collapse', function () { 74 $fieldset 75 .addClass('collapsed') 76 .find('> legend span.fieldset-legend-prefix').html(Drupal.t('Show')); 77 $body.addClass('collapsed'); 78 }) 79 .on('hidden.bs.collapse', function () { 80 $fieldset.trigger({ type: 'collapsed', value: true }); 81 }); 82 }); 83 } 84}; 85 86})(jQuery); 87; 88/** 89 * @file 90 * Unlock protected forms by resetting the form action to the path that 91 * it should be, only if the current user is verified to be human. 92 */ 93(function ($) { 94 Drupal.antibot = {}; 95 96 Drupal.behaviors.antibot = { 97 attach: function (context) { 98 // Assume the user is not human, despite JS being enabled. 99 Drupal.settings.antibot.human = false; 100 101 // Wait for a mouse to move, indicating they are human. 102 $('body').mousemove(function() { 103 // Unlock the forms. 104 Drupal.antibot.unlockForms(); 105 }); 106 107 // Wait for a touch move event, indicating that they are human. 108 $('body').bind('touchmove', function() { 109 // Unlock the forms. 110 Drupal.antibot.unlockForms(); 111 }); 112 113 // A tab or enter key pressed can also indicate they are human. 114 $('body').keydown(function(e) { 115 if ((e.keyCode == 9) || (e.keyCode == 13)) { 116 // Unlock the forms. 117 Drupal.antibot.unlockForms(); 118 } 119 }); 120 } 121 }; 122 123 /** 124 * Revert the action on the protected forms to what it was originally 125 * set to. 126 */ 127 Drupal.antibot.unlockForms = function() { 128 // Act only if we haven't yet verified this user as being human.
129 if (!Drupal.settings.antibot.human) { 130 // Iterate all antibot forms that we need to unlock. 131 for (var id in Drupal.settings.antibot.forms) { 132 // Switch the action to the original value. 133 $('form#' + id).attr('action', Drupal.settings.antibot.forms[id].action); 134 135 // Check if a key is required. 136 if (Drupal.settings.antibot.forms[id].key) { 137 // Inject the key value. 138 $('form#' + id).find('input[name="antibot_key"]').val(Drupal.settings.antibot.forms[id].key.split("").reverse().join("").match(/.{1,2}/g).map((value) => value.split("").reverse().join("")).join("")); 139 } 140 } 141 // Mark this user as being human. 142 Drupal.settings.antibot.human = true; 143 } 144 }; 145 146})(jQuery); 147; 148(function ($) { 149 150Drupal.behaviors.textarea = { 151 attach: function (context, settings) { 152 $('.form-textarea-wrapper.resizable', context).once('textarea', function () { 153 var staticOffset = null; 154 var textarea = $(this).addClass('resizable-textarea').find('textarea'); 155 var grippie = $('<div class="grippie"></div>').mousedown(startDrag); 156 157 grippie.insertAfter(textarea); 158 159 function startDrag(e) { 160 staticOffset = textarea.height() - e.pageY; 161 textarea.css('opacity', 0.25); 162 $(document).mousemove(performDrag).mouseup(endDrag); 163 return false; 164 } 165 166 function performDrag(e) { 167 textarea.height(Math.max(32, staticOffset + e.pageY) + 'px'); 168 return false; 169 } 170 171 function endDrag(e) { 172 $(document).unbind('mousemove', performDrag).unbind('mouseup', endDrag); 173 textarea.css('opacity', 1); 174 } 175 }); 176 } 177}; 178 179})(jQuery); 180;
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.