1(function($){ 2/** 3 * To make a form auto submit, all you have to do is 3 things: 4 * 5 * ctools_add_js('auto-submit'); 6 * 7 * On gadgets you want to auto-submit when changed, add the ctools-auto-submit 8 * class. With FAPI, add: 9 * @code 10 * '#attributes' => array('class' => array('ctools-auto-submit')), 11 * @endcode 12 * 13 * If you want to have auto-submit for every form element, 14 * add the ctools-auto-submit-full-form to the form. With FAPI, add: 15 * @code 16 * '#attributes' => array('class' => array('ctools-auto-submit-full-form')), 17 * @endcode 18 * 19 * If you want to exclude a field from the ctool-auto-submit-full-form auto submission, 20 * add the class ctools-auto-submit-exclude to the form element. With FAPI, add: 21 * @code 22 * '#attributes' => array('class' => array('ctools-auto-submit-exclude')), 23 * @endcode 24 * 25 * Finally, you have to identify which button you want clicked for autosubmit. 26 * The behavior of this button will be honored if it's ajaxy or not: 27 * @code 28 * '#attributes' => array('class' => array('ctools-use-ajax', 'ctools-auto-submit-click')), 29 * @endcode 30 * 31 * Currently only 'select', 'radio', 'checkbox' and 'textfield' types are supported. We probably 32 * could use additional support for HTML5 input types. 33 */ 34 35Drupal.behaviors.CToolsAutoSubmit = { 36 attach: function(context) { 37 // 'this' references the form element 38 function triggerSubmit (e) { 39 if ($.contains(document.body, this)) { 40 var $this = $(this); 41 if (!$this.hasClass('ctools-ajaxing')) { 42 $this.find('.ctools-auto-submit-click').click(); 43 } 44 } 45 } 46 47 // the change event bubbles so we only need to bind it to the outer form 48 $('form.ctools-auto-submit-full-form', context) 49 .add('.ctools-auto-submit', context) 50 .filter('form, select, input:not(:text, :submit)') 51 .once('ctools-auto-submit') 52 .change(function (e) { 53 // don't trigger on text change for full-form 54 if ($(e.target).is(':not(:text, :submit, .ctools-auto-submit-exclude)')) { 55 triggerSubmit.call(e.target.form); 56 } 57 }); 58 59 // e.keyCode: key 60 var discardKeyCode = [ 61 16, // shift 62 17, // ctrl 63 18, // alt 64 20, // caps lock 65 33, // page up 66 34, // page down 67 35, // end 68 36, // home 69 37, // left arrow 70 38, // up arrow 71 39, // right arrow 72 40, // down arrow 73 9, // tab 74 13, // enter 75 27 // esc 76 ]; 77 // Don't wait for change event on textfields 78 $('.ctools-auto-submit-full-form input:text, input:text.ctools-auto-submit', context) 79 .filter(':not(.ctools-auto-submit-exclude)') 80 .once('ctools-auto-submit', function () { 81 // each textinput element has his own timeout 82 var timeoutID = 0; 83 $(this) 84 .bind('keydown keyup', function (e) { 85 if ($.inArray(e.keyCode, discardKeyCode) === -1) { 86 timeoutID && clearTimeout(timeoutID); 87 } 88 }) 89 .keyup(function(e) { 90 if ($.inArray(e.keyCode, discardKeyCode) === -1) { 91 timeoutID = setTimeout($.proxy(triggerSubmit, this.form), 500); 92 } 93 }) 94 .bind('change', function (e) { 95 if ($.inArray(e.keyCode, discardKeyCode) === -1) { 96 timeoutID = setTimeout($.proxy(triggerSubmit, this.form), 500); 97 } 98 }); 99 }); 100 } 101} 102})(jQuery); 103 104;/*})'"*/ 105;/*})'"*/ 106(function ($) { 107 108Drupal.googleanalytics = {}; 109 110$(document).ready(function() { 111 112 // Attach mousedown, keyup, touchstart events to document only and catch 113 // clicks on all elements. 114 $(document.body).bind("mousedown keyup touchstart", function(event) { 115 116 // Catch the closest surrounding link of a clicked element. 117 $(event.target).closest("a,area").each(function() { 118 119 // Is the clicked URL internal? 120 if (Drupal.googleanalytics.isInternal(this.href)) { 121 // Skip 'click' tracking, if custom tracking events are bound. 122 if ($(this).is('.colorbox') && (Drupal.settings.googleanalytics.trackColorbox)) { 123 // Do nothing here. The custom event will handle all tracking. 124 //console.info("Click on .colorbox item has been detected."); 125 } 126 // Is download tracking activated and the file extension configured for download tracking? 127 else if (Drupal.settings.googleanalytics.trackDownload && Drupal.googleanalytics.isDownload(this.href)) { 128 // Download link clicked. 129 gtag('event', Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase(), { 130 event_category: 'Downloads', 131 event_label: Drupal.googleanalytics.getPageUrl(this.href), 132 transport_type: 'beacon' 133 }); 134 } 135 else if (Drupal.googleanalytics.isInternalSpecial(this.href)) { 136 // Keep the internal URL for Google Analytics website overlay intact. 137 // @todo: May require tracking ID 138 var target = this; 139 $.each(Drupal.settings.googleanalytics.account, function () { 140 gtag('config', this, { 141 page_path: Drupal.googleanalytics.getPageUrl(target.href), 142 transport_type: 'beacon' 143 }); 144 }); 145 } 146 } 147 else { 148 if (Drupal.settings.googleanalytics.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) { 149 // Mailto link clicked. 150 gtag('event', 'Click', { 151 event_category: 'Mails', 152 event_label: this.href.substring(7), 153 transport_type: 'beacon' 154 }); 155 } 156 else if (Drupal.settings.googleanalytics.trackOutbound && this.href.match(/^\w+:\/\//i)) { 157 if (Drupal.settings.googleanalytics.trackDomainMode !== 2 || (Drupal.settings.googleanalytics.trackDomainMode === 2 && !Drupal.googleanalytics.isCrossDomain(this.hostname, Drupal.settings.googleanalytics.trackCrossDomains))) { 158 // External link clicked / No top-level cross domain clicked. 159 gtag('event', 'Click', { 160 event_category: 'Outbound links', 161 event_label: this.href, 162 transport_type: 'beacon' 163 }); 164 } 165 } 166 } 167 }); 168 }); 169 170 // Track hash changes as unique pageviews, if this option has been enabled. 171 if (Drupal.settings.googleanalytics.trackUrlFragments) { 172 window.onhashchange = function() { 173 $.each(Drupal.settings.googleanalytics.account, function () { 174 gtag('config', this, { 175 page_path: location.pathname + location.search + location.hash 176 }); 177 }); 178 }; 179 } 180 181 // Colorbox: This event triggers when the transition has completed and the 182 // newly loaded content has been revealed. 183 if (Drupal.settings.googleanalytics.trackColorbox) { 184 $(document).bind("cbox_complete", function () {
185 var href = $.colorbox.element().attr("href"); 186 if (href) { 187 $.each(Drupal.settings.googleanalytics.account, function () { 188 gtag('config', this, { 189 page_path: Drupal.googleanalytics.getPageUrl(href) 190 }); 191 }); 192 } 193 }); 194 } 195 196}); 197 198/** 199 * Check whether the hostname is part of the cross domains or not. 200 * 201 * @param string hostname 202 * The hostname of the clicked URL. 203 * @param array crossDomains 204 * All cross domain hostnames as JS array. 205 * 206 * @return boolean 207 */ 208Drupal.googleanalytics.isCrossDomain = function (hostname, crossDomains) { 209 /** 210 * jQuery < 1.6.3 bug: $.inArray crushes IE6 and Chrome if second argument is 211 * `null` or `undefined`, https://bugs.jquery.com/ticket/10076, 212 * https://github.com/jquery/jquery/commit/a839af034db2bd934e4d4fa6758a3fed8de74174 213 * 214 * @todo: Remove/Refactor in D8 215 */ 216 if (!crossDomains) { 217 return false; 218 } 219 else { 220 return $.inArray(hostname, crossDomains) > -1 ? true : false; 221 } 222}; 223 224/** 225 * Check whether this is a download URL or not. 226 * 227 * @param string url 228 * The web url to check. 229 * 230 * @return boolean 231 */ 232Drupal.googleanalytics.isDownload = function (url) { 233 var isDownload = new RegExp("\\.(" + Drupal.settings.googleanalytics.trackDownloadExtensions + ")([\?#].*)?$", "i"); 234 return isDownload.test(url); 235}; 236 237/** 238 * Check whether this is an absolute internal URL or not. 239 * 240 * @param string url 241 * The web url to check. 242 * 243 * @return boolean 244 */ 245Drupal.googleanalytics.isInternal = function (url) { 246 var isInternal = new RegExp("^(https?):\/\/" + window.location.host, "i"); 247 return isInternal.test(url); 248}; 249 250/** 251 * Check whether this is a special URL or not. 252 * 253 * URL types: 254 * - gotwo.module /go/* links. 255 * 256 * @param string url 257 * The web url to check. 258 * 259 * @return boolean 260 */ 261Drupal.googleanalytics.isInternalSpecial = function (url) { 262 var isInternalSpecial = new RegExp("(\/go\/.*)$", "i"); 263 return isInternalSpecial.test(url); 264}; 265 266/** 267 * Extract the relative internal URL from an absolute internal URL. 268 * 269 * Examples: 270 * - https://mydomain.com/node/1 -> /node/1 271 * - https://example.com/foo/bar -> https://example.com/foo/bar 272 * 273 * @param string url 274 * The web url to check. 275 * 276 * @return string 277 * Internal website URL 278 */ 279Drupal.googleanalytics.getPageUrl = function (url) { 280 var extractInternalUrl = new RegExp("^(https?):\/\/" + window.location.host, "i"); 281 return url.replace(extractInternalUrl, ''); 282}; 283 284/** 285 * Extract the download file extension from the URL. 286 * 287 * @param string url 288 * The web url to check. 289 * 290 * @return string 291 * The file extension of the passed url. e.g. "zip", "txt" 292 */ 293Drupal.googleanalytics.getDownloadExtension = function (url) { 294 var extractDownloadextension = new RegExp("\\.(" + Drupal.settings.googleanalytics.trackDownloadExtensions + ")([\?#].*)?$", "i"); 295 var extension = extractDownloadextension.exec(url); 296 return (extension === null) ? '' : extension[1]; 297}; 298 299})(jQuery); 300 301;/*})'"*/ 302;/*})'"*/
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.