1(function ($) { 2 3/** 4 * Override Views prototype function so it can recognize Bootstrap AJAX pagers. 5 * Attach the ajax behavior to each link. 6 */ 7Drupal.views.ajaxView.prototype.attachPagerAjax = function() { 8 this.$view.find('ul.pager > li > a, th.views-field a, .attachment .views-summary a, ul.pagination li a') 9 .each(jQuery.proxy(this.attachPagerLinkAjax, this)); 10}; 11 12})(jQuery); 13; 14(function ($) { 15 16/** 17 * Override Drupal's AJAX prototype beforeSend function so it can append the 18 * throbber inside the pager links. 19 */ 20Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) { 21 // For forms without file inputs, the jQuery Form plugin serializes the form 22 // values, and then calls jQuery's $.ajax() function, which invokes this 23 // handler. In this circumstance, options.extraData is never used. For forms 24 // with file inputs, the jQuery Form plugin uses the browser's normal form 25 // submission mechanism, but captures the response in a hidden IFRAME. In this 26 // circumstance, it calls this handler first, and then appends hidden fields 27 // to the form to submit the values in options.extraData. There is no simple 28 // way to know which submission mechanism will be used, so we add to extraData 29 // regardless, and allow it to be ignored in the former case. 30 if (this.form) { 31 options.extraData = options.extraData || {}; 32 33 // Let the server know when the IFRAME submission mechanism is used. The 34 // server can use this information to wrap the JSON response in a TEXTAREA, 35 // as per http://jquery.malsup.com/form/#file-upload. 36 options.extraData.ajax_iframe_upload = '1'; 37 38 // The triggering element is about to be disabled (see below), but if it 39 // contains a value (e.g., a checkbox, textfield, select, etc.), ensure that 40 // value is included in the submission. As per above, submissions that use 41 // $.ajax() are already serialized prior to the element being disabled, so 42 // this is only needed for IFRAME submissions. 43 var v = $.fieldValue(this.element); 44 if (v !== null) { 45 options.extraData[this.element.name] = v; 46 } 47 } 48 49 var $element = $(this.element); 50 51 // Disable the element that received the change to prevent user interface 52 // interaction while the Ajax request is in progress. ajax.ajaxing prevents 53 // the element from triggering a new request, but does not prevent the user 54 // from changing its value. 55 $element.addClass('progress-disabled').attr('disabled', true); 56 57 // Insert progressbar or throbber. 58 if (this.progress.type == 'bar') { 59 var progressBar = new Drupal.progressBar('ajax-progress-' + this.element.id, eval(this.progress.update_callback), this.progress.method, eval(this.progress.error_callback)); 60 if (this.progress.message) { 61 progressBar.setProgress(-1, this.progress.message); 62 } 63 if (this.progress.url) { 64 progressBar.startMonitoring(this.progress.url, this.progress.interval || 500); 65 } 66 this.progress.element = $(progressBar.element).addClass('ajax-progress ajax-progress-bar'); 67 this.progress.object = progressBar; 68 if (!$element.closest('.file-widget,.form-item').length) { 69 $element.before(this.progress.element); 70 } 71 else { 72 $element.closest('.file-widget,.form-item').after(this.progress.element); 73 } 74 } 75 else if (this.progress.type == 'throbber') { 76 this.progress.element = $('<div class="ajax-progress ajax-progress-throbber"><i class="glyphicon glyphicon-refresh glyphicon-spin"></i></div>'); 77 if (this.progress.message) { 78 $('.throbber', this.progress.element).after('<div class="message">' + this.progress.message + '</div>'); 79 } 80 81 // If element is an input type, append after. 82 if ($element.is('input')) { 83 $element.after(this.progress.element); 84 } 85 else if ($element.is('select')) { 86 var $inputGroup = $element.closest('.form-item').find('.input-group-addon, .input-group-btn'); 87 if (!$inputGroup.length) { 88 $element.wrap('<div class="input-group">'); 89 $inputGroup = $('<span class="input-group-addon">'); 90 $element.after($inputGroup); 91 } 92 $inputGroup.append(this.progress.element); 93 } 94 // Otherwise append the throbber inside the element. 95 else { 96 $element.append(this.progress.element); 97 } 98 } 99}; 100 101})(jQuery); 102;
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.