root / htmltest / sites / all / modules / ds / js / ds.admin.js @ 5fc58a68
1 | 85ad3d82 | Assos Assos | /**
|
---|---|---|---|
2 | * @file
|
||
3 | * Javascript functionality for Display Suite's administration UI.
|
||
4 | */
|
||
5 | |||
6 | (function($) { |
||
7 | |||
8 | Drupal.DisplaySuite = Drupal.DisplaySuite || {}; |
||
9 | Drupal.DisplaySuite.fieldopened = '';
|
||
10 | Drupal.DisplaySuite.layout_original = '';
|
||
11 | |||
12 | /**
|
||
13 | * Ctools selection content.
|
||
14 | */
|
||
15 | Drupal.behaviors.CToolsSelection = { |
||
16 | attach: function (context) { |
||
17 | if ($('#ctools-content-selection').length > 0) { |
||
18 | $('#ctools-content-selection .section-link').click(function() { |
||
19 | $('#ctools-content-selection .content').hide(); |
||
20 | container = $(this).attr('id') + '-container'; |
||
21 | $('#' + container).show(); |
||
22 | return false; |
||
23 | }); |
||
24 | } |
||
25 | } |
||
26 | }; |
||
27 | |||
28 | /**
|
||
29 | * Save the Dynamic field content configuration.
|
||
30 | */
|
||
31 | $.fn.dsCtoolsContentConfiguration = function (configuration) { |
||
32 | $(this[0]).val(configuration); |
||
33 | } |
||
34 | |||
35 | /**
|
||
36 | * Update the select content text.
|
||
37 | */
|
||
38 | $.fn.dsCtoolsContentUpdate = function () { |
||
39 | $(this[0]).html(Drupal.t('Click update to save the configuration')); |
||
40 | } |
||
41 | |||
42 | /**
|
||
43 | * Save the page after saving a new field.
|
||
44 | */
|
||
45 | $.fn.dsRefreshDisplayTable = function () { |
||
46 | $('#edit-submit').click(); |
||
47 | } |
||
48 | |||
49 | /**
|
||
50 | * Row handlers for the 'Manage display' screen.
|
||
51 | */
|
||
52 | Drupal.fieldUIDisplayOverview = Drupal.fieldUIDisplayOverview || {}; |
||
53 | |||
54 | Drupal.fieldUIDisplayOverview.ds = function (row, data) { |
||
55 | |||
56 | this.row = row;
|
||
57 | this.name = data.name;
|
||
58 | this.region = data.region;
|
||
59 | this.tableDrag = data.tableDrag;
|
||
60 | |||
61 | // Attach change listener to the 'region' select.
|
||
62 | this.$regionSelect = $('select.ds-field-region', row); |
||
63 | this.$regionSelect.change(Drupal.fieldUIOverview.onChange); |
||
64 | |||
65 | // Attach change listener to the 'formatter type' select.
|
||
66 | this.$formatSelect = $('select.field-formatter-type', row); |
||
67 | this.$formatSelect.change(Drupal.fieldUIOverview.onChange); |
||
68 | |||
69 | return this; |
||
70 | }; |
||
71 | |||
72 | Drupal.fieldUIDisplayOverview.ds.prototype = { |
||
73 | |||
74 | /**
|
||
75 | * Returns the region corresponding to the current form values of the row.
|
||
76 | */
|
||
77 | getRegion: function () { |
||
78 | return this.$regionSelect.val(); |
||
79 | }, |
||
80 | |||
81 | /**
|
||
82 | * Reacts to a row being changed regions.
|
||
83 | *
|
||
84 | * This function is called when the row is moved to a different region, as a
|
||
85 | * result of either :
|
||
86 | * - a drag-and-drop action
|
||
87 | * - user input in one of the form elements watched by the
|
||
88 | * Drupal.fieldUIOverview.onChange change listener.
|
||
89 | *
|
||
90 | * @param region
|
||
91 | * The name of the new region for the row.
|
||
92 | * @return
|
||
93 | * A hash object indicating which rows should be AJAX-updated as a result
|
||
94 | * of the change, in the format expected by
|
||
95 | * Drupal.displayOverview.AJAXRefreshRows().
|
||
96 | */
|
||
97 | regionChange: function (region) { |
||
98 | |||
99 | // Replace dashes with underscores.
|
||
100 | region = region.replace(/-/g, '_'); |
||
101 | |||
102 | // Set the region of the select list.
|
||
103 | this.$regionSelect.val(region); |
||
104 | |||
105 | // Prepare rows to be refreshed in the form.
|
||
106 | var refreshRows = {};
|
||
107 | refreshRows[this.name] = this.$regionSelect.get(0); |
||
108 | |||
109 | // If a row is handled by field_group module, loop through the children.
|
||
110 | if ($(this.row).hasClass('field-group') && $.isFunction(Drupal.fieldUIDisplayOverview.group.prototype.regionChangeFields)) { |
||
111 | Drupal.fieldUIDisplayOverview.group.prototype.regionChangeFields(region, this, refreshRows);
|
||
112 | } |
||
113 | |||
114 | return refreshRows;
|
||
115 | } |
||
116 | }; |
||
117 | |||
118 | })(jQuery); |