MDL-29512 Revert "MDL-25937 Forms Library: Added Javascript validation for filepicker...
[moodle.git] / lib / form / filepicker.js
2 M.form_filepicker = {};
5 M.form_filepicker.callback = function(params) {
6     var html = '<a href="'+params['url']+'">'+params['file']+'</a>';
7     document.getElementById('file_info_'+params['client_id']).innerHTML = html;
8 };
10 /**
11  * This fucntion is called for each file picker on page.
12  */
13 M.form_filepicker.init = function(Y, options) {
14     options.formcallback = M.form_filepicker.callback;
15     if (!M.core_filepicker.instances[options.client_id]) {
16         M.core_filepicker.init(Y, options); 
17     }
18     Y.on('click', function(e, client_id) {
19         e.preventDefault();
20         M.core_filepicker.instances[client_id].show();
21     }, '#filepicker-button-'+options.client_id, null, options.client_id);
23     var item = document.getElementById('nonjs-filepicker-'+options.client_id);
24     if (item) {
25         item.parentNode.removeChild(item);
26     }
27     item = document.getElementById('filepicker-wrapper-'+options.client_id);
28     if (item) {
29         item.style.display = '';
30     }
31 };