media-youtube.browser.js
1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* @file
* Handles the JS for the views file browser. Note that this does not currently
* support multiple file selection
*/
(function ($) {
Drupal.behaviors.mediaYouTubeBrowser = {
attach: function (context, settings) {
// Container for the files that get passed back to the browser
var files = {};
// Disable the links on media items list
$('ul#media-browser-library-list a').click(function() {
return false;
});
// Catch the click on a media item
$('#media-youtube-add .media-item').bind('click', function () {
// Remove all currently selected files
$('.media-item').removeClass('selected');
// Set the current item to active
$(this).addClass('selected');
// Add this FID to the array of selected files
var uri = $(this).parent('a[data-uri]').attr('data-uri');
// Get the file from the settings which was stored in
// template_preprocess_media_views_view_media_browser()
var file = Drupal.settings.media.files[uri];
var files = new Array();
files.push(file);
Drupal.media.browser.selectMedia(files);
$("input[name='submitted-video']").val(uri);
});
// $('.')
}
}
}(jQuery));