1 |
85ad3d82
|
Assos Assos
|
(function ($) {
|
2 |
7547bb19
|
Assos Assos
|
|
3 |
|
|
if (typeof $.fn.prop != 'function') {
|
4 |
|
|
jQuery.fn.extend({
|
5 |
|
|
prop: jQuery.fn.attr
|
6 |
|
|
});
|
7 |
|
|
}
|
8 |
|
|
|
9 |
85ad3d82
|
Assos Assos
|
Drupal.behaviors.vbo = {
|
10 |
|
|
attach: function(context) {
|
11 |
|
|
$('.vbo-views-form', context).each(function() {
|
12 |
|
|
Drupal.vbo.initTableBehaviors(this);
|
13 |
|
|
Drupal.vbo.initGenericBehaviors(this);
|
14 |
7547bb19
|
Assos Assos
|
Drupal.vbo.toggleButtonsState(this);
|
15 |
85ad3d82
|
Assos Assos
|
});
|
16 |
|
|
}
|
17 |
|
|
}
|
18 |
|
|
|
19 |
|
|
Drupal.vbo = Drupal.vbo || {};
|
20 |
|
|
Drupal.vbo.initTableBehaviors = function(form) {
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
var selectAllMarkup = $('.vbo-table-select-all-markup', form);
|
24 |
|
|
if (selectAllMarkup.length) {
|
25 |
|
|
$('.views-table > tbody', form).prepend('<tr class="views-table-row-select-all even">></tr>');
|
26 |
|
|
var colspan = $('table th', form).length;
|
27 |
|
|
$('.views-table-row-select-all', form).html('<td colspan="' + colspan + '">' + selectAllMarkup.html() + '</td>');
|
28 |
|
|
|
29 |
|
|
$('.vbo-table-select-all-pages', form).click(function() {
|
30 |
|
|
Drupal.vbo.tableSelectAllPages(form);
|
31 |
|
|
return false;
|
32 |
|
|
});
|
33 |
|
|
$('.vbo-table-select-this-page', form).click(function() {
|
34 |
|
|
Drupal.vbo.tableSelectThisPage(form);
|
35 |
|
|
return false;
|
36 |
|
|
});
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
$('.vbo-table-select-all', form).show();
|
40 |
|
|
|
41 |
|
|
$('.vbo-table-select-all', form).click(function() {
|
42 |
|
|
var table = $(this).closest('table')[0];
|
43 |
7547bb19
|
Assos Assos
|
$('input[id^="edit-views-bulk-operations"]:not(:disabled)', table).prop('checked', this.checked);
|
44 |
|
|
Drupal.vbo.toggleButtonsState(form);
|
45 |
85ad3d82
|
Assos Assos
|
|
46 |
|
|
|
47 |
|
|
if (this.checked) {
|
48 |
|
|
$('.views-table-row-select-all', table).show();
|
49 |
|
|
}
|
50 |
|
|
else {
|
51 |
|
|
$('.views-table-row-select-all', table).hide();
|
52 |
|
|
|
53 |
|
|
Drupal.vbo.tableSelectThisPage(form);
|
54 |
|
|
}
|
55 |
|
|
});
|
56 |
|
|
|
57 |
|
|
|
58 |
9df8b457
|
Assos Assos
|
if (Drupal.settings.vbo.row_clickable) {
|
59 |
|
|
$('.views-table tbody tr', form).click(function(event) {
|
60 |
|
|
if (event.target.tagName.toLowerCase() != 'input' && event.target.tagName.toLowerCase() != 'a') {
|
61 |
|
|
$('input[id^="edit-views-bulk-operations"]:not(:disabled)', this).each(function() {
|
62 |
|
|
var checked = this.checked;
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
this.checked = !checked;
|
69 |
|
|
$(this).trigger('click');
|
70 |
|
|
this.checked = !checked;
|
71 |
|
|
});
|
72 |
|
|
}
|
73 |
|
|
});
|
74 |
|
|
}
|
75 |
85ad3d82
|
Assos Assos
|
}
|
76 |
|
|
|
77 |
|
|
Drupal.vbo.tableSelectAllPages = function(form) {
|
78 |
|
|
$('.vbo-table-this-page', form).hide();
|
79 |
|
|
$('.vbo-table-all-pages', form).show();
|
80 |
|
|
|
81 |
|
|
$('.select-all-rows', form).val('1');
|
82 |
|
|
}
|
83 |
|
|
Drupal.vbo.tableSelectThisPage = function(form) {
|
84 |
|
|
$('.vbo-table-all-pages', form).hide();
|
85 |
|
|
$('.vbo-table-this-page', form).show();
|
86 |
|
|
|
87 |
|
|
$('.select-all-rows', form).val('0');
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
Drupal.vbo.initGenericBehaviors = function(form) {
|
91 |
|
|
|
92 |
|
|
$('.vbo-select-all-markup', form).show();
|
93 |
|
|
|
94 |
|
|
$('.vbo-select-this-page', form).click(function() {
|
95 |
7547bb19
|
Assos Assos
|
$('input[id^="edit-views-bulk-operations"]', form).prop('checked', this.checked);
|
96 |
|
|
Drupal.vbo.toggleButtonsState(form);
|
97 |
|
|
$('.vbo-select-all-pages', form).prop('checked', false);
|
98 |
85ad3d82
|
Assos Assos
|
|
99 |
|
|
|
100 |
7547bb19
|
Assos Assos
|
$('.vbo-table-select-all', form).prop('checked', this.checked);
|
101 |
85ad3d82
|
Assos Assos
|
});
|
102 |
|
|
$('.vbo-select-all-pages', form).click(function() {
|
103 |
7547bb19
|
Assos Assos
|
$('input[id^="edit-views-bulk-operations"]', form).prop('checked', this.checked);
|
104 |
|
|
Drupal.vbo.toggleButtonsState(form);
|
105 |
|
|
$('.vbo-select-this-page', form).prop('checked', false);
|
106 |
85ad3d82
|
Assos Assos
|
|
107 |
|
|
|
108 |
7547bb19
|
Assos Assos
|
$('.vbo-table-select-all', form).prop('checked', this.checked);
|
109 |
85ad3d82
|
Assos Assos
|
|
110 |
|
|
|
111 |
|
|
$('.select-all-rows', form).val(this.checked);
|
112 |
|
|
});
|
113 |
|
|
|
114 |
7547bb19
|
Assos Assos
|
|
115 |
|
|
|
116 |
|
|
$('select[name="operation"]', form).change(function () {
|
117 |
|
|
Drupal.vbo.toggleButtonsState(form);
|
118 |
|
|
});
|
119 |
|
|
|
120 |
85ad3d82
|
Assos Assos
|
$('.vbo-select', form).click(function() {
|
121 |
|
|
|
122 |
|
|
if (!this.checked) {
|
123 |
7547bb19
|
Assos Assos
|
$('.vbo-select-this-page', form).prop('checked', false);
|
124 |
|
|
$('.vbo-select-all-pages', form).prop('checked', false);
|
125 |
85ad3d82
|
Assos Assos
|
|
126 |
|
|
$('.select-all-rows', form).val('0')
|
127 |
|
|
|
128 |
|
|
var table = $(this).closest('table')[0];
|
129 |
|
|
if (table) {
|
130 |
|
|
|
131 |
7547bb19
|
Assos Assos
|
$('.vbo-table-select-all', table).prop('checked', false);
|
132 |
85ad3d82
|
Assos Assos
|
|
133 |
|
|
|
134 |
|
|
if ($('.vbo-table-select-this-page', table).length) {
|
135 |
|
|
$('.views-table-row-select-all', table).hide();
|
136 |
|
|
|
137 |
|
|
Drupal.vbo.tableSelectThisPage(form);
|
138 |
|
|
}
|
139 |
|
|
}
|
140 |
|
|
}
|
141 |
7547bb19
|
Assos Assos
|
|
142 |
|
|
Drupal.vbo.toggleButtonsState(form);
|
143 |
85ad3d82
|
Assos Assos
|
});
|
144 |
|
|
}
|
145 |
|
|
|
146 |
7547bb19
|
Assos Assos
|
Drupal.vbo.toggleButtonsState = function(form) {
|
147 |
|
|
|
148 |
|
|
var selectbox = $('select[name="operation"]', form);
|
149 |
|
|
var checkedCheckboxes = $('.vbo-select:checked', form);
|
150 |
|
|
var buttons = $('[id^="edit-select"] input[type="submit"]', form);
|
151 |
|
|
|
152 |
|
|
if (selectbox.length) {
|
153 |
|
|
var has_selection = checkedCheckboxes.length && selectbox.val() !== '0';
|
154 |
|
|
buttons.prop('disabled', !has_selection);
|
155 |
|
|
}
|
156 |
|
|
else {
|
157 |
|
|
buttons.prop('disabled', !checkedCheckboxes.length);
|
158 |
|
|
}
|
159 |
|
|
};
|
160 |
|
|
|
161 |
85ad3d82
|
Assos Assos
|
})(jQuery); |