root / drupal7 / sites / all / modules / ds / modules / ds_forms / js / ds_forms.admin.js @ 6e9292aa
1 | 85ad3d82 | Assos Assos | |
---|---|---|---|
2 | (function($) { |
||
3 | |||
4 | /**
|
||
5 | * Attach behaviors.
|
||
6 | */
|
||
7 | Drupal.behaviors.fieldUIFieldsFormsOverview = { |
||
8 | attach: function (context, settings) { |
||
9 | $('table#field-overview', context).once('field-field-overview', function() { |
||
10 | Drupal.fieldUIOverview.attach(this, settings.fieldUIRowsData, Drupal.fieldUIFieldOverview);
|
||
11 | }); |
||
12 | } |
||
13 | }; |
||
14 | |||
15 | /**
|
||
16 | * Row handlers for the 'Manage fields' screen.
|
||
17 | */
|
||
18 | Drupal.fieldUIFieldOverview = Drupal.fieldUIFieldOverview || {}; |
||
19 | |||
20 | Drupal.fieldUIFieldOverview.ds = function (row, data) { |
||
21 | |||
22 | this.row = row;
|
||
23 | this.name = data.name;
|
||
24 | this.region = data.region;
|
||
25 | this.tableDrag = data.tableDrag;
|
||
26 | |||
27 | this.$regionSelect = $('select.ds-field-region', row); |
||
28 | this.$regionSelect.change(Drupal.fieldUIOverview.onChange); |
||
29 | |||
30 | return this; |
||
31 | }; |
||
32 | |||
33 | Drupal.fieldUIFieldOverview.ds.prototype = { |
||
34 | |||
35 | /**
|
||
36 | * Returns the region corresponding to the current form values of the row.
|
||
37 | */
|
||
38 | getRegion: function () { |
||
39 | return this.$regionSelect.val(); |
||
40 | }, |
||
41 | |||
42 | /**
|
||
43 | * Reacts to a row being changed regions.
|
||
44 | *
|
||
45 | * This function is called when the row is moved to a different region, as a
|
||
46 | * result of either :
|
||
47 | * - a drag-and-drop action
|
||
48 | * - user input in one of the form elements watched by the
|
||
49 | * Drupal.fieldUIOverview.onChange change listener.
|
||
50 | *
|
||
51 | * @param region
|
||
52 | * The name of the new region for the row.
|
||
53 | * @return
|
||
54 | * A hash object indicating which rows should be AJAX-updated as a result
|
||
55 | * of the change, in the format expected by
|
||
56 | * Drupal.fieldOverview.AJAXRefreshRows().
|
||
57 | */
|
||
58 | regionChange: function (region, recurse) { |
||
59 | |||
60 | // Replace dashes with underscores.
|
||
61 | 6e9292aa | Assos Assos | region = region.replace(/-/g, '_'); |
62 | 85ad3d82 | Assos Assos | |
63 | // Set the region of the select list.
|
||
64 | this.$regionSelect.val(region); |
||
65 | |||
66 | // Prepare rows to be refreshed in the form.
|
||
67 | var refreshRows = {};
|
||
68 | refreshRows[this.name] = this.$regionSelect.get(0); |
||
69 | |||
70 | // If a row is handled by field_group module, loop through the children.
|
||
71 | if ($(this.row).hasClass('field-group') && $.isFunction(Drupal.fieldUIFieldOverview.group.prototype.regionChangeFields)) { |
||
72 | Drupal.fieldUIFieldOverview.group.prototype.regionChangeFields(region, this, refreshRows);
|
||
73 | } |
||
74 | |||
75 | return refreshRows;
|
||
76 | } |
||
77 | }; |
||
78 | |||
79 | 6e9292aa | Assos Assos | })(jQuery); |