1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
(function ($) {
|
11
|
|
12
|
|
13
|
|
14
|
Drupal.behaviors.viewsSlideshowCycleAmountAllowedVisible = {
|
15
|
attach: function (context) {
|
16
|
|
17
|
|
18
|
var type = $(":input[name='style_options[views_slideshow_cycle][pause_when_hidden_type]']").val();
|
19
|
if (type == 'full') {
|
20
|
$(":input[name='style_options[views_slideshow_cycle][amount_allowed_visible]']").parent().hide();
|
21
|
}
|
22
|
|
23
|
|
24
|
$(":input[name='style_options[views_slideshow_cycle][action_advanced]']").change(function() {
|
25
|
processValues('action_advanced');
|
26
|
});
|
27
|
|
28
|
|
29
|
$(':input[name="style_options[views_slideshow_cycle][pause_when_hidden]"]').change(function() {
|
30
|
processValues('pause_when_hidden');
|
31
|
});
|
32
|
|
33
|
|
34
|
$(":input[name='style_options[views_slideshow_cycle][pause_when_hidden_type]']").change(function() {
|
35
|
processValues('pause_when_hidden_type');
|
36
|
});
|
37
|
|
38
|
|
39
|
function processValues(field) {
|
40
|
switch (field) {
|
41
|
case 'action_advanced':
|
42
|
if (!$(':input[name="style_options[views_slideshow_cycle][action_advanced]"]').is(':checked')) {
|
43
|
$(":input[name='style_options[views_slideshow_cycle][amount_allowed_visible]']").parent().hide();
|
44
|
break;
|
45
|
}
|
46
|
case 'pause_when_hidden':
|
47
|
if (!$(':input[name="style_options[views_slideshow_cycle][pause_when_hidden]"]').is(':checked')) {
|
48
|
$(":input[name='style_options[views_slideshow_cycle][amount_allowed_visible]']").parent().hide();
|
49
|
break;
|
50
|
}
|
51
|
case 'pause_when_hidden_type':
|
52
|
if ($(":input[name='style_options[views_slideshow_cycle][pause_when_hidden_type]']").val() == 'full') {
|
53
|
$(":input[name='style_options[views_slideshow_cycle][amount_allowed_visible]']").parent().hide();
|
54
|
}
|
55
|
else {
|
56
|
$(":input[name='style_options[views_slideshow_cycle][amount_allowed_visible]']").parent().show();
|
57
|
}
|
58
|
}
|
59
|
}
|
60
|
}
|
61
|
}
|
62
|
|
63
|
|
64
|
Drupal.behaviors.viewsSlideshowCycleOptions = {
|
65
|
attach: function (context) {
|
66
|
if ($(":input[name='style_options[views_slideshow_cycle][advanced_options]']").length) {
|
67
|
$(":input[name='style_options[views_slideshow_cycle][advanced_options]']").parent().hide();
|
68
|
|
69
|
$(":input[name='style_options[views_slideshow_cycle][advanced_options_entry]']").parent().after(
|
70
|
'<div style="margin-left: 10px; padding: 10px 0;">' +
|
71
|
'<a id="edit-style-options-views-slideshow-cycle-advanced-options-update-link" href="#">' + Drupal.t('Update Advanced Option') + '</a>' +
|
72
|
'</div>'
|
73
|
);
|
74
|
|
75
|
$("#edit-style-options-views-slideshow-cycle-advanced-options-table").append('<tr><th colspan="2">' + Drupal.t('Applied Options') + '</th><tr>')
|
76
|
|
77
|
var initialValue = $(":input[name='style_options[views_slideshow_cycle][advanced_options]']").val();
|
78
|
var advancedOptions = JSON.parse(initialValue);
|
79
|
for (var option in advancedOptions) {
|
80
|
viewsSlideshowCycleAdvancedOptionsAddRow(option);
|
81
|
}
|
82
|
|
83
|
|
84
|
viewsSlideshowCycleAdvancedOptionsRemoveEvent();
|
85
|
|
86
|
$(":input[name='style_options[views_slideshow_cycle][advanced_options_choices]']").change(function() {
|
87
|
var selectedValue = $(":input[name='style_options[views_slideshow_cycle][advanced_options_choices]'] option:selected").val();
|
88
|
if (typeof advancedOptions[selectedValue] !== 'undefined') {
|
89
|
$(":input[name='style_options[views_slideshow_cycle][advanced_options_entry]']").val(advancedOptions[selectedValue]);
|
90
|
}
|
91
|
else {
|
92
|
$(":input[name='style_options[views_slideshow_cycle][advanced_options_entry]']").val('');
|
93
|
}
|
94
|
});
|
95
|
|
96
|
$('#edit-style-options-views-slideshow-cycle-advanced-options-update-link').click(function() {
|
97
|
var option = $(":input[name='style_options[views_slideshow_cycle][advanced_options_choices]']").val();
|
98
|
if (option) {
|
99
|
var value = $(":input[name='style_options[views_slideshow_cycle][advanced_options_entry]']").val();
|
100
|
|
101
|
if (typeof advancedOptions[option] == 'undefined') {
|
102
|
viewsSlideshowCycleAdvancedOptionsAddRow(option);
|
103
|
viewsSlideshowCycleAdvancedOptionsRemoveEvent()
|
104
|
}
|
105
|
advancedOptions[option] = value;
|
106
|
viewsSlideshowCycleAdvancedOptionsSave();
|
107
|
}
|
108
|
|
109
|
return false;
|
110
|
});
|
111
|
}
|
112
|
|
113
|
function viewsSlideshowCycleAdvancedOptionsAddRow(option) {
|
114
|
$("#edit-style-options-views-slideshow-cycle-advanced-options-table").append(
|
115
|
'<tr id="views-slideshow-cycle-advanced-options-table-row-' + option + '">' +
|
116
|
'<td>' + option + '</td>' +
|
117
|
'<td style="width: 20px;">' +
|
118
|
'<a style="margin-top: 6px" title="Remove ' + option + '" alt="Remove ' + option + '" class="views-hidden views-button-remove views-slideshow-cycle-advanced-options-table-remove" id="views-slideshow-cycle-advanced-options-table-remove-' + option + '" href="#"><span>Remove</span></a>' +
|
119
|
'</td>' +
|
120
|
'</tr>'
|
121
|
);
|
122
|
}
|
123
|
|
124
|
function viewsSlideshowCycleAdvancedOptionsRemoveEvent() {
|
125
|
$('.views-slideshow-cycle-advanced-options-table-remove').unbind().click(function() {
|
126
|
var itemID = $(this).attr('id');
|
127
|
var uniqueID = itemID.replace('views-slideshow-cycle-advanced-options-table-remove-', '');
|
128
|
delete advancedOptions[uniqueID];
|
129
|
$('#views-slideshow-cycle-advanced-options-table-row-' + uniqueID).remove();
|
130
|
viewsSlideshowCycleAdvancedOptionsSave();
|
131
|
return false;
|
132
|
});
|
133
|
}
|
134
|
|
135
|
function viewsSlideshowCycleAdvancedOptionsSave() {
|
136
|
var advancedOptionsString = JSON.stringify(advancedOptions);
|
137
|
$(":input[name='style_options[views_slideshow_cycle][advanced_options]']").val(advancedOptionsString);
|
138
|
}
|
139
|
}
|
140
|
}
|
141
|
})(jQuery);
|