Spaces:
Running
Running
File size: 11,589 Bytes
1e4c25f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
(function ($) {
/**
* Attaches the autocomplete behavior to all required fields.
*/
Drupal.behaviors.autocomplete = {
attach: function (context) {
var $context = $(context);
var acdb = [];
$context.find('input.autocomplete').once('autocomplete', function () {
var uri = this.value;
if (!acdb[uri]) {
acdb[uri] = new Drupal.ACDB(uri);
}
var $input = $context.find('#' + this.id.substr(0, this.id.length - 13))
.attr('autocomplete', 'OFF')
.attr('aria-autocomplete', 'list');
$context.find($input[0].form).submit(Drupal.autocompleteSubmit);
$input.parents('.form-item')
.attr('role', 'application')
.append($('<span class="element-invisible" aria-live="assertive"></span>')
.attr('id', $input.attr('id') + '-autocomplete-aria-live')
);
new Drupal.jsAC($input, acdb[uri], $context);
});
}
};
/**
* Prevents the form from submitting if the suggestions popup is open
* and closes the suggestions popup when doing so.
*/
Drupal.autocompleteSubmit = function () {
$('.form-autocomplete > .dropdown').each(function () {
this.owner.hidePopup();
});
// Always return true to make it possible to submit even when there was an
// autocomplete suggestion list open.
return true;
};
/**
* Highlights a suggestion.
*/
Drupal.jsAC.prototype.highlight = function (node) {
if (this.selected) {
$(this.selected).removeClass('active');
}
$(node).addClass('active');
this.selected = node;
$(this.ariaLive).html($(this.selected).html());
};
/**
* Unhighlights a suggestion.
*/
Drupal.jsAC.prototype.unhighlight = function (node) {
$(node).removeClass('active');
this.selected = false;
$(this.ariaLive).empty();
};
/**
* Positions the suggestions popup and starts a search.
*/
Drupal.jsAC.prototype.populatePopup = function () {
var $input = $(this.input);
// Show popup.
if (this.popup) {
$(this.popup).remove();
}
this.selected = false;
this.popup = $('<div class="dropdown"></div>')[0];
this.popup.owner = this;
$input.parent().after(this.popup);
// Do search.
this.db.owner = this;
this.db.search(this.input.value);
};
/**
* Fills the suggestion popup with any matches received.
*/
Drupal.jsAC.prototype.found = function (matches) {
// If no value in the textfield, do not show the popup.
if (!this.input.value.length) {
return false;
}
// Prepare matches.
var ul = $('<ul class="dropdown-menu"></ul>');
var ac = this;
ul.css({
display: 'block',
right: 0
});
for (var key in matches) {
$('<li></li>')
.html($('<a href="#"></a>').html(matches[key]).on('click', function (e) {
e.preventDefault();
}))
.on('mousedown', function () {
ac.hidePopup(this);
})
.on('mouseover', function () {
ac.highlight(this);
})
.on('mouseout', function () {
ac.unhighlight(this);
})
.data('autocompleteValue', key)
.appendTo(ul);
}
// Show popup with matches, if any.
if (this.popup) {
if (ul.children().length) {
$(this.popup).empty().append(ul).show();
$(this.ariaLive).html(Drupal.t('Autocomplete popup'));
}
else {
$(this.popup).css({visibility: 'hidden'});
this.hidePopup();
}
}
};
/**
* Finds the next sibling item.
*/
Drupal.jsAC.prototype.findNextSibling = function (element) {
var sibling = element && element.nextSibling;
if (sibling && !this.validItem(sibling)) {
return this.findNextSibling(sibling.nextSibling);
}
return sibling;
};
/**
* Finds the previous sibling item.
*/
Drupal.jsAC.prototype.findPreviousSibling = function (element) {
var sibling = element && element.previousSibling;
if (sibling && !this.validItem(sibling)) {
return this.findPreviousSibling(sibling.previousSibling);
}
return sibling;
};
/**
* Highlights the next suggestion.
*/
Drupal.jsAC.prototype.selectDown = function () {
var sibling = this.findNextSibling(this.selected);
if (sibling) {
this.highlight(sibling);
}
else if (this.popup) {
var lis = $('li', this.popup);
if (lis.length > 0) {
if (this.validItem(lis[0])) {
this.highlight(lis[0]);
}
else {
this.highlight(this.findNextSibling(lis[0]));
}
}
}
};
/**
* Highlights the previous suggestion.
*/
Drupal.jsAC.prototype.selectUp = function () {
var sibling = this.findPreviousSibling(this.selected);
if (sibling) {
this.highlight(sibling);
}
else if (this.popup) {
var lis = $('li', this.popup);
if (lis.length > 0) {
if (this.validItem(lis[lis.length - 1])) {
this.highlight(lis[lis.length - 1]);
}
else {
this.highlight(this.findPreviousSibling(lis[lis.length - 1]));
}
}
}
};
/**
* Ensures the item is valid.
*/
Drupal.jsAC.prototype.validItem = function (element) {
return !$(element).is('.dropdown-header, .divider, .disabled');
};
Drupal.jsAC.prototype.setStatus = function (status) {
var $throbber = $(this.input).parent().find('.glyphicon-refresh, .autocomplete-throbber').first();
var throbbingClass = $throbber.is('.autocomplete-throbber') ? 'throbbing' : 'glyphicon-spin';
switch (status) {
case 'begin':
$throbber.addClass(throbbingClass);
$(this.ariaLive).html(Drupal.t('Searching for matches...'));
break;
case 'cancel':
case 'error':
case 'found':
$throbber.removeClass(throbbingClass);
break;
}
};
// Save the previous autocomplete prototype.
var oldPrototype = Drupal.jsAC.prototype;
/**
* Override the autocomplete constructor.
*/
Drupal.jsAC = function ($input, db, context) {
var ac = this;
// Context is normally passed by Drupal.behaviors.autocomplete above. However,
// if a module has manually invoked this method they will likely not know
// about this feature and a global fallback context to document must be used.
// @see https://www.drupal.org/node/2594243
// @see https://www.drupal.org/node/2315295
this.$context = context && $(context) || $(document);
this.input = $input[0];
this.ariaLive = this.$context.find('#' + this.input.id + '-autocomplete-aria-live');
this.db = db;
$input
.keydown(function (event) {
return ac.onkeydown(this, event);
})
.keyup(function (event) {
ac.onkeyup(this, event);
})
.blur(function () {
ac.hidePopup();
ac.db.cancel();
});
};
// Restore the previous prototype.
Drupal.jsAC.prototype = oldPrototype;
})(jQuery);
;/*})'"*/
;/*})'"*/
(function ($) {
/**
* Override Drupal's AJAX prototype beforeSend function so it can append the
* throbber inside the pager links.
*/
Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) {
// For forms without file inputs, the jQuery Form plugin serializes the form
// values, and then calls jQuery's $.ajax() function, which invokes this
// handler. In this circumstance, options.extraData is never used. For forms
// with file inputs, the jQuery Form plugin uses the browser's normal form
// submission mechanism, but captures the response in a hidden IFRAME. In this
// circumstance, it calls this handler first, and then appends hidden fields
// to the form to submit the values in options.extraData. There is no simple
// way to know which submission mechanism will be used, so we add to extraData
// regardless, and allow it to be ignored in the former case.
if (this.form) {
options.extraData = options.extraData || {};
// Let the server know when the IFRAME submission mechanism is used. The
// server can use this information to wrap the JSON response in a TEXTAREA,
// as per http://jquery.malsup.com/form/#file-upload.
options.extraData.ajax_iframe_upload = '1';
// The triggering element is about to be disabled (see below), but if it
// contains a value (e.g., a checkbox, textfield, select, etc.), ensure that
// value is included in the submission. As per above, submissions that use
// $.ajax() are already serialized prior to the element being disabled, so
// this is only needed for IFRAME submissions.
var v = $.fieldValue(this.element);
if (v !== null) {
options.extraData[this.element.name] = v;
}
}
var $element = $(this.element);
// Disable the element that received the change to prevent user interface
// interaction while the Ajax request is in progress. ajax.ajaxing prevents
// the element from triggering a new request, but does not prevent the user
// from changing its value.
$element.addClass('progress-disabled').attr('disabled', true);
// Insert progressbar or throbber.
if (this.progress.type == 'bar') {
var progressBar = new Drupal.progressBar('ajax-progress-' + this.element.id, eval(this.progress.update_callback), this.progress.method, eval(this.progress.error_callback));
if (this.progress.message) {
progressBar.setProgress(-1, this.progress.message);
}
if (this.progress.url) {
progressBar.startMonitoring(this.progress.url, this.progress.interval || 500);
}
this.progress.element = $(progressBar.element).addClass('ajax-progress ajax-progress-bar');
this.progress.object = progressBar;
$element.closest('.file-widget,.form-item').after(this.progress.element);
}
else if (this.progress.type == 'throbber') {
this.progress.element = $('<div class="ajax-progress ajax-progress-throbber"><i class="glyphicon glyphicon-refresh glyphicon-spin"></i></div>');
if (this.progress.message) {
$('.throbber', this.progress.element).after('<div class="message">' + this.progress.message + '</div>');
}
// If element is an input type, append after.
if ($element.is('input')) {
$element.after(this.progress.element);
}
else if ($element.is('select')) {
var $inputGroup = $element.closest('.form-item').find('.input-group-addon, .input-group-btn');
if (!$inputGroup.length) {
$element.wrap('<div class="input-group">');
$inputGroup = $('<span class="input-group-addon">');
$element.after($inputGroup);
}
$inputGroup.append(this.progress.element);
}
// Otherwise append the throbber inside the element.
else {
$element.append(this.progress.element);
}
}
};
})(jQuery);
;/*})'"*/
;/*})'"*/
(function ($) {
function updateFilterHelpLink () {
var $link = $(this).parents('.filter-wrapper').find('.filter-help > a');
var originalLink = $link.data('originalLink');
if (!originalLink) {
originalLink = $link.attr('href');
$link.data('originalLink', originalLink);
}
$link.attr('href', originalLink + '/' + $(this).find(':selected').val());
}
$(document).on('change', '.filter-wrapper select.filter-list', updateFilterHelpLink);
/**
* Override core's functionality.
*/
Drupal.behaviors.filterGuidelines = {
attach: function (context) {
$(context).find('.filter-wrapper select.filter-list').once('filter-list', updateFilterHelpLink);
}
};
})(jQuery);
;/*})'"*/
;/*})'"*/
|