root / drupal7 / sites / all / themes / bootstrap / js / modules / field_ui / field_ui.js @ 749b8a23
1 |
(function ($) { |
---|---|
2 |
// Override core JS so it works with "button" tags.
|
3 |
if (Drupal.fieldUIOverview && Drupal.fieldUIOverview.AJAXRefreshRows) {
|
4 |
/**
|
5 |
* Triggers Ajax refresh of selected rows.
|
6 |
*
|
7 |
* The 'format type' selects can trigger a series of changes in child rows.
|
8 |
* The #ajax behavior is therefore not attached directly to the selects, but
|
9 |
* triggered manually through a hidden #ajax 'Refresh' button.
|
10 |
*
|
11 |
* @param rows
|
12 |
* A hash object, whose keys are the names of the rows to refresh (they
|
13 |
* will receive the 'ajax-new-content' effect on the server side), and
|
14 |
* whose values are the DOM element in the row that should get an Ajax
|
15 |
* throbber.
|
16 |
*/
|
17 |
Drupal.fieldUIOverview.AJAXRefreshRows = function (rows) { |
18 |
// Separate keys and values.
|
19 |
var rowNames = [];
|
20 |
var ajaxElements = [];
|
21 |
$.each(rows, function (rowName, ajaxElement) { |
22 |
rowNames.push(rowName); |
23 |
ajaxElements.push(ajaxElement); |
24 |
}); |
25 |
|
26 |
if (rowNames.length) {
|
27 |
// Add a throbber next each of the ajaxElements.
|
28 |
var $throbber = $('<div class="ajax-progress ajax-progress-throbber"><div class="throbber"> </div></div>'); |
29 |
$(ajaxElements)
|
30 |
.addClass('progress-disabled')
|
31 |
.after($throbber);
|
32 |
|
33 |
// Fire the Ajax update.
|
34 |
$(':input[name=refresh_rows]').val(rowNames.join(' ')); |
35 |
$(':input#edit-refresh').mousedown(); |
36 |
|
37 |
// Disabled elements do not appear in POST ajax data, so we mark the
|
38 |
// elements disabled only after firing the request.
|
39 |
$(ajaxElements).attr('disabled', true); |
40 |
} |
41 |
}; |
42 |
} |
43 |
})(jQuery); |