1 |
85ad3d82
|
Assos Assos
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
(function ($) {
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
Drupal.behaviors.mediaAdmin = {
|
15 |
|
|
attach: function (context) {
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
$('.tabs.secondary a').once('media-admin').bind('click', function () {
|
19 |
|
|
if ($(':checkbox:checked', $('.file-entity-admin-file-form')).length != 0) {
|
20 |
|
|
return confirm(Drupal.t('If you switch views, you will lose your selection.'));
|
21 |
|
|
}
|
22 |
|
|
});
|
23 |
|
|
|
24 |
|
|
if ($('.media-display-thumbnails').length && !$('.media-thumbnails-select').length) {
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
var allLink = $('<a href="#">' + Drupal.t('all') + '</a>')
|
28 |
|
|
.click(function () {
|
29 |
|
|
$('.media-display-thumbnails', $(this).parents('form')).find(':checkbox').attr('checked', true).change();
|
30 |
|
|
return false;
|
31 |
|
|
});
|
32 |
|
|
var noneLink = $('<a href="#">' + Drupal.t('none') + '</a>')
|
33 |
|
|
.click(function () {
|
34 |
|
|
$('.media-display-thumbnails', $(this).parents('form')).find(':checkbox').attr('checked', false).change();
|
35 |
|
|
return false;
|
36 |
|
|
});
|
37 |
|
|
$('<div class="media-thumbnails-select" />')
|
38 |
|
|
.append('<strong>' + Drupal.t('Select') + ':</strong> ')
|
39 |
|
|
.append(allLink)
|
40 |
|
|
.append(', ')
|
41 |
|
|
.append(noneLink)
|
42 |
|
|
.prependTo('.media-display-thumbnails')
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
$('.media-item').bind('click', function (e) {
|
46 |
|
|
if ($(e.target).is('img, a')) {
|
47 |
|
|
return;
|
48 |
|
|
}
|
49 |
|
|
var checkbox = $(this).parent().find(':checkbox');
|
50 |
|
|
if (checkbox.is(':checked')) {
|
51 |
|
|
checkbox.attr('checked', false).change();
|
52 |
|
|
} else {
|
53 |
|
|
checkbox.attr('checked', true).change();
|
54 |
|
|
}
|
55 |
|
|
});
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
$('.media-display-thumbnails :checkbox').each(function () {
|
59 |
|
|
var checkbox = $(this);
|
60 |
|
|
if (checkbox.is(':checked')) {
|
61 |
|
|
$(checkbox.parents('li').find('.media-item')).addClass('selected');
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
checkbox.bind('change.media', function () {
|
65 |
|
|
if (checkbox.is(':checked')) {
|
66 |
|
|
$(checkbox.parents('li').find('.media-item')).addClass('selected');
|
67 |
|
|
}
|
68 |
|
|
else {
|
69 |
|
|
$(checkbox.parents('li').find('.media-item')).removeClass('selected');
|
70 |
|
|
}
|
71 |
|
|
});
|
72 |
|
|
});
|
73 |
|
|
}
|
74 |
|
|
}
|
75 |
|
|
};
|
76 |
|
|
|
77 |
|
|
})(jQuery); |